Rules File Creator
Create effective AGENTS.md (or CLAUDE.md) files that maximize AI agent performance.
Core Insight
LLMs are stateless. They know nothing about your codebase at session start. The rules file is the only content guaranteed in every conversation—making it high-leverage but also high-risk if poorly written.
The Three Pillars
A good rules file answers:
| Pillar | Purpose |
|---|---|
| WHAT | Tech stack, project structure, codebase map |
| WHY | Purpose of the project and its components |
| HOW | How to work on the project (tools, commands, verification) |
Guiding Principles
Less Is More
- LLMs reliably follow ~150-200 instructions
- Agent harnesses already consume ~50 instructions
- Each unnecessary instruction degrades performance uniformly across all instructions
- Target: <300 lines, ideally <100
Universal Applicability
- Only include what applies to every session
- Task-specific content dilutes relevance and may be ignored
- Agent harnesses wrap rules with "may or may not be relevant"—bloated files get skipped
Progressive Disclosure
Don't dump everything in the file. Maintain separate docs and point to them:
agent_docs/
├── building.md
├── testing.md
├── code_conventions.md
├── architecture.md
└── database_schema.md
Then in your rules file:
## Additional Context
When working on specific areas, read the relevant guide:
- Building: `agent_docs/building.md`
- Testing: `agent_docs/testing.md`
- Architecture: `agent_docs/architecture.md`
Pointers Over Copies
- Use
file:linereferences instead of embedding code - Code snippets become stale; references stay current
- Example: "See the validation logic in
app/models/user.rb:42-58"
Don't Replicate Tooling
- Never use LLMs as linters—they're slow and expensive
- Reference your linter/formatter config instead
- Example: "Format with
npm run formatbefore committing"
Craft Deliberately
- Never auto-generate with
/initor similar - This is your highest leverage point
- Every line affects all downstream work: research, plans, implementation
Instructions
Creating a New Rules File
Assess the project:
- Identify the tech stack and key dependencies
- Understand the project structure (monorepo? microservices?)
- Find existing build/test/lint commands
Draft the WHAT section:
- Brief repository overview (1-2 sentences)
- Project structure with directories and their purposes
- Key technologies and frameworks
Draft the WHY section (often implicit):
- What problem does this project solve?
- What are the main components and their roles?
Draft the HOW section:
- Build commands (keep concise—just the essentials)
- Test commands
- Lint/format commands
- Any project-specific workflows
Add progressive disclosure pointers:
- List any existing documentation the agent should reference
- Create
agent_docs/if needed for complex topics
Review for bloat:
- Remove anything not universally applicable
- Convert code snippets to file references
- Ensure <300 lines
Auditing an Existing Rules File
- Count instructions: Estimate the number of discrete directives
- Check universality: Flag anything task-specific
- Identify code snippets: Convert to file references
- Look for linter duplication: Remove style rules handled by tools
- Measure length: Target <300 lines
- Suggest progressive disclosure: Move specialized content to separate docs
Template
# AGENTS.md
Brief description of the repository and its purpose.
## Project Structure
\`\`\`
project/
├── src/ # Application source code
├── tests/ # Test suite
└── docs/ # Documentation
\`\`\`
## Tech Stack
- Language: [e.g., TypeScript 5.x]
- Framework: [e.g., Next.js 14]
- Database: [e.g., PostgreSQL 16]
## Commands
| Task | Command |
| ------ | ---------------- |
| Build | `npm run build` |
| Test | `npm run test` |
| Lint | `npm run lint` |
| Format | `npm run format` |
## Code Style
[Reference your linter/formatter config, don't enumerate rules]
Formatting is handled by Prettier (`.prettierrc`). Linting by ESLint (`.eslintrc`).
Run `npm run format` before committing.
## Additional Context
For detailed guidance on specific areas:
- Architecture decisions: `docs/architecture.md`
- Database schema: `docs/schema.md`
- API conventions: `docs/api.md`
## Important Notes
[Only include truly universal gotchas—things that affect every session]
- Environment variables are in `.env.example`
- Never commit secrets
- Default branch is `main`
Anti-Patterns to Avoid
| Anti-Pattern | Why It's Bad | Instead |
|---|---|---|
| Exhaustive command lists | Bloats context, rarely all relevant | Essential commands only |
| Inline code style rules | Duplicates linter, wastes instructions | Reference config files |
| Task-specific instructions | Dilutes relevance, may cause file to be ignored | Move to separate docs |
| Auto-generated content | Generic, misses project nuance | Hand-craft deliberately |
| Long code examples | Becomes stale, bloats context | Use file:line references |
| "Always do X" for edge cases | Wastes instruction budget on rare scenarios | Document in task-specific guides |
Output
When creating or auditing a rules file:
- Present the proposed content in a code block
- Note the line count
- Highlight any sections that could be moved to progressive disclosure
- Flag any remaining anti-patterns for user decision
Converted and distributed by TomeVault — claim your Tome and manage your conversions.