start-vibing-stacks 2.12.0 → 2.13.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
@@ -1,63 +1,100 @@
1
1
  # Start Vibing Stacks
2
2
 
3
- Multi-stack AI workflow for Claude Code & Cursor. One command installs agents, skills, hooks, and quality gates tailored to your stack.
3
+ Multi-stack AI workflow for **Claude Code** & **Cursor**. One command installs agents, skills, hooks, and quality gates tailored to your stack.
4
4
 
5
5
  ```bash
6
6
  npx start-vibing-stacks
7
7
  ```
8
8
 
9
- ## What It Installs
9
+ > Latest: **v2.12.0** — `security-auditor` rewritten as stack-aware adversarial auditor with VETO power; `documenter` rewritten with search-optimized memory layer (YAML frontmatter + `_index.json` sidecar); `research-web` MCP-first; CI on Node 22.
10
+
11
+ ---
12
+
13
+ ## What it installs
10
14
 
11
15
  | Layer | Count | Purpose |
12
16
  |---|---|---|
13
- | Agents | 7 universal | research-web, documenter, domain-updater, commit-manager, tester, claude-md-compactor, **security-auditor** (VETO) |
14
- | Skills | 13 shared + 513 stack-specific + 7–9 frontend | Versioned (`version:` frontmatter), upgradable via `migrate` |
15
- | Hooks | `stop-validator`, `final-check`, `user-prompt-submit` | Block completion on git/docs/secrets/code-quality issues |
16
- | Commands | `/feature`, `/fix`, `/research`, `/validate` | Slash commands |
17
+ | Agents | **7** universal | `research-web` (MCP-first) · `documenter` (memory layer) · `domain-updater` · `commit-manager` · `tester` · `claude-md-compactor` (compaction) · **`security-auditor` (VETO)** |
18
+ | Skills | **22** shared + **714** stack-specific + **2–7** frontend | Versioned (`version:` frontmatter), upgradable via `migrate` |
19
+ | Hooks | `stop-validator` · `final-check` · `user-prompt-submit` | Block completion on git/docs/secrets/code-quality issues |
20
+ | Commands | `/feature` · `/fix` · `/research` · `/validate` | Slash commands |
17
21
  | Workflows | `ci.yml` + `security.yml` per stack | Copied to `.github/workflows/` when target is empty |
22
+ | Configs | `active-project.json` · `domain-mapping.json` · `security-rules.json` · `standards-review.json` | Drives every agent's stack detection |
18
23
 
19
- ## Supported Stacks
24
+ ---
25
+
26
+ ## Supported stacks
20
27
 
21
28
  | Stack | Frameworks | Databases | Frontend |
22
29
  |---|---|---|---|
23
- | 🐘 **PHP 8.3+** | Laravel 12 + Octane, Laravel 12 | MariaDB/MySQL, PostgreSQL, SQLite | Inertia + React, Blade, Livewire, API only |
24
- | 📦 **Node.js / TS** | Next.js, Nuxt, Astro, Express, Fastify, Vanilla | MongoDB, Postgres, MariaDB/MySQL, SQLite/Turso, Redis, None | React + Tailwind, Vue, Svelte, API only |
25
- | 🐍 **Python 3.12+** | FastAPI, Django 5, Flask, Local Scripts | MariaDB/MySQL, Postgres, SQLite, MongoDB, None | React, HTMX + Jinja2, API/CLI only |
30
+ | 🐘 **PHP 8.3+** | Laravel 12 + Octane, Laravel 12 | MariaDB/MySQL, PostgreSQL, SQLite | **React + Axios (API-first, default)** · Blade · Livewire · Inertia + React (legacy) |
31
+ | 📦 **Node.js / TS** | Next.js · Nuxt · Astro · Express · Fastify · Vanilla | MongoDB · Postgres · MariaDB/MySQL · SQLite/Turso · Redis · None | React + Tailwind · Vue · Svelte · API only |
32
+ | 🐍 **Python 3.12+** | FastAPI · Django 5 · Flask · Local Scripts | MariaDB/MySQL · Postgres · SQLite · MongoDB · None | React · HTMX + Jinja2 · API/CLI only |
33
+
34
+ ---
26
35
 
27
- ## Universal Skills (shared across stacks)
36
+ ## Skill matrix
28
37
 
29
- | Skill | Topic |
38
+ ### Universal (22 shared across stacks)
39
+
40
+ | Group | Skills |
30
41
  |---|---|
31
- | `security-baseline` | OWASP Top 10 with stack-aware examples |
32
- | `secrets-management` | `.env` hygiene, gitleaks, rotation playbook |
33
- | `observability` | Structured logs, OpenTelemetry, Sentry, PII redaction |
34
- | `error-handling` | Result types, error taxonomy, retry/backoff, circuit breaker |
35
- | `database-migrations` | Parallel change, lock timeouts, chunked backfills |
36
- | `accessibility-wcag22` | WCAG 2.2 AA + axe-core/Playwright |
37
- | `ci-pipelines` | GitHub Actions discipline + ready-to-use templates |
38
- | `quality-gate` · `final-check` · `git-workflow` · `docker-patterns` · `debugging-patterns` · `performance-patterns` · `playwright-automation` · `test-coverage` · `ui-ux-audit` · `codebase-knowledge` · `docs-tracker` · `research-cache` · `hook-development` | Workflow & tooling |
42
+ | **Security** | `security-baseline` · `secrets-management` |
43
+ | **Observability** | `observability` |
44
+ | **Reliability** | `error-handling` · `database-migrations` |
45
+ | **A11y / UX** | `accessibility-wcag22` · `ui-ux-audit` |
46
+ | **CI / Quality** | `ci-pipelines` · `quality-gate` · `final-check` · `git-workflow` |
47
+ | **Infra** | `docker-patterns` · `hook-development` |
48
+ | **Testing** | `playwright-automation` · `test-coverage` |
49
+ | **Performance** | `performance-patterns` |
50
+ | **API design** | `openapi-design` · `postgres-patterns` |
51
+ | **Memory layer** | `codebase-knowledge` · `docs-tracker` · `research-cache` |
52
+ | **Debug** | `debugging-patterns` |
53
+
54
+ ### Stack-specific (added on top of the universal set)
55
+
56
+ | Stack | Count | Skills |
57
+ |---|---|---|
58
+ | **PHP** | 14 | `api-design` · `api-security` (Sanctum SPA, v2.0.0) · `composer-workflow` · `external-api-patterns` · `inertia-react` (legacy) · **`laravel-api-architecture`** · `laravel-inertia-i18n` (legacy) · `laravel-octane` · `laravel-patterns` · `mariadb-octane` · `php-patterns` · `phpstan-analysis` · `phpunit-testing` · `security-scan-php` |
59
+ | **Node.js** | 7 | `api-security-node` · `bun-runtime` · `fastify-api` · `mongoose-patterns` · `nextjs-app-router` · `trpc-api` · `typescript-strict` |
60
+ | **Python** | 9 | `api-security-python` · `async-patterns` · `django-patterns` · `fastapi-patterns` · `pydantic-validation` · `pytest-testing` · `python-patterns` · `python-performance` · `scripting-automation` |
61
+
62
+ ### Frontend (3 options, opt-in)
63
+
64
+ | Folder | Skills | Inherits from |
65
+ |---|---|---|
66
+ | `react` (generic) | `react-patterns` · `react-standards` · `react-ui-patterns` · `shadcn-ui` · `preline-ui` · `tailwind-patterns` · `zod-validation` | — |
67
+ | **`react-api` (default for new PHP/Node API stacks)** | `axios-laravel-api` · `react-api-standards` | `react/` |
68
+ | `react-inertia` (legacy) | `inertia-react` · `react-standards` | `react/` |
39
69
 
40
- Plus stack-specific: `api-security-node`, `api-security-python`, `api-security` (PHP), `typescript-strict`, `nextjs-app-router`, `trpc-api`, `bun-runtime`, `mongoose-patterns`, `pydantic-validation`, `pytest-testing`, `python-patterns`, `python-performance`, `async-patterns`, `fastapi-patterns`, `django-patterns`, `scripting-automation`, `laravel-patterns`, `laravel-octane`, `phpstan-analysis`, `phpunit-testing`, `composer-workflow`, `mariadb-octane`, `external-api-patterns`, `inertia-react`, `laravel-inertia-i18n`, `security-scan-php`, `api-design`, `php-patterns`.
70
+ ---
41
71
 
42
- ## Layout in Your Project
72
+ ## Layout in your project
43
73
 
44
74
  ```
45
75
  your-project/
46
- ├── CLAUDE.md # AI memory: architecture, rules, FORBIDDEN
76
+ ├── CLAUDE.md # AI memory 20 KB target (Anthropic May-2026)
47
77
  ├── .claude/
48
- │ ├── agents/ # 7 universal agents
49
- │ ├── skills/ # versioned skill set (stack + shared + frontend)
50
- │ ├── hooks/ # stop-validator, final-check, prompt-submit
51
- │ ├── commands/ # /feature, /fix, /research, /validate
52
- └── config/ # active-project, security-rules, ...
53
- └── .github/workflows/ # ci.yml + security.yml (if dir was empty)
78
+ │ ├── agents/ # 7 universal agents
79
+ │ ├── skills/
80
+ ├── codebase-knowledge/
81
+ │ │ ├── _INDEX.md # human-readable domain index
82
+ │ │ ├── _index.json # machine-readable, regenerated by documenter
83
+ │ │ │ └── domains/ # one file per domain ( 8 KB each)
84
+ │ │ └── <other skills>/
85
+ │ ├── hooks/ # stop-validator, final-check, prompt-submit
86
+ │ ├── commands/ # /feature, /fix, /research, /validate
87
+ │ └── config/ # active-project, domain-mapping, security-rules, ...
88
+ └── .github/workflows/ # ci.yml + security.yml (if dir was empty)
54
89
  ```
55
90
 
91
+ ---
92
+
56
93
  ## CLI
57
94
 
58
95
  ```bash
59
- npx start-vibing-stacks # setup or resume current project
60
- npx start-vibing-stacks migrate # show outdated/missing skills
96
+ npx start-vibing-stacks # setup or resume current project
97
+ npx start-vibing-stacks migrate # show outdated/missing skills
61
98
  npx start-vibing-stacks migrate --apply # update outdated skills/agents
62
99
 
63
100
  # flags: --force --no-claude --no-mcp --no-install --help --version
@@ -65,63 +102,117 @@ npx start-vibing-stacks migrate --apply # update outdated skills/agents
65
102
 
66
103
  Global install: `npm i -g start-vibing-stacks` → `svs` (alias).
67
104
 
105
+ ---
106
+
68
107
  ## Hooks (block completion)
69
108
 
70
109
  | Hook | Blocks when |
71
110
  |---|---|
72
- | `stop-validator` | not on main, uncommitted changes, CLAUDE.md missing/stale, **secret pattern in diff** (gitleaks or regex) |
73
- | `final-check` | hardcoded secret, `eval`, SQL string concat, `.skip`/`.only`, `any`, `console.log`, `var_dump` |
74
- | `user-prompt-submit` | injects workflow + standards context |
111
+ | `stop-validator` | not on `main` (configurable) · uncommitted changes · `CLAUDE.md` missing/stale · secret pattern in diff (gitleaks if installed, regex fallback) |
112
+ | `final-check` | hardcoded secret · `eval` · SQL string concat · `.skip`/`.only` · `any` (TS) · `console.log` · `var_dump` |
113
+ | `user-prompt-submit` | injects workflow + standards context into every prompt |
114
+
115
+ ---
75
116
 
76
- ## Workflow per Task
117
+ ## Workflow per task
77
118
 
78
119
  ```
79
- 1. BRANCH feature/ | fix/ | refactor/ | test/
80
- 2. RESEARCH research-web agent (new features)
81
- 3. IMPLEMENT stack rules + strict types + security
82
- 4. TEST tester agent (Vitest / pytest / PHPUnit / Playwright)
83
- 5. SECURITY security-auditor agent — VETO on findings
84
- 6. DOCUMENT documenter agent
85
- 7. UPDATE CLAUDE.md "Last Change" section
86
- 8. QUALITY typecheck lint test → build
87
- 9. COMMIT conventional commit, merge to main
120
+ 1. BRANCH feature/ | fix/ | refactor/ | test/
121
+ 2. RESEARCH research-web agent (MCP-first; new features only)
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
88
130
  ```
89
131
 
90
- ## Security Features
132
+ Steps 5–6 cannot be skipped — `security-auditor` and `quality-gate` veto `commit-manager` on findings.
91
133
 
92
- - **Environment isolation**: scanner blocks `NEXT_PUBLIC_*SECRET|*TOKEN|*PRIVATE` patterns; teaches Route Handler / Server Action proxy patterns.
93
- - **OWASP Top 10**: stack-aware skills cover A01–A10 (broken access control, injection, SSRF, etc.).
134
+ ---
135
+
136
+ ## Memory layer (v2.0.0 — search-optimized)
137
+
138
+ `documenter` v2.0.0 maintains `.claude/skills/codebase-knowledge/domains/` so the next session does not re-explore your repo.
139
+
140
+ | Property | Value | Why |
141
+ |---|---|---|
142
+ | File size cap | ≤ 8 KB / ~2k tokens / 200 lines per domain | Cheap local grep; auto-split on overflow |
143
+ | Frontmatter | `domain · tags · owner · last_commit · last_date · files_count · connections · status` | Machine-filterable without parsing markdown |
144
+ | Index | `_index.json` (regenerated each pass) + `_INDEX.md` (human view) | One `jq` query finds any domain |
145
+ | Commit log | Capped at 20 entries; older rolls into `<slug>.archive.md` | Live file stays small, history one click away |
146
+ | Connections | Bidirectional (A→B forces B←A) | No dangling links |
147
+ | Edit policy | `Edit` known anchors; never `Write` over an existing domain | Diff stability for code review |
148
+ | `summary_sha` | sha256 of the TL;DR block | Drift detector for CI hooks |
149
+
150
+ This layer is **separate** from `CLAUDE.md`: that file holds project-wide rules and "Last Change"; the memory layer holds domain knowledge.
151
+
152
+ ---
153
+
154
+ ## Security features
155
+
156
+ - **`security-auditor` v2.0.0** — stack-aware (forks on PHP / Node / Python), CWE-mapped findings, severity matrix (CRITICAL · HIGH · MEDIUM block; LOW warns), VETO power against `commit-manager` and `domain-updater`. Adversarial probes: `npm audit` · `composer audit` · `pip-audit` · `gitleaks` · PHPStan.
157
+ - **OWASP Top 10** — `security-baseline` (universal A01–A10) + `security-scan-php` (Laravel-specific) + `api-security-node` + `api-security-python`.
158
+ - **Environment isolation** — scanner blocks `NEXT_PUBLIC_*SECRET|*TOKEN|*PRIVATE` and `VITE_*SECRET|*TOKEN|*PRIVATE` patterns; teaches Route Handler / Server Action proxy patterns.
94
159
  - **Secret scanning** in `stop-validator` — gitleaks if installed, regex fallback otherwise.
95
- - **`security-auditor` agent** with VETO runs after tester, before commit, blocks insecure code.
96
- - **CI templates**: gitleaks, `npm audit` / `pip-audit` / `composer audit`, CodeQL/Bandit, weekly cron.
160
+ - **CI templates** gitleaks · `npm audit` / `pip-audit` / `composer audit` · CodeQL/Bandit · weekly cron.
97
161
 
98
- ## Standards Review
162
+ ---
99
163
 
100
- CLI scans existing config (cursorrules, composer.json, tsconfig, eslint, phpstan, `.env*`, lockfiles) and asks **"adapt to your standards or use defaults?"** Imported standards are written to `standards-review.json` and injected into every prompt.
164
+ ## Standards review
101
165
 
102
- ## Migrate Existing Projects
166
+ CLI scans existing config (`.cursorrules` · `composer.json` · `tsconfig.json` · `.eslintrc*` · `phpstan.neon` · `.env*` · lockfiles) and asks **"adapt to your standards or use defaults?"** Imported standards are written to `standards-review.json` and injected into every prompt by `user-prompt-submit`.
167
+
168
+ ---
169
+
170
+ ## Migrate existing projects
103
171
 
104
172
  ```bash
105
- npx start-vibing-stacks migrate # report drift
173
+ npx start-vibing-stacks migrate # report drift only
106
174
  npx start-vibing-stacks migrate --apply # apply updates
107
175
  ```
108
176
 
109
- Compares `version:` in your installed `SKILL.md` files against the bundled package. Missing → install. Outdated → upgrade. Ahead (you customized) → kept. Unversioned → flagged for manual review.
177
+ Compares `version:` in your installed `SKILL.md` / agent files against the bundled package:
178
+
179
+ | Result | Action |
180
+ |---|---|
181
+ | Missing | install |
182
+ | Outdated | upgrade (older ones moved to `.archive/`) |
183
+ | Ahead (you customized) | kept as-is |
184
+ | Unversioned | flagged for manual review |
185
+
186
+ ---
110
187
 
111
188
  ## Requirements
112
189
 
113
190
  | Stack | Required |
114
191
  |---|---|
115
- | PHP | PHP ≥ 8.3, Composer ≥ 2.0, Node.js ≥ 18 |
116
- | Node.js | Node.js ≥ 18 (Bun optional) |
117
- | Python | Python ≥ 3.12, pip ≥ 23 |
192
+ | PHP | PHP ≥ 8.3 · Composer ≥ 2.0 · Node.js ≥ 20 |
193
+ | Node.js | Node.js ≥ 20 (Bun optional) |
194
+ | Python | Python ≥ 3.12 · pip ≥ 23 |
118
195
 
119
196
  Missing dependencies are auto-installed via Homebrew on macOS.
120
197
 
198
+ ---
199
+
121
200
  ## Releases
122
201
 
123
202
  GitHub Release → npm publish (workflow `publish.yml`).
124
- Version bump in `package.json` on `main` → auto-creates the GitHub Release (workflow `auto-release.yml`). Add `[skip release]` to the commit to opt out.
203
+ Version bump in `package.json` on `main` → auto-creates the GitHub Release (workflow `auto-release.yml`).
204
+ Both workflows run on **Node 22** (Active LTS until Oct 2026).
205
+ Add `[skip release]` to the commit message to opt out of auto-release.
206
+
207
+ ---
208
+
209
+ ## MCP integrations (optional)
210
+
211
+ `research-web` v2.0.0 is **MCP-first**: it prefers a local `web-scraper` MCP (Brave + Vertex AI + Grok with dedupe + scoring · stealth scraping · sitemap crawler · persistent memory) and falls back gracefully to built-in `WebSearch` / `WebFetch` if the MCP is not registered. Capability detection happens once per session.
212
+
213
+ Run `npx start-vibing-stacks --no-mcp` to skip MCP wiring entirely.
214
+
215
+ ---
125
216
 
126
217
  ## Credits
127
218
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "start-vibing-stacks",
3
- "version": "2.12.0",
3
+ "version": "2.13.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,83 @@
1
+ ---
2
+ name: documenter
3
+ version: 1.0.0
4
+ description: "AUTOMATICALLY invoke AFTER any code implementation. Creates/updates domain documentation. PROACTIVELY runs after implementation."
5
+ model: sonnet
6
+ tools: Read, Write, Edit, Grep, Glob, Bash
7
+ skills: docs-tracker, codebase-knowledge
8
+ ---
9
+
10
+ # Documenter Agent
11
+
12
+ You create and maintain domain documentation so Claude doesn't need to re-explore the codebase every session.
13
+
14
+ ## Step-by-Step
15
+
16
+ ### 1. Read Stack Config
17
+
18
+ ```bash
19
+ cat .claude/config/active-project.json # Know the stack, extensions
20
+ ```
21
+
22
+ ### 2. Detect Changed Files
23
+
24
+ ```bash
25
+ git diff --name-only HEAD
26
+ ```
27
+
28
+ ### 3. Map Files to Domains
29
+
30
+ Read `.claude/config/domain-mapping.json` for patterns.
31
+
32
+ ### 4. For Each Affected Domain
33
+
34
+ **If exists** → Update "Last Update", add files, add commit
35
+ **If not** → CREATE from template
36
+
37
+ ### 5. Domain File Template
38
+
39
+ ```markdown
40
+ # {Domain Name}
41
+
42
+ ## Last Update
43
+ - **Date:** {YYYY-MM-DD}
44
+ - **Commit:** {hash}
45
+ - **Summary:** {what changed}
46
+
47
+ ## Files
48
+
49
+ | File | Purpose |
50
+ |------|---------|
51
+ | `path/file.ext` | Description |
52
+
53
+ ## Connections
54
+
55
+ | Domain | How They Connect |
56
+ |--------|-----------------|
57
+ | {domain} | {description} |
58
+
59
+ ## Recent Commits
60
+
61
+ | Hash | Date | Description |
62
+ |------|------|-------------|
63
+ | abc123 | YYYY-MM-DD | feat: description |
64
+
65
+ ## Attention Points
66
+
67
+ - {Important consideration or gotcha}
68
+
69
+ ## Problems & Solutions
70
+
71
+ ### {Problem Title}
72
+ **Problem:** {What went wrong}
73
+ **Solution:** {How it was fixed}
74
+ **Prevention:** {How to avoid in future}
75
+ ```
76
+
77
+ ## Critical Rules
78
+
79
+ 1. **RUN AFTER EVERY IMPLEMENTATION**
80
+ 2. **UPDATE DOMAINS, NOT JUST CLAUDE.MD**
81
+ 3. **INCLUDE COMMIT HASH**
82
+ 4. **DOCUMENT CONNECTIONS** bidirectionally
83
+ 5. **RECORD PROBLEMS** for future sessions
@@ -1,83 +1,227 @@
1
1
  ---
2
2
  name: documenter
3
- version: 1.0.0
4
- description: "AUTOMATICALLY invoke AFTER any code implementation. Creates/updates domain documentation. PROACTIVELY runs after implementation."
3
+ version: 2.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). Anthropic Skills May-2026 best practices."
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 (v2.0.0 — search-optimized memory layer)
11
11
 
12
- You create and maintain domain documentation so Claude doesn't need to re-explore the codebase every session.
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
 
14
- ## Step-by-Step
14
+ ## Why a memory layer
15
15
 
16
- ### 1. Read Stack Config
16
+ Anthropic May-2026 Skills guidance: every token spent re-discovering codebase context is a token NOT spent on the task. Domain files act as **persistent skill data** — `codebase-knowledge` loads them on demand, much cheaper than re-reading source. Optimizing this layer for **local grep/glob** (not embeddings) keeps it free, deterministic, and offline.
17
+
18
+ ## When to run
19
+
20
+ - **AFTER `commit-manager` succeeds** — the hash must be real, never `pending`.
21
+ - **One pass per commit** — multiple commits = multiple passes.
22
+ - **Skip when** only docs/CI files changed: `--filter '**/*.md' '**/.github/**' 'CHANGELOG*'`.
23
+ - **Block** if `_index.json` is corrupt (rebuild before continuing).
24
+
25
+ ## Storage layout
26
+
27
+ ```
28
+ .claude/skills/codebase-knowledge/
29
+ ├── _INDEX.md # human-readable: alphabetical domains + tags + last update
30
+ ├── _index.json # machine-readable index (one record per domain). SOURCE OF TRUTH for fast filter
31
+ └── domains/
32
+ ├── <slug>.md # one domain per file. ≤ 8 KB / ~2k tokens / 200 lines. Split when bigger.
33
+ └── <slug>.archive.md # commits older than 20 roll into here (append-only, never read by default)
34
+ ```
35
+
36
+ The agent **regenerates** `_index.json` and `_INDEX.md` from frontmatter every pass — these two files are derived; never hand-edit them.
37
+
38
+ ---
39
+
40
+ ## Step-by-step
41
+
42
+ ### 1. Resolve stack + commit metadata
17
43
 
18
44
  ```bash
19
- cat .claude/config/active-project.json # Know the stack, extensions
45
+ STACK=$(jq -r '.stack' .claude/config/active-project.json 2>/dev/null || echo unknown)
46
+ SHA=$(git rev-parse HEAD)
47
+ SHORT=$(git rev-parse --short HEAD)
48
+ DATE=$(git show -s --format=%cs HEAD)
49
+ SUBJECT=$(git show -s --format=%s HEAD)
50
+ echo "Stack=$STACK Commit=$SHORT ($DATE) Subject=$SUBJECT"
20
51
  ```
21
52
 
22
- ### 2. Detect Changed Files
53
+ ### 2. Files in this commit, mapped to domains
23
54
 
24
55
  ```bash
25
- git diff --name-only HEAD
56
+ git diff-tree --no-commit-id --name-status -r HEAD
26
57
  ```
27
58
 
28
- ### 3. Map Files to Domains
59
+ 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/`.
29
60
 
30
- Read `.claude/config/domain-mapping.json` for patterns.
61
+ ### 3. For each affected domain
31
62
 
32
- ### 4. For Each Affected Domain
63
+ | Case | Action |
64
+ |---|---|
65
+ | Domain file exists + < 8 KB | `Edit` only the changed anchors (frontmatter, `## Files`, `## Recent Commits`) |
66
+ | Domain file exists + ≥ 8 KB | **Split**: move oldest 5 commit-log rows into `<slug>.archive.md`, then `Edit` |
67
+ | Domain file missing | `Write` from the template in §"Domain template" |
68
+ | Connection added (A→B) | **Bidirectional**: also add `B←A` in the other domain (rollback both if either fails) |
33
69
 
34
- **If exists** Update "Last Update", add files, add commit
35
- **If not** → CREATE from template
70
+ ### 4. Append commit row, capped at 20
36
71
 
37
- ### 5. Domain File Template
72
+ Count rows in the `## Recent Commits` table. If `count ≥ 20`, move the oldest 5 rows to `<slug>.archive.md` (creating it if absent) **before** prepending the new row. Keep the most recent 20 in the live file — older history stays one click away in the archive.
73
+
74
+ ### 5. Regenerate `_index.json`
75
+
76
+ ```bash
77
+ # pseudo: iterate every domain file, parse frontmatter, emit one record
78
+ for f in .claude/skills/codebase-knowledge/domains/*.md; do
79
+ # extract: domain, tags, owner, last_commit, last_date, files_count, connections, status
80
+ # compute summary_sha = sha256(TL;DR block) — drift detector
81
+ # write JSON record
82
+ done | jq -s '{schema_version:1, generated_at:(now|todate), domain_count:length, domains:.}' \
83
+ > .claude/skills/codebase-knowledge/_index.json
84
+ ```
85
+
86
+ ### 6. Regenerate `_INDEX.md` from `_index.json`
87
+
88
+ A single markdown table sorted alphabetically: `slug | tags | last_commit | last_date | connections`. This file is for humans; agents should read `_index.json` directly because it is faster to parse.
89
+
90
+ ### 7. Report (6 lines, deterministic)
91
+
92
+ ```
93
+ Domains affected: <n>
94
+ Created: [list]
95
+ Updated: [list]
96
+ Splits triggered: [list]
97
+ New connections: A↔B, ...
98
+ Index regenerated: yes
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Domain file template (atomic, search-optimized)
38
104
 
39
105
  ```markdown
40
- # {Domain Name}
106
+ ---
107
+ domain: <slug> # MUST equal filename without .md
108
+ tags: [auth, security, sanctum] # 1-5 short tokens, lowercase, kebab-case
109
+ owner: backend # team name or "shared"
110
+ last_commit: <short-sha>
111
+ last_date: YYYY-MM-DD
112
+ files_count: <int>
113
+ connections: [api, users] # other domain slugs
114
+ status: active # active | dormant | archived
115
+ ---
41
116
 
42
- ## Last Update
43
- - **Date:** {YYYY-MM-DD}
44
- - **Commit:** {hash}
45
- - **Summary:** {what changed}
117
+ # <Title> domain
118
+
119
+ > **TL;DR** (≤ 3 lines). What lives here, where the boundary is, who calls it.
120
+ > Example: "User session lifecycle. Owns Sanctum cookie, login endpoint, password
121
+ > reset. Called by every protected route. Does NOT own user profile data
122
+ > (see `users` domain)."
46
123
 
47
124
  ## Files
48
125
 
49
- | File | Purpose |
50
- |------|---------|
51
- | `path/file.ext` | Description |
126
+ | Path | Role |
127
+ |---|---|
128
+ | `app/Http/Controllers/Auth/LoginController.php` | POST /login |
129
+ | `app/Models/Session.php` | session row |
52
130
 
53
131
  ## Connections
54
132
 
55
- | Domain | How They Connect |
56
- |--------|-----------------|
57
- | {domain} | {description} |
133
+ | Direction | Domain | What flows |
134
+ |---|---|---|
135
+ | | api | every protected handler reads `auth()` |
136
+ | ← | users | LoginController hydrates `User` from `users` repo |
58
137
 
59
- ## Recent Commits
138
+ ## Recent Commits (capped at 20 — oldest auto-archived)
60
139
 
61
- | Hash | Date | Description |
62
- |------|------|-------------|
63
- | abc123 | YYYY-MM-DD | feat: description |
140
+ | Hash | Date | Subject |
141
+ |---|---|---|
142
+ | `50f8c64` | 2026-05-13 | feat(security-auditor): v2.0.0 stack-aware |
64
143
 
65
144
  ## Attention Points
66
145
 
67
- - {Important consideration or gotcha}
146
+ - Octane: keep no per-request state in static fields (see `security-scan-php` "Octane Security").
147
+
148
+ ## Problems & Solutions (append-only)
149
+
150
+ ### [resolved 2026-05-12] cookie domain mismatch in dev
151
+
152
+ - **Symptom:** 419 on POST after fresh login.
153
+ - **Cause:** `SESSION_DOMAIN` was set to `.example.com` in `.env.example`.
154
+ - **Fix:** leave blank in dev; auto-derived from request host.
155
+ - **Prevented by:** `api-security §1.A` checklist item.
156
+
157
+ ## See Also
68
158
 
69
- ## Problems & Solutions
159
+ - Skill: `api-security §1.A`
160
+ - Domain: `api`
161
+ ```
162
+
163
+ ---
70
164
 
71
- ### {Problem Title}
72
- **Problem:** {What went wrong}
73
- **Solution:** {How it was fixed}
74
- **Prevention:** {How to avoid in future}
165
+ ## `_index.json` schema (machine-readable, source of truth)
166
+
167
+ ```json
168
+ {
169
+ "schema_version": 1,
170
+ "generated_at": "2026-05-13T22:30:00Z",
171
+ "domain_count": 12,
172
+ "domains": [
173
+ {
174
+ "slug": "auth",
175
+ "path": "domains/auth.md",
176
+ "tags": ["auth", "security", "sanctum"],
177
+ "owner": "backend",
178
+ "files_count": 14,
179
+ "last_commit": "50f8c64",
180
+ "last_date": "2026-05-13",
181
+ "connections": ["api", "users"],
182
+ "status": "active",
183
+ "summary_sha": "<sha256 of TL;DR block, used as drift detector>"
184
+ }
185
+ ]
186
+ }
75
187
  ```
76
188
 
77
- ## Critical Rules
189
+ A `pre-commit` hook can grep `_index.json` for `last_commit` ≠ HEAD to detect "documenter forgot to run" without parsing markdown.
190
+
191
+ ---
192
+
193
+ ## Edit, do NOT rewrite
194
+
195
+ | Anchor | When |
196
+ |---|---|
197
+ | frontmatter | always update `last_commit`, `last_date`, `files_count`; add `tags` if applicable |
198
+ | `## Files` table | add row for new files; mark deleted with `~~strike~~`, prune at the next commit |
199
+ | `## Recent Commits` | prepend new row; cap at 20 |
200
+ | `## Connections` | add only NEW edges; **bidirectional** (both files updated atomically) |
201
+ | `## Problems & Solutions` | append only; never delete; mark `[resolved YYYY-MM-DD]` |
202
+ | `## TL;DR` | edit only when the boundary actually changed |
203
+
204
+ Use `Edit` / `StrReplace`, never `Write`, on existing domain files.
205
+
206
+ ---
78
207
 
79
- 1. **RUN AFTER EVERY IMPLEMENTATION**
80
- 2. **UPDATE DOMAINS, NOT JUST CLAUDE.MD**
81
- 3. **INCLUDE COMMIT HASH**
82
- 4. **DOCUMENT CONNECTIONS** bidirectionally
83
- 5. **RECORD PROBLEMS** for future sessions
208
+ ## Critical rules
209
+
210
+ 1. **AFTER `commit-manager`** — the hash must be real, not `pending` or `HEAD~1`.
211
+ 2. **ATOMIC files** — split when a domain hits 8 KB / ~2k tokens / 200 lines.
212
+ 3. **APPEND, DON'T REWRITE** `Edit` known anchors; never overwrite an existing domain.
213
+ 4. **BIDIRECTIONAL connections** — both sides updated, or neither (rollback on partial failure).
214
+ 5. **CAP commit log at 20** — older rows roll into `<slug>.archive.md`.
215
+ 6. **REGENERATE `_index.json` + `_INDEX.md` every pass** — derived files, never hand-edited.
216
+ 7. **TL;DR ≤ 3 lines** — front-loads what the next session needs to know.
217
+ 8. **NO PII / SECRETS** — never quote env values, tokens, customer data inside domains.
218
+ 9. **NO source-code dumps** — link to file path + role; the model can `Read` the file when it needs the bytes.
219
+ 10. **MEASURE BEFORE WRITING** — if total domain folder exceeds 200 KB, surface a "memory budget" warning so the user knows local grep is approaching slowness.
220
+
221
+ ## See Also
222
+
223
+ - `docs-tracker` skill — file → doc mapping rules + changelog templates
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
226
+ - `claude-md-compactor` v2.0.0 — keeps top-level `CLAUDE.md` ≤ 20 KB; this layer keeps each domain ≤ 8 KB
227
+ - `security-auditor` v2.0.0 — vetoes commit if PII/secret leaks into a domain file