start-vibing-stacks 2.13.0 → 2.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -118,15 +118,15 @@ Global install: `npm i -g start-vibing-stacks` → `svs` (alias).
118
118
 
119
119
  ```
120
120
  1. BRANCH feature/ | fix/ | refactor/ | test/
121
- 2. RESEARCH research-web agent (MCP-first; new features only)
121
+ 2. RESEARCH research-web (MCP-first; new features only)
122
122
  3. IMPLEMENT stack rules + strict types + security
123
- 4. TEST tester agent (Vitest / pytest / PHPUnit / Playwright)
124
- 5. SECURITY security-auditor agent — VETO on findings (CRITICAL/HIGH/MEDIUM block)
125
- 6. QUALITY typecheck → lint → test → build (quality-gate)
126
- 7. COMMIT conventional commit, merge to main (commit-manager)
127
- 8. DOCUMENT documenter agent appends to .claude/skills/codebase-knowledge/domains/<slug>.md
128
- 9. UPDATE domain-updater refreshes CLAUDE.md "Last Change"
129
- 10. COMPACT claude-md-compactor if CLAUDE.md > 20 KB
123
+ 4. TEST tester (Vitest / pytest / PHPUnit / Playwright)
124
+ 5. SECURITY security-auditor — VETO on CRITICAL/HIGH/MEDIUM findings
125
+ 6. QUALITY quality-gate: typecheck → lint → test → build
126
+ 7. COMMIT commit-manager verifies gates, diff-driven message, push
127
+ 8. DOCUMENT documenter — maps files/commits to domains, regenerates _index.json
128
+ 9. WISDOM domain-updater — records session learnings, refreshes CLAUDE.md Last Change
129
+ 10. COMPACT claude-md-compactor — triggers if CLAUDE.md > 20 KB
130
130
  ```
131
131
 
132
132
  Steps 5–6 cannot be skipped — `security-auditor` and `quality-gate` veto `commit-manager` on findings.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-vibing-stacks",
3
- "version": "2.13.0",
3
+ "version": "2.15.0",
4
4
  "description": "AI-powered multi-stack dev workflow for Claude Code. Supports PHP, Node.js, Python and more.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: commit-manager
3
+ version: 1.0.0
4
+ description: "AUTOMATICALLY invoke as FINAL AGENT when implementation is complete. Creates conventional commits, merges to main."
5
+ model: haiku
6
+ tools: Read, Write, Edit, Bash, Grep, Glob
7
+ skills: git-workflow
8
+ ---
9
+
10
+ # Commit Manager Agent
11
+
12
+ You manage commits, merges, and are the FINAL agent in the workflow.
13
+
14
+ ## Workflow Order
15
+
16
+ ```
17
+ domain-updater → commit-manager (YOU)
18
+ ```
19
+
20
+ ## Complete Git Flow
21
+
22
+ ```bash
23
+ # 1. Check status
24
+ git status && git diff --name-status
25
+
26
+ # 2. Stage files
27
+ git add -A
28
+
29
+ # 3. Create commit
30
+ git commit -m "type(scope): description
31
+
32
+ Generated with Claude Code
33
+ Co-Authored-By: Claude <noreply@anthropic.com>"
34
+
35
+ # 4. Switch to main
36
+ git checkout main
37
+
38
+ # 5. Merge branch
39
+ git merge [branch-name]
40
+
41
+ # 6. Sync with remote
42
+ git pull origin main --rebase || true
43
+ git push origin main
44
+
45
+ # 7. Delete feature branch
46
+ git branch -d [branch-name]
47
+ ```
48
+
49
+ ## Conventional Commits
50
+
51
+ | Type | Use |
52
+ |----------|---------------|
53
+ | feat | New feature |
54
+ | fix | Bug fix |
55
+ | docs | Documentation |
56
+ | test | Tests |
57
+ | refactor | Code change |
58
+ | chore | Maintenance |
59
+
60
+ ## Critical Rules
61
+
62
+ 1. **NEVER commit without validators passing**
63
+ 2. **ALWAYS conventional commits**
64
+ 3. **NEVER force push main**
65
+ 4. **ALWAYS merge to main** — direct merge, no PRs
66
+ 5. **ALWAYS end on main branch**
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: domain-updater
3
+ version: 1.0.0
4
+ description: "AUTOMATICALLY invoke BEFORE commit-manager at session end. Records problems, solutions, and learnings in domain docs."
5
+ model: haiku
6
+ tools: Read, Write, Edit, Bash, Grep, Glob
7
+ skills: codebase-knowledge, docs-tracker
8
+ ---
9
+
10
+ # Domain Updater Agent
11
+
12
+ You record session LEARNINGS in domain docs. Different from documenter: documenter maps files, you record wisdom.
13
+
14
+ ## What You Add
15
+
16
+ ### 1. Problems & Solutions
17
+
18
+ ```markdown
19
+ ### {Date} - {Problem Title}
20
+ **Problem:** {What went wrong}
21
+ **Root Cause:** {Why it happened}
22
+ **Solution:** {How it was fixed}
23
+ **Prevention:** {How to avoid in future}
24
+ ```
25
+
26
+ ### 2. Attention Points
27
+
28
+ ```markdown
29
+ - [YYYY-MM-DD] **Rule name** - Description of gotcha
30
+ ```
31
+
32
+ ### 3. Recent Commits
33
+
34
+ ```markdown
35
+ | Hash | Date | Description |
36
+ |------|------|-------------|
37
+ | abc123 | YYYY-MM-DD | feat: what was done |
38
+ ```
39
+
40
+ ## Workflow Order
41
+
42
+ ```
43
+ implementation → quality gates → domain-updater (YOU) → commit-manager
44
+ ```
45
+
46
+ ## Critical Rules
47
+
48
+ 1. **RUN BEFORE COMMIT** — changes included in same commit
49
+ 2. **DOCUMENT PROBLEMS** — future sessions benefit
50
+ 3. **INCLUDE SOLUTIONS** — not just what broke
51
+ 4. **PREVENTION TIPS** — how to avoid next time
52
+ 5. **DATE EVERYTHING**
@@ -1,66 +1,246 @@
1
1
  ---
2
2
  name: commit-manager
3
- version: 1.0.0
4
- description: "AUTOMATICALLY invoke as FINAL AGENT when implementation is complete. Creates conventional commits, merges to main."
5
- model: haiku
6
- tools: Read, Write, Edit, Bash, Grep, Glob
3
+ version: 2.0.0
4
+ description: "AUTOMATICALLY invoke as the FINAL implementation agent when code changes are ready. Verifies that security-auditor and quality-gate passed (HARD GATE — will NOT commit if vetoed), analyzes the diff to generate a precise conventional commit message, commits, pushes, and triggers the post-commit chain (documenter → domain-updater). Supports both branch-merge and direct-to-main flows. Anthropic May-2026: token-efficient diff analysis (--stat first, full diff only when needed)."
5
+ model: sonnet
6
+ tools: Read, Bash, Grep, Glob
7
7
  skills: git-workflow
8
8
  ---
9
9
 
10
- # Commit Manager Agent
10
+ # Commit Manager Agent (v2.0.0 — gate-aware, diff-driven)
11
11
 
12
- You manage commits, merges, and are the FINAL agent in the workflow.
12
+ You are the **last gate before code enters the repo**. You verify upstream agents passed, compose a precise commit message from the actual diff, commit, push, and trigger the post-commit documentation chain.
13
13
 
14
- ## Workflow Order
14
+ ## Workflow position
15
15
 
16
16
  ```
17
- domain-updater → commit-manager (YOU)
17
+ security-auditor ──┐
18
+ quality-gate ──────┼──→ commit-manager (YOU) ──→ documenter ──→ domain-updater ──→ session end
19
+ │ ▲
20
+ │ │ VETOED if findings open
21
+ └─────────┘
18
22
  ```
19
23
 
20
- ## Complete Git Flow
24
+ ---
25
+
26
+ ## Step 1 — Verify upstream gates (HARD REQUIREMENT)
27
+
28
+ Before touching git, confirm that `security-auditor` and `quality-gate` are green.
21
29
 
22
30
  ```bash
23
- # 1. Check status
24
- git status && git diff --name-status
31
+ echo "=== Checking upstream gates ==="
32
+ # Look for the most recent security-auditor and quality-gate reports in the session.
33
+ # If either contains BLOCKED / VETO / CRITICAL / HIGH / MEDIUM → STOP.
34
+ ```
35
+
36
+ ### Decision matrix
37
+
38
+ | security-auditor | quality-gate | Action |
39
+ |---|---|---|
40
+ | passed | passed | proceed to Step 2 |
41
+ | passed | not run | warn, proceed (quality-gate is recommended, not mandatory) |
42
+ | not run | passed | warn, proceed (security-auditor runs on security-relevant files only) |
43
+ | **BLOCKED** | any | **STOP — print the veto reason and exit. Do NOT commit.** |
44
+ | any | **FAILED** | **STOP — print the failure reason and exit. Do NOT commit.** |
45
+
46
+ If stopped, output:
47
+
48
+ ```
49
+ 🛑 COMMIT BLOCKED — upstream gate failed
50
+ Gate: <security-auditor|quality-gate>
51
+ Reason: <one-line summary>
52
+ Action: fix the findings and re-run the gate before calling commit-manager again
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Step 2 — Detect commit flow
58
+
59
+ ```bash
60
+ BRANCH=$(git branch --show-current)
61
+ MAIN=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo main)
62
+
63
+ # Check if project allows direct-to-main
64
+ DIRECT_MAIN=$(jq -r '.skip_checks // [] | if index("DIRECT_MAIN_COMMIT_FORBIDDEN") then "yes" else "no" end' .stop-validator.json 2>/dev/null || echo no)
65
+
66
+ echo "Branch=$BRANCH Main=$MAIN DirectToMain=$DIRECT_MAIN"
67
+ ```
68
+
69
+ | Scenario | Flow |
70
+ |---|---|
71
+ | On a feature branch (`feature/*`, `fix/*`, `refactor/*`, etc.) | commit → checkout main → merge → push → delete branch |
72
+ | On `main` AND `DIRECT_MAIN=yes` | commit → push (no branch dance) |
73
+ | On `main` AND `DIRECT_MAIN=no` | **STOP — create a branch first** |
74
+
75
+ ---
25
76
 
26
- # 2. Stage files
77
+ ## Step 3 — Analyze diff (token-efficient)
78
+
79
+ Read the diff in two passes to minimize token consumption:
80
+
81
+ ### Pass 1: stat overview (cheap — ≤ 50 tokens per file)
82
+
83
+ ```bash
84
+ git diff --cached --stat 2>/dev/null || git diff --stat HEAD
85
+ ```
86
+
87
+ This gives you file names + lines changed. Enough to determine `type` and `scope`.
88
+
89
+ ### Pass 2: semantic summary (only when needed)
90
+
91
+ Only if the stat is ambiguous (e.g., many files, unclear purpose), read the actual diff:
92
+
93
+ ```bash
94
+ git diff --cached -U3 -- <specific-files> 2>/dev/null || git diff -U3 HEAD -- <specific-files>
95
+ ```
96
+
97
+ Read at most 3 files in full diff. For the rest, rely on the stat + file names.
98
+
99
+ ### Determine commit metadata
100
+
101
+ | Field | How to derive |
102
+ |---|---|
103
+ | `type` | `feat` (new file/function), `fix` (bug keyword in diff or branch name), `refactor` (rename/move), `docs` (only .md), `test` (only test files), `chore` (deps/CI/config), `perf` (perf keyword), `ci` (only .github/) |
104
+ | `scope` | Dominant directory or domain name (e.g., `auth`, `api`, `security-auditor`) |
105
+ | `subject` | ≤ 72 chars, imperative mood, lowercase, no period. Describe the **why**, not the **what** |
106
+ | `body` | 2-5 bullet points. Each names a file or group + what changed. Only for commits touching ≥ 3 files |
107
+
108
+ ---
109
+
110
+ ## Step 4 — Stage and commit
111
+
112
+ ### 4a. Stage
113
+
114
+ ```bash
27
115
  git add -A
116
+ git status --short
117
+ ```
118
+
119
+ Verify no unexpected files (`.DS_Store`, `.env`, `*.log`). If found:
120
+
121
+ ```bash
122
+ git reset HEAD -- .DS_Store .env *.log 2>/dev/null || true
123
+ ```
124
+
125
+ ### 4b. Commit with HEREDOC (shell-safe multi-line)
126
+
127
+ ```bash
128
+ git commit -m "$(cat <<'EOF'
129
+ <type>(<scope>): <subject>
130
+
131
+ <body — 2-5 bullets if ≥ 3 files>
132
+
133
+ EOF
134
+ )"
135
+ ```
136
+
137
+ Rules:
138
+ - **No** `Co-Authored-By` header unless the user explicitly asked for it.
139
+ - **No** `Generated with Claude Code` footer — it adds noise to git log.
140
+ - Subject line ≤ 72 chars.
141
+ - Body wraps at 80 chars.
142
+ - Empty body is fine for single-file changes.
143
+
144
+ ---
145
+
146
+ ## Step 5 — Merge and push
147
+
148
+ ### Branch flow (default)
149
+
150
+ ```bash
151
+ git checkout "$MAIN"
152
+ git pull origin "$MAIN" --rebase --autostash || true
153
+ git merge "$BRANCH" --no-edit
154
+ git push origin "$MAIN"
155
+ git branch -d "$BRANCH"
156
+ ```
157
+
158
+ ### Direct-to-main flow
28
159
 
29
- # 3. Create commit
30
- git commit -m "type(scope): description
160
+ ```bash
161
+ git pull origin "$MAIN" --rebase --autostash || true
162
+ git push origin "$MAIN"
163
+ ```
164
+
165
+ ### Push failure recovery
166
+
167
+ If `git push` fails:
168
+
169
+ ```bash
170
+ # Retry with rebase (handles race condition with remote)
171
+ git pull origin "$MAIN" --rebase --autostash
172
+ git push origin "$MAIN"
173
+ ```
174
+
175
+ If still fails → **STOP**, print the error, and let the user decide. Do NOT force-push.
176
+
177
+ ---
31
178
 
32
- Generated with Claude Code
33
- Co-Authored-By: Claude <noreply@anthropic.com>"
179
+ ## Step 6 — Trigger post-commit chain
34
180
 
35
- # 4. Switch to main
36
- git checkout main
181
+ After successful push, inform the orchestrator that these agents should run next:
37
182
 
38
- # 5. Merge branch
39
- git merge [branch-name]
183
+ ```
184
+ Commit successful
185
+ Hash: <short-sha>
186
+ Branch: <main>
187
+ Subject: <subject line>
188
+ Files: <n> changed, <insertions>+, <deletions>-
189
+
190
+ Next agents (in order):
191
+ 1. documenter — map files + commits to domains
192
+ 2. domain-updater — record session wisdom + refresh CLAUDE.md Last Change
193
+ ```
194
+
195
+ Do NOT run them yourself — the orchestrator or the user triggers them. Your job is done after push.
196
+
197
+ ---
40
198
 
41
- # 6. Sync with remote
42
- git pull origin main --rebase || true
43
- git push origin main
199
+ ## Step 7 Report (deterministic, ≤ 10 lines)
44
200
 
45
- # 7. Delete feature branch
46
- git branch -d [branch-name]
201
+ ### Success
202
+
203
+ ```
204
+ ✅ Commit pushed
205
+ Hash: <short-sha>
206
+ Branch: <branch> → <main>
207
+ Type: <type>(<scope>)
208
+ Subject: <subject>
209
+ Files: <n> changed (<insertions>+, <deletions>-)
210
+ Flow: <branch-merge|direct-to-main>
211
+ Push: origin/<main>
212
+ Next: documenter → domain-updater
47
213
  ```
48
214
 
49
- ## Conventional Commits
215
+ ### Blocked
50
216
 
51
- | Type | Use |
52
- |----------|---------------|
53
- | feat | New feature |
54
- | fix | Bug fix |
55
- | docs | Documentation |
56
- | test | Tests |
57
- | refactor | Code change |
58
- | chore | Maintenance |
217
+ ```
218
+ 🛑 COMMIT BLOCKED
219
+ Gate: <security-auditor|quality-gate|branch-policy>
220
+ Reason: <one-line>
221
+ Action: <what the user should do>
222
+ ```
59
223
 
60
- ## Critical Rules
224
+ ---
61
225
 
62
- 1. **NEVER commit without validators passing**
63
- 2. **ALWAYS conventional commits**
64
- 3. **NEVER force push main**
65
- 4. **ALWAYS merge to main** — direct merge, no PRs
66
- 5. **ALWAYS end on main branch**
226
+ ## Critical rules
227
+
228
+ 1. **GATE CHECK FIRST** — NEVER commit if `security-auditor` has open CRITICAL/HIGH/MEDIUM findings or `quality-gate` failed. This is non-negotiable.
229
+ 2. **DIFF-DRIVEN MESSAGES** — read the actual diff (stat first, full only when needed). Never generate generic messages.
230
+ 3. **HEREDOC** always use `cat <<'EOF'` for commit messages. Never inline multi-line strings.
231
+ 4. **NO FORCE PUSH** — never `git push --force` or `--force-with-lease` to main/master unless the user explicitly requests it.
232
+ 5. **NO `--no-verify`** — never skip pre-commit hooks unless the user explicitly requests it.
233
+ 6. **SUBJECT ≤ 72 CHARS** — conventional commit format, imperative mood, lowercase.
234
+ 7. **TOKEN EFFICIENT** — use `--stat` first (cheap). Only `diff -U3` specific files when stat is ambiguous. Never read the full diff of 20+ files.
235
+ 8. **CLEAN STAGE** — verify no `.env`, `.DS_Store`, `*.log` are staged. Unstage them silently.
236
+ 9. **PUSH FAILURE = STOP** — retry once with `--rebase --autostash`. If still fails, stop and report. Never force push.
237
+ 10. **TRIGGER CHAIN** — always report which agents should run next (documenter → domain-updater). You do not run them.
238
+
239
+ ## See Also
240
+
241
+ - `git-workflow` skill — branch naming, conventional commits, merge strategies, HEREDOC examples
242
+ - `security-auditor` v2.0.0 — VETO gate; blocks this agent on open findings
243
+ - `quality-gate` skill — typecheck → lint → test → build pipeline
244
+ - `documenter` v2.0.0 — runs AFTER this agent to map files/commits
245
+ - `domain-updater` v2.0.0 — runs AFTER documenter to record wisdom + refresh Last Change
246
+ - `stop-validator` hook — validates clean tree + CLAUDE.md at session end
@@ -222,6 +222,7 @@ Use `Edit` / `StrReplace`, never `Write`, on existing domain files.
222
222
 
223
223
  - `docs-tracker` skill — file → doc mapping rules + changelog templates
224
224
  - `codebase-knowledge` skill — consumer of this layout (reads domains BEFORE implementing)
225
- - `domain-updater` agent — runs AFTER documenter to refresh `CLAUDE.md` Last Change line
225
+ - `commit-manager` v2.0.0 — runs BEFORE this agent; triggers the documenter domain-updater chain
226
+ - `domain-updater` v2.0.0 — runs AFTER this agent; records session wisdom + refreshes `CLAUDE.md` Last Change
226
227
  - `claude-md-compactor` v2.0.0 — keeps top-level `CLAUDE.md` ≤ 20 KB; this layer keeps each domain ≤ 8 KB
227
228
  - `security-auditor` v2.0.0 — vetoes commit if PII/secret leaks into a domain file
@@ -1,52 +1,177 @@
1
1
  ---
2
2
  name: domain-updater
3
- version: 1.0.0
4
- description: "AUTOMATICALLY invoke BEFORE commit-manager at session end. Records problems, solutions, and learnings in domain docs."
5
- model: haiku
6
- tools: Read, Write, Edit, Bash, Grep, Glob
7
- skills: codebase-knowledge, docs-tracker
3
+ version: 2.0.0
4
+ description: "AUTOMATICALLY invoke AFTER `documenter` completes. Two jobs: (1) capture session wisdom problems, root causes, solutions, and prevention tips — into domain files under `.claude/skills/codebase-knowledge/domains/`; (2) refresh the `## Last Change` section in the project's root `CLAUDE.md`. Does NOT map files or commits (that is `documenter`'s job). Runs AFTER documenter, BEFORE session ends. Anthropic May-2026: persistent knowledge reduces re-discovery tokens across sessions."
5
+ model: sonnet
6
+ tools: Read, Edit, Bash, Grep, Glob
7
+ skills: codebase-knowledge
8
8
  ---
9
9
 
10
- # Domain Updater Agent
10
+ # Domain Updater Agent (v2.0.0 — wisdom layer + Last Change)
11
11
 
12
- You record session LEARNINGS in domain docs. Different from documenter: documenter maps files, you record wisdom.
12
+ You record **session-level learnings** so the next session avoids the same mistakes and has immediate context. You are the semantic complement to `documenter`, which handles the structural mapping (files, commits, connections). You handle **why** things happened and **what was learned**.
13
13
 
14
- ## What You Add
14
+ ## Role boundary
15
15
 
16
- ### 1. Problems & Solutions
16
+ | Responsibility | Owner |
17
+ |---|---|
18
+ | File → domain mapping, `## Files` table, commit log, `_index.json` | `documenter` |
19
+ | Problems & Solutions, Attention Points, session wisdom | **you** (`domain-updater`) |
20
+ | `CLAUDE.md` `## Last Change` update | **you** |
21
+ | Commit the changes | `commit-manager` (only if running in pre-commit position) |
22
+
23
+ You **Edit** existing domain files (never `Write` over them). If a domain file does not exist yet, skip — `documenter` creates it. If `documenter` has not run, warn and exit.
24
+
25
+ ## Workflow position
26
+
27
+ ```
28
+ commit-manager → documenter → domain-updater (YOU) → session end
29
+ ```
30
+
31
+ Both `documenter` output and your edits are committed together in a single follow-up "docs" commit, or staged for the next task commit — whichever the project's `git-workflow` skill dictates. You never commit yourself; you only stage.
32
+
33
+ ---
34
+
35
+ ## Step 1 — Gather session context (token-efficient)
36
+
37
+ ```bash
38
+ SHORT=$(git rev-parse --short HEAD)
39
+ DATE=$(git show -s --format=%cs HEAD)
40
+ SUBJECT=$(git show -s --format=%s HEAD)
41
+ STACK=$(jq -r '.stack' .claude/config/active-project.json 2>/dev/null || echo unknown)
42
+ echo "Commit=$SHORT ($DATE) Stack=$STACK Subject=$SUBJECT"
43
+ ```
44
+
45
+ Do NOT read source files — you already have session context from the conversation. Only read **domain files** that need editing.
46
+
47
+ ## Step 2 — Identify session wisdom to record
48
+
49
+ Scan the current session for:
50
+
51
+ | Signal | Extract |
52
+ |---|---|
53
+ | An error you hit and fixed | **Problem & Solution** entry |
54
+ | A non-obvious gotcha discovered | **Attention Point** entry |
55
+ | A decision with trade-offs | **Attention Point** (record the reasoning) |
56
+ | A skill section that saved the fix | **See Also** cross-reference |
57
+
58
+ If NONE of the above occurred in this session, skip to Step 4 (Last Change).
59
+
60
+ ## Step 3 — Write wisdom into domain files
61
+
62
+ ### 3a. Determine target domain(s)
63
+
64
+ Use `_index.json` (or `_INDEX.md` if JSON is absent) to find which domain slug matches the area of the session. If ambiguous, pick the domain where the problem manifested (not where the fix lives).
65
+
66
+ ### 3b. Deduplicate
67
+
68
+ Before appending, grep the domain file for the **symptom** or **root cause** keywords. If a substantially similar entry already exists:
69
+ - Do NOT duplicate
70
+ - If the existing entry has new info, **Edit** to append (e.g., add a "Recurrence" note)
71
+
72
+ ### 3c. Append Problem & Solution (capped structure)
17
73
 
18
74
  ```markdown
19
- ### {Date} - {Problem Title}
20
- **Problem:** {What went wrong}
21
- **Root Cause:** {Why it happened}
22
- **Solution:** {How it was fixed}
23
- **Prevention:** {How to avoid in future}
75
+ ### [resolved YYYY-MM-DD] <title — ≤ 10 words>
76
+
77
+ - **Symptom:** <what the user/agent observed>
78
+ - **Root cause:** <why it happened — be specific, name the file/line/config>
79
+ - **Fix:** <one-liner what was changed>
80
+ - **Prevention:** <which check/skill/hook prevents recurrence>
81
+ - **Skill ref:** `<skill-name §section>` (if applicable)
24
82
  ```
25
83
 
26
- ### 2. Attention Points
84
+ Rules:
85
+ - **≤ 5 entries** per domain in the live file. If count ≥ 5, move the oldest 2 to `<slug>.archive.md`.
86
+ - **≤ 4 lines per entry** (Symptom + Root cause + Fix + Prevention). No prose paragraphs.
87
+ - Mark as `[resolved YYYY-MM-DD]` or `[open]`. Resolved entries are archive-eligible.
88
+
89
+ ### 3d. Append Attention Point
27
90
 
28
91
  ```markdown
29
- - [YYYY-MM-DD] **Rule name** - Description of gotcha
92
+ - [YYYY-MM-DD] **<Rule name>** <one sentence gotcha>. Ref: `<skill §section>`.
30
93
  ```
31
94
 
32
- ### 3. Recent Commits
95
+ Rules:
96
+ - **≤ 10 attention points** per domain in the live file. Oldest beyond 10 → archive.
97
+ - No duplicates (grep before appending).
98
+
99
+ ### 3e. Size guard
100
+
101
+ After editing, check file size:
102
+
103
+ ```bash
104
+ wc -c < .claude/skills/codebase-knowledge/domains/<slug>.md
105
+ ```
106
+
107
+ If > 8192 bytes (8 KB), move the oldest 2 Problem & Solution entries + oldest 3 Attention Points to `<slug>.archive.md`. The live file must stay ≤ 8 KB.
108
+
109
+ ---
110
+
111
+ ## Step 4 — Refresh `CLAUDE.md` `## Last Change`
112
+
113
+ This is the most-read section in the entire project — every session loads it at boot.
114
+
115
+ ### 4a. Read current Last Change
116
+
117
+ ```bash
118
+ head -40 CLAUDE.md
119
+ ```
120
+
121
+ ### 4b. Compose new entry
122
+
123
+ Format — compact, scannable, token-efficient:
33
124
 
34
125
  ```markdown
35
- | Hash | Date | Description |
36
- |------|------|-------------|
37
- | abc123 | YYYY-MM-DD | feat: what was done |
126
+ ## Last Change
127
+
128
+ **Branch:** <branch>
129
+ **Date:** <YYYY-MM-DD>
130
+ **Summary:** v<version> — <one paragraph, ≤ 8 lines, plain text>.
131
+ Earlier: <previous summary condensed to ≤ 3 lines>.
38
132
  ```
39
133
 
40
- ## Workflow Order
134
+ Rules:
135
+ - **Current change**: ≤ 8 lines. Name agents/skills touched, describe what changed and why. No file-by-file lists — use categories.
136
+ - **Earlier block**: condense ALL prior history into ≤ 3 lines (version numbers + one-clause summary each). If it grows beyond 3 lines, drop the oldest entry (it's in git history).
137
+ - **No markdown formatting** inside the summary (no bold, no bullets). Plain text is cheapest to parse.
138
+ - **Validate size after edit**: `wc -c CLAUDE.md` must stay ≤ 20480 bytes (20 KB). If over, condense the "Earlier" block further.
139
+
140
+ ### 4c. Apply with Edit
141
+
142
+ Use `Edit` / `StrReplace` on `CLAUDE.md` — replace only the `## Last Change` section (from `## Last Change` to the next `---` or `##`). Never rewrite the rest of the file.
143
+
144
+ ---
145
+
146
+ ## Step 5 — Report (deterministic, ≤ 8 lines)
41
147
 
42
148
  ```
43
- implementation quality gates domain-updater (YOU) → commit-manager
149
+ Domain wisdom appended: <n> entries across <domains>
150
+ Problems & Solutions: <n> new, <n> deduplicated
151
+ Attention Points: <n> new, <n> deduplicated
152
+ Archives triggered: <domains> (size guard)
153
+ CLAUDE.md Last Change: updated (v<version>, <size> bytes)
44
154
  ```
45
155
 
46
- ## Critical Rules
156
+ ---
157
+
158
+ ## Critical rules
159
+
160
+ 1. **AFTER documenter** — never run before `documenter` maps the commit. If documenter hasn't run, warn and exit.
161
+ 2. **EDIT, NEVER WRITE** — use `Edit` / `StrReplace` on existing domain files. If the domain file doesn't exist, skip (documenter creates it).
162
+ 3. **DEDUPLICATE** — grep before appending. Same symptom or root cause = update existing entry, don't add new.
163
+ 4. **CAP ENTRIES** — ≤ 5 Problems & Solutions + ≤ 10 Attention Points per live domain file. Overflow → archive.
164
+ 5. **≤ 8 KB per domain** — measure after edit; trim if exceeded.
165
+ 6. **CLAUDE.md ≤ 20 KB** — measure after edit; condense "Earlier" if exceeded.
166
+ 7. **NO SOURCE CODE** — never paste code into wisdom entries. Reference `file:line` or `skill §section`.
167
+ 8. **NO PII / SECRETS** — never quote env values, tokens, customer data.
168
+ 9. **TOKEN-EFFICIENT** — don't read source files. You have session context; only read domain files you're about to edit.
169
+ 10. **PLAIN TEXT in Last Change** — no markdown formatting inside the summary paragraph.
170
+
171
+ ## See Also
47
172
 
48
- 1. **RUN BEFORE COMMIT** changes included in same commit
49
- 2. **DOCUMENT PROBLEMS**future sessions benefit
50
- 3. **INCLUDE SOLUTIONS**not just what broke
51
- 4. **PREVENTION TIPS**how to avoid next time
52
- 5. **DATE EVERYTHING**
173
+ - `documenter` v2.0.0structural mapping (files, commits, connections, `_index.json`)
174
+ - `codebase-knowledge` skillreads domain files BEFORE implementing
175
+ - `commit-manager` v2.0.0commits implementation; triggers documenter + domain-updater chain
176
+ - `claude-md-compactor` v2.0.0enforces `CLAUDE.md` 20 KB budget
177
+ - `security-auditor` v2.0.0 vetoes commit if PII/secret leaks into domain files
@@ -1,13 +1,25 @@
1
+ ---
2
+ name: feature
3
+ description: Start a new feature with the full workflow (research → plan → implement → test → security → quality → commit → docs).
4
+ version: 1.0.0
5
+ ---
6
+
1
7
  # /feature — Start New Feature
2
8
 
3
- Execute in order:
9
+ Always read `.claude/config/active-project.json` first to know the active stack.
10
+
11
+ Execute in order — do not skip steps. Steps 5–6 have **VETO power** over commit.
4
12
 
5
- 1. **Research** research-web agent (if new tech)
6
- 2. **Plan** → Break into tasks, create TODO list
7
- 3. **Implement** Write code following stack patterns
8
- 4. **Test** tester agent (PHPUnit / Vitest / pytest)
9
- 5. **Document** documenter agent
10
- 6. **Update domains** domain-updater agent
11
- 7. **Commit** commit-manager agent
13
+ | # | Step | Agent / Skill |
14
+ |---|---|---|
15
+ | 1 | **Research** (only for new tech / patterns) | `research-web` |
16
+ | 2 | **Plan** break into tasks, create TODO list | (you, in plan mode) |
17
+ | 3 | **Implement** follow stack patterns + strict types | (you) |
18
+ | 4 | **Test** unit + e2e | `tester` |
19
+ | 5 | **Security** adversarial audit | `security-auditor` (VETO) |
20
+ | 6 | **Quality** — typecheck → lint → test → build | `quality-gate` |
21
+ | 7 | **Commit** — gate-aware, diff-driven message | `commit-manager` |
22
+ | 8 | **Map** — files + commits → domains | `documenter` |
23
+ | 9 | **Wisdom + Last Change** — record learnings, refresh `CLAUDE.md` | `domain-updater` |
12
24
 
13
- Always read `.claude/config/active-project.json` first.
25
+ If `security-auditor` returns CRITICAL/HIGH/MEDIUM, fix before re-running step 5. Steps 8–9 run AFTER push and never before.
@@ -1,9 +1,23 @@
1
+ ---
2
+ name: fix
3
+ description: Fix a bug — reproduce, isolate, minimal fix, regression test, security check, commit, record wisdom.
4
+ version: 1.0.0
5
+ ---
6
+
1
7
  # /fix — Fix Bug
2
8
 
3
- Execute in order:
9
+ Always read `.claude/config/active-project.json` first.
10
+
11
+ | # | Step | Agent / Skill |
12
+ |---|---|---|
13
+ | 1 | **Reproduce** — read the error, reproduce locally, isolate the root cause (NOT the symptom) | (you) |
14
+ | 2 | **Failing test first** — write a regression test that proves the bug | `tester` |
15
+ | 3 | **Apply minimal fix** — do not refactor adjacent code in the same commit | (you) |
16
+ | 4 | **Verify** — re-run the regression test + the wider suite | `tester` |
17
+ | 5 | **Security** — only if the bug touched auth / input / secrets / SSRF surface | `security-auditor` (VETO) |
18
+ | 6 | **Quality gate** — typecheck → lint → test → build | `quality-gate` |
19
+ | 7 | **Commit** — `fix(scope): <subject>`, diff-driven body | `commit-manager` |
20
+ | 8 | **Map** — files + commit → domain | `documenter` |
21
+ | 9 | **Wisdom** — append to domain `## Problems & Solutions` (symptom + root cause + fix + prevention + skill ref) | `domain-updater` |
4
22
 
5
- 1. **Analyze** Read error, reproduce, isolate
6
- 2. **Fix** → Apply minimal fix
7
- 3. **Test** → Add regression test (tester agent)
8
- 4. **Document** → Record in domain Problems & Solutions
9
- 5. **Commit** → commit-manager agent
23
+ `domain-updater` deduplicates by symptom/root-cause. If the same bug recurred, it appends a "Recurrence" note instead of a duplicate entry.
@@ -1,10 +1,21 @@
1
+ ---
2
+ name: research
3
+ description: Research best practices using research-web (MCP-first) with cache lookup before any web call.
4
+ version: 1.0.0
5
+ ---
6
+
1
7
  # /research — Research Best Practices
2
8
 
3
- Execute in order:
9
+ Always read `.claude/config/active-project.json` first to know the active stack.
10
+
11
+ | # | Step | Tool / Skill |
12
+ |---|---|---|
13
+ | 1 | **Cache lookup** — check `.claude/skills/research-cache/cache/<topic>.md` first. If fresh (≤ 30 days), use it and skip steps 2–5 | `research-cache` |
14
+ | 2 | **MCP probe** — detect `mcp__web-scraper__*` availability (one-shot per session) | `research-web` |
15
+ | 3 | **Search** — Tier 1: `unified_search` (Brave + Vertex AI + Grok, dedupe + scoring). Tier 2 fallback: built-in `WebSearch` | `research-web` |
16
+ | 4 | **Source ranking** — official docs > engineering blogs > GitHub issues > Stack Overflow. Reject anything > 18 months old without re-validation | (you) |
17
+ | 5 | **Deep read** — Tier 1: `scrape_url` (stealth + proxy). Tier 2 fallback: built-in `WebFetch` | `research-web` |
18
+ | 6 | **Document** — write `.claude/skills/research-cache/cache/<topic>.md` with: date · expiry (now + 30 days) · sources · TL;DR · actionable rules | `research-cache` |
19
+ | 7 | **Promote** — if any rule applies project-wide, propose adding it to `CLAUDE.md` (do NOT auto-edit; surface the proposal) | (you) |
4
20
 
5
- 1. **Check cache** `.claude/skills/research-cache/cache/`
6
- 2. **Search web** → "[topic] best practices [year] [stack]"
7
- 3. **Sources**: Official docs > Engineering blogs > OWASP > GitHub issues
8
- 4. **Document** → Create `.claude/skills/research-cache/cache/[topic].md`
9
- 5. **Extract rules** → Add actionable rules to CLAUDE.md if applicable
10
- 6. **Update cache** → Date + expiry (30 days)
21
+ Each cache entry has frontmatter `expires_on:` so a future session can detect stale notes without re-reading the body.
@@ -1,10 +1,37 @@
1
+ ---
2
+ name: validate
3
+ description: Run the full quality gate (typecheck → lint → test → build) using the stack's commands from active-project.json.
4
+ version: 1.0.0
5
+ ---
6
+
1
7
  # /validate — Run Full Validation
2
8
 
3
- Read quality gates from `.claude/config/active-project.json` and run all:
9
+ Read the quality gates from `.claude/config/active-project.json#qualityGates` and run them in order. Stop at the first failure.
4
10
 
5
11
  ```bash
6
- # Read stack commands
7
- cat .claude/config/active-project.json | jq '.qualityGates'
12
+ jq -r '.qualityGates' .claude/config/active-project.json
13
+ ```
14
+
15
+ Execution order (each step blocks the next):
16
+
17
+ | # | Gate | Typical commands |
18
+ |---|---|---|
19
+ | 1 | **Typecheck** | `npx tsc --noEmit` · `mypy .` · `vendor/bin/phpstan analyse` |
20
+ | 2 | **Lint** | `npx eslint .` · `ruff check .` · `vendor/bin/pint --test` |
21
+ | 3 | **Unit tests** | `npx vitest run` · `pytest` · `vendor/bin/phpunit` |
22
+ | 4 | **E2E** (only if configured) | `npx playwright test` |
23
+ | 5 | **Build** | `npm run build` · `composer dump-autoload --optimize` |
24
+
25
+ Output format (one line per gate):
26
+
27
+ ```
28
+ typecheck: PASS (1.4s)
29
+ lint: PASS (0.8s)
30
+ tests: PASS (45/45 in 6.2s)
31
+ e2e: SKIP (not configured)
32
+ build: PASS (3.1s)
33
+
34
+ ✅ All gates passed — safe to invoke commit-manager
8
35
  ```
9
36
 
10
- Then execute each gate in order. Report pass/fail for each.
37
+ If any gate fails, print the failure output and exit non-zero. `commit-manager` will refuse to commit while validation is failing.
@@ -1,71 +1,68 @@
1
1
  ---
2
2
  name: codebase-knowledge
3
- version: 1.0.0
3
+ version: 2.0.0
4
+ description: "Cached domain knowledge consumed BEFORE implementing any feature. Reads `.claude/skills/codebase-knowledge/_index.json` (machine-readable, regenerated by `documenter`) for fast filter, then reads only the affected `domains/<slug>.md` files. Avoids re-exploring the codebase every session."
4
5
  ---
5
6
 
6
- # Codebase Knowledge — Domain Mapping System
7
+ # Codebase Knowledge — Domain Knowledge Reader (v2.0.0)
7
8
 
8
9
  **ALWAYS invoke BEFORE implementing any feature.**
9
10
 
10
- ## Purpose
11
+ This skill is the **read side** of the project memory layer maintained by the `documenter` and `domain-updater` agents. Its job is to load just enough context for the next change without re-discovering the whole codebase.
11
12
 
12
- Maps files by domain, tracks connections, caches architecture decisions.
13
-
14
- ## Domain Files Location
13
+ ## Storage layout (maintained by `documenter` v2.0.0)
15
14
 
16
15
  ```
17
- .claude/skills/codebase-knowledge/domains/
18
- ├── authentication.md
19
- ├── api.md
20
- ├── database.md
21
- ├── ui-components.md
22
- └── [domain-name].md
16
+ .claude/skills/codebase-knowledge/
17
+ ├── SKILL.md # this file
18
+ ├── TEMPLATE.md # template for new domain files (no version — it is a template)
19
+ ├── _INDEX.md # human-readable list of all domains
20
+ ├── _index.json # machine-readable index — SOURCE OF TRUTH for filter
21
+ └── domains/
22
+ ├── <slug>.md # one file per domain. ≤ 8 KB / ~2k tokens / 200 lines
23
+ └── <slug>.archive.md # commits/wisdom older than the cap (read on demand only)
23
24
  ```
24
25
 
25
- ## Domain File Template
26
-
27
- ```markdown
28
- # {Domain Name}
26
+ ## Read protocol (token-efficient)
29
27
 
30
- ## Last Update
31
- - **Date:** YYYY-MM-DD
32
- - **Commit:** abc123
33
- - **Summary:** What changed
28
+ | # | Step | Tool |
29
+ |---|---|---|
30
+ | 1 | **Resolve which domain(s) you need** by glob/grep on the affected file paths against `.claude/config/domain-mapping.json` | Bash + jq |
31
+ | 2 | **Read `_index.json` first** — one query gives you `last_commit`, `tags`, `connections` for every domain | `jq '.domains[] \| select(.slug == "auth")' _index.json` |
32
+ | 3 | **Read only the matched `domains/<slug>.md`** files — never `cat domains/*.md` (that defeats the budget) | Read |
33
+ | 4 | **Follow `connections`** if the change crosses a domain boundary; read those neighbours too | Read |
34
+ | 5 | **Skip `<slug>.archive.md`** unless `_index.json` flags `status: archived` and you actually need history | Read |
34
35
 
35
- ## Files
36
- | File | Purpose |
37
- |------|---------|
38
- | `path/file.ext` | Description |
36
+ ## Domain file shape
39
37
 
40
- ## Connections
41
- | Domain | How They Connect |
42
- |--------|-----------------|
43
- | auth | Validates tokens before API calls |
38
+ Defined by `documenter` v2.0.0 — see `TEMPLATE.md` in this folder for the canonical layout. Required sections:
44
39
 
45
- ## Recent Commits
46
- | Hash | Date | Description |
47
- |------|------|-------------|
48
- | abc123 | YYYY-MM-DD | feat: description |
49
-
50
- ## Attention Points
51
- - Important gotcha or consideration
52
-
53
- ## Problems & Solutions
54
- ### Problem Title
55
- **Problem:** What went wrong
56
- **Solution:** How it was fixed
57
- **Prevention:** How to avoid in future
58
- ```
40
+ - YAML frontmatter (`domain · tags · owner · last_commit · last_date · files_count · connections · status`)
41
+ - TL;DR (≤ 3 lines, front-loads boundary)
42
+ - Files table (path → role)
43
+ - Connections table (bidirectional: and rows)
44
+ - Recent Commits (capped at 20)
45
+ - Attention Points (capped at 10)
46
+ - Problems & Solutions (capped at 5, append-only)
59
47
 
60
48
  ## Workflow
61
49
 
62
- 1. **Before coding** Read relevant domain files
63
- 2. **During coding** Note connections and gotchas
64
- 3. **After coding** documenter + domain-updater agents update these files
50
+ 1. **Before coding** read this skill, then `_index.json`, then the affected `domains/<slug>.md` files.
51
+ 2. **During coding** note any new connection, gotcha, or non-obvious decision (you do not write here directly).
52
+ 3. **After commit** `documenter` maps files+commits, `domain-updater` records the wisdom you collected.
65
53
 
66
54
  ## Rules
67
55
 
68
- 1. **CHECK BEFORE IMPLEMENTING** — always read affected domains first
69
- 2. **BIDIRECTIONAL CONNECTIONS**if A connects to B, update both
70
- 3. **INCLUDE COMMIT HASHES** — traceability
71
- 4. **RECORD PROBLEMS** — future sessions benefit from lessons learned
56
+ 1. **READ `_index.json` FIRST** — it is regenerated each commit; it is the cheapest way to filter.
57
+ 2. **NEVER `cat domains/*.md`** you will blow the context budget.
58
+ 3. **BIDIRECTIONAL CONNECTIONS** — if `auth.md` lists `→ api`, then `api.md` MUST list `← auth`. If you spot a missing reverse edge, surface it for `domain-updater`.
59
+ 4. **ARCHIVE FILES ARE OPT-IN** — read `<slug>.archive.md` only when `_index.json` shows `status: archived` or when you need pre-cap history.
60
+ 5. **DO NOT EDIT DOMAIN FILES DIRECTLY** — only `documenter` and `domain-updater` write here. If something is wrong, fix the agent or report drift.
61
+ 6. **TRUST `last_commit`** — if `_index.json#last_commit` ≠ HEAD, the documenter forgot to run; pause and fix instead of working with stale knowledge.
62
+
63
+ ## See Also
64
+
65
+ - `documenter` v2.0.0 — writes to this layout (after every commit)
66
+ - `domain-updater` v2.0.0 — writes session wisdom (Problems & Solutions, Attention Points)
67
+ - `docs-tracker` v2.0.0 — file → domain mapping rules
68
+ - `claude-md-compactor` v2.0.0 — keeps `CLAUDE.md` ≤ 20 KB; this layer keeps each domain ≤ 8 KB
@@ -1,23 +1,44 @@
1
- # {Domain Name}
1
+ ---
2
+ domain: <slug>
3
+ tags: [tag1, tag2]
4
+ owner: <team or "shared">
5
+ last_commit: <short-sha>
6
+ last_date: YYYY-MM-DD
7
+ files_count: 0
8
+ connections: []
9
+ status: active
10
+ ---
2
11
 
3
- ## Last Update
4
- - **Date:** YYYY-MM-DD
5
- - **Commit:**
6
- - **Summary:**
12
+ # <Title> Domain
13
+
14
+ > **TL;DR** (≤ 3 lines). What lives here, where the boundary is, who calls it.
15
+ > Example: "User session lifecycle. Owns Sanctum cookie, login, password reset.
16
+ > Does NOT own user profile data (see `users` domain)."
7
17
 
8
18
  ## Files
9
- | File | Purpose |
10
- |------|---------|
19
+
20
+ | Path | Role |
21
+ |---|---|
11
22
 
12
23
  ## Connections
13
- | Domain | How They Connect |
14
- |--------|-----------------|
15
24
 
16
- ## Recent Commits
17
- | Hash | Date | Description |
18
- |------|------|-------------|
25
+ | Direction | Domain | What flows |
26
+ |---|---|---|
27
+
28
+ ## Recent Commits (capped at 20 — oldest auto-archived)
29
+
30
+ | Hash | Date | Subject |
31
+ |---|---|---|
19
32
 
20
33
  ## Attention Points
21
- -
22
34
 
23
- ## Problems & Solutions
35
+ (≤ 10 entries; oldest beyond 10 → `<slug>.archive.md`)
36
+
37
+ ## Problems & Solutions (append-only)
38
+
39
+ (≤ 5 entries; oldest beyond 5 → `<slug>.archive.md`)
40
+
41
+ ## See Also
42
+
43
+ - Skill: `<skill-name §section>`
44
+ - Domain: `<related-slug>`
@@ -1,56 +1,104 @@
1
1
  ---
2
2
  name: docs-tracker
3
- version: 1.0.0
3
+ version: 2.0.0
4
+ description: "File → domain mapping rules and changelog templates consumed by `documenter` v2.0.0. Detects modified files via `git diff-tree`, classifies them via `.claude/config/domain-mapping.json`, and emits the actions documenter must apply (Edit known anchors, never Write over existing files; bidirectional connections; cap commit log at 20)."
4
5
  ---
5
6
 
6
- # Docs Tracker — Automatic Documentation System
7
+ # Docs Tracker — File Domain Mapping Rules (v2.0.0)
7
8
 
8
- **ALWAYS invoke AFTER implementation completes.**
9
+ **ALWAYS invoke AFTER `commit-manager` succeeds (so the commit hash is real).**
9
10
 
10
- ## Execution Flow
11
+ This skill is the **rule set** consumed by `documenter` v2.0.0. It does not write files itself — it tells documenter what to do with each changed file.
11
12
 
13
+ ## Detection (one git call, not many)
14
+
15
+ ```bash
16
+ # Files in the LAST commit (after commit-manager pushed)
17
+ git diff-tree --no-commit-id --name-status -r HEAD
12
18
  ```
13
- 1. DETECT CHANGES → git diff --name-status
14
-
15
- 2. CLASSIFY → A=Added, M=Modified, D=Deleted
16
-
17
- 3. CHECK EXISTING DOCS → codebase-knowledge/domains/
18
-
19
- 4. CREATE/UPDATE/REMOVE as needed
20
-
21
- 5. UPDATE CLAUDE.md "Last Change" section
22
- ```
23
19
 
24
- ## What to Document
20
+ Status codes: `A` = added, `M` = modified, `D` = deleted, `R` = renamed, `C` = copied. Treat `R` and `C` as `M` for mapping purposes plus a "renamed from" note in the destination domain.
21
+
22
+ ## File → Domain mapping
23
+
24
+ Source of truth: `.claude/config/domain-mapping.json` (shipped with this CLI; project may override). A path may map to ≥1 domain. Unmatched paths → `general`.
25
+
26
+ Skip the entire pass if every changed path matches one of:
25
27
 
26
- | Change Type | Action |
28
+ | Skip pattern | Reason |
27
29
  |---|---|
28
- | New file | Create domain entry if new domain |
29
- | Modified file | Update domain "Last Update" + "Recent Commits" |
30
- | Deleted file | Remove from domain "Files" table |
31
- | New connection | Add to "Connections" in BOTH domains |
32
- | Bug fix | Add to "Problems & Solutions" |
30
+ | `.claude/**` | meta does not belong to any product domain |
31
+ | `docs/**` | docs commit no code drift |
32
+ | `.github/**` | CI handled by `infrastructure` domain only if pattern is added |
33
+ | `CHANGELOG*`, `*.md` (root only) | release docs |
34
+ | `package.json`, `composer.json`, `pyproject.toml` (deps only not scripts) | bumps tracked elsewhere |
35
+
36
+ ## Action matrix (applied by `documenter`)
37
+
38
+ | Git status | Domain file state | Action |
39
+ |---|---|---|
40
+ | `A` | exists | `Edit`: append row to `## Files`, prepend row to `## Recent Commits`, increment `files_count` in frontmatter |
41
+ | `A` | missing | `Write`: create from `TEMPLATE.md`, fill TL;DR, add the file row, add the commit row |
42
+ | `M` | exists | `Edit`: prepend row to `## Recent Commits`; if file's role description changed, update its row in `## Files` |
43
+ | `M` | missing | unusual — investigate; usually means mapping rule was added but file existed before. Treat as `A` |
44
+ | `D` | exists | `Edit`: strike-through (`~~path~~`) row in `## Files`, decrement `files_count`. Prune at the next pass |
45
+ | `R src→dst` | exists | `Edit`: replace `src` row with `dst` row, add note `(renamed from src in <short-sha>)` to Attention Points |
46
+
47
+ ## Bidirectional connections (mandatory)
48
+
49
+ When a session adds `auth → api` to `auth.md`, **also** add `api ← auth` to `api.md`. The two edits must succeed atomically — if the second fails, roll back the first. The `security-auditor` flags dangling links as a MEDIUM finding.
50
+
51
+ ## Cap and archive (size guard)
33
52
 
34
- ## Detection Commands
53
+ After any edit, check the live file:
35
54
 
36
55
  ```bash
37
- # What changed?
38
- git diff --name-status HEAD~1
56
+ [ "$(wc -c < domains/<slug>.md)" -gt 8192 ] && trigger_archive
57
+ ```
58
+
59
+ When triggered, move the **oldest 5 rows** of `## Recent Commits` (and oldest 2 Problems & Solutions, oldest 3 Attention Points) into `<slug>.archive.md`. Live file must stay ≤ 8 KB.
39
60
 
40
- # What's staged?
41
- git diff --name-only --cached
61
+ ## Index regeneration (after every pass)
42
62
 
43
- # What's unstaged?
44
- git diff --name-only
63
+ ```bash
64
+ # Regenerate _index.json from frontmatter of every domain file
65
+ for f in .claude/skills/codebase-knowledge/domains/*.md; do
66
+ # parse YAML frontmatter, compute summary_sha = sha256(TL;DR block), emit one record
67
+ done | jq -s '{schema_version:1, generated_at:(now|todate), domain_count:length, domains:.}' \
68
+ > .claude/skills/codebase-knowledge/_index.json
45
69
 
46
- # What's untracked?
47
- git ls-files --others --exclude-standard
70
+ # Then derive _INDEX.md from _index.json
71
+ ```
72
+
73
+ `_index.json` is the source of truth — `_INDEX.md` is human-readable derivative.
74
+
75
+ ## Pre-commit hook (CI integration)
76
+
77
+ A repository can add this check to fail builds when documenter forgot to run:
78
+
79
+ ```bash
80
+ HEAD_SHA=$(git rev-parse --short HEAD)
81
+ LAST_INDEXED=$(jq -r '.domains | map(.last_commit) | unique[]' \
82
+ .claude/skills/codebase-knowledge/_index.json)
83
+ echo "$LAST_INDEXED" | grep -qx "$HEAD_SHA" || {
84
+ echo "ERROR: _index.json is stale. Run documenter before pushing."
85
+ exit 1
86
+ }
48
87
  ```
49
88
 
50
89
  ## Rules
51
90
 
52
- 1. **RUN AFTER EVERY IMPLEMENTATION** no exceptions
53
- 2. **DETECT VIA GIT** — don't guess, use git diff
54
- 3. **UPDATE DOMAINS** — not just CLAUDE.md
55
- 4. **BIDIRECTIONAL** — if A↔B connection, update both
56
- 5. **INCLUDE COMMIT HASH** — traceability
91
+ 1. **AFTER `commit-manager`**never before; the hash must be real.
92
+ 2. **DETECT VIA GIT** — `git diff-tree -r HEAD`, never guess from session memory.
93
+ 3. **EDIT KNOWN ANCHORS** — `documenter` uses `Edit` / `StrReplace` on existing domain files; never `Write` over them.
94
+ 4. **BIDIRECTIONAL** — both ends of every connection updated atomically.
95
+ 5. **CAP AT 8 KB / 20 commits / 10 attention / 5 P&S** — archive overflow into `<slug>.archive.md`.
96
+ 6. **REGENERATE `_index.json` EVERY PASS** — derived; never hand-edited.
97
+ 7. **SKIP META PATHS** — `.claude/**`, `docs/**`, `.github/**` do not get domain entries.
98
+
99
+ ## See Also
100
+
101
+ - `documenter` v2.0.0 — applies the actions defined here
102
+ - `codebase-knowledge` v2.0.0 — reads what documenter wrote
103
+ - `domain-updater` v2.0.0 — appends session wisdom AFTER documenter
104
+ - `.claude/config/domain-mapping.json` — pattern → domain rules
@@ -1,62 +1,139 @@
1
1
  ---
2
2
  name: research-cache
3
- version: 1.0.0
3
+ version: 2.0.0
4
+ description: "Caches web research findings under `.claude/skills/research-cache/cache/` to avoid redundant searches. Each entry has YAML frontmatter (`expires_on`, `sources`, `tier`, `engines`) so a session can grep-filter fresh entries without reading the body. Consumed by `research-web` v2.0.0 BEFORE any MCP / WebSearch call."
4
5
  ---
5
6
 
6
- # Research Cache — Best Practices Storage
7
+ # Research Cache — Best-Practices Storage (v2.0.0)
7
8
 
8
- **ALWAYS invoke BEFORE any web research.**
9
+ **ALWAYS invoke BEFORE any web research.** This skill is the **read AND write** side of `research-web` v2.0.0.
9
10
 
10
- ## Purpose
11
-
12
- Caches research findings to avoid redundant searches and maintain institutional knowledge.
13
-
14
- ## Structure
11
+ ## Layout
15
12
 
16
13
  ```
17
14
  .claude/skills/research-cache/
18
15
  ├── SKILL.md
19
16
  └── cache/
20
- ├── php-uuid-performance.md
21
- ├── laravel-octane-memory.md
22
- └── [topic].md
17
+ ├── _index.json # auto-derived, optional (one record per cache entry)
18
+ └── <topic-slug>.md # one file per topic. ≤ 8 KB. Pruned at expires_on.
19
+ ```
20
+
21
+ ## Cache entry frontmatter (token-efficient lookup)
22
+
23
+ Every cache entry MUST start with this frontmatter so a `grep` over `cache/*.md` filters fresh entries without parsing bodies:
24
+
25
+ ```yaml
26
+ ---
27
+ topic: <kebab-case>
28
+ stack: php | nodejs | python | universal | frontend
29
+ researched_on: YYYY-MM-DD
30
+ expires_on: YYYY-MM-DD # researched_on + 30 days (60 for stable specs, 14 for moving libraries)
31
+ tier: 1 | 2 # 1 = MCP web-scraper used; 2 = built-in WebSearch fallback
32
+ engines: [brave, vertex, grok] # which engines contributed (Tier 1 only)
33
+ sources_count: <int>
34
+ confidence: high | medium | low # high = 3+ official-doc sources agree; low = single blog post
35
+ ---
23
36
  ```
24
37
 
25
- ## Before Searching
38
+ ## Read protocol (lookup BEFORE searching)
26
39
 
27
- 1. Check cache: `ls .claude/skills/research-cache/cache/`
28
- 2. Grep for topic: `grep -rl "topic" .claude/skills/research-cache/cache/`
29
- 3. If found and recent (<30 days) → USE CACHE
30
- 4. If not found → Research and CREATE cache entry
40
+ ```bash
41
+ TOPIC="<kebab-case>"
42
+ TODAY=$(date +%F)
31
43
 
32
- ## Cache Entry Template
44
+ # 1. Direct hit?
45
+ F=".claude/skills/research-cache/cache/${TOPIC}.md"
46
+ if [ -f "$F" ]; then
47
+ EXPIRES=$(awk -F': ' '/^expires_on:/{print $2; exit}' "$F")
48
+ [ "$EXPIRES" \> "$TODAY" ] && echo "FRESH cache hit: $F" && exit 0
49
+ echo "STALE: $F (expired $EXPIRES); will refresh"
50
+ fi
51
+
52
+ # 2. Fuzzy hit? (alias / synonym)
53
+ grep -l "topic:.*${TOPIC%%-*}" .claude/skills/research-cache/cache/*.md 2>/dev/null
54
+ ```
55
+
56
+ If FRESH → use the cache, do NOT re-search.
57
+ If STALE or MISSING → research, then write a new entry (overwrite or create).
58
+
59
+ ## Write protocol (after research)
60
+
61
+ Always overwrite — never append. Stale data is worse than missing data.
62
+
63
+ ### Body template
33
64
 
34
65
  ```markdown
35
- # Research: {Topic}
66
+ ---
67
+ topic: <kebab-case>
68
+ stack: <one-of>
69
+ researched_on: 2026-05-13
70
+ expires_on: 2026-06-12
71
+ tier: 1
72
+ engines: [brave, vertex, grok]
73
+ sources_count: 5
74
+ confidence: high
75
+ ---
76
+
77
+ # Research: <Topic Title>
36
78
 
37
- **Date:** YYYY-MM-DD
38
- **Stack:** PHP|Node.js|Universal
39
- **Sources:** [list]
40
- **Expires:** YYYY-MM-DD (30 days from research)
79
+ > **TL;DR** (≤ 3 lines). The actionable answer in 30 seconds.
41
80
 
42
- ## Key Findings
43
- 1. Finding — Source: [URL]
81
+ ## Findings (cited)
82
+
83
+ | # | Finding | Source | Date | Tier |
84
+ |---|---|---|---|---|
85
+ | 1 | <one-line> | https://docs.example.com/foo | 2026-04-12 | official |
86
+ | 2 | <one-line> | https://eng-blog.example.com/bar | 2026-03-30 | engineering |
44
87
 
45
88
  ## Recommendations
46
- - Actionable recommendation
47
89
 
48
- ## Code Examples
49
- \`\`\`php
50
- // Example implementation
51
- \`\`\`
90
+ - <actionable rule, ready to drop into a skill or CLAUDE.md>
91
+ - <do this, not that>
92
+
93
+ ## Anti-patterns
94
+
95
+ - <something to avoid + why>
96
+
97
+ ## Code reference (optional)
98
+
99
+ - File / line / commit pointing at where this rule should be applied — NOT inline code dumps.
100
+
101
+ ## Open questions
52
102
 
53
- ## References
54
- - [URL] — [Description]
103
+ - <thing the research did NOT answer; flag for next round>
55
104
  ```
56
105
 
106
+ ## Expiry policy (cost vs freshness)
107
+
108
+ | Topic kind | TTL | Example |
109
+ |---|---|---|
110
+ | Specification (W3C, RFC, OpenAPI) | 60 days | WCAG 2.2 conformance |
111
+ | Stable framework (Laravel, Django, Express) | 30 days | Laravel 12 sessions |
112
+ | Fast-moving library (any minor < 1.0, anything pre-release) | 14 days | shadcn registries, AI SDKs |
113
+ | Security advisory | 7 days | CVE feeds, OWASP draft |
114
+
115
+ After `expires_on`, the entry is read-only history — `research-web` will refresh it on the next lookup.
116
+
117
+ ## Source ranking (recorded in each finding row)
118
+
119
+ 1. **official** — vendor docs, RFCs, W3C, MDN
120
+ 2. **engineering** — engineering blogs of the project (vercel.com/blog, fastify.io/blog)
121
+ 3. **community** — high-signal: Stack Overflow with 50+ votes, GitHub issues with maintainer response
122
+ 4. **opinion** — random blog post — accepted only if it confirms an official-doc claim, never as primary
123
+
57
124
  ## Rules
58
125
 
59
- 1. **CHECK CACHE FIRST** — avoid redundant searches
60
- 2. **CITE SOURCES** — every finding needs URL
61
- 3. **DATE ENTRIES** — for freshness checks
62
- 4. **STACK-SPECIFIC** — tag by stack for filtering
126
+ 1. **CHECK CACHE FIRST** — frontmatter `expires_on` lookup is one `awk`. Cheaper than any web call.
127
+ 2. **OVERWRITE, NEVER APPEND** — stale information is worse than missing.
128
+ 3. **CITE EVERY FINDING** — URL + date + tier. No bare claims.
129
+ 4. **TTL BY TOPIC KIND** — see table above. A spec lasts longer than a pre-release library.
130
+ 5. **CONFIDENCE EXPLICIT** — `high` requires ≥ 3 official-doc sources agreeing; `low` is single source.
131
+ 6. **NO INLINE CODE DUMPS** — link to file/line; the model can `Read` when it needs the bytes.
132
+ 7. **NO PII / SECRETS / CUSTOMER DATA** — never quote env values, tokens, internal hostnames.
133
+ 8. **PROMOTE WHAT'S UNIVERSAL** — if a rule applies project-wide, surface it for inclusion in `CLAUDE.md` (do not auto-edit).
134
+
135
+ ## See Also
136
+
137
+ - `research-web` v2.0.0 — MCP-first researcher; reads/writes this cache
138
+ - `claude-md-compactor` v2.0.0 — receives promoted rules; enforces 20 KB CLAUDE.md budget
139
+ - `mcp-web-scraper` skill — the MCP server providing Tier 1 search/scrape capability