Example: Debug a production bug
Prompt examples are illustrative; commands are verified against official docs.
Scenario: login returns HTTP 500 after the latest deploy. A reasonable agent-driven investigation: gather logs, form a hypothesis, reproduce locally, fix, verify.
Workflow
- Gather evidence (logs, recent changes, error output).
- Hypothesize with the agent.
- Reproduce the failure.
- Fix the root cause.
- Verify with tests and a re-run of the failing path.
Claude Code
Start a session and gather evidence — paste logs directly, or pipe them in non-interactively:
claude
Here is the stack trace from production: [paste]. Also run
`git log --oneline -10` and tell me which recent change could cause a 500
on POST /login.
Piped variant:
kubectl logs deploy/api --since=30m | claude -p "Find the root cause of the login 500 in these logs."
Use the built-in diagnostic skill for runtime issues:
/debug Login returns 500 after the latest deploy
Hypothesize and reproduce:
Form a hypothesis, then reproduce the failure locally by running the auth
service and posting to /login with a test user.
Fix and verify:
Fix the root cause, add a regression test that reproduces the 500, and run
the full auth test suite.
If a fix attempt goes sideways, /rewind rolls code and conversation back to a checkpoint.
Codex
Investigate interactively in the TUI, or script the log triage with codex exec (default sandbox for exec is read-only — safe for log analysis):
kubectl logs deploy/api --since=30m | codex exec "Summarize the root cause of the login 500 from these logs."
In the TUI, correlate with recent changes:
codex
POST /login returns 500 since the last deploy. Look at `git log -10` and
the auth code, and identify the most likely culprit.
Reproduce under the workspace sandbox:
Start the auth service locally, reproduce the 500 with curl, and show me
the failing code path.
Fix and verify:
Fix the root cause and add a regression test. Run `npm test -- auth` until
green, then summarize the diff.
Check the result with /diff before committing. Background dev servers show up in /ps; /stop stops them.
Kimi Code
Start a session and gather logs via shell mode (! in the empty input box runs a local command; output enters the conversation):
kimi
!kubectl logs deploy/api --since=30m | tail -100
Login returns 500 after the latest deploy. Given the logs above and
`git log --oneline -10`, what is the most likely root cause?
Reproduce:
Run the auth service locally in the background, reproduce the 500 with a
curl POST to /login, and capture the stack trace.
Fix and verify:
Fix the root cause, add a regression test that reproduces the 500, and run
the auth test suite to confirm green.
For a longer unattended investigation you can hand off a persistent objective:
/goal Reproduce the login 500 locally, fix the root cause, and finish only
when the auth test suite passes.
Related
- Claude Code workflows: Claude Code — Workflows
- Codex workflows: Codex CLI workflows
- Kimi Code workflows: Workflows
- Quick-reference tables: All Tools Cheat Sheet
Last verified: 2026-09-07
AI coding tools evolve quickly. If you find outdated information, please open an issue or pull request.