Standards for writing CLAUDE.md and modular rules files (.claude/rules/) that maximize LLM execution efficiency. Use when creating or editing project instructions, defining conventions, or optimizing agent behavior for determinism and token efficiency. Focuses on eliminating ambiguity and producing consistent agent execution.
This skill inherits all available tools. When active, it can use any tool Claude has access to.
Write CLAUDE.md and rules files optimized for LLM parsing, not human aesthetics.
CLAUDE.md provides persistent project context loaded at conversation start. Content becomes part of the system prompt.
Rules files (.claude/rules/) organize instructions into focused modules. Support unconditional rules (apply everywhere) and path-specific rules (apply to matching files only).
Determinism and token efficiency matter because context window is shared. Every token competes with conversation history and other context. Instructions that permit multiple interpretations produce inconsistent agent behavior.
For foundational instruction authoring principles (token economics, imperative language, formatting, anti-patterns), invoke the authoring-prompts skill first. This skill applies those principles specifically to CLAUDE.md and rules files.
Include when applicable:
Project Overview (2-3 sentences): What the project is. Technology stack. Omit if name and structure make it obvious.
Commands: Exact commands with all flags. One per concern (test, build, deploy, lint).
File Boundaries: Explicit paths for safe-to-edit and never-touch locations.
Conventions: Project-specific patterns only. Omit generic programming advice.
Workflows: Step-by-step procedures for complex operations (deployment, releases).
Generic programming advice Claude already knows: "Write clean code", "Use meaningful names", "Add comments where necessary."
Information inferable from codebase: Framework being used (visible in imports), file organization (visible in structure).
Decorative content: Welcome messages, motivational statements, background history.
Hypothetical scenarios: "If we ever migrate to Postgres..." Address when actual, not hypothetical.
Before finalizing CLAUDE.md:
| Put in CLAUDE.md | Put in .claude/rules/ |
|---|---|
| Project-wide commands (test, build, deploy) | Language-specific patterns (Ruby, TypeScript, Python) |
| Global file boundaries (vendor/, node_modules/) | Framework conventions (Rails, React, FastAPI) |
| Workflow procedures (release process) | Path-specific constraints (API validation, test structure) |
| Architecture decisions (monorepo structure) | Domain-specific rules (frontend styles, backend errors) |
Unconditional rules: .claude/rules/security.md, .claude/rules/testing.md - apply to all files.
Path-specific rules: Use YAML frontmatter with paths field - apply only to matching files.
---
paths: src/api/**/*.ts
---
# API Conventions
Return `IActionResult<T>` for all endpoints.
Subdirectories: Organize by domain - .claude/rules/frontend/, .claude/rules/backend/.
Naming: Descriptive, singular topic per file - api-design.md, error-handling.md, not stuff.md.
Use glob patterns for precise scope:
| Pattern | Matches |
|---|---|
**/*.ts | All TypeScript files anywhere |
src/**/* | All files under src/ |
*.md | Markdown files in project root only |
src/components/**/*.tsx | React components in src/components/ |
{src,lib}/**/*.ts | TypeScript in src/ or lib/ |
Multiple patterns: paths: src/**/*.{ts,tsx}, tests/**/*.test.ts
Test patterns before committing. Verify they match intended files only.
Use path-specific rules when conventions apply to subset of files:
Use unconditional rules for project-wide requirements that apply everywhere.
Create personal rules in ~/.claude/rules/ that apply to all projects.
User-level rules load before project rules. Project rules take precedence on conflict.
Use for personal preferences: editor configuration, commit message style, code review approach.
# [Project Name]
## Commands
- `[command with all flags]`: [description]
- `[command with all flags]`: [description]
## File Boundaries
- Edit: [explicit paths]
- Never touch: [explicit paths]
## Conventions
[Only project-specific patterns Claude cannot infer]
---
paths: [glob pattern]
---
# [Domain] Conventions
[Imperative instruction]
[Imperative instruction]
[Imperative instruction]
See templates/minimal-claude.md for annotated starting point.
For path-specific rule template, see templates/path-rule.md.
For before/after optimization examples, see references/examples.md.