@adia-ai/adia-ui-forge 0.1.2 → 0.1.3

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.
Files changed (85) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/CHANGELOG.md +8 -0
  3. package/agents/README.md +209 -0
  4. package/agents/a2ui-engineer.md +57 -0
  5. package/agents/author.md +56 -0
  6. package/agents/release-engineer.md +85 -0
  7. package/agents/repo-steward.md +56 -0
  8. package/agents/routing-corpus.json +89 -0
  9. package/agents/spec-architect.md +53 -0
  10. package/agents/tech-lead.md +57 -0
  11. package/agents/verifier.md +55 -0
  12. package/package.json +3 -2
  13. package/skills/adia-ui-authoring/SKILL.md +2 -2
  14. package/skills/adia-ui-authoring/assets/case-studies/theme-panel-promotion.md +1 -1
  15. package/skills/adia-ui-authoring/references/module-promotion.md +2 -2
  16. package/skills/adia-ui-gen-review/skill.json +1 -0
  17. package/skills/adia-ui-ops/CHANGELOG.md +291 -0
  18. package/skills/adia-ui-ops/SKILL.md +401 -0
  19. package/skills/adia-ui-ops/references/INDEX.md +158 -0
  20. package/skills/adia-ui-ops/references/audit-cadence.md +263 -0
  21. package/skills/adia-ui-ops/references/audit-patterns/archive-link-sweep.md +96 -0
  22. package/skills/adia-ui-ops/references/audit-patterns/audit-history-ledger.md +162 -0
  23. package/skills/adia-ui-ops/references/audit-patterns/browser-bundle-node-imports.md +154 -0
  24. package/skills/adia-ui-ops/references/audit-patterns/changelog-unreleased-bloat.md +75 -0
  25. package/skills/adia-ui-ops/references/audit-patterns/coverage-gaps.md +187 -0
  26. package/skills/adia-ui-ops/references/audit-patterns/entry-file-coverage.md +122 -0
  27. package/skills/adia-ui-ops/references/audit-patterns/format-hygiene.md +217 -0
  28. package/skills/adia-ui-ops/references/audit-patterns/lockstep-versioning.md +113 -0
  29. package/skills/adia-ui-ops/references/audit-patterns/memory-fragmentation.md +180 -0
  30. package/skills/adia-ui-ops/references/audit-patterns/orphan-detection.md +202 -0
  31. package/skills/adia-ui-ops/references/audit-patterns/pointer-validation.md +180 -0
  32. package/skills/adia-ui-ops/references/audit-patterns/redundancy-detection.md +210 -0
  33. package/skills/adia-ui-ops/references/audit-patterns/spec-dating-sweep.md +91 -0
  34. package/skills/adia-ui-ops/references/audit-patterns/stale-content.md +182 -0
  35. package/skills/adia-ui-ops/references/audit-patterns/staleness-tooling.md +156 -0
  36. package/skills/adia-ui-ops/references/audit-patterns/token-waste-detection.md +196 -0
  37. package/skills/adia-ui-ops/references/deploy-playbooks.md +259 -0
  38. package/skills/adia-ui-ops/references/doc-types/adr-pattern.md +210 -0
  39. package/skills/adia-ui-ops/references/doc-types/architecture-md.md +190 -0
  40. package/skills/adia-ui-ops/references/doc-types/changelog.md +183 -0
  41. package/skills/adia-ui-ops/references/doc-types/decisions-log.md +146 -0
  42. package/skills/adia-ui-ops/references/doc-types/plan-roadmap.md +182 -0
  43. package/skills/adia-ui-ops/references/doc-types/postmortem-pattern.md +206 -0
  44. package/skills/adia-ui-ops/references/genres/prose-and-writing.md +149 -0
  45. package/skills/adia-ui-ops/references/guidance/context-budget.md +137 -0
  46. package/skills/adia-ui-ops/references/guidance/llm-doc-writing.md +116 -0
  47. package/skills/adia-ui-ops/references/guidance/reliability-dial.md +186 -0
  48. package/skills/adia-ui-ops/references/recipes/adr-introduction.md +211 -0
  49. package/skills/adia-ui-ops/references/recipes/audit-existing-repo.md +234 -0
  50. package/skills/adia-ui-ops/references/recipes/cold-start-harvest.md +263 -0
  51. package/skills/adia-ui-ops/references/recipes/concurrent-learnings-merge.md +158 -0
  52. package/skills/adia-ui-ops/references/recipes/continuous-learning-loop.md +169 -0
  53. package/skills/adia-ui-ops/references/recipes/external-reference-verification.md +158 -0
  54. package/skills/adia-ui-ops/references/recipes/findings-index-readout.md +126 -0
  55. package/skills/adia-ui-ops/references/recipes/greenfield-setup.md +252 -0
  56. package/skills/adia-ui-ops/references/recipes/harvest-repo-brain.md +169 -0
  57. package/skills/adia-ui-ops/references/recipes/import-repo-brain-harvest.md +153 -0
  58. package/skills/adia-ui-ops/references/recipes/memory-organization.md +182 -0
  59. package/skills/adia-ui-ops/references/recipes/recommend-then-validate.md +199 -0
  60. package/skills/adia-ui-ops/references/recipes/self-healing-hooks.md +366 -0
  61. package/skills/adia-ui-ops/references/recipes/skill-stewardship-loop.md +113 -0
  62. package/skills/adia-ui-ops/references/standards/agents-md-spec.md +138 -0
  63. package/skills/adia-ui-ops/references/standards/claude-md-convention.md +123 -0
  64. package/skills/adia-ui-ops/references/standards/cross-tool-matrix.md +85 -0
  65. package/skills/adia-ui-ops/references/standards/readme-conventions.md +232 -0
  66. package/skills/adia-ui-ops/references/teach-protocol.md +215 -0
  67. package/skills/adia-ui-ops/scripts/audit-ops-roster.mjs +104 -0
  68. package/skills/adia-ui-ops/skill.json +65 -0
  69. package/skills/adia-ui-release/CHANGELOG.md +43 -0
  70. package/skills/adia-ui-release/SKILL.md +34 -6
  71. package/skills/adia-ui-release/references/independent-package-release.md +129 -0
  72. package/skills/adia-ui-release/references/recovery-paths.md +49 -2
  73. package/skills/adia-ui-release/scripts/dispatch-publish.mjs +68 -5
  74. package/skills/adia-ui-release/scripts/insert-stub.mjs +5 -3
  75. package/skills/adia-ui-release/scripts/make-ledger.mjs +22 -1
  76. package/skills/adia-ui-release/scripts/package-paths.mjs +44 -0
  77. package/skills/adia-ui-release/scripts/promote-unreleased.mjs +3 -2
  78. package/skills/adia-ui-release/scripts/release-pack.mjs +36 -7
  79. package/skills/adia-ui-release/scripts/tag-lockstep.mjs +10 -2
  80. package/skills/adia-ui-release/skill.json +9 -7
  81. package/skills/dogfood-sweep/CHANGELOG.md +37 -0
  82. package/skills/dogfood-sweep/README.md +105 -0
  83. package/skills/dogfood-sweep/SKILL.md +1000 -0
  84. package/skills/dogfood-sweep/analyze.mjs +600 -0
  85. package/skills/dogfood-sweep/skill.json +31 -0
@@ -0,0 +1,186 @@
1
+ ---
2
+ date: 2026-04-27
3
+ coverage: canonical
4
+ peers:
5
+ - llm-doc-writing.md
6
+ - context-budget.md
7
+ - ../recipes/self-healing-hooks.md
8
+ - ../recipes/recommend-then-validate.md
9
+ primary_sources:
10
+ - Steve Yegge, "Welcome to Gas City" — https://steve-yegge.medium.com/welcome-to-gas-city-57f564bb3607
11
+ - https://code.claude.com/docs/en/best-practices
12
+ status: research-verified
13
+ ---
14
+
15
+ # Reliability dial (configurable strictness)
16
+
17
+ > _"Reliability, friends, is a dial. You choose where to set it. More rounds of review, more backstops, more guardrails… you can get agentic workers to be as reliable as you need."_
18
+ > — Steve Yegge, "Welcome to Gas City"
19
+
20
+ ## What this delivers
21
+
22
+ Yegge's load-bearing insight: trying to set one absolute level of strictness for every repo is wrong. A solo side project and a regulated production codebase need different friction. `ops-repo` exposes a single explicit knob — **strictness** — and routes every trip-wire's threshold through it.
23
+
24
+ Three positions:
25
+
26
+ | Position | Posture | When to use |
27
+ |---|---|---|
28
+ | **`lax`** | Discoverable but never blocks | Side projects, prototypes, exploration phases |
29
+ | **`normal`** | Default. Pre-commit warns/fails on critical | Most production repos |
30
+ | **`strict`** | Every promise's trip-wire must pass; multi-agent review required for any apply-mode fix | Regulated codebases, monorepos with many contributors, repos where doc breakage is costly |
31
+
32
+ Explicit knob beats implicit severity rubric: the team picks its dial position once, in `.brain/config.toml`, and every check derives from there.
33
+
34
+ ## The config file
35
+
36
+ `.brain/config.toml` at repo root:
37
+
38
+ ```toml
39
+ [ops-repo]
40
+ strictness = "normal" # lax | normal | strict
41
+ version = "1.1"
42
+
43
+ # Optional per-trip-wire overrides
44
+ [ops-repo.overrides]
45
+ entry_file_max_lines = 200 # default for "normal"; "strict" = 150
46
+ orphan_grace_days = 30 # default for "normal"; "strict" = 7
47
+ doc_age_threshold_days = 365 # default for "normal"; "strict" = 180
48
+ ```
49
+
50
+ For Node projects, equivalent block in `package.json`:
51
+
52
+ ```json
53
+ {
54
+ "ops-repo": { "strictness": "normal" }
55
+ }
56
+ ```
57
+
58
+ For Python projects, `pyproject.toml`:
59
+
60
+ ```toml
61
+ [tool.ops-repo]
62
+ strictness = "normal"
63
+ ```
64
+
65
+ ## What each position does
66
+
67
+ | Trip-wire | `lax` | `normal` | `strict` |
68
+ |---|---|---|---|
69
+ | **Entry-file length** | Warn >250 lines | Warn >150, fail pre-commit >200 | Fail pre-commit >150 |
70
+ | **AGENTS.md/CLAUDE.md drift** | Warn | Fail pre-commit | Require symlink (`ln -s AGENTS.md CLAUDE.md`) |
71
+ | **Broken intra-repo links** | Report only | Fail PR | Fail pre-commit |
72
+ | **Broken external links** (lychee) | Report weekly | Fail PR | Fail PR + fail pre-commit |
73
+ | **Doc frontmatter dates** | Suggest | Require on new docs | Require on all docs; review every 365d |
74
+ | **Orphan grace period** | 90 days | 30 days | 7 days |
75
+ | **AGENTS.md "Memory primitives" section** | Recommend | Require | Require + fail audit if missing |
76
+ | **`.brain/adrs/` for repos > 1 year old** | Recommend | Recommend (medium severity) | Required (high severity) |
77
+ | **Apply-mode fixes** | Single agent | Single agent | Recommend agent + validate agent (see `../recipes/recommend-then-validate.md`) |
78
+ | **Auto-archive PR** | Manual review | Manual review | Multi-agent review |
79
+
80
+ ## Choosing your position
81
+
82
+ The dial is **not a quality scale**. `lax` isn't bad and `strict` isn't good. They're matched to *cost of failure*.
83
+
84
+ ```
85
+ cost of doc breakage to your team
86
+ low ←───────────────────────────────────────→ high
87
+
88
+ lax normal strict
89
+ │ │ │
90
+ solo prototype most production repos monorepo, regulated,
91
+ high-stakes shared codebase
92
+ ```
93
+
94
+ If `strict` causes more friction than it prevents, you're at the wrong position. Try `normal` first.
95
+
96
+ ## Git sync (where the brain lives)
97
+
98
+ By default, `.brain/` is committed to git — the brain *is* shared across the team. But not every team wants this. Solo developers, research notebooks, individual scratch repos, or teams that sync memory through a non-git mechanism (internal wiki, S3, Notion) may prefer to keep `.brain/` local.
99
+
100
+ Two modes:
101
+
102
+ | Mode | What gets committed | Promise 5 (continuously-learning) | When to use |
103
+ |---|---|---|---|
104
+ | **`shared`** (default) | `.brain/{adrs,postmortems,runbooks,archive,architecture,audit-history,changesets,config.toml}` (`cache/` + `cold-start/working/` always gitignored) | Applies to the team — artifacts compound across contributors | Most repos with >1 contributor |
105
+ | **`local-only`** | Nothing in `.brain/` is committed; entire `.brain/` is gitignored | Applies to **your local clone only** — your individual brain compounds; the team's doesn't | Solo, prototypes, or repos where memory syncs via a non-git system |
106
+
107
+ Configure in `.brain/config.toml`:
108
+
109
+ ```toml
110
+ [ops-repo.git-sync]
111
+ mode = "shared" # shared | local-only
112
+ ```
113
+
114
+ Default is `shared` — when omitted, behavior is identical to v1.5.0.
115
+
116
+ ### What `local-only` changes
117
+
118
+ When `mode = "local-only"`:
119
+
120
+ - `.gitignore` should include `.brain/` at the top (greenfield adds this automatically when configured).
121
+ - Every contributor maintains their own `.brain/`. Your ADRs are not your teammate's ADRs.
122
+ - The **auto-archive PR workflow is disabled** (no PRs because nothing is tracked).
123
+ - The audit-history-ledger remains useful as a *local* diagnostic but is not a SOC2-grade shared trail.
124
+ - The `concurrent-learnings-merge.md` recipe is irrelevant (no shared brain to merge into).
125
+ - The `cold-start-harvest.md` recipe is irrelevant (no shared brain to import into).
126
+ - Promise 5 still applies — but to *you*, not the team.
127
+
128
+ Switching `local-only` → `shared` later: remove `.brain/` from `.gitignore`, set `mode = "shared"`, then `git add .brain/` to stage what you've accumulated. The reverse direction (`shared` → `local-only`) requires deciding what to do with already-committed artifacts (typically: leave them committed for history; new artifacts go local).
129
+
130
+ ### Granular per-subdir sync (advanced)
131
+
132
+ Some teams want finer control — e.g., share ADRs but keep `audit-history/` local-only (less PR noise; the SOC2 trail kept on a separate machine):
133
+
134
+ ```toml
135
+ [ops-repo.git-sync]
136
+ mode = "shared"
137
+
138
+ [ops-repo.git-sync.committed]
139
+ adrs = true
140
+ postmortems = true
141
+ runbooks = true
142
+ archive = true
143
+ architecture = true
144
+ changesets = true
145
+ config = true # config.toml itself
146
+ audit-history = false # opt out of committing audit-history; stays local
147
+ ```
148
+
149
+ Defaults match the `shared` mode table above. The audit warns if a subdir is gitignored when the chosen mode says it should be committed (or vice versa).
150
+
151
+ ### Why this is separate from strictness
152
+
153
+ Strictness controls *how loud* the audit/hooks are. Git-sync controls *where the brain lives*. The two are orthogonal:
154
+
155
+ - A **`local-only` + `strict`** brain is fine — you take your own notes very seriously.
156
+ - A **`shared` + `lax`** brain is fine — the team gathers but doesn't enforce.
157
+ - A **`shared` + `strict`** brain is the regulated-codebase posture (the original v1.1 default).
158
+ - A **`local-only` + `lax`** brain is the personal-scratch posture.
159
+
160
+ ## How the audit honors the dial
161
+
162
+ When the audit runs, it loads `.brain/config.toml` and threshold-routes every check. Findings include the dial position they were evaluated against:
163
+
164
+ ```markdown
165
+ - **DRIFT — CLAUDE.md vs AGENTS.md** (severity: critical, evaluated at strictness=strict)
166
+ - At `lax`: would have been a warning.
167
+ - At `normal`: would have failed pre-commit.
168
+ - At `strict`: requires symlink. Recommended fix: `ln -s AGENTS.md CLAUDE.md`.
169
+ ```
170
+
171
+ This makes the dial *visible*, not just operative — when a finding fires, the team can see whether re-tuning the dial is the right answer or fixing the issue is.
172
+
173
+ ## Anti-patterns
174
+
175
+ - **Setting `strict` and ignoring half the trip-wires.** Inconsistent. Either commit to the position or move to `normal`.
176
+ - **Setting `lax` permanently as a way to silence findings.** That defeats the purpose. Lax is for prototypes; if a real repo lives at `lax` for a year, escalate.
177
+ - **Per-file overrides everywhere.** Override sparingly. The defaults exist because they're empirically reasonable; per-file exceptions become drift over time.
178
+ - **Changing the dial mid-PR to make a check pass.** The dial belongs to the team and the repo, not to a single change.
179
+
180
+ ## Cross-references
181
+
182
+ - The trip-wires themselves: `../recipes/self-healing-hooks.md`
183
+ - Recommend-then-validate (the multi-agent pattern `strict` requires): `../recipes/recommend-then-validate.md`
184
+ - Token-budget defaults (entry-file lengths): `context-budget.md`
185
+ - LLM-doc-writing (content quality): `llm-doc-writing.md`
186
+ - Audit history (where the dial position is recorded per run): `../audit-patterns/audit-history-ledger.md`
@@ -0,0 +1,211 @@
1
+ ---
2
+ date: 2026-04-27
3
+ coverage: canonical
4
+ peers:
5
+ - greenfield-setup.md
6
+ - memory-organization.md
7
+ - audit-existing-repo.md
8
+ - continuous-learning-loop.md
9
+ - ../doc-types/adr-pattern.md
10
+ primary_sources:
11
+ - https://www.cognitect.com/blog/2011/11/15/documenting-architecture-decisions
12
+ - https://adr.github.io/madr/
13
+ - https://github.com/joelparkerhenderson/architecture-decision-record
14
+ - https://github.com/npryce/adr-tools
15
+ status: research-verified
16
+ ---
17
+
18
+ # Recipe: introduce ADRs to an established repo (delivers Promise 5)
19
+
20
+ > **The premise.** A repo without ADRs has scattered architectural memory — decisions live in PR descriptions, Slack archives, code comments, and senior engineers' heads. The "continuously-learning" promise is broken until the repo has a place to land decisions *at decision time*. This recipe creates that place and seeds it just enough that the practice survives.
21
+
22
+ ## What this recipe is *not*
23
+
24
+ - **Not** a backfill-everything-ever campaign. Reconstructing 10 years of decisions almost never finishes.
25
+ - **Not** a bureaucratic gate. Most PRs aren't architectural; most don't need ADRs.
26
+ - **Not** a tooling adoption. `adr-tools` (Pryce) is optional and lightly maintained as of April 2026. `mkdir .brain/adrs/` is enough to start.
27
+
28
+ ## What this recipe *is*
29
+
30
+ A 60-minute setup that (1) creates `.brain/adrs/` with an index and the bootstrap ADR; (2) backfills 3-5 *load-bearing* historical decisions; (3) wires the AGENTS.md `Memory primitives` section; (4) adds the architectural-impact checkbox to the PR template; (5) briefs the team in one paragraph.
31
+
32
+ ## Step 1 — Create the ADR home + index
33
+
34
+ ```bash
35
+ mkdir -p docs/adrs
36
+
37
+ cat > .brain/adrs/README.md <<'EOF'
38
+ # Architecture Decision Records
39
+
40
+ This folder captures architectural decisions. Each ADR is dated, numbered,
41
+ and immutable — decisions don't get edited; they get superseded.
42
+
43
+ Format: MADR 4.0.0 (https://adr.github.io/madr/) for new ADRs.
44
+ Read newest-first. See `../../AGENTS.md` "Memory primitives" for when
45
+ to consult.
46
+
47
+ ## Index
48
+
49
+ | # | Title | Status | Date |
50
+ |---|---|---|---|
51
+ | 0001 | Record architecture decisions | Accepted | 2026-04-27 |
52
+
53
+ _Last reviewed: 2026-04-27_
54
+ EOF
55
+ ```
56
+
57
+ ## Step 2 — Bootstrap ADR 0001
58
+
59
+ Use the Nygard format ([cognitect.com 2011](https://www.cognitect.com/blog/2011/11/15/documenting-architecture-decisions)) for the bootstrap; canonical templates in `../doc-types/adr-pattern.md`. The bootstrap ADR records the decision to *use ADRs* — without it, future contributors don't know whether the practice is required.
60
+
61
+ Save as `.brain/adrs/0001-record-architecture-decisions.md` (full content in `greenfield-setup.md`). Update the README index.
62
+
63
+ ## Step 3 — Backfill 3-5 load-bearing historical ADRs
64
+
65
+ This is where teams either succeed or burn out. **Do not try to backfill every past decision.** Pick the 3-5 commitments that (a) are still live, (b) get questioned by new contributors, (c) would change the agent's behavior if it knew them.
66
+
67
+ ### How to find them — git archaeology in 20 minutes
68
+
69
+ ```bash
70
+ # 1. Framework / library / runtime introductions
71
+ git log --diff-filter=A --name-only --pretty=format:'%h %ad %s' --date=short \
72
+ -- 'package.json' 'Gemfile' 'requirements.txt' 'go.mod' 'Cargo.toml' \
73
+ 'pyproject.toml' '*.csproj' 'pom.xml' 'mix.exs' | head -50
74
+
75
+ # 2. DB-related decisions
76
+ git log --all --oneline --grep -E -i 'postgres|mysql|mongo|redis|sqlite|dynamo' | head -30
77
+
78
+ # 3. Deployment platform decisions
79
+ git log --all --oneline --grep -E -i 'deploy|kubernetes|cloud-run|fly|render|vercel|heroku' | head -30
80
+
81
+ # 4. Auth / security decisions
82
+ git log --all --oneline --grep -E -i 'auth|jwt|session|oauth|saml' | head -20
83
+ ```
84
+
85
+ Triangulate with the team: "What three things do people ask about most often?"
86
+
87
+ ### Typical high-value backfill candidates
88
+
89
+ | ADR # | Decision shape | Why it earns its place |
90
+ |---|---|---|
91
+ | 0002 | Framework choice (e.g., Next.js over Remix) | Agent reaches for wrong framework conventions otherwise |
92
+ | 0003 | Database choice (e.g., Postgres over MySQL) | Affects schema design, query patterns |
93
+ | 0004 | Deployment platform (e.g., Cloud Run, not k8s) | Affects observability, CI, ops |
94
+ | 0005 | Auth provider (e.g., Auth0 over rolling our own) | Affects security model, user model |
95
+ | 0006 | Module boundaries (e.g., monorepo, not split repos) | Affects refactor blast radius |
96
+
97
+ ### Backfill ADR template
98
+
99
+ Backfill ADRs **explicitly mark themselves as backfilled**. The team didn't go through the ADR process at the time — that's fine, just be honest.
100
+
101
+ ```markdown
102
+ # 2. Use Postgres over MySQL
103
+
104
+ Date: 2026-04-27 (decision made: 2024-03-12; backfilled retroactively)
105
+
106
+ ## Status
107
+ Accepted
108
+
109
+ ## Context
110
+ [Reconstructed from git log + PR #142 + memory of who was around. Some
111
+ of the original constraint analysis is unrecoverable; this ADR captures
112
+ the load-bearing context.]
113
+
114
+ In Q1 2024, we needed a relational database for the user-account service.
115
+ Drivers: JSONB for flexible user-profile fields, mature partitioning for
116
+ the multi-tenant rollout, team familiarity (3 of 5 had Postgres experience).
117
+
118
+ ## Decision
119
+ Postgres 15. Hosted on RDS in us-east-1.
120
+
121
+ ## Consequences
122
+ - Locked into Postgres dialect (we use JSONB ops + LATERAL joins).
123
+ - Migrating later requires schema rewrite + data backfill.
124
+ - Connection pool management is a known op concern (see
125
+ `.brain/postmortems/2026-04-12-checkout-outage.md`).
126
+ ```
127
+
128
+ The "(decision made: ... ; backfilled retroactively)" tag is critical — tells the next reader the ADR isn't reconstructing perfect history, just the load-bearing summary.
129
+
130
+ **Stop at 3-5.** A 6th tempting backfill is usually scope creep. Add to the backlog and let it appear when someone next touches the relevant area.
131
+
132
+ ## Step 4 — Wire AGENTS.md Memory primitives
133
+
134
+ If AGENTS.md doesn't have a `Memory primitives` section, add one. If it does, add the ADR pointer:
135
+
136
+ ```markdown
137
+ ## Where to find things
138
+ (...)
139
+ - **Architecture Decision Records:** `.brain/adrs/` (index: `.brain/adrs/README.md`)
140
+
141
+ ## Memory primitives
142
+ - **Before architectural decisions**, read `.brain/adrs/` newest-first.
143
+ If your proposed change conflicts with an `Accepted` ADR, write a new
144
+ ADR superseding it; don't silently override.
145
+ ```
146
+
147
+ Without this section, the ADRs exist but the agent doesn't know to read them — single most-common loop break (see `continuous-learning-loop.md`).
148
+
149
+ ## Step 5 — Update the PR template
150
+
151
+ Add the architectural-impact checkbox to `.github/pull_request_template.md`:
152
+
153
+ ```markdown
154
+ ## Architectural impact
155
+ - [ ] No architectural change (no ADR needed)
156
+ - [ ] Architectural change — ADR added at: `.brain/adrs/NNNN-*.md`
157
+ - [ ] Architectural change — ADR exemption granted by: [name]
158
+ Reason: [why no ADR]
159
+ ```
160
+
161
+ Optionally add the auto-detection CI workflow from `continuous-learning-loop.md` that warns when architectural files change without an accompanying ADR.
162
+
163
+ ## Step 6 — Brief the team
164
+
165
+ One paragraph. Post in #engineering:
166
+
167
+ > We've added `.brain/adrs/` for architectural decisions. New decisions
168
+ > that change framework / DB / deployment / auth / module boundaries
169
+ > get an ADR alongside the PR. The PR template has a checkbox to remind.
170
+ > We've backfilled 5 historical ones (Postgres, Cloud Run, Next.js,
171
+ > Auth0, monorepo). Format is MADR 4.0.0 — see `.brain/adrs/README.md`.
172
+ > AGENTS.md now points to this folder so LLM agents read it before
173
+ > architectural changes.
174
+
175
+ Don't send a 500-word memo — short, factual, links.
176
+
177
+ ## Verification checklist
178
+
179
+ - [ ] `.brain/adrs/` exists with `README.md` index
180
+ - [ ] `0001-record-architecture-decisions.md` is `Accepted`
181
+ - [ ] 3-5 backfill ADRs landed, each marked retroactive in the date line
182
+ - [ ] AGENTS.md `Where to find things` references `.brain/adrs/`
183
+ - [ ] AGENTS.md `Memory primitives` instructs newest-first reading
184
+ - [ ] `.github/pull_request_template.md` has architectural-impact checkbox
185
+ - [ ] Team brief sent
186
+
187
+ ## When to choose Nygard vs MADR vs Y-statements
188
+
189
+ | Format | When to use |
190
+ |---|---|
191
+ | **Nygard** (Title / Date / Status / Context / Decision / Consequences) | Small teams, fast cadence, straightforward decisions |
192
+ | **MADR 4.0.0** (adds Deciders / Considered Options / Decision Drivers) | Larger teams, audit-trail matters, multi-option |
193
+ | **Y-statements** (Zimmermann SATURN 2012) | One-line reversible choices; or summary atop a longer ADR |
194
+
195
+ The audit treats all three as valid; `../doc-types/adr-pattern.md` covers detection.
196
+
197
+ ## Common mistakes
198
+
199
+ - **Backfilling everything.** Past 5 ADRs you're doing archaeology, not setup.
200
+ - **No bootstrap ADR.** Without `0001`, future contributors don't know whether ADRs are mandatory.
201
+ - **Backfill ADRs that pretend they were written contemporaneously.** Reads as historical revisionism.
202
+ - **Adding ADRs but not the AGENTS.md pointer.** Corpus exists; agent doesn't read it.
203
+ - **PR template without the checkbox.** New decisions don't get captured.
204
+
205
+ ## Cross-references
206
+
207
+ - ADR pattern (templates, anti-patterns, audit checks): `../doc-types/adr-pattern.md`
208
+ - Memory organization (where ADRs sit relative to runbooks/postmortems): `memory-organization.md`
209
+ - Greenfield setup (the day-one version): `greenfield-setup.md`
210
+ - Continuous-learning loop (the system this plugs into): `continuous-learning-loop.md`
211
+ - AGENTS.md Memory primitives section: `../standards/agents-md-spec.md`
@@ -0,0 +1,234 @@
1
+ ---
2
+ date: 2026-04-27
3
+ coverage: canonical
4
+ peers:
5
+ - greenfield-setup.md
6
+ - adr-introduction.md
7
+ - memory-organization.md
8
+ primary_sources:
9
+ - SKILL.md (this skill's own audit categories)
10
+ status: needs-research-enhancement
11
+ ---
12
+
13
+ # Recipe: audit an existing repo
14
+
15
+ > **The end-to-end procedure** for running `ops-repo` against a real repo and producing an actionable gap report. Includes the v1.5 `.brain/` layout migration recipe.
16
+
17
+ ## Inputs
18
+
19
+ - A path to a git repo (working tree)
20
+ - Optional: severity threshold (`critical` / `high` / `medium` / `low`) — default `medium`
21
+ - Optional: write-mode flag (`recommend-only` / `apply-fixes`) — default `recommend-only`
22
+
23
+ ## Outputs
24
+
25
+ - `stale-docs-audit.md` (or stdout) with the gap report
26
+ - (If `apply-fixes`) edits to `AGENTS.md`, `CLAUDE.md`, etc., or new files in `.brain/`
27
+
28
+ ## The 7-step procedure
29
+
30
+ ### Step 1 — Discovery
31
+
32
+ Enumerate everything that matters:
33
+
34
+ ```bash
35
+ # Entry-file candidates at root
36
+ ls -la AGENTS.md CLAUDE.md README.md CONTRIBUTING.md SECURITY.md \
37
+ .cursorrules .windsurfrules .aider.conf.yml 2>/dev/null
38
+
39
+ # Cursor newer-style rules folder
40
+ ls -la .cursor/rules/ 2>/dev/null
41
+
42
+ # Continue config
43
+ ls -la .continue/ 2>/dev/null
44
+
45
+ # GitHub Copilot instructions
46
+ ls -la .github/copilot-instructions.md 2>/dev/null
47
+
48
+ # Brain artifacts (v1.5 layout) + legacy docs/ tree
49
+ find .brain docs -type f -name '*.md' 2>/dev/null
50
+ find . -maxdepth 2 \( -name 'CHANGELOG*.md' -o -name 'ARCHITECTURE.md' -o -name 'PLAN.md' -o -name 'ROADMAP.md' \) 2>/dev/null
51
+ ```
52
+
53
+ Build two sets:
54
+ - **EntryFiles**: files found at the root that are entry candidates
55
+ - **DocFiles**: files found anywhere under `.brain/` or `docs/`, plus well-known top-level docs (CHANGELOG.md, ARCHITECTURE.md, PLAN.md, ROADMAP.md)
56
+
57
+ **Git-sync mode detection.** Check `.gitignore`. If `.brain/` (the directory itself, not just `.brain/cache/` or `.brain/cold-start/`) appears in `.gitignore`, the repo is in `local-only` mode (per `../guidance/reliability-dial.md` § Git sync). The audit still runs against the working tree, but Promise 5 findings apply to the local clone only — multi-contributor recipes (`concurrent-learnings-merge.md`, `cold-start-harvest.md`) and the auto-archive PR workflow are moot in this mode and should be skipped.
58
+
59
+ ### Step 2 — Pointer trace
60
+
61
+ For each file in `EntryFiles`, parse it as Markdown and extract every relative-path link or backtick-quoted path. Build a set:
62
+
63
+ - **PointedTo**: union of all paths referenced from any entry file
64
+
65
+ Cross-check against `DocFiles`:
66
+
67
+ - **PointedTo ∩ DocFiles** — files reachable from entry. ✅
68
+ - **PointedTo \ DocFiles** — referenced but missing. ❌ *Broken pointer.*
69
+ - **DocFiles \ PointedTo** — exist but unreachable. 🟡 *Orphan.*
70
+
71
+ ### Step 3 — Canonical determination
72
+
73
+ Decide which entry file is *canonical* (the one that should hold instructions; others should redirect to it).
74
+
75
+ Decision tree:
76
+
77
+ ```
78
+ Is AGENTS.md present and ≥30 lines?
79
+ YES → AGENTS.md is canonical.
80
+ NO → Is exactly one fat (≥30 lines) entry file present?
81
+ YES → Recommend renaming it to AGENTS.md.
82
+ NO → Are multiple fat files present?
83
+ YES → DRIFT. Recommend consolidation.
84
+ NO → No canonical file. CRITICAL gap.
85
+ ```
86
+
87
+ ### Step 4 — Thin-pointer compliance
88
+
89
+ For every entry file that is NOT canonical, verify it's a thin pointer:
90
+
91
+ - Length ≤ 15 lines
92
+ - References the canonical file by name
93
+ - No substantive instructions of its own
94
+
95
+ Findings:
96
+ - **Fat non-canonical** → drift risk → recommend converting to pointer.
97
+ - **Wrong target** → e.g. CLAUDE.md exists, points at `AGENTS.md`, but AGENTS.md doesn't exist → broken redirect.
98
+
99
+ ### Step 5 — Memory-primitive check
100
+
101
+ For each of the standard memory homes, check existence and pointer-from-AGENTS.md:
102
+
103
+ | Home | Required? | If missing |
104
+ |---|---|---|
105
+ | `.brain/adrs/` (or legacy `docs/adrs/`) | Recommended | "No ADR home — recommend introducing them. See `recipes/adr-introduction.md`." |
106
+ | `.brain/decisions/` | Optional | If absent and no ADRs either, both flagged. |
107
+ | `.brain/postmortems/` (or legacy `docs/postmortems/` / `docs/incidents/`) | Optional | Flag only if repo has had production incidents (heuristic: search for `incident`, `outage`, `post-mortem` in commit log). |
108
+ | `CHANGELOG.md` | Strongly recommended | Flag as gap if missing. |
109
+ | `.brain/runbooks/` (or legacy `docs/runbooks/`) | Optional | Flag if production-facing repo. |
110
+
111
+ ### Step 6 — Staleness probe
112
+
113
+ For each file in `DocFiles`:
114
+
115
+ - **Last modified** > 6 months ago AND **no `_Last reviewed:_` line** → flag as needs-review.
116
+ - File contains references to symbols/files that no longer exist in the repo → flag as broken-reference.
117
+ - File contains commands that fail dry-run (e.g., `npm install` but project is pnpm) → flag as command-stale. (Best-effort; may require running commands.)
118
+
119
+ ### Step 7 — Synthesize the gap report
120
+
121
+ Write `stale-docs-audit.md` with sections:
122
+
123
+ ```markdown
124
+ # Stale-docs audit — <repo name>
125
+
126
+ _Generated: 2026-04-27_
127
+
128
+ ## Summary
129
+
130
+ - **Critical**: 1 finding
131
+ - **High**: 3 findings
132
+ - **Medium**: 7 findings
133
+ - **Low**: 4 findings
134
+
135
+ ## Critical
136
+
137
+ ### MISSING — AGENTS.md
138
+ [detail per the entry-file-coverage.md output shape]
139
+
140
+ ## High
141
+
142
+ ### DRIFT — CLAUDE.md vs .cursorrules
143
+ [detail]
144
+
145
+ ### NO ADR HOME
146
+ The repo has architectural decisions scattered across PR descriptions and code
147
+ comments but no `.brain/adrs/`. Recommend introducing ADRs.
148
+
149
+ [continue per severity]
150
+
151
+ ## Recommended fixes (ordered)
152
+
153
+ 1. Rename `CLAUDE.md` → `AGENTS.md`; create thin `CLAUDE.md` redirect.
154
+ 2. Create `.brain/adrs/` with `0001-record-architecture-decisions.md`.
155
+ 3. Add "Where to find things" and "Memory primitives" sections to AGENTS.md.
156
+ 4. Update `.cursorrules` to be a thin pointer.
157
+ 5. Resolve drift between CLAUDE.md and .cursorrules: pnpm vs npm.
158
+
159
+ ## Suggested edits (when in apply-fixes mode)
160
+
161
+ [concrete diffs — not applied without explicit user confirmation]
162
+ ```
163
+
164
+ ## Migration: legacy `docs/` layout → `.brain/`
165
+
166
+ If the audit finds memory artifacts in `docs/{adrs,postmortems,runbooks,archive,architecture}/` (the pre-v1.5 layout), the recommended migration is one git move that preserves history:
167
+
168
+ ```bash
169
+ mkdir -p .brain
170
+
171
+ # Move each memory primitive that exists. Skip silently if absent.
172
+ [ -d docs/adrs ] && git mv docs/adrs .brain/adrs
173
+ [ -d docs/postmortems ] && git mv docs/postmortems .brain/postmortems
174
+ # Or if the repo used the docs/incidents alias:
175
+ [ -d docs/incidents ] && [ ! -d .brain/postmortems ] && git mv docs/incidents .brain/postmortems
176
+ [ -d docs/runbooks ] && git mv docs/runbooks .brain/runbooks
177
+ [ -d docs/archive ] && git mv docs/archive .brain/archive
178
+ [ -d docs/architecture ] && git mv docs/architecture .brain/architecture
179
+ [ -d docs/ops-repo/audit-history ] && git mv docs/ops-repo/audit-history .brain/audit-history
180
+
181
+ # Config + transient state homes
182
+ [ -f .ops-repo.toml ] && git mv .ops-repo.toml .brain/config.toml
183
+ [ -d .ops-repo/changesets ] && git mv .ops-repo/changesets .brain/changesets
184
+
185
+ git commit -m "chore: migrate memory layer to .brain/ (ops-repo v1.5)"
186
+ ```
187
+
188
+ After the move, also update:
189
+
190
+ - **`AGENTS.md`** — every "Where to find things" pointer (`docs/adrs/` → `.brain/adrs/`, etc.)
191
+ - **`.gitignore`** — add `.brain/cache/` and `.brain/cold-start/working/` (transient state)
192
+ - **`.github/workflows/`** — rename `repo-fixer-*.yml` → `repo-brain-*.yml` if hooks were installed pre-v1.3
193
+ - **Workflow path filters / lychee globs** — add `'.brain/**/*.md'` next to `'docs/**/*.md'` (verbatim recipes in `self-healing-hooks.md`)
194
+
195
+ The audit recognizes either layout — **migration is opt-in for v1.5**, not enforced. Repos that prefer the established `docs/{adrs,...}/` convention can stay there; the audit's checks adapt. Greenfield setup defaults to `.brain/`.
196
+
197
+ **What stays at the repo root regardless of layout:**
198
+
199
+ - `AGENTS.md`, `CLAUDE.md`
200
+ - `README.md`, `CONTRIBUTING.md`, `SECURITY.md`, `CODE_OF_CONDUCT.md`
201
+ - `ARCHITECTURE.md` (matklad pattern)
202
+ - `CHANGELOG.md`
203
+ - `PLAN.md`, `ROADMAP.md` (if used)
204
+
205
+ ## Apply-fixes mode safety rules
206
+
207
+ When `apply-fixes` is on:
208
+
209
+ 1. **Never delete a file** without showing the user and asking.
210
+ 2. **Never overwrite a file >50 lines** without showing a diff and asking.
211
+ 3. **Always commit each fix as a separate commit** with a clear message — this is reversible.
212
+ 4. **Never rewrite git history.**
213
+ 5. If asked to delete an orphaned doc, prefer **moving to `.brain/archive/`** with a date suffix over outright deletion.
214
+
215
+ ## Common findings on real repos
216
+
217
+ From running this audit across real-world projects, the most frequent gaps:
218
+
219
+ 1. **No AGENTS.md, fat CLAUDE.md** — repo predates the standard or only used Claude Code.
220
+ 2. **No "Where to find things" section** — naked entry; agent has nothing to navigate.
221
+ 3. **CLAUDE.md and .cursorrules drifted** — duplicate maintenance burden, rarely consistent.
222
+ 4. **No ADR home** — decisions scattered across PRs.
223
+ 5. **Stale build commands** — entry file says `npm` but repo migrated to pnpm/bun.
224
+ 6. **Orphaned `docs/old-plan.md`** — never cleaned up after being superseded.
225
+ 7. **Undated `ARCHITECTURE.md`** — no way to know if it's current.
226
+ 8. **Pre-v1.5 `docs/` layout** — opportunity to migrate to `.brain/` (see § Migration above).
227
+
228
+ ## Cross-references
229
+
230
+ - Entry-file checks: `../audit-patterns/entry-file-coverage.md`
231
+ - Pointer validation: `../audit-patterns/pointer-validation.md`
232
+ - Orphan detection: `../audit-patterns/orphan-detection.md`
233
+ - Greenfield setup: `greenfield-setup.md`
234
+ - Adding ADRs to existing repo: `adr-introduction.md`