TL;DR
The paper studies tests that an LLM writes for LLM-generated Python functions. The outcome hinges on one thing: does the test-writing model have an explicit list of requirements, or is it hunting for problems "by eye"? Giving it the requirements as a list of rules, one test per rule, made a big difference: on the core tasks, the final code was correct 100% of the time versus 60% with an "include invalid inputs and edge cases" prompt (+38 to +40 points across settings). We think the same idea carries over to reviewing documents, plans and texts, but the paper only tested code.
The core finding — a model told to "check for edge cases" without explicit rules catches only part of the problems. Not because it's lazy, but because it doesn't know what exactly the author forgot. It guesses — on the core tasks, its tests caught 18 of 30 buggy functions, versus 30 of 30 with the rules. Worst of all, the misses happen precisely where the author themselves forgot something: non-obvious cases that nobody spelled out explicitly.
The fix is simple: instead of "find the problems," say "here's a list of N specific requirements, check each one in turn." The content of the specification is what does all the work. Even a plain paragraph of requirements beats an elaborate "think about edge cases" instruction (27 of 30 bugs caught). A numbered checklist with one test per rule adds a small margin on top (30 of 30).
Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.
Method Blueprint
STEP 1: Build a specification -> an explicit list of requirements (N rules)
Can be a separate request: "Give me a list of criteria for [task]"
STEP 2: Feed the model the spec + the material to review
-> For each rule: find a violation or confirm compliance
-> Output: specific violations with the rule they broke
STEP 3: Fix the material based on the violations found
-> Targeted edits only, don't rewrite everything from scratch
Steps 1 and 2 can be merged into one request if the criteria are already known. If not, get the criteria list first, then run the check. This review procedure is our adaptation: in the paper, the rules came from the real spec and were used to write tests for code.
Example in Action
Task: You wrote a sales proposal for a major client worth $50,000. You want to review it before sending — you don't want to hear "looks good overall," you want to know exactly what's wrong.
Prompt:
You are an experienced sales manager who reviews sales proposals before they go out to a client.
Here's a list of requirements for a strong proposal:
1. The client's pain point is clearly stated — not our product, but their problem
2. A concrete, measurable outcome (numbers, timelines, units)
3. Explains WHY us specifically, not competitors
4. Transparent pricing structure — the client understands what they're paying for
5. A specific next step with a deadline
6. No corporate jargon ("leverage," "synergy," "utilize," "in scope of")
7. Length — no more than one page
Check my proposal against each of these 7 rules, one at a time. For each rule: status (✅ met / ⚠️ partial / ❌ violated) and a specific explanation of what exactly is wrong.
Here's the proposal:
[proposal text]
Result:
The model walks through each of the 7 rules separately. For each one — a status and specifics: not "the outcome section feels weak," but "rule 2 is missing numbers — it says 'we'll improve efficiency' but doesn't specify by what percentage or over what timeframe." At the end — a list of exactly the spots that need rewriting, each tied to a rule.
Why This Works
An LLM without explicit criteria is like an editor told to "just check the text." It'll check whatever it itself considers important. If the author forgot to include a price, the editor might skip that, because in their mental model a price is "usually there." The model doesn't know what the author actually left out — it's not a mind reader.
When you give it an explicit list of rules, something different happens: each rule becomes its own separate check request. The model isn't choosing what to check — it's checking everything. A non-obvious case ("what if the client submits an empty string?") becomes explicit ("rule 4: handling empty input"). The model can't skip it.
Prompt control levers: - Number of rules → there's no magic number. In the paper, what mattered was covering the right rules (the core tasks had 4–5 each), not the raw count. Cover every requirement that can actually be broken - Rule specificity → the more concrete the wording ("numbers and timelines" instead of "specifics"), the more precise the check - Output format → add "output only the violations" for a quick result, or "output everything with explanations" for a full audit - Source of rules → rules can come from a standard, a methodology, a client checklist — and they're already explicit criteria
Prompt Template
Check {what we're reviewing} against the following list of requirements.
Requirements:
1. {requirement_1}
2. {requirement_2}
3. {requirement_3}
[... all requirements]
For each requirement, in turn:
- Status: ✅ met / ⚠️ partial / ❌ violated
- Specific explanation: what exactly is wrong (if not met)
- A quote from the material demonstrating the issue (if applicable)
At the end — a short list of edits: what exactly to rewrite and how.
Here's the material to review:
{text / plan / document}
Placeholders:
- {what we're reviewing} — "sales proposal," "product spec," "article," "business plan"
- {requirement_N} — specific criteria for your task (you can ask the LLM to generate the list first)
- {text / plan / document} — the actual material to review
🚀 Quick Start — paste into the chat:
Here's the Specification Grounding template — checking material against an explicit list of criteria.
Adapt it to my task: [your task].
Ask me questions to fill in the fields.
[paste the template above]
The LLM will ask what material you're reviewing and whether you have criteria — because without a list of requirements, the method won't run. If you don't have criteria, it will first offer to generate some for your task, then apply the review template.
Limitations
⚠️ Algorithmic logic: The method helps wherever there's a specification — clear requirements for behavior. For tasks where the main difficulty is the algorithm itself ("figure out how to optimize...") rather than rule compliance, the paper saw no gain: on its logic tasks it neither helped nor hurt.
⚠️ Spec quality: If the rules are incomplete or vague, you lose much of the benefit: in the paper, detection depended on covering the right rules. "The text should be good" is not a rule. "Each paragraph starts with a thesis explained in the following sentences" is a rule.
⚠️ False alarms without a spec: Without explicit rules, LLMs not only miss real problems but also flag nonexistent ones more often. In the study, on three behavioural tasks, tests written with the edge-case prompt falsely rejected correct code on 33% of checks; rule-based tests had 0%. Rules give the model an anchor: "this violates rule N" instead of a subjective judgment call.
⚠️ Subjective criteria: If the rules describe taste or style ("the text should feel alive"), expect the model to be less accurate than with objective criteria (our caution; the paper only tested checkable code behaviour).
How It Was Studied
A team from TD Bank ran an elegant experiment: one variable, everything else fixed. They took 18 tasks involving writing small Python functions. Each function was generated by an LLM — and it almost always handled ordinary cases correctly but forgot the edge cases. They then had a fixed tester model (Claude Sonnet 4.6) write tests for the exact same code in two ways: FREE+ ("include invalid inputs and edge cases") and SPEC (same tester, same number of tests — but with explicit rules, one test per rule). Failing tests were fed back for repair. Correctness was determined by an independent "gold" test suite no model ever saw.
What was surprising: doubling the number of tests for the plain baseline (no edge-case prompt) produced almost nothing (+4 pp). On a separate set of 29 buggy functions, combining 8 independent edge-case runs caught 15, while a single pass through the rules caught all 29. The researchers expected quantity to help — it didn't. Only the content of the specification helped.
They also checked whether it was about format rather than content. They gave the model the spec as a single connected paragraph (not a list) — it still caught 27 of 30 buggy functions. Asked to plan tests from the task description alone, with no spec — 2 of 30. That answers the "why": the model doesn't infer what the author left out. It needs to be told explicitly.
The main study used Claude models only (Haiku 4.5, Sonnet 4.6, Opus 4.8 as code writers; +38 points on each). A smaller cross-vendor check on 12 tasks also showed gains with GPT-5.3-codex (+28) and Gemini 3.5 Flash (+19). An appendix test on tasks whose specs come from public standards (RFC, CSS, ISO) gave 100% vs 32% — so the researchers couldn't simply "stack the deck" by inventing convenient rules.
Original from the Paper
SPEC arm (tester sees the ticket + the spec as K rules; prompt from Appendix B):
"Produce exactly K test cases, one focused case per rule, in order.
A rule about invalid input should give a case that expects an error."
FREE+ arm (tester sees only the ticket; prompt from Appendix B):
"Produce exactly K test cases that check the function thoroughly.
Be sure to include cases for invalid inputs, error conditions,
and boundary/edge values, not just typical inputs."
Expected values come from the specification, never from any code.
Key ablation results (§4.2, buggy functions caught):
- Plan only (task decomposition, no spec): 2/30 bugs caught
- Spec as plain paragraph: 27/30 bugs caught
- Spec as enumerated checklist (one test per rule): 30/30 bugs caught
Context: These are the paper's tester prompts for the two main arms, SPEC and FREE+. The key difference is that SPEC gets the specification as a list of rules. The ablation shows that most of the gain comes from the content of the spec, not the format: enumerating the rules adds only a small margin over a paragraph (30 vs 27 of 30).
Adaptations and Extrapolations
1. Adaptation: generating the spec before reviewing
If you don't have rules — ask the LLM to come up with them first, then apply the method. Be careful: in an appendix test, rules drafted by a model instead of taken from a real spec brought false alarms back (up to 33%), so check the list yourself.
💡 Two-step SPEC:
Step 1:
I want to review {what we're reviewing} before finalizing it. Draft a list of 7-10 specific, checkable quality criteria for {type of material}. Each criterion should be objective: answerable with YES or NO.Step 2: use the resulting list in the main review template.
2. Technique: "SPEC for the other side"
🔧 Use the client's/audience's requirements as the spec → review from their point of view
Instead of your own criteria — the other party's explicit objections or requirements:
Here's a list of typical investor objections at a pitch session: 1. Market is too small — less than $100 million 2. No defense against a big player copying it (Google, Amazon) 3. Unit economics don't hold up at scale 4. Team has no experience in this industry 5. Dependent on a single customer-acquisition channel Check my pitch against each objection. For each one: is it addressed in the pitch, and how convincingly?
3. Extrapolation: SPEC + iterative improvement
Standard SPEC gives you a review and a list of edits. You can add a repair loop:
[SPEC review prompt]
After reviewing: fix every item marked ❌ and ⚠️.
Output the corrected version and a list of changes.
Then go through the requirements list again — confirm every ❌ became a ✅.
This mirrors the repair loop from the study — just in a single conversation. The LLM first finds violations, then fixes them, then double-checks itself.
Resources
Paper: "Specification Grounding Drives Test Effectiveness for LLM Code"
Authors: Amin Haeri, Mahdi Ghelichi — Model Development Innovation, TD Bank, Toronto, Canada
Contact: [email protected], [email protected]
Related work cited in the paper: - AlphaCodium (Ridnik et al., 2024) — iterative code generation with tests - Self-Refine (Madaan et al., 2023) — LLM self-correction - Reflexion (Shinn et al., 2023) — feedback-based iteration - EvalPlus (Liu et al., 2023) — extended test suites for code evaluation - TiCoder (Lahiri et al., 2022) — formalizing intent through human-in-the-loop tests