codeflash-agent/.claude/rules/debugging.md
Kevin Turcios c0a72e978d Add rules from session audit: error handling, testing, debugging
- sessions.md: hard compaction limits, no-polling, file read budget
- debugging.md: root cause first, isolated testing, subprocess logging
- github.md: strengthen MCP-first enforcement
- error-handling.md (packages): no silent swallowing, protect ast.parse
- test-coverage.md (packages): every module needs tests, known gaps
2026-04-21 21:06:15 -05:00

1 KiB

Debugging and Testing

Root cause first

When encountering a bug, always investigate the root cause. Don't patch symptoms. If you're about to add a try/except, a fallback default, or a defensive check -- ask whether the real fix is upstream.

The user will tell you "fix the root cause" if you get this wrong. Don't make them say it twice.

Isolated testing

Prefer running individual test functions or modules over full E2E suites. Only run the full suite when explicitly asked or before pushing.

  • Single function: uv run pytest tests/test_foo.py::TestBar::test_baz -v
  • Single module: uv run pytest tests/test_foo.py -v
  • Full suite: only when asked, or before git push

When debugging a specific endpoint or integration, test it directly (e.g., requests.post() to a local server) instead of running the entire pipeline end-to-end.

Subprocess failures

When a subprocess fails, always log stdout and stderr. "Exit code 1" with no output is useless. If you see a subprocess failure without output, add logging before moving on.