← All use cases

中文

Building software · Claude Code

Point Claude Code at a failing test to find a hard bug

Idea + starter prompt, not run by us yet

For: Developers stuck on a tricky bug who have a test that shows the failure

Filippo Valsorda gave Claude Code the test command, the code folder and the failing symptom for his new Go crypto code. It read the code, traced the bug and checked a theory by writing a quick extra test. It found all three bugs, but its fixes were weak, so he rewrote them himself.

Steps

  1. Write or find a test that fails because of the bug.
  2. Start a fresh session for each separate bug.
  3. Paste the starter prompt with the test command, folder and symptom.
  4. Use its answer as a pointer to the bug, then write the fix yourself or review it closely.

Starter prompt

Starter prompt. Change the [brackets] first.

There is a bug in the code in [folder]. Run the tests with [test command]. The failing test is [test name] and the symptom is [what goes wrong].

Think it through carefully. Read the code, form a guess about the cause and test it with a small extra test if that helps.

Tell me where the bug is and why it happens. Do not commit any changes. If you suggest a fix, keep it separate so I can review it.

Original post: words.filippo.io · found via agentusecases.ai. Written up in our own words. We haven't run it, so test it on made-up data first.