AGENTS.md
Copy this into the AGENTS.md at the root of your project, or into your global agent instructions. It tells coding agents when to call the MCP server and which skill to load, so the code they write follows the patterns on this site.
# Agent instructions
## Design patterns, refactoring and code smells
This project uses the AI Patterns reference. Consult it before adding a design pattern or refactoring code.
- MCP server: https://aipatterns.dev/mcp (read-only, OAuth). Call recommend with a plain description of the problem. Call find_refactorings, then get_refactoring_steps, before you restructure code. Call detect_smells, then get_smell_treatment, when code seems wrong but the cause has no name. Call check_pattern_fit before adding a pattern, then grill_pattern before implementing it - it lists the infrastructure to check and the questions to settle with the user. Call search to find a slug, and get_entry for a full entry. Call get_section with "Do not use it when" or "Agent checklist" to save tokens.
- Skills: aipatterns-pattern-selection decides whether a pattern is warranted. aipatterns-grill interrogates a codebase before a pattern is applied. aipatterns-design-patterns implements a GoF pattern. aipatterns-refactoring applies a technique in small steps. aipatterns-code-smells names the smell behind a problem.
## Rules
1. Name the problem, a smell or a force that hurts, before you choose a pattern. Call recommend first.
2. Read "Do not use it when" before "Use it when". If none of the forces apply, write the simplest code and add no pattern.
3. Prefer a language feature (function values, generics, closures, sum types) over a pattern that emulates it.
4. Refactor in small, behavior-preserving steps, and run the tests after each one.
5. Work through the entry's "Agent checklist" before you report the work as done.
6. Cite the entry URL in your explanation, so a human can check your reasoning.
7. Use the code examples in the language of this codebase.