counterexample-explainer
Explain why counterexamples violate specifications by analyzing formal specifications (temporal logic, invariants, pre/postconditions, code contracts), informal requirements (user stories, acceptance criteria), test specifications (assertions, property-based tests), and providing step-by-step traces showing state changes, comparing expected vs actual behavior, identifying root causes, and assessing violation impact. Use when debugging test failures, understanding model checker output, explaining runtime assertion violations, analyzing static analysis warnings, or teaching specification concept
npx skills add majiayu000/claude-skill-registry --skill counterexample-explainer --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Counterexample Explainer ## Overview Analyze counterexamples that violate specifications and produce clear, structured explanations showing step-by-step how and why the violation occurs, with root cause analysis and impact assessment. ## Workflow ### 1. Understand the Specification Identify what property is being checked. **Questions to ask:** - What is the specification or requirement? - Is it formal (invariant, temporal logic) or informal (requirement doc)? - What should happen vs what actually happened? - Is this from a test failure, model checker, or runtime error? See [specification-types.md](references/specification-types.md) for comprehensive specification catalog. **Common specification types:** **Formal specifications:** - Invariants: `balance >= 0` - Temporal logic: `G(request → F grant)` - Pre/postconditions: `@requires(x > 0)`, `@ensures(result >= 0)` - State machines: Valid state transitions - Concurrency: Atomicity, deadlock freedom **Informal requirements:** - User stories with acceptance criteria - Functional requirements - API contracts - Expected behavior descriptions **Test specifications:** - Assertions: `assert result == expected` - Property-based tests - Int
- Overview
- Workflow
- 1. Understand the Specification
- 2. Collect Counterexample Information
- 3. Identify Violation Point
- 4. Generate Step-by-Step Trace
- 5. Compare Expected vs Actual
- 6. Identify Root Cause
- 7. Assess Impact
- 8. Present Complete Explanation
- Example Workflows
- Example 1: Test Failure Explanation
- Example 2: Temporal Logic Violation
- Tips for Clear Explanations
Run test to get failure details pytest test_file.py::test_name -v Get stack trace pytest test_file.py::test_name -v --tb=long Get variable values at failure pytest test_file.py::test_name -v -l
What does the counterexample-explainer skill do?
Explain why counterexamples violate specifications by analyzing formal specifications (temporal logic, invariants, pre/postconditions, code contracts), informal requirements (user stories, acceptance criteria), test specifications (assertions, property-based tests), and providing step-by-step traces showing state changes, comparing expected vs actual behavior, identifying root causes, and assessing violation impact. Use when debugging test failures, understanding model checker output, explaining runtime assertion violations, analyzing static analysis warnings, or teaching specification concept
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill counterexample-explainer --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
