Investigate a bug systematically β reproduce, trace root cause, form hypotheses, fix with TDD discipline, and escalate if the bug resists.
/ctdd when a complex bug needs investigation beyond a simple fix round/cspec), planned refactoring (use /crefactor), or spec reviews/cdebug is a standalone workflow β it does not interact with the TDD state machine. It can be invoked during an active TDD workflow (when QA flags a complex bug) or independently for production bugs. Fixes should go through /ctdd on a fix branch or be committed directly with manual verification.
git bisect to find the exact commit that introduced it. Stashes dirty state, runs bisect, cleans up automatically.User: /cdebug β webhooks from Stripe are returning 401 in production
but pass in our tests
Agent: Reproduction confirmed β webhook to /api/webhooks/stripe returns
401 when called with a valid Stripe signature.
Tracing code path: request hits authMiddleware before reaching
the webhook handler...
I have a failing test. Want me to run git bisect to find the
exact commit? Takes about 1 minute.
User: Yes, go ahead.
Agent: Bisect found commit `a3f2c91`: "refactor: reorganize middleware"
Changed: src/middleware/index.ts
Hypothesis 1: The auth middleware was registered before the
webhook route during the middleware reorganization. Webhook
endpoints should bypass auth because they use signature
verification instead. β CONFIRMED.
The middleware order in index.ts puts authMiddleware() before
app.use('/api/webhooks'). Before commit a3f2c91, webhooks
were registered first.
Writing failing test: "webhook endpoint should not require
auth header when valid Stripe signature is present"...
Spawning implementation agent...
Fix: moved webhook routes above auth middleware registration.
All tests passing (existing + new).
Class fix: this is a middleware ordering bug (AP-007 in your
antipatterns). Added structural test that asserts webhook
routes are registered before auth middleware in the route
chain.
| Reads | Writes |
|---|---|
AGENT_CONTEXT.md |
.correctless/artifacts/debug-investigation-{slug}.md |
ARCHITECTURE.md |
.correctless/artifacts/debug-bisect-test.sh (temporary, cleaned up) |
.correctless/antipatterns.md |
.correctless/antipatterns.md (new entry, if class fix) |
.correctless/artifacts/qa-findings-*.json |
.correctless/artifacts/token-log-{slug}.json |
.correctless/meta/drift-debt.json |
Test and source files (fix) |
| Git history and blame | Β |
Same at all intensity levels. There is no difference in /cdebug behavior β bug investigation follows the same systematic process regardless of intensity.
git stash list. Run git stash pop manually after resolving conflicts.