Path Rules complement the bootstrap system (RULES.md). While RULES.md defines global rules, Path Rules defines rules specific to parts of the codebase.
Concept
The idea is simple: different parts of the codebase have different conventions. Go code follows different rules than HTML templates. Tests have different patterns than production code. Path Rules lets you define all of this granularly.File Structure
Rules are placed in the.chatcli/rules/ directory (workspace) or ~/.chatcli/rules/ (global):
File Format
Each rule file is Markdown with YAML frontmatter containing thepaths field:
Precedence
- Workspace vs Global
- Multiple rules
Rules exist at two levels with workspace taking priority:
If a rule file with the same name exists at both levels, the workspace version takes precedence.
Glob Matching
Thepaths field uses glob patterns to match file paths:
Lazy Loading
Path Rules uses lazy loading based on conversation hints:1
Context detection
ChatCLI analyzes recent messages and tool calls to identify which files are in context (read, edited, mentioned).
2
Pattern matching
Detected paths are compared against the
paths patterns of each rule file.3
Selective injection
Only rules that match files in context are injected into the system prompt.
4
Dynamic update
Every turn, patterns are re-evaluated. New rules can be injected and irrelevant rules can be removed.
Lazy loading ensures the system prompt doesn’t get overloaded with irrelevant rules. Only rules needed for the files under discussion are loaded, saving tokens.
Rule Examples
- Go
- Tests
- Security
- Migrations
.chatcli/rules/go-rules.md:Viewing Active Rules
You can check which rules are currently active:Best Practices
Specific rules
Define precise path patterns. Rules that are too broad (
**/*) waste tokens on irrelevant contexts.Concise rules
Keep each rule file short and focused. Long rules consume more tokens.
Version in Git
Put
.chatcli/rules/ in your repository to share with the team.Combine with RULES.md
Use RULES.md for global rules and Path Rules for rules specific to areas of the codebase.
Next Steps
Bootstrap and Memory
Configure RULES.md for global rules that complement Path Rules.
Customizable Agents
Combine Path Rules with specialized agents for maximum context.