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 backend route handler and the backend 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/
├── backend.md # Loaded when editing backend/**/*
├── web.md # Loaded when editing web/**/*
├── mobile.md # Loaded when editing mobile/**/*
└── general.md # Loaded for all filesRule file format
Rules are plain markdown. No special frontmatter required.
# Backend Rules
## Tech Stack
- Express (JSON API endpoints)
- MySQL 8
- Jest for testing
## Patterns
- Route handlers are thin — business logic lives in services
- Authorization checks live in middleware, not handlers
- All queries scoped to the current accountPath-based auto-loading
crewkit uses the file path pattern in the rule name to determine when to load it:
| Rule file | Loaded when editing |
|---|---|
backend.md | Files under backend/ |
web.md | Files under web/ |
mobile.md | Files under mobile/ |
general.md | All files |
This is configured in your project's CLAUDE.md:
> Component-specific rules auto-load by path:
> `backend/**/*` -> `.claude/rules/backend.md`
> `web/**/*` -> `.claude/rules/web.md`
> `mobile/**/*` -> `.claude/rules/mobile.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.