Rules
Path-based rules that auto-load context for Claude Code.
Rules are markdown files that provide context and constraints to Claude Code. They auto-load based on file paths — edit a Rails controller and the API rules kick in automatically.
How rules work
Rules live in .claude/rules/ and are scoped by file path patterns. When Claude Code is working on a file, matching rules are injected into context.
.claude/rules/
├── api.md # Loaded when editing api/**/*
├── cli.md # Loaded when editing cli/**/*
├── dashboard.md # Loaded when editing dashboard/**/*
└── general.md # Loaded for all filesRule file format
Rules are plain markdown. No special frontmatter required.
# API Rules
## Tech Stack
- Rails 8.0 API (JSON endpoints)
- PostgreSQL 15+
- MiniTest for testing
## Patterns
- Controllers are thin — business logic lives in services
- Use Pundit for authorization
- All queries scoped to current organizationPath-based auto-loading
crewkit uses the file path pattern in the rule name to determine when to load it:
| Rule file | Loaded when editing |
|---|---|
api.md | Files under api/ |
cli.md | Files under cli/ |
dashboard.md | Files under dashboard/ |
general.md | All files |
This is configured in your project's CLAUDE.md:
> Component-specific rules auto-load by path:
> `api/**/*` -> `.claude/rules/api.md`
> `cli/**/*` -> `.claude/rules/cli.md`
> `dashboard/**/*` -> `.claude/rules/dashboard.md`Sync behavior
Rules sync the same way as agents — fetched from the API, written to .claude/rules/, checksummed to avoid overwriting local edits.
Rule tiers
Rules can exist at platform, organization, or project level. See Inheritance.