Apply Model-First Reasoning (MFR) to code generation tasks. Use when the user requests "model-first", "MFR", "formal modeling before coding", "model then implement", or when tasks involve complex logic, state machines, constraint systems, or any implementation requiring formal correctness guarantees. Enforces strict separation between modeling and implementation phases.
View on GitHubpetekp/agent-skills
explainer
January 25, 2026
Select agents to install to:
npx add-skill https://github.com/petekp/agent-skills/blob/main/skills/model-first-reasoning/SKILL.md -a claude-code --skill model-first-reasoningInstallation paths:
.claude/skills/model-first-reasoning/# Model-First Reasoning (MFR) A rigorous methodology that REQUIRES constructing an explicit problem MODEL before any reasoning or implementation. The model becomes a frozen contract that governs all downstream work. > Based on Kumar & Rana (2025), "Model-First Reasoning LLM Agents: Reducing Hallucinations through Explicit Problem Modeling" (arXiv:2512.14474) ## Why MFR Works **Hallucination is not merely the generation of false statements—it is a symptom of reasoning performed without a clearly defined model of the problem space.** Reasoning does not create structure; it operates on structure. When that structure is implicit or unstable, reasoning becomes unreliable. MFR provides "soft symbolic grounding"—enough structure to stabilize reasoning without imposing rigid formalism. ## Core Principle **Phase 1 produces the MODEL. Phase 2 reasons/implements ONLY within the model.** This prevents the common failure mode where reasoning introduces ad-hoc decisions, missing constraints, or invented behavior not grounded in the problem definition. ## Non-Negotiable Rules 1. **Phase 1 (Model)** produces NO code, no solution steps—only the formal model 2. **Phase 2 (Implement)** may NOT introduce new entities, state, actions, or constraints 3. If you need something not in the model: output exactly `MODEL INCOMPLETE` + what to add, then STOP 4. No invented APIs or dependencies. If not provided, either ask (unknowns) or create a stub clearly marked `STUB` ## The Model as Contract After creating the model, run a **MODEL AUDIT** before coding: ### Audit Checks | Check | Description | |-------|-------------| | **Coverage** | Every user requirement is represented in exactly one of: a constraint, the goal/acceptance criteria, or an action precondition/effect | | **Operability** | Every operation your plan would require is present as an action | | **Consistency** | Constraints don't contradict each other; action effects don't violate invariants | | **Testability** | Every