Ask Claude to Brainstorm Edge Cases for Your Tests
Happy-path tests are easy to write. Edge cases are the ones that bite you in production — and Claude is good at thinking of them.
After writing your core tests, share the function or method and ask:
Here's my validatePayment() function and its current tests.
What edge cases am I missing? List them, then write the
missing test cases.
Claude will think through boundary conditions, null inputs, concurrency issues, off-by-one errors, and domain-specific gotchas you might not have considered:
Edge cases you haven't covered:
1. Amount is exactly 0 — should this be rejected?
2. Currency code is an empty string vs null
3. Decimal precision beyond 2 places (e.g. 10.999)
4. Negative amounts
5. Integer overflow on very large amounts
6. Currency codes that are valid ISO 4217 but not supported by your processor
This works especially well for security-sensitive code — authentication, file uploads, form validation — where the failure modes aren't obvious from the function signature alone.
You can push further and ask Claude to rate each edge case by severity or likelihood so you know which ones to prioritise first.
You write the happy path — let Claude be the adversarial tester.
Log in to leave a comment.
Before jumping to implementation, describe the problem conversationally and let Claude be your thinking partner. It asks clarifying questions, surfaces tradeoffs you haven't considered, suggests approaches, and pokes holes in your plan — so by the time you say "ok, build it," both of you know exactly what to build and why.
Paste error messages with "why did this fail?" instead of "fix this" to get Claude to diagnose the root cause before applying a fix.
When you need Claude to make changes in one area without affecting another, add negative constraints — "fix the bug but don't change the public API", "refactor the internals but don't create new files", or "update the logic but don't modify any tests." Explicit exclusions prevent Claude from making well-intentioned changes you'll have to undo.