@@ -6,20 +6,24 @@ This document defines the format for context files used by mantra.
66
77** Base context** (shipped with plugin):
88```
9- <plugin-root>/context/
10- ├── behavior.yml # AI behavior rules
11- ├── behavior.md # Detailed behavior guide
12- ├── context-format.yml # Format specification
13- ├── context-format.md # Detailed format guide
14- └── format-guide.yml # Compact YAML conventions
9+ <plugin-root>/
10+ ├── rules/ # Rule files (auto-injected)
11+ │ ├── behavior.md # AI behavior rules (frontmatter + optional body)
12+ │ ├── test.md # Testing conventions
13+ │ └── ...
14+ └── context/ # Companion docs (on-demand)
15+ ├── behavior.md # Detailed behavior guide
16+ ├── test.md # Detailed test examples
17+ └── ...
1518```
1619
1720** Project extensions** (your project):
1821```
19- .claude/context/
20- ├── project.yml # Project-specific context
21- ├── testing.yml # Testing patterns
22- └── *.yml # Additional context
22+ .claude/
23+ ├── rules/ # Project rule overrides
24+ │ └── *.md # Custom rules with YAML frontmatter
25+ └── context/ # Project companion docs
26+ └── *.md # Detailed examples
2327```
2428
2529** Loading order** : base → sibling plugins → project extensions → CLAUDE.md
@@ -28,22 +32,47 @@ This document defines the format for context files used by mantra.
2832
2933Each topic should have TWO files:
3034
31- ### 1. YAML File (` .yml ` )
35+ ### 1. Rule File (` rules/*.md ` )
3236** Purpose:** Quick context injection for Claude
37+ ** Format:** YAML frontmatter (extracted and injected automatically)
3338** Characteristics:**
3439- Token-efficient (aim for 89% reduction vs prose)
35- - Key-value assertions
40+ - Key-value assertions in frontmatter
3641- Minimal prose
37- - Target size: 10-30 lines
42+ - Target size: 10-30 lines of frontmatter
3843
39- ### 2. Markdown File (` .md ` )
44+ ### 2. Companion Doc (` context/* .md` )
4045** Purpose:** Detailed reference for humans and Claude deep-dives
4146** Characteristics:**
4247- Full prose explanations
4348- Code examples
4449- Edge cases and troubleshooting
4550- Not injected automatically (read on-demand)
4651
52+ ## Rule File Format
53+
54+ Rule files use YAML frontmatter with an optional markdown body:
55+
56+ ``` markdown
57+ ---
58+ companion: behavior.md
59+ type: actionable
60+
61+ ## Assessment
62+ stance: skeptical-default
63+ assess-first: correctness, architecture, risks
64+ never: eager-agreement, sycophantic-tone
65+
66+ ## Implementation
67+ mode: discuss-first (non-trivial) | build-first (trivial)
68+ order: syntax → runtime → logic → optimize
69+ ---
70+
71+ Optional body content (usually omitted for rule files).
72+ ```
73+
74+ The frontmatter between ` --- ` markers is extracted and injected.
75+
4776## YAML Format Conventions
4877
4978### Operators
@@ -71,14 +100,15 @@ Each topic should have TWO files:
71100
72101** Don't:**
73102- Write complete sentences
74- - Include explanations (put in ` .md ` file)
103+ - Include explanations (put in companion ` .md ` file)
75104- Use markdown formatting in YAML
76105- Repeat information
77106
78- ### Example
107+ ### Example Frontmatter
79108
80109``` yaml
81- # behavior.yml - Compact Reference
110+ # behavior.md - Compact Reference
111+ companion : context/behavior.md
82112
83113# # Assessment
84114stance : skeptical-default
@@ -102,18 +132,17 @@ skip: simple-DTOs, getters, boilerplate
102132
103133| File | Purpose |
104134|------|---------|
105- | ` project.yml` | Project identity, architecture, tech stack |
106- | `behavior.yml` | AI behavior rules, assessment stance |
107- | `git.yml` | Git conventions, commit format, PR rules |
108- | `testing.yml` | Testing patterns, what to test/skip |
109- | `sessions.yml` | Session management workflow |
110- | `<domain>.yml` | Domain-specific context |
135+ | ` behavior.md` | AI behavior rules, assessment stance |
136+ | `git.md` | Git conventions, commit format, PR rules |
137+ | `test.md` | Testing patterns, what to test/skip |
138+ | `sessions.md` | Session management workflow |
139+ | `<domain>.md` | Domain-specific rules |
111140
112141# ## Naming Rules
113142- Use lowercase
114143- Use hyphens for multi-word names
115144- Be descriptive but concise
116- - Pair with same-name `.md` file for details
145+ - Pair with same-name companion file in `context/` for details
117146
118147# # Token Efficiency
119148
@@ -132,13 +161,13 @@ Context files are injected into Claude's context window. Efficiency matters.
132161
1331621. **Abbreviate consistently** - Use same short forms throughout
1341632. **Omit obvious context** - Don't repeat what's in project files
135- 3. **Use references** - Point to `.md` files for details
164+ 3. **Use references** - Point to companion `.md` files for details
1361654. **Prioritize** - Put most important rules first
1371665. **Prune regularly** - Remove obsolete content
138167
139168# # Interpretation Guide
140169
141- When Claude reads compact YAML :
170+ When Claude reads compact YAML frontmatter :
142171
143172| Pattern | Interpretation |
144173|---------|----------------|
@@ -153,7 +182,7 @@ When Claude reads compact YAML:
153182
154183mantra validates :
155184- File exists and is readable
156- - Valid YAML syntax
185+ - Valid YAML frontmatter syntax
157186- File size within limits
158187
159188mantra does NOT validate :
@@ -166,8 +195,8 @@ mantra does NOT validate:
166195If migrating from a single `CLAUDE.md` :
167196
1681971. **Identify topics** - Group related rules
169- 2. **Extract assertions ** - Pull out key rules for YAML
170- 3. **Keep details** - Leave examples/explanations in `.md`
198+ 2. **Create rule file ** - Add YAML frontmatter to `rules/<topic>.md`
199+ 3. **Keep details** - Leave examples/explanations in `context/<topic> .md`
1712004. **Test refresh** - Verify context injects correctly
172201
173202# ## Before (CLAUDE.md excerpt)
@@ -179,10 +208,14 @@ or Co-Authored-By tags. Commit messages should be lowercase after
179208the issue number. Format: "#N - verb description"
180209` ` `
181210
182- # ## After (git.yml)
183- ` ` ` yaml
211+ # ## After (rules/git.md)
212+ ` ` ` markdown
213+ ---
184214# Git Workflow - Compact Reference
215+ companion: context/git.md
216+
185217commit-format: "#N - verb desc" | "chore - desc"
186218commit-style: HEREDOC, lowercase-after-dash
187219no: attribution, co-authored-by, emojis
220+ ---
188221` ` `
0 commit comments