Analyze code to suggest and add Design by Contract specifications (preconditions, postconditions, invariants, semantic invariants) in any language. Trigger on: "Design by Contract", "DBC", "preconditions", "postconditions", "class invariants", "code contracts", "formal specifications", "document assumptions", "add contracts", "make this function safer", "define what this function guarantees", "add assertions to document behavior", Bertrand Meyer, Eiffel contracts, or when discussing invariants that should always hold. Do NOT skip for non-Eiffel code — DBC applies everywhere via assertions, type guards, properties.
92
90%
Does it follow best practices?
Impact
95%
1.05xAverage score across 5 eval scenarios
Passed
No known issues
{
"context": "Tests Python DBC analysis, documentation, executable assertions, and validation artifacts.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Structured analysis",
"description": "Uses Contract Analysis sections for preconditions, postconditions, invariants or semantic invariants, and summary.",
"max_score": 9
},
{
"name": "Status markers",
"description": "Uses ✅, ⚠, or ❌ markers to classify existing or missing contracts.",
"max_score": 6
},
{
"name": "Inputs outputs state",
"description": "Identifies inputs, return value, and whether the items argument or other state is mutated.",
"max_score": 8
},
{
"name": "Preconditions",
"description": "Documents caller obligations for order total range, allowed tier values, and item collection validity.",
"max_score": 12
},
{
"name": "Postconditions",
"description": "Documents guarantees such as result range/relationship to input total and no item mutation.",
"max_score": 10
},
{
"name": "Executable asserts",
"description": "Adds Python executable checks/assertions or equivalent validators with clear error messages.",
"max_score": 12
},
{
"name": "Contract comments",
"description": "Adds comments or docstring describing preconditions and postconditions before or alongside assertions.",
"max_score": 8
},
{
"name": "Crash early",
"description": "Invalid inputs raise immediately instead of returning NaN, None, default totals, or silently accepting unknown tiers.",
"max_score": 10
},
{
"name": "Bad input tests",
"description": "Includes tests or examples showing invalid inputs trigger contract failures.",
"max_score": 10
},
{
"name": "Good input tests",
"description": "Includes tests or examples showing valid current behavior still works.",
"max_score": 7
},
{
"name": "False positive note",
"description": "Mentions that failures during normal operation indicate either a wrong contract or a code bug to investigate.",
"max_score": 8
}
]
}