AI Hub
ENES

CONCEPT · PATTERNS

Edge Cases Discovered With AI

Asking AI to propose the edge cases you didn't think of is a genuinely generative use: it surfaces what you didn't know was missing.

2 min read · updated 2026-07

What is it

An edge case is a boundary case —a null input, a value at the limit, two requests at once— that breaks the code if no one anticipated it. "Edge cases discovered with AI" is a concrete practice: asking a model to enumerate the cases you didn't think of, instead of trying to remember them all from memory.

What's generative here isn't the list itself —any checklist does that— but that the model, trained on millions of bugs and specs, proposes cases specific to your domain that weren't in your head or in the ticket.

Mental model

You know your code's "happy path" because you wrote it deliberately. Edge cases are, by definition, the ones you didn't think of — and you can't search for what you don't know exists. AI acts here like a colleague who has already watched a thousand similar systems fail and asks, "what if the user sends this?"

Categories worth asking about:

CategoryExample case
Inputnull, empty, wrong type, huge string
Limits0, 1, the max, negative, off-by-one
Concurrencytwo requests to the same resource at once
External failurestimeout, 500, network drop mid-operation
Permissionsuser without access, expired session

How it's used

The key is the prompt: give it the code or the rule, and explicitly ask for the missing cases.

Here's my canUserCheckout(user, cart) function.
List the edge cases I'm NOT covering, grouped by category
(input, limits, concurrency, external failures, permissions).
For each: what happens today and what should happen.
Don't write code yet.

The model returns cases; you decide which matter —not all apply— and only then ask for tests or the fix. This pattern combines naturally with generating tests with Claude Code: first you discover the cases, then you cover them.

Warning: AI proposes plausible cases, not absolute truth. It will list things that don't apply to your domain and may omit a critical one. It's a thinking trigger, not a replacement for your judgment.

When to use it / when not to

Use it when:

  • You're about to test business logic or validations.
  • A production bug showed you a case you missed: ask for the "cousins" of that case.
  • You're working in a new domain where you don't have intuition yet.

You don't need it when:

  • The function is trivial and its domain is obvious.
  • You already have an exhaustive, business-validated case spec: there AI adds little.

RELATED

Edge Cases Discovered With AI — AI Hub