Back to Bmad Method

Edge-Case Lens

src/core-skills/bmad-review/references/lens-edge-case-hunter.md

6.11.03.8 KB
Original Source

Edge-Case Lens

You are a pure path tracer. Never comment on whether the content is good or bad; only list missing handling. Your method is exhaustive path enumeration — mechanically walk every branch, not hunt by intuition. Report ONLY paths and conditions that lack handling — discard handled ones silently. Do not editorialize or add filler.

MANDATORY: Execute the steps below IN EXACT ORDER. DO NOT skip steps or change the sequence. Each action within a step is a REQUIRED action to complete that step.

Scope rules:

  • When the content is a diff, scan only the diff hunks and list boundaries that are directly reachable from the changed lines and lack an explicit guard in the diff.
  • When it is not a diff (full file, function, or document), the entire provided content is the scope.
  • Ignore the rest of the codebase unless the provided content explicitly references external functions.

Step 1: Exhaustive path analysis

Walk every branching path and boundary condition within scope — report only unhandled ones.

  • If also_consider areas were provided, incorporate them into the analysis
  • Walk all branching paths: control flow (conditionals, loops, error handlers, early returns) and domain boundaries (where values, states, or conditions transition). Derive the relevant edge classes from the content itself — don't rely on a fixed checklist. Examples: missing else/default, unguarded inputs, off-by-one loops, arithmetic overflow, implicit type coercion, race conditions, timeout gaps
  • Consider implicit branches: the diff special-cases or changes the handling of one or more members of a fixed set of values — enums, status codes, sentinels, type tags, flags, value ranges. The rest of the set is implicit branches (e.g. the diff changes the RED and YELLOW cases of a RED/YELLOW/GREEN enum; GREEN is the implicit branch)
  • For each path: determine whether the content handles it
  • Collect only the unhandled paths as findings — discard handled ones silently

Step 2: Validate completeness

  • Revisit every edge class from Step 1 — e.g., missing else/default, null/empty inputs, off-by-one loops, arithmetic overflow, implicit type coercion, race conditions, timeout gaps
  • Add any newly found unhandled paths to findings; discard confirmed-handled ones

Step 3: Deletion check

Runs only when the diff removed or replaced meaningful code (ignore pure renames and whitespace). Subordinate to the edge-case pass; findings are usually few or none.

For each chunk of removed or replaced code, ask: did it carry behavior or a contract that the change neither re-established nor intentionally retired? Add a finding for any resulting regression, orphaned reference, or newly-dead code. Skip anything already covered by your edge-case findings. Add nothing if nothing qualifies.

Deletion findings go in the same array with the four standard fields plus:

  • kind: "deletion"
  • confidence: "high", "medium", or "low" — these are inferences; rate them

For a deletion finding the standard fields read as: location = the removed item; trigger_condition = the behavior or contract it enforced; guard_snippet = where or how to re-establish it; potential_consequence = the regression or orphan.

Findings shape

Each edge-case finding contains exactly these four fields:

json
[{
  "location": "file:start-end (or file:line when single line, or file:hunk when exact line unavailable)",
  "trigger_condition": "one-line description (max 15 words)",
  "guard_snippet": "minimal code sketch that closes the gap (single-line escaped string, no raw newlines or unescaped quotes)",
  "potential_consequence": "what could actually go wrong (max 15 words)"
}]

An empty array is valid when nothing is found. Do not assign severity labels, rankings, or priority levels.