start-vibing-stacks 2.25.2 → 2.28.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 +2 -2
- package/dist/migrate.d.ts +3 -1
- package/dist/migrate.js +23 -1
- package/dist/setup.js +7 -0
- package/package.json +1 -1
- package/stacks/_shared/agents/claude-md-compactor.md +38 -4
- package/stacks/_shared/agents/commit-manager.md +100 -36
- package/stacks/_shared/agents/documenter.md +11 -6
- package/stacks/_shared/agents/domain-updater.md +107 -42
- package/stacks/_shared/commands/commit-mine.md +78 -0
- package/stacks/_shared/commands/feature.md +4 -2
- package/stacks/_shared/commands/fix.md +6 -4
- package/stacks/_shared/hooks/_state.README.md +2 -2
- package/stacks/_shared/hooks/_state.ts +25 -9
- package/stacks/_shared/hooks/pre-tool-use.ts +6 -5
- package/stacks/_shared/hooks/scope.ts +478 -0
- package/stacks/_shared/hooks/session-start.ts +3 -2
- package/stacks/_shared/hooks/stop-validator.ts +79 -14
- package/stacks/_shared/hooks/user-prompt-submit.ts +12 -4
- package/stacks/_shared/skills/git-workflow/SKILL.md +1 -1
- package/stacks/_shared/skills/hook-development/SKILL.md +5 -1
- package/stacks/_shared/skills/multi-instance-coordination/SKILL.md +5 -5
- package/templates/CLAUDE-default.md +8 -4
- package/templates/CLAUDE-nodejs.md +14 -10
- package/templates/CLAUDE-php.md +14 -10
- package/templates/CLAUDE-python.md +23 -10
package/README.md
CHANGED
|
@@ -173,7 +173,7 @@ Global install: `npm i -g start-vibing-stacks` → `svs` (alias).
|
|
|
173
173
|
6. QUALITY quality-gate: typecheck → lint → test → build
|
|
174
174
|
7. COMMIT commit-manager — verifies gates, diff-driven message, push
|
|
175
175
|
8. DOCUMENT documenter — maps files/commits to domains, regenerates _index.json
|
|
176
|
-
9. WISDOM domain-updater — records session learnings,
|
|
176
|
+
9. WISDOM domain-updater — records session learnings, PREPENDS new entry to CLAUDE.md ## Recent Changes (append-only LIFO, cap 10, multi-instance safe)
|
|
177
177
|
10. COMPACT claude-md-compactor — triggers if CLAUDE.md > 20 KB
|
|
178
178
|
```
|
|
179
179
|
|
|
@@ -195,7 +195,7 @@ Steps 5–6 cannot be skipped — `security-auditor` and `quality-gate` veto `co
|
|
|
195
195
|
| Edit policy | `Edit` known anchors; never `Write` over an existing domain | Diff stability for code review |
|
|
196
196
|
| `summary_sha` | sha256 of the TL;DR block | Drift detector for CI hooks |
|
|
197
197
|
|
|
198
|
-
This layer is **separate** from `CLAUDE.md`: that file holds project-wide rules and
|
|
198
|
+
This layer is **separate** from `CLAUDE.md`: that file holds project-wide rules and `## Recent Changes` (append-only LIFO, cap 10 entries, multi-instance safe — see `claude-md-compactor.md §6.1`); the memory layer holds domain knowledge.
|
|
199
199
|
|
|
200
200
|
---
|
|
201
201
|
|
package/dist/migrate.d.ts
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* - commands: same `version:` frontmatter contract as skills/agents.
|
|
11
11
|
* - .claude/settings.json — patched idempotently to ensure the bundled hook
|
|
12
12
|
* chain (SessionStart / UserPromptSubmit / PreToolUse / PostToolUse / Stop /
|
|
13
|
-
* SessionEnd) is wired
|
|
13
|
+
* SessionEnd) is wired, plus high-reasoning defaults `effortLevel: "xhigh"`
|
|
14
|
+
* and `permissions.defaultMode: "plan"` (only when MISSING — user choices are
|
|
15
|
+
* never clobbered). Existing entries are preserved; only missing entries
|
|
14
16
|
* are appended. Atomic write (.tmp + rename).
|
|
15
17
|
* - .claude/state/ — runtime layout for multi-instance coordination is
|
|
16
18
|
* auto-created and the `_state.README.md` is staged as `.claude/state/README.md`.
|
package/dist/migrate.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* - commands: same `version:` frontmatter contract as skills/agents.
|
|
11
11
|
* - .claude/settings.json — patched idempotently to ensure the bundled hook
|
|
12
12
|
* chain (SessionStart / UserPromptSubmit / PreToolUse / PostToolUse / Stop /
|
|
13
|
-
* SessionEnd) is wired
|
|
13
|
+
* SessionEnd) is wired, plus high-reasoning defaults `effortLevel: "xhigh"`
|
|
14
|
+
* and `permissions.defaultMode: "plan"` (only when MISSING — user choices are
|
|
15
|
+
* never clobbered). Existing entries are preserved; only missing entries
|
|
14
16
|
* are appended. Atomic write (.tmp + rename).
|
|
15
17
|
* - .claude/state/ — runtime layout for multi-instance coordination is
|
|
16
18
|
* auto-created and the `_state.README.md` is staged as `.claude/state/README.md`.
|
|
@@ -302,6 +304,26 @@ export function patchSettings(projectDir, dryRun) {
|
|
|
302
304
|
}
|
|
303
305
|
report.added.push(event);
|
|
304
306
|
}
|
|
307
|
+
// High-reasoning defaults (v2.28.0). Only set when MISSING so we never clobber
|
|
308
|
+
// a user's explicit choice. `ultracode` is intentionally never written here:
|
|
309
|
+
// it is session-only (/effort) and cannot be persisted in settings.json.
|
|
310
|
+
if (settings.effortLevel === undefined) {
|
|
311
|
+
if (!dryRun)
|
|
312
|
+
settings.effortLevel = 'xhigh';
|
|
313
|
+
report.added.push('effortLevel:xhigh');
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
report.alreadyPresent.push('effortLevel');
|
|
317
|
+
}
|
|
318
|
+
settings.permissions = settings.permissions || {};
|
|
319
|
+
if (settings.permissions.defaultMode === undefined) {
|
|
320
|
+
if (!dryRun)
|
|
321
|
+
settings.permissions.defaultMode = 'plan';
|
|
322
|
+
report.added.push('permissions.defaultMode:plan');
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
report.alreadyPresent.push('permissions.defaultMode');
|
|
326
|
+
}
|
|
305
327
|
if (!dryRun && report.added.length > 0 && !report.error) {
|
|
306
328
|
mkdirSync(dirname(path), { recursive: true });
|
|
307
329
|
writeFileAtomic(path, JSON.stringify(settings, null, '\t'));
|
package/dist/setup.js
CHANGED
|
@@ -226,6 +226,10 @@ export async function setupProject(projectDir, config, options = {}) {
|
|
|
226
226
|
model: 'sonnet',
|
|
227
227
|
max_tokens: 8192,
|
|
228
228
|
max_turns: 100,
|
|
229
|
+
// Persistent high-reasoning effort. Note: 'ultracode' is session-only
|
|
230
|
+
// (set via /effort) and cannot be persisted here; 'xhigh' is the highest
|
|
231
|
+
// persistable level. On 'sonnet' it falls back to 'high'.
|
|
232
|
+
effortLevel: 'xhigh',
|
|
229
233
|
enableAllProjectMcpServers: true,
|
|
230
234
|
autoMemoryEnabled: true,
|
|
231
235
|
context: {
|
|
@@ -235,6 +239,9 @@ export async function setupProject(projectDir, config, options = {}) {
|
|
|
235
239
|
memory_files: ['.claude/CLAUDE.md', 'CLAUDE.md'],
|
|
236
240
|
},
|
|
237
241
|
permissions: {
|
|
242
|
+
// Always start sessions in plan mode (read-only): the agent must
|
|
243
|
+
// present a plan before editing. Shift+Tab still cycles modes per turn.
|
|
244
|
+
defaultMode: 'plan',
|
|
238
245
|
allow: [
|
|
239
246
|
'Bash(*)',
|
|
240
247
|
'Read(*)',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: claude-md-compactor
|
|
3
|
-
version: 2.
|
|
4
|
-
description: "AUTOMATICALLY invoke when project CLAUDE.md > 20 KB OR any nested CLAUDE.md > 16 KB OR MEMORY.md > 25 KB / 200 lines OR any SKILL.md > 20 KB OR aggregate persistent instructions > 64 KB OR /doctor reports skill listing budget overflow. Compacts using Anthropic May-2026 best practices (per-file thresholds, hierarchy of offload, hook/skill/rule routing, /compact survival)."
|
|
3
|
+
version: 2.1.0
|
|
4
|
+
description: "AUTOMATICALLY invoke when project CLAUDE.md > 20 KB OR any nested CLAUDE.md > 16 KB OR MEMORY.md > 25 KB / 200 lines OR any SKILL.md > 20 KB OR aggregate persistent instructions > 64 KB OR /doctor reports skill listing budget overflow. Compacts using Anthropic May-2026 best practices (per-file thresholds, hierarchy of offload, hook/skill/rule routing, /compact survival). Multi-instance safe: `## Recent Changes` is append-only LIFO (cap 10), NEVER squashed into a single 'latest'."
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Read, Write, Edit, Bash, Grep, Glob
|
|
7
7
|
---
|
|
@@ -197,7 +197,7 @@ grep -rh '^- ' .claude/rules/ ~/.claude/rules/ 2>/dev/null | sort | uniq -d
|
|
|
197
197
|
| Section | Budget | Overflow target |
|
|
198
198
|
|---|---|---|
|
|
199
199
|
| Title + 1-paragraph overview | 500 chars | — |
|
|
200
|
-
|
|
|
200
|
+
| Recent Changes (LIFO, ≤ 10 entries) | 2.500 chars | git log; drop OLDEST when count > 10 |
|
|
201
201
|
| Stack table | 600 chars | — |
|
|
202
202
|
| Architecture tree | 1.000 chars | — |
|
|
203
203
|
| Critical Rules (bullets) | 4.000 chars | `.claude/rules/<topic>.md` (with `paths:` when scoped) |
|
|
@@ -213,7 +213,8 @@ grep -rh '^- ' .claude/rules/ ~/.claude/rules/ 2>/dev/null | sort | uniq -d
|
|
|
213
213
|
|---|---|
|
|
214
214
|
| Delete rules entirely | Move to `.claude/rules/` or skill instead |
|
|
215
215
|
| Remove FORBIDDEN table | Security visibility is the point |
|
|
216
|
-
|
|
|
216
|
+
| Collapse `## Recent Changes` into a single "latest" | Multi-instance overwrites = lost work. Keep as append-only LIFO; drop only the OLDEST `###` block when count > 10 |
|
|
217
|
+
| Edit or remove a `###` entry you did not author | Each instance owns its own entry. Compaction is cap-based pruning, not editing |
|
|
217
218
|
| Remove architecture tree | Essential for navigation |
|
|
218
219
|
| Truncate code examples mid-block | Reference the file instead |
|
|
219
220
|
| Edit auto memory of other projects | Stay in current `~/.claude/projects/<proj>/` |
|
|
@@ -222,6 +223,39 @@ grep -rh '^- ' .claude/rules/ ~/.claude/rules/ 2>/dev/null | sort | uniq -d
|
|
|
222
223
|
| Trust `@import` to save context | It does NOT — imports load full at launch |
|
|
223
224
|
| Keep nested CLAUDE.md content critical | Lost after `/compact` — promote to rule with `paths:` |
|
|
224
225
|
|
|
226
|
+
## 6.1 Multi-Instance Safety (CRITICAL — read before touching `## Recent Changes`)
|
|
227
|
+
|
|
228
|
+
CLAUDE.md is read by EVERY parallel Claude session in the project. The `## Recent Changes` section
|
|
229
|
+
is the single piece of content that every session WRITES TO. Without a contract, two instances editing
|
|
230
|
+
within the same minute will overwrite each other (last `Write` wins; the loser's entry vanishes silently
|
|
231
|
+
and is unrecoverable unless committed).
|
|
232
|
+
|
|
233
|
+
**Contract enforced by this agent:**
|
|
234
|
+
|
|
235
|
+
1. **Append-only LIFO.** New entries PREPEND directly under the `<!-- APPEND-ONLY LIFO ... -->` HTML
|
|
236
|
+
comment. Use the heading format `### YYYY-MM-DD · <branch> · <vX.Y.Z | tag>`, followed by 1–4 lines.
|
|
237
|
+
2. **Cap is 10.** When count > 10, drop ONLY the bottom (oldest) `###` block. Never reorder.
|
|
238
|
+
3. **No squashing.** Two entries on the same day are TWO entries. Squashing them into a single "May-19
|
|
239
|
+
summary" destroys multi-instance attribution.
|
|
240
|
+
4. **No editing peer entries.** If an entry is malformed, leave it. Diagnose with `git blame CLAUDE.md`
|
|
241
|
+
and let the author fix it.
|
|
242
|
+
5. **Atomic write contract.** The `Write` tool used by Claude is atomic at the FS level (tmp + rename),
|
|
243
|
+
but it overwrites the ENTIRE file. Before any `Write CLAUDE.md`, the agent MUST `Read CLAUDE.md`
|
|
244
|
+
immediately prior and operate on the just-read content; any older copy in context is stale.
|
|
245
|
+
6. **Compaction trigger.** Cap pruning runs only when `wc -c CLAUDE.md` > 20 KB AND
|
|
246
|
+
`grep -c '^### ' CLAUDE.md` between the `## Recent Changes` and next `## ` headers exceeds 10.
|
|
247
|
+
Pruning is `tail -n` style on `###` blocks, not paragraph editing.
|
|
248
|
+
|
|
249
|
+
**Verification one-liner (run before compacting `## Recent Changes`):**
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
awk '/^## Recent Changes/{f=1;next} /^## /{f=0} f && /^### /{n++} END{print n " entries"}' CLAUDE.md
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Companion: per-instance commit scoping lives in `.claude/hooks/scope.ts` + `/commit-mine` command.
|
|
256
|
+
Together they ensure each instance prepends its OWN entry AND commits only its OWN files. See the
|
|
257
|
+
"Instance N's commit bundling instance M's uncommitted files" NRY in CLAUDE.md.
|
|
258
|
+
|
|
225
259
|
## 7. Verification (mandatory after compaction)
|
|
226
260
|
|
|
227
261
|
```bash
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: commit-manager
|
|
3
|
-
version:
|
|
4
|
-
description: "AUTOMATICALLY invoke as the FINAL implementation agent when code changes are ready. Verifies
|
|
3
|
+
version: 3.1.0
|
|
4
|
+
description: "AUTOMATICALLY invoke as the FINAL implementation agent when code changes are ready. Verifies security-auditor and quality-gate passed (HARD GATE — will NOT commit if vetoed), analyzes the diff for a precise conventional commit message, commits ONLY this session's files via `scope.ts commit` (atomic `git commit -o`, never bundles a peer's staged work; `git add -A` only in solo projects), pushes, and triggers the post-commit chain (documenter → domain-updater). Multi-instance safe: never bundles peer sessions' uncommitted files into your commit, and STOPS rather than falling back to `git add -A` when the session cannot be resolved. Supports branch-merge and direct-to-main flows. v3.1.0 (May-2026): atomic pathspec commit + safe (no -A) fallback + CLAUDE_SESSION_ID requirement."
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Read, Bash, Grep, Glob
|
|
7
7
|
skills: git-workflow
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
# Commit Manager Agent (
|
|
10
|
+
# Commit Manager Agent (v3.0.0 — gate-aware, diff-driven, per-instance scoped)
|
|
11
11
|
|
|
12
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
|
|
|
@@ -54,6 +54,27 @@ Action: fix the findings and re-run the gate before calling commit-manager agai
|
|
|
54
54
|
|
|
55
55
|
---
|
|
56
56
|
|
|
57
|
+
## Step 1.5 — Peer awareness (multi-instance only)
|
|
58
|
+
|
|
59
|
+
If `.claude/state/` exists, surface active peers BEFORE staging. This is informational —
|
|
60
|
+
not blocking — but a Claude session that pushes while a peer is editing the same files can
|
|
61
|
+
cause a remote race condition.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
if [ -d "$CLAUDE_PROJECT_DIR/.claude/state" ]; then
|
|
65
|
+
PEERS=$(npx tsx "$CLAUDE_PROJECT_DIR/.claude/hooks/peers.ts" list 2>/dev/null | grep -c '\[active\]' || true)
|
|
66
|
+
if [ "${PEERS:-0}" -gt 0 ]; then
|
|
67
|
+
echo "⚠️ $PEERS active peer session(s). Your commit will scope to THIS session's files only,"
|
|
68
|
+
echo " but a `git push` may race with a peer's push. Coordinate via:"
|
|
69
|
+
echo " npx tsx \"\$CLAUDE_PROJECT_DIR/.claude/hooks/peers.ts\" notify <id> \"committing now\""
|
|
70
|
+
fi
|
|
71
|
+
fi
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This step is skipped silently in solo projects (no `.claude/state/` directory).
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
57
78
|
## Step 2 — Detect commit flow
|
|
58
79
|
|
|
59
80
|
```bash
|
|
@@ -107,29 +128,15 @@ Read at most 3 files in full diff. For the rest, rely on the stat + file names.
|
|
|
107
128
|
|
|
108
129
|
---
|
|
109
130
|
|
|
110
|
-
## Step 4 — Stage and commit
|
|
111
|
-
|
|
112
|
-
### 4a. Stage
|
|
113
|
-
|
|
114
|
-
```bash
|
|
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
|
-
```
|
|
131
|
+
## Step 4 — Stage and commit (per-instance scoped)
|
|
124
132
|
|
|
125
|
-
###
|
|
133
|
+
### 4a. Compose the message (HEREDOC, shell-safe multi-line)
|
|
126
134
|
|
|
127
135
|
```bash
|
|
128
|
-
|
|
136
|
+
MSG="$(cat <<'EOF'
|
|
129
137
|
<type>(<scope>): <subject>
|
|
130
138
|
|
|
131
139
|
<body — 2-5 bullets if ≥ 3 files>
|
|
132
|
-
|
|
133
140
|
EOF
|
|
134
141
|
)"
|
|
135
142
|
```
|
|
@@ -137,9 +144,59 @@ EOF
|
|
|
137
144
|
Rules:
|
|
138
145
|
- **No** `Co-Authored-By` header unless the user explicitly asked for it.
|
|
139
146
|
- **No** `Generated with Claude Code` footer — it adds noise to git log.
|
|
140
|
-
- Subject line ≤ 72 chars.
|
|
141
|
-
|
|
142
|
-
|
|
147
|
+
- Subject line ≤ 72 chars. Body wraps at 80 chars. Empty body is fine for single-file changes.
|
|
148
|
+
|
|
149
|
+
### 4b. Commit — `scope.ts commit` (multi-instance) or `git add -A` (solo only)
|
|
150
|
+
|
|
151
|
+
The truth of "what did THIS session edit?" lives in `.claude/state/sessions/<id>.json#filesTouched`,
|
|
152
|
+
maintained by `post-tool-use.ts`. In a multi-instance project, commit ONLY those files. `scope.ts
|
|
153
|
+
commit` does this atomically via `git commit -o -- <files>` (commits exactly your paths regardless
|
|
154
|
+
of what a peer has staged) — there is NO `git add -A`, because that is precisely what bundles a
|
|
155
|
+
peer's uncommitted work into your commit.
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
SCOPE_TS="$CLAUDE_PROJECT_DIR/.claude/hooks/scope.ts"
|
|
159
|
+
STATE_DIR="$CLAUDE_PROJECT_DIR/.claude/state"
|
|
160
|
+
|
|
161
|
+
if [ -f "$SCOPE_TS" ] && [ -d "$STATE_DIR" ]; then
|
|
162
|
+
# Multi-instance project: commit this session's files only (never -A).
|
|
163
|
+
# scope.ts resolves the session via $CLAUDE_SESSION_ID, else the single active
|
|
164
|
+
# session. With ≥2 active sessions and no $CLAUDE_SESSION_ID it returns 1.
|
|
165
|
+
npx tsx "$SCOPE_TS" commit "$MSG"
|
|
166
|
+
COMMIT_CODE=$?
|
|
167
|
+
case "$COMMIT_CODE" in
|
|
168
|
+
0) ;; # committed your scope cleanly
|
|
169
|
+
2)
|
|
170
|
+
# A peer touched one of your files in the last 5 min. Do NOT override blindly.
|
|
171
|
+
echo "⛔ Conflict: a peer is editing one of your files. Coordinate via:"
|
|
172
|
+
echo " npx tsx \"$CLAUDE_PROJECT_DIR/.claude/hooks/peers.ts\" notify <id> \"...\""
|
|
173
|
+
echo " Then re-run, or (only if you own the change) add --include-conflicted."
|
|
174
|
+
exit 1
|
|
175
|
+
;;
|
|
176
|
+
*)
|
|
177
|
+
# Session could not be resolved (≥2 active, no $CLAUDE_SESSION_ID) or no dirty
|
|
178
|
+
# files in scope. STOP — do NOT fall back to `git add -A` (it bundles peers).
|
|
179
|
+
echo "⛔ scope.ts could not commit this session's scope (code $COMMIT_CODE)."
|
|
180
|
+
echo " Set CLAUDE_SESSION_ID or pass --session <id>, then re-run."
|
|
181
|
+
echo " Inspect with: npx tsx \"$SCOPE_TS\" status"
|
|
182
|
+
exit 1
|
|
183
|
+
;;
|
|
184
|
+
esac
|
|
185
|
+
else
|
|
186
|
+
# Solo project (no .claude/state/) — only here is `git add -A` safe.
|
|
187
|
+
git add -A
|
|
188
|
+
# Guard against incidental junk (multi-instance path is immune: scope commits
|
|
189
|
+
# only filesTouched, so these never get staged in the first place).
|
|
190
|
+
git reset HEAD -- .DS_Store .env *.log 2>/dev/null || true
|
|
191
|
+
git commit -m "$MSG"
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
git status --short
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
> Operational requirement: `scope.ts` needs to know which session is committing.
|
|
198
|
+
> Ensure `CLAUDE_SESSION_ID` is exported to the shell, OR run with `--session <id>`
|
|
199
|
+
> when more than one instance is active. The fallback is to STOP, never `git add -A`.
|
|
143
200
|
|
|
144
201
|
---
|
|
145
202
|
|
|
@@ -189,7 +246,8 @@ Files: <n> changed, <insertions>+, <deletions>-
|
|
|
189
246
|
|
|
190
247
|
Next agents (in order):
|
|
191
248
|
1. documenter — map files + commits to domains
|
|
192
|
-
2. domain-updater — record session wisdom +
|
|
249
|
+
2. domain-updater — record session wisdom + PREPEND new entry to CLAUDE.md `## Recent Changes`
|
|
250
|
+
(append-only LIFO, cap 10 — multi-instance safe)
|
|
193
251
|
```
|
|
194
252
|
|
|
195
253
|
Do NOT run them yourself — the orchestrator or the user triggers them. Your job is done after push.
|
|
@@ -226,21 +284,27 @@ Action: <what the user should do>
|
|
|
226
284
|
## Critical rules
|
|
227
285
|
|
|
228
286
|
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. **
|
|
230
|
-
3. **
|
|
231
|
-
4. **
|
|
232
|
-
5. **NO
|
|
233
|
-
6. **
|
|
234
|
-
7. **
|
|
235
|
-
8. **
|
|
236
|
-
9. **
|
|
237
|
-
10. **
|
|
287
|
+
2. **PER-INSTANCE COMMIT** — when `.claude/state/` exists, ALWAYS commit via `scope.ts commit` (Step 4b), which uses `git commit -o -- <files>` to commit EXACTLY your files. NEVER `git add -A` in a multi-instance project; it bundles peers' uncommitted files. If `scope.ts` cannot resolve the session, STOP — do NOT fall back to `git add -A`. See CLAUDE.md NRY "Instance N's commit bundling instance M's uncommitted files".
|
|
288
|
+
3. **DIFF-DRIVEN MESSAGES** — read the actual diff (stat first, full only when needed). Never generate generic messages.
|
|
289
|
+
4. **HEREDOC** — always use `cat <<'EOF'` for commit messages. Never inline multi-line strings.
|
|
290
|
+
5. **NO FORCE PUSH** — never `git push --force` or `--force-with-lease` to main/master unless the user explicitly requests it.
|
|
291
|
+
6. **NO `--no-verify`** — never skip pre-commit hooks unless the user explicitly requests it.
|
|
292
|
+
7. **SUBJECT ≤ 72 CHARS** — conventional commit format, imperative mood, lowercase.
|
|
293
|
+
8. **TOKEN EFFICIENT** — use `--stat` first (cheap). Only `diff -U3` specific files when stat is ambiguous. Never read the full diff of 20+ files.
|
|
294
|
+
9. **CLEAN STAGE** — verify no `.env`, `.DS_Store`, `*.log` are staged. Unstage them silently.
|
|
295
|
+
10. **PUSH FAILURE = STOP** — retry once with `--rebase --autostash`. If still fails, stop and report. Never force push.
|
|
296
|
+
11. **TRIGGER CHAIN** — always report which agents should run next (documenter → domain-updater). You do not run them.
|
|
297
|
+
12. **NEVER REFRESH "Last Change"** — that section no longer exists. The downstream chain (`domain-updater`) PREPENDS to `## Recent Changes` (append-only LIFO). Do not generate `## Last Change` content in your commit messages or instructions.
|
|
238
298
|
|
|
239
299
|
## See Also
|
|
240
300
|
|
|
241
301
|
- `git-workflow` skill — branch naming, conventional commits, merge strategies, HEREDOC examples
|
|
302
|
+
- `scope.ts` (`.claude/hooks/scope.ts`) — per-instance staging tool used by Step 4a
|
|
303
|
+
- `peers.ts` (`.claude/hooks/peers.ts`) — peer discovery CLI used by Step 1.5
|
|
304
|
+
- `/commit-mine` slash command — interactive equivalent of this agent's Step 4a + Step 4b for manual use
|
|
242
305
|
- `security-auditor` v2.0.0 — VETO gate; blocks this agent on open findings
|
|
243
306
|
- `quality-gate` skill — typecheck → lint → test → build pipeline
|
|
244
|
-
- `documenter`
|
|
245
|
-
- `domain-updater`
|
|
246
|
-
- `
|
|
307
|
+
- `documenter` v3.0.0 — runs AFTER this agent to map files/commits (uses `git diff-tree HEAD`, which is per-instance scoped because YOUR commit was already scoped)
|
|
308
|
+
- `domain-updater` v3.0.0 — runs AFTER documenter to record wisdom + PREPEND to `## Recent Changes`
|
|
309
|
+
- `claude-md-compactor` v2.1.0 §6.1 — append-only LIFO contract for `## Recent Changes`
|
|
310
|
+
- `stop-validator` hook v1.2.0 — per-instance dirty-tree check; accepts `## Last Change` OR `## Recent Changes`
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: documenter
|
|
3
|
-
version:
|
|
4
|
-
description: "AUTOMATICALLY invoke AFTER `commit-manager` succeeds. Maintains the project's local long-term memory under `.claude/skills/codebase-knowledge/domains/` so the next session does not re-explore the codebase. Search-optimized layout (YAML frontmatter + `_index.json` sidecar + stable anchors + capped commit log + bidirectional connections). Atomic files (≤ 8 KB / ~2k tokens / 200 lines).
|
|
3
|
+
version: 3.0.0
|
|
4
|
+
description: "AUTOMATICALLY invoke AFTER `commit-manager` succeeds. Maintains the project's local long-term memory under `.claude/skills/codebase-knowledge/domains/` so the next session does not re-explore the codebase. Search-optimized layout (YAML frontmatter + `_index.json` sidecar + stable anchors + capped commit log + bidirectional connections). Atomic files (≤ 8 KB / ~2k tokens / 200 lines). v3.0.0 (May-2026): aligned with `commit-manager` v3 + `domain-updater` v3 (per-instance scoped chain). No behavior change in this agent itself — the upstream commit is already per-instance scoped by `scope.ts`, so `git diff-tree HEAD` naturally returns only THIS session's files."
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Read, Write, Edit, Grep, Glob, Bash
|
|
7
7
|
skills: docs-tracker, codebase-knowledge
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
# Documenter Agent (
|
|
10
|
+
# Documenter Agent (v3.0.0 — search-optimized memory layer, per-instance-aware chain)
|
|
11
11
|
|
|
12
12
|
You are the project memory engineer. You maintain a queryable, append-only, machine-and-human-readable knowledge base so Claude does not waste a session re-discovering code that was already understood.
|
|
13
13
|
|
|
@@ -56,6 +56,10 @@ echo "Stack=$STACK Commit=$SHORT ($DATE) Subject=$SUBJECT"
|
|
|
56
56
|
git diff-tree --no-commit-id --name-status -r HEAD
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
> **Per-instance scoping is inherited from `commit-manager`.** Since `commit-manager` v3.0.0 stages
|
|
60
|
+
> only THIS session's files via `scope.ts`, `HEAD` already represents this instance's scope. You do
|
|
61
|
+
> NOT need to filter further by `session.filesTouched` — that work was done one step upstream.
|
|
62
|
+
|
|
59
63
|
Map each path to a `domain` slug using `.claude/config/domain-mapping.json`. A file may belong to ≥1 domain. If no pattern matches → `general`. Skip if all matched files are inside `.claude/`, `docs/`, or `.github/`.
|
|
60
64
|
|
|
61
65
|
### 3. For each affected domain
|
|
@@ -222,7 +226,8 @@ Use `Edit` / `StrReplace`, never `Write`, on existing domain files.
|
|
|
222
226
|
|
|
223
227
|
- `docs-tracker` skill — file → doc mapping rules + changelog templates
|
|
224
228
|
- `codebase-knowledge` skill — consumer of this layout (reads domains BEFORE implementing)
|
|
225
|
-
- `commit-manager`
|
|
226
|
-
- `domain-updater`
|
|
227
|
-
- `claude-md-compactor` v2.
|
|
229
|
+
- `commit-manager` v3.0.0 — runs BEFORE this agent; stages this session's files via `scope.ts`, triggers the chain
|
|
230
|
+
- `domain-updater` v3.0.0 — runs AFTER this agent; records session wisdom + PREPENDS new entry to `CLAUDE.md` `## Recent Changes` (append-only LIFO, cap 10)
|
|
231
|
+
- `claude-md-compactor` v2.1.0 — keeps top-level `CLAUDE.md` ≤ 20 KB (see §5 budget, §6 forbidden, §6.1 multi-instance safety); this layer keeps each domain ≤ 8 KB
|
|
232
|
+
- `scope.ts` (`.claude/hooks/scope.ts`) — per-instance staging tool; the reason `HEAD` already reflects this session's scope
|
|
228
233
|
- `security-auditor` v2.0.0 — vetoes commit if PII/secret leaks into a domain file
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: domain-updater
|
|
3
|
-
version:
|
|
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)
|
|
3
|
+
version: 3.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) PREPEND a new `### YYYY-MM-DD · branch · vX.Y.Z` entry to the `## Recent Changes` section in the project's root `CLAUDE.md` (append-only LIFO, cap 10). Does NOT map files or commits (that is `documenter`'s job). Runs AFTER documenter, BEFORE session ends. v3.0.0 (May-2026): Recent Changes (LIFO) replaces the old Last Change overwrite pattern — multi-instance safe; no longer stomps peers' entries."
|
|
5
5
|
model: sonnet
|
|
6
6
|
tools: Read, Edit, Bash, Grep, Glob
|
|
7
7
|
skills: codebase-knowledge
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
-
# Domain Updater Agent (
|
|
10
|
+
# Domain Updater Agent (v3.0.0 — wisdom layer + Recent Changes prepend)
|
|
11
11
|
|
|
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
|
|
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**, and you PREPEND a new entry to `## Recent Changes` (append-only LIFO) — the multi-instance-safe replacement for the old `## Last Change` overwrite pattern (which caused parallel sessions to silently lose each other's entries).
|
|
13
13
|
|
|
14
14
|
## Role boundary
|
|
15
15
|
|
|
@@ -17,7 +17,7 @@ You record **session-level learnings** so the next session avoids the same mista
|
|
|
17
17
|
|---|---|
|
|
18
18
|
| File → domain mapping, `## Files` table, commit log, `_index.json` | `documenter` |
|
|
19
19
|
| Problems & Solutions, Attention Points, session wisdom | **you** (`domain-updater`) |
|
|
20
|
-
| `CLAUDE.md` `##
|
|
20
|
+
| `CLAUDE.md` `## Recent Changes` PREPEND (append-only LIFO, cap 10) | **you** |
|
|
21
21
|
| Commit the changes | `commit-manager` (only if running in pre-commit position) |
|
|
22
22
|
|
|
23
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.
|
|
@@ -55,7 +55,7 @@ Scan the current session for:
|
|
|
55
55
|
| A decision with trade-offs | **Attention Point** (record the reasoning) |
|
|
56
56
|
| A skill section that saved the fix | **See Also** cross-reference |
|
|
57
57
|
|
|
58
|
-
If NONE of the above occurred in this session, skip to Step 4 (
|
|
58
|
+
If NONE of the above occurred in this session, skip to Step 4 (Recent Changes prepend).
|
|
59
59
|
|
|
60
60
|
## Step 3 — Write wisdom into domain files
|
|
61
61
|
|
|
@@ -108,49 +108,109 @@ If > 8192 bytes (8 KB), move the oldest 2 Problem & Solution entries + oldest 3
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
-
## Step 4 —
|
|
111
|
+
## Step 4 — PREPEND new entry to `CLAUDE.md` `## Recent Changes`
|
|
112
112
|
|
|
113
|
-
This is the most-read section in the entire project — every session loads it at boot
|
|
113
|
+
This is the most-read section in the entire project — every session loads it at boot — AND it is the
|
|
114
|
+
only section that EVERY session writes to. The append-only LIFO contract (formally specified in
|
|
115
|
+
`claude-md-compactor.md §6.1`) is the ONLY thing preventing multi-instance overwrites. Read §6.1
|
|
116
|
+
once; the rules below are the operational consequence.
|
|
114
117
|
|
|
115
|
-
### 4a.
|
|
118
|
+
### 4a. READ `CLAUDE.md` IMMEDIATELY before editing (atomic-write contract)
|
|
116
119
|
|
|
117
120
|
```bash
|
|
118
|
-
head -
|
|
121
|
+
head -80 CLAUDE.md
|
|
119
122
|
```
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
Any version of `CLAUDE.md` in your context from earlier in the session is STALE. A peer instance
|
|
125
|
+
may have prepended an entry while you were doing wisdom updates. **Always read immediately before
|
|
126
|
+
composing the edit.** Two instances editing within the same minute = last `Write` wins; the loser's
|
|
127
|
+
entry is silently lost. The `Read` here is your idempotency window.
|
|
122
128
|
|
|
123
|
-
|
|
129
|
+
### 4b. Compose ONE entry — strict format
|
|
124
130
|
|
|
125
131
|
```markdown
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Earlier: <previous summary condensed to ≤ 3 lines>.
|
|
132
|
+
### YYYY-MM-DD · <branch> · <version-or-tag>
|
|
133
|
+
<1–4 lines of plain text. Describe the WHY, not just the WHAT. Name agents/skills/files
|
|
134
|
+
in inline code (e.g. `commit-manager`, `scope.ts`). No bullets, no nested headers, no
|
|
135
|
+
horizontal rules. Aim for a self-contained 1-paragraph summary that a peer reading
|
|
136
|
+
CLAUDE.md tomorrow can decode without context.>
|
|
132
137
|
```
|
|
133
138
|
|
|
134
139
|
Rules:
|
|
135
|
-
- **
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
|
|
140
|
+
- **Heading format is mandatory** — compactor counts entries with `grep -c '^### '`. The `· ` (middle
|
|
141
|
+
dot space) separators are part of the contract; do not substitute with `-` or `|`.
|
|
142
|
+
- `<version-or-tag>`: if `commit-manager` just pushed a version bump (`package.json` changed), use that
|
|
143
|
+
version (e.g. `v2.26.0`). Else use a short kebab-case slug describing the change category
|
|
144
|
+
(`docs-only`, `bugfix`, `coordination-fix`, `revert`, `refactor-noop`).
|
|
145
|
+
- **1–4 lines, plain text.** No markdown lists, no nested `####` headers, no horizontal rules. Inline
|
|
146
|
+
code (`` `name` ``) is allowed and encouraged for agent/skill/file names.
|
|
147
|
+
|
|
148
|
+
### 4c. PREPEND directly below the HTML comment anchor
|
|
149
|
+
|
|
150
|
+
The `## Recent Changes` section begins with an invariant HTML comment that never changes:
|
|
151
|
+
|
|
152
|
+
```html
|
|
153
|
+
<!-- APPEND-ONLY LIFO. Each Claude instance PREPENDS a new `### YYYY-MM-DD · branch · vX.Y.Z` heading
|
|
154
|
+
+ 1–4 lines below it. Drop only the OLDEST entry when count > 10. NEVER edit a peer's entry.
|
|
155
|
+
Compactor (`claude-md-compactor.md §5–§6`) enforces the cap, not the prepend. -->
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Use `Edit` / `StrReplace` with anchor = the END of that HTML comment + the BEGINNING of the
|
|
159
|
+
current first entry. Replace with: HTML comment end + blank line + your new entry + blank line +
|
|
160
|
+
current first entry.
|
|
161
|
+
|
|
162
|
+
**Concretely:**
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
old_string:
|
|
166
|
+
Compactor (`claude-md-compactor.md §5–§6`) enforces the cap, not the prepend. -->
|
|
167
|
+
|
|
168
|
+
### <CURRENT-FIRST-ENTRY-HEADING>
|
|
169
|
+
|
|
170
|
+
new_string:
|
|
171
|
+
Compactor (`claude-md-compactor.md §5–§6`) enforces the cap, not the prepend. -->
|
|
172
|
+
|
|
173
|
+
### <YOUR-NEW-HEADING>
|
|
174
|
+
<your 1–4 lines>
|
|
175
|
+
|
|
176
|
+
### <CURRENT-FIRST-ENTRY-HEADING>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The HTML comment is your invariant. Do not edit it.
|
|
180
|
+
|
|
181
|
+
### 4d. Cap at 10 — drop the OLDEST if needed (NEVER reorder middle entries)
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
COUNT=$(awk '/^## Recent Changes/{f=1;next} /^## /{f=0} f && /^### /{n++} END{print n}' CLAUDE.md)
|
|
185
|
+
echo "Recent Changes entries: $COUNT (cap: 10)"
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
If `COUNT > 10`, delete ONLY the bottom-most `### ...` block (from its `### ` heading down to the
|
|
189
|
+
blank line before the next entry or the closing `---` of the section). Never reorder. Never edit a
|
|
190
|
+
peer's entry. Never collapse two entries into one.
|
|
191
|
+
|
|
192
|
+
### 4e. Size guard
|
|
139
193
|
|
|
140
|
-
|
|
194
|
+
```bash
|
|
195
|
+
wc -c CLAUDE.md
|
|
196
|
+
```
|
|
141
197
|
|
|
142
|
-
|
|
198
|
+
If > 20480 bytes (20 KB), surface a `[warning]` line in your final report asking the user to invoke
|
|
199
|
+
`claude-md-compactor` after the session. Do NOT shrink on your own — compaction is a deliberate
|
|
200
|
+
operation with its own rules (§5 budget, §6 forbidden, §6.1 multi-instance safety).
|
|
143
201
|
|
|
144
202
|
---
|
|
145
203
|
|
|
146
204
|
## Step 5 — Report (deterministic, ≤ 8 lines)
|
|
147
205
|
|
|
148
206
|
```
|
|
149
|
-
Domain wisdom appended:
|
|
150
|
-
Problems & Solutions:
|
|
151
|
-
Attention Points:
|
|
152
|
-
Archives triggered:
|
|
153
|
-
CLAUDE.md
|
|
207
|
+
Domain wisdom appended: <n> entries across <domains>
|
|
208
|
+
Problems & Solutions: <n> new, <n> deduplicated
|
|
209
|
+
Attention Points: <n> new, <n> deduplicated
|
|
210
|
+
Archives triggered: <domains> (size guard)
|
|
211
|
+
CLAUDE.md Recent Changes: PREPENDED 1 entry (now <n>/10 entries, <size> bytes)
|
|
212
|
+
Oldest dropped: <heading-or-"none">
|
|
213
|
+
Compactor recommended: <yes-if-over-20KB|no>
|
|
154
214
|
```
|
|
155
215
|
|
|
156
216
|
---
|
|
@@ -158,20 +218,25 @@ CLAUDE.md Last Change: updated (v<version>, <size> bytes)
|
|
|
158
218
|
## Critical rules
|
|
159
219
|
|
|
160
220
|
1. **AFTER documenter** — never run before `documenter` maps the commit. If documenter hasn't run, warn and exit.
|
|
161
|
-
2. **EDIT, NEVER WRITE** —
|
|
162
|
-
3. **
|
|
163
|
-
4. **
|
|
164
|
-
5.
|
|
165
|
-
6. **
|
|
166
|
-
7. **
|
|
167
|
-
8. **
|
|
168
|
-
9.
|
|
169
|
-
10. **
|
|
221
|
+
2. **EDIT, NEVER WRITE on CLAUDE.md** — `Write` overwrites the entire file and is fatal for multi-instance safety. Use `Edit` / `StrReplace` with the HTML comment as anchor (Step 4c). Same rule for domain files.
|
|
222
|
+
3. **READ IMMEDIATELY BEFORE EDIT** — atomic-write contract. Any `CLAUDE.md` content older than your current Read is stale; a peer may have prepended while you worked. Re-read before Step 4c.
|
|
223
|
+
4. **NEVER touch `## Last Change`** — that section no longer exists in this stack's CLAUDE.md template. It was replaced by `## Recent Changes` (LIFO) precisely to fix the multi-instance overwrite bug. If you encounter a legacy `## Last Change` in an older project, leave it alone and PREPEND to `## Recent Changes` if present, OR warn the user that their CLAUDE.md predates the chain and needs migration.
|
|
224
|
+
5. **PREPEND ONLY** — never reorder middle entries, never edit a peer's entry, never collapse two entries into one. Cap-pruning (Step 4d) drops only the OLDEST.
|
|
225
|
+
6. **HEADING FORMAT IS A CONTRACT** — `### YYYY-MM-DD · <branch> · <version-or-tag>` with `· ` middle-dot-space separators. The compactor regex depends on this exact shape.
|
|
226
|
+
7. **DEDUPLICATE wisdom** — grep before appending. Same symptom or root cause = update existing entry, don't add new.
|
|
227
|
+
8. **CAP wisdom entries** — ≤ 5 Problems & Solutions + ≤ 10 Attention Points per live domain file. Overflow → archive.
|
|
228
|
+
9. **≤ 8 KB per domain** — measure after edit; trim if exceeded.
|
|
229
|
+
10. **CLAUDE.md ≤ 20 KB** — measure after edit; surface compactor recommendation if exceeded. Do NOT shrink on your own.
|
|
230
|
+
11. **NO SOURCE CODE** — never paste code into wisdom or Recent Changes entries. Reference `file:line` or `skill §section`.
|
|
231
|
+
12. **NO PII / SECRETS** — never quote env values, tokens, customer data.
|
|
232
|
+
13. **TOKEN-EFFICIENT** — don't read source files. You have session context; only read domain files + CLAUDE.md.
|
|
233
|
+
14. **PLAIN TEXT in Recent Changes** — 1–4 lines, inline `code` allowed for names, no bullets/lists/nested headers.
|
|
170
234
|
|
|
171
235
|
## See Also
|
|
172
236
|
|
|
173
|
-
- `documenter`
|
|
237
|
+
- `documenter` v3.0.0 — structural mapping (files, commits, connections, `_index.json`); runs BEFORE this agent
|
|
174
238
|
- `codebase-knowledge` skill — reads domain files BEFORE implementing
|
|
175
|
-
- `commit-manager`
|
|
176
|
-
- `claude-md-compactor` v2.
|
|
177
|
-
- `
|
|
239
|
+
- `commit-manager` v3.0.0 — commits implementation via per-instance staging; triggers this chain
|
|
240
|
+
- `claude-md-compactor` v2.1.0 — see §5 budget (`Recent Changes` ≤ 2.5 KB) + §6 forbidden + §6.1 multi-instance safety contract (read once before your first Step 4)
|
|
241
|
+
- `scope.ts` (`.claude/hooks/scope.ts`) — per-instance commit scoping; used by `commit-manager` Step 4a
|
|
242
|
+
- `security-auditor` v2.0.0 — vetoes commit if PII/secret leaks into domain files or Recent Changes
|