How Do You Get Claude to Find the Edge Cases You Missed?
Ask for a ranked list of untested cases before you ask for any test code, and give Claude the function plus its current tests. In Claude Code, it can read both and trace the real callers, so you're choosing from cases that can actually happen.
Read [path to function] and [path to its tests]. Then look at how it's actually called in this repo. Don't write any tests yet. List the cases the current tests don't cover: - boundary values, and empty or missing input - malformed input and unexpected types - [time zones / currency rounding / concurrency / whatever applies here] For each one, give a concrete input, what happens now according to the code, and what should happen if you can tell. Cite the file and line. Rank by likely harm in production. Mark any case no current caller can produce as "unreachable", and leave out anything you can't tie to this code. I'll choose which ones become tests.
Try it now
- 1In Claude Code, run
/effort high, then paste the prompt with your paths. In a chat window, paste the function and its tests instead. - 2Cross off whatever is marked unreachable, then reply with the numbers of the cases you want.
- 3Ask
add tests for cases 1, 3 and 4 in the existing test file, run them, and show me the output. The docs say Claude checks your existing test files to match their style, framework and assertions. - 4A case earns its place if the test fails on the current code, or proves something you hadn't checked. If every new test passes first time, ask which bug each one would catch.
Use it when
Parsers, validators, date math, money, permission checks and anything that takes user input. Also when coverage looks high but bugs still get through, or when you've inherited tests nobody trusts.
Skip it when
A short pure function with an obvious input range, where the list would be longer than the code. Also code you're about to delete or rewrite, since new tests would pin behavior you plan to throw away.
Why it works
Anthropic's docs describe this use directly: Claude can analyze code paths and suggest tests for error conditions, boundary values and unexpected inputs. Keeping the list separate from the writing matters, because the same docs warn that a reviewer asked to find problems will always find something, and fixing every finding leaves you with tests for cases that can't happen. A list lets you reject those before they cost anything. Effort matters too. The docs recommend /effort high or /effort xhigh when getting it right depends on cases that are quick to overlook, because Claude then checks more edge cases. Writing be thorough is only ordinary prompt text.
Example
Take a dateRange(start, end) function whose tests cover only a normal week. A useful list might include a start after the end, a one-day range, a null end, and a range across a daylight saving change. Then check the callers. If your form already rejects a null end, that case is unreachable from the form, though the same function may still be reachable through your public API. Telling those apart is the judgment you keep.
Going further
For a whole class of inputs, ask for a property test instead of more examples. In Python, Hypothesis's @given(st.integers()) generates inputs, 100 per test by default, and reports a failing case it found. Have Claude state the property as one sentence first, such as parsing then formatting returns the original string, and check that sentence yourself. If the property is wrong, every generated case is testing the wrong thing.
Common mistakes
- Accepting every item. Anthropic's best-practices page warns that this is how you get tests for cases that can't happen.
- Pasting only the function into a chat, so Claude can't see the callers and can't tell which cases are reachable.
- Asking for the list and the tests in one request, which skips the step where you choose.
- Testing a case the code documents as out of scope, which locks in behavior you chose not to support.
Sources
Checked 6 November 2026. Products change often, so confirm details with the vendor.