@lifeaitools/rdc-skills 0.14.0 → 0.16.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rdc",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "RDC typed-agent dispatch skill suite for Claude Code — plan, build, review, overnight unattended builds with work-item tracking and TDD enforcement.",
5
5
  "author": {
6
6
  "name": "LIFEAI",
@@ -954,6 +954,49 @@
954
954
  "enabled_default": true,
955
955
  "codeflow_required": false
956
956
  },
957
+ "housekeeping": {
958
+ "name": "housekeeping",
959
+ "slash": "rdc:housekeeping",
960
+ "category": "reporting",
961
+ "usage": "rdc:housekeeping [--fix]",
962
+ "args": {
963
+ "positional": [],
964
+ "flags": [
965
+ {
966
+ "name": "--fix",
967
+ "type": "boolean",
968
+ "default": false,
969
+ "description": "Auto-remediate safe issues (scaffold CLAUDE.md, fix PUBLISH.md URLs, create missing dirs)"
970
+ }
971
+ ]
972
+ },
973
+ "requires": [
974
+ "supabase",
975
+ "clauth",
976
+ "coolify",
977
+ "git"
978
+ ],
979
+ "produces": [
980
+ ".rdc/reports/"
981
+ ],
982
+ "default_model": "sonnet",
983
+ "triggers": [
984
+ "weekly maintenance",
985
+ "housekeeping",
986
+ "directory structure audit",
987
+ "verify all apps",
988
+ "check repo health",
989
+ "maintenance audit"
990
+ ],
991
+ "follows": [],
992
+ "leads_to": [
993
+ "review"
994
+ ],
995
+ "sandbox_aware": true,
996
+ "output_contract": "guides/output-contract.md",
997
+ "enabled_default": true,
998
+ "codeflow_required": false
999
+ },
957
1000
  "status": {
958
1001
  "name": "status",
959
1002
  "slash": "rdc:status",
@@ -0,0 +1,153 @@
1
+ ---
2
+ mdk_schema_version: "1.0"
3
+ doc_type: guide
4
+ system: claude-workflow
5
+ status: active
6
+ owner: infrastructure
7
+ created: 2026-06-08
8
+ last_reviewed: 2026-06-08
9
+ source_of_truth: true
10
+ supersedes: []
11
+ depends_on:
12
+ - ".claude/rules/architectural-change-approval.md"
13
+ - ".rdc/guides/output-contract.md"
14
+ tags: [rdc, lessons-learned, skills, housekeeping, adaptive]
15
+ ---
16
+
17
+ # Lessons-Learned Capture & Triage — Spec
18
+
19
+ > Auto-referenced by long-running `rdc:*` skills at exit, and by `rdc:housekeeping` for triage.
20
+ > Goal: make the fleet an **interactive adaptive modeler** — every run that teaches us
21
+ > something writes it down, and the weekly housekeeping pass turns those lessons into
22
+ > actual fixes (rules, skill docs, work_items).
23
+
24
+ ---
25
+
26
+ ## Why this exists
27
+
28
+ Lessons learned during a run (a non-obvious infra trap, a wrong assumption, a missing
29
+ gate, a tooling gotcha) used to survive only if someone hand-wrote a memory. This system
30
+ makes capture a **routine exit step** of every long skill, and triage a **routine phase**
31
+ of the weekly housekeeping. Capture is cheap and append-only; triage is where fixes happen.
32
+
33
+ Precedent: brochurify's `rdc-extract-verifier-rules` already does read-log → cluster →
34
+ propose-rule for one domain. This generalizes that pattern fleet-wide.
35
+
36
+ ---
37
+
38
+ ## Storage — directory of per-lesson files
39
+
40
+ Lessons live in **`.rdc/lessons/`**, one markdown file per lesson:
41
+
42
+ ```
43
+ .rdc/lessons/<YYYY-MM-DD>-<skill>-<short-slug>.md
44
+ ```
45
+
46
+ - One file per lesson (NOT a single appended file) so parallel agents finishing at the
47
+ same time never collide on one file in git.
48
+ - `<skill>` is the capturing skill (`build`, `deploy`, `overnight`, `fixit`, `plan`,
49
+ `preplan`, `review`, `release`, `collab`).
50
+ - `<short-slug>` is 2–4 kebab words naming the lesson.
51
+
52
+ A run that taught nothing writes nothing — **absence is the default**. Only write a lesson
53
+ when something was genuinely learned (see § When to capture).
54
+
55
+ ---
56
+
57
+ ## Lesson file schema
58
+
59
+ ```markdown
60
+ ---
61
+ id: <YYYY-MM-DD>-<skill>-<short-slug>
62
+ date: "<YYYY-MM-DD>"
63
+ skill: build | deploy | overnight | fixit | plan | preplan | review | release | collab
64
+ session: <session-id or short ref>
65
+ scope: simple | architectural # triage routing — see § Scope gate
66
+ status: open | triaged | applied | wont-fix
67
+ area: infra | skill | guide | rule | schema | ui | content | other
68
+ links:
69
+ commits: [] # SHAs that relate to the lesson
70
+ memory: [] # memory file slugs, if a memory was also written
71
+ work_items: [] # work_item UUIDs spawned during triage
72
+ ---
73
+
74
+ ## What happened
75
+ <one paragraph — the concrete situation, with evidence (exit code, file:line, command)>
76
+
77
+ ## Root cause
78
+ <one paragraph — the evidenced cause, not a guess>
79
+
80
+ ## The fix / rule
81
+ <what should change so this never recurs: a rule edit, skill-doc line, code change,
82
+ or a check. If already applied in the same run, say so and link the commit.>
83
+ ```
84
+
85
+ `scope` is the single most important field — it routes triage:
86
+
87
+ - **`simple`** — a doc line, a one-file fix, a config tweak, a clarifying sentence in a
88
+ skill, a missing grep guard. Housekeeping applies these directly.
89
+ - **`architectural`** — anything matching `.claude/rules/architectural-change-approval.md`
90
+ (rule/CLAUDE.md/ARCHITECTURE.md edits, cross-cutting refactors, schema reshape, public
91
+ API/MCP changes, skill-contract changes affecting multiple skills). Housekeeping does
92
+ NOT apply these; it surfaces them via `AskUserQuestion` for explicit approval first.
93
+
94
+ When unsure, mark `architectural`.
95
+
96
+ ---
97
+
98
+ ## When to capture (at skill exit)
99
+
100
+ Write a lesson when ANY of these were true during the run:
101
+
102
+ 1. A root cause turned out to be different from the first theory (a wrong assumption).
103
+ 2. The standard/documented path didn't work and you had to do something non-obvious.
104
+ 3. A gate, check, or doc was missing and its absence cost a round.
105
+ 4. A tool/infra behaved in a surprising way (exit codes, caching, serve/PM2/webhook quirks).
106
+ 5. A hook blocked you and the block revealed a real gap (not just your mistake).
107
+
108
+ Do NOT capture: routine success, your own one-off typo, anything already fully documented
109
+ in a rule/guide. If a durable user preference or correction was involved, also write a
110
+ `memory` (this spec and memory are complementary — link them).
111
+
112
+ ---
113
+
114
+ ## Capture procedure (the exit step long skills call)
115
+
116
+ At the end of a long skill run, before the final verdict line:
117
+
118
+ 1. Decide if anything qualifies (§ When to capture). If not, write nothing and move on.
119
+ 2. For each lesson, write `.rdc/lessons/<date>-<skill>-<slug>.md` using the schema above.
120
+ Set `status: open` (or `applied` if you already shipped the fix in this same run, with
121
+ the commit linked).
122
+ 3. Set `scope` honestly (`simple` vs `architectural`).
123
+ 4. Commit the lesson file(s) on `develop` alongside the run's other commits.
124
+ 5. Mention in the verdict/summary that N lessons were captured.
125
+
126
+ ---
127
+
128
+ ## Triage procedure (rdc:housekeeping, weekly)
129
+
130
+ `rdc:housekeeping` adds a **Lessons triage** phase:
131
+
132
+ 1. Read all `.rdc/lessons/*.md` with `status: open`.
133
+ 2. Cluster by `area` + root-cause similarity (dedupe repeats into one fix).
134
+ 3. For each cluster:
135
+ - `scope: simple` → apply the fix directly (rule line, skill-doc edit, config, guard),
136
+ commit it, set the lesson(s) `status: applied` and link the commit.
137
+ - `scope: architectural` → do NOT edit. Present the issue + options via
138
+ `AskUserQuestion` (per `architectural-change-approval.md`). On approval, apply via the
139
+ correct lifecycle (rdc-skills tag/push for skills; cited commit for rules) and set
140
+ `status: applied`. If deferred, set `status: triaged` and spawn a `work_item`.
141
+ - Not worth fixing → `status: wont-fix` with a one-line reason.
142
+ 4. Summarize in the housekeeping report: captured / applied / escalated / deferred counts.
143
+
144
+ Lessons are never silently deleted — `applied` and `wont-fix` files stay as the audit trail.
145
+
146
+ ---
147
+
148
+ ## Skills that capture (the long-running set)
149
+
150
+ `build` · `deploy` · `overnight` · `fixit` · `plan` · `preplan` · `review` · `release` · `collab`
151
+
152
+ Each references this spec from a final "§ Capture lessons" step. A Stop-hook backstop warns
153
+ when one of these skills ends a run with findings but no new `.rdc/lessons/` file.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifeaitools/rdc-skills",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "RDC typed-agent dispatch skill suite for Claude Code - plan, build, review, overnight builds",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -0,0 +1,70 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"/>
5
+ <title>{{TITLE}}</title>
6
+ <link rel="preconnect" href="https://fonts.googleapis.com"/>
7
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
8
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300..900;1,8..60,300..900&family=Hanken+Grotesk:ital,wght@0,300..900;1,300..900&display=swap"/>
9
+ <style>
10
+ /* TOKENS_INJECT */
11
+ @page { size: letter; margin: 0.6in 0.7in; }
12
+ :root {
13
+ --loam-800:#2b2218; --loam-700:#3d2f1f; --loam-600:#5c4628;
14
+ --loam-300:#bda079; --loam-200:#d9c4a4; --loam-100:#ece0c8;
15
+ --moss-700:#4f5a37; --ochre-700:#97772c; --ochre-100:#f4e9d4;
16
+ --linen-50:#faf8f5; --linen-100:#f4edde;
17
+ --char-700:#2b2e26; --char-500:#4d5145; --char-400:#6d7164;
18
+ --ff-display:'Source Serif 4', Georgia, serif;
19
+ --ff-sans:'Hanken Grotesk', system-ui, sans-serif;
20
+ }
21
+ * { box-sizing: border-box; }
22
+ html, body { background: white; }
23
+ body {
24
+ margin: 0; font-family: var(--ff-sans); font-size: 10.5pt; line-height: 1.55;
25
+ color: var(--char-700);
26
+ -webkit-print-color-adjust: exact; print-color-adjust: exact;
27
+ }
28
+ h1, h2, h3, h4 { font-family: var(--ff-display); color: var(--loam-800); font-weight: 600; letter-spacing: -0.005em; }
29
+ h1 { font-size: 28pt; line-height: 1.15; margin: 0 0 0.4em; }
30
+ h2 { font-size: 18pt; line-height: 1.2; margin: 1.8em 0 0.4em; padding-bottom: 0.25em; border-bottom: 1px solid var(--loam-200); }
31
+ h3 { font-size: 13pt; margin: 1.4em 0 0.3em; color: var(--loam-700); }
32
+ p { margin: 0 0 0.7em; }
33
+ ul, ol { margin: 0 0 0.8em 1.1em; padding: 0; }
34
+ li { margin: 0.15em 0; }
35
+ code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 9pt; background: var(--linen-100); padding: 0.05em 0.3em; border-radius: 2px; }
36
+ pre { background: var(--linen-100); padding: 0.7em 0.9em; border-radius: 4px; overflow-wrap: anywhere; font-size: 8.5pt; }
37
+ img { max-width: 100%; height: auto; display: block; margin: 0.8em auto; }
38
+ strong { color: var(--loam-800); }
39
+ em { color: var(--char-500); }
40
+
41
+ .cover { page-break-after: always; min-height: 9in; display: flex; flex-direction: column; justify-content: space-between; padding: 0.3in 0; }
42
+ .cover-eyebrow { font-family: var(--ff-sans); font-size: 9pt; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ochre-700); }
43
+ .cover-title { font-family: var(--ff-display); font-size: 44pt; line-height: 1.05; color: var(--loam-800); margin: 0.2em 0 0.4em; }
44
+ .cover-sub { font-family: var(--ff-display); font-style: italic; font-size: 14pt; color: var(--loam-600); max-width: 5.5in; }
45
+ .cover-foot { font-size: 8.5pt; color: var(--char-400); border-top: 1px solid var(--loam-200); padding-top: 0.4em; display: flex; justify-content: space-between; }
46
+
47
+ .brochure-section { page-break-before: always; }
48
+ .brochure-section:first-of-type { page-break-before: auto; }
49
+
50
+ @media screen {
51
+ body { max-width: 7.1in; margin: 0.6in auto; padding: 0 0.7in; }
52
+ }
53
+ </style>
54
+ </head>
55
+ <body>
56
+ <header class="cover">
57
+ <div>
58
+ <div class="cover-eyebrow">Brochure</div>
59
+ <h1 class="cover-title">{{TITLE}}</h1>
60
+ <div class="cover-sub">Composed by rdc:brochure</div>
61
+ </div>
62
+ <div class="cover-foot">
63
+ <span>RDC</span>
64
+ <span>{{TITLE}}</span>
65
+ </div>
66
+ </header>
67
+
68
+ {{SECTIONS}}
69
+ </body>
70
+ </html>
@@ -401,3 +401,7 @@ NEVER run pnpm build or pnpm turbo. Use npx vitest run only.
401
401
  - Unattended: max 2 retries per task before escalating to advisor
402
402
  - Every Agent() dispatch: `model: <routed>` + `max_turns: 70` + `isolation: "worktree"` — non-negotiable. Model is chosen per task per the routing table in Step 7: Sonnet 4.6 for updates/edits, Opus 4.6 for harder coding, Opus 4.8 for design/innovative thought (CS 2.0, brand/UX, architecture). Supervisor logs `model=<chosen> reason=<phrase>` per agent. Exception: validator agent in Step 10 omits isolation; validator model stays `claude-sonnet-4-6` (verification, not generation).
403
403
  - Finding an existing file is NOT task completion — verify it satisfies the spec
404
+
405
+ ## Capture lessons (exit step)
406
+
407
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-build-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -215,3 +215,7 @@ If Dave types in this terminal during a turn:
215
215
  - Treat it as an override injected into the current task
216
216
  - Acknowledge it in your `chitchat_reply` response
217
217
  - If it changes direction mid-task, note what you stopped and why
218
+
219
+ ## Capture lessons (exit step)
220
+
221
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-collab-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -372,6 +372,10 @@ Fields:
372
372
 
373
373
  When diagnosing a broken deploy in Mode 3: query `coolify_events` FIRST before re-running the deploy — the most recent event row tells you whether the previous deploy actually triggered, whether it failed, and how long it ran. Faster than checking the Coolify UI.
374
374
 
375
+ ## Capture lessons (exit step)
376
+
377
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-deploy-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
378
+
375
379
  ## References
376
380
 
377
381
  - Type-specific checklists + DNS tree + gate commands: `docs/runbooks/coolify-deploy-checklist.md`
@@ -159,3 +159,7 @@ Report: what was fixed, file(s) changed, commit hash. One sentence.
159
159
  - Never run `pnpm build` — not needed for a fixit
160
160
  - If scope expands mid-fix: stop, escalate to rdc:build, don't finish under fixit
161
161
  - Marker file must be cleaned up whether fix succeeds or escalates
162
+
163
+ ## Capture lessons (exit step)
164
+
165
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-fixit-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -0,0 +1,176 @@
1
+ ---
2
+ name: rdc:housekeeping
3
+ description: "Usage `rdc:housekeeping [--fix]` — Weekly maintenance audit: directory structure verification, PUBLISH.md URL validation, CLAUDE.md freshness, orphan detection, places compliance, and stale version scan. Produces `.rdc/reports/YYYY-MM-DD-housekeeping.md`. With `--fix`, auto-remediate safe issues."
4
+ ---
5
+
6
+ > **⚠️ OUTPUT CONTRACT (READ FIRST):** `guides/output-contract.md`
7
+ > Checklist-only output. No tool-call narration. No raw MCP/JSON/log dumps.
8
+ > One checklist upfront, updated in place, shown again at end with a 1-line verdict.
9
+
10
+ > If dispatching subagents or running as a subagent: read `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md` first (fallback: `{PROJECT_ROOT}/.rdc/guides/agent-bootstrap.md`), then `{PROJECT_ROOT}/.rdc/guides/engineering-behavior.md` (fallback: `{PROJECT_ROOT}/.rdc/guides/engineering-behavior.md`).
11
+
12
+ > **Sandbox contract:** This skill honors `RDC_TEST=1` per `guides/agent-bootstrap.md` § RDC_TEST Sandbox Contract. Destructive external calls short-circuit under the flag.
13
+
14
+
15
+ # rdc:housekeeping — Weekly Maintenance Audit
16
+
17
+ ## When to Use
18
+ - Weekly maintenance (Sunday or session start)
19
+ - After large batch of new apps/packages/sites added
20
+ - Before monthly `workspace-intelligence-audit`
21
+ - When disoriented about repo health
22
+ - Called by `rdc:overnight` as a pre-flight if `--housekeeping` flag set
23
+
24
+ ## Arguments
25
+ - `rdc:housekeeping` — audit only, report issues
26
+ - `rdc:housekeeping --fix` — auto-remediate safe issues (scaffold missing CLAUDE.md, fix PUBLISH.md URLs, create missing tracker dirs)
27
+
28
+ ## Procedure
29
+
30
+ ### 1. Directory Structure Verification
31
+
32
+ Scan every deployable target for required files:
33
+
34
+ ```
35
+ For each dir in apps/*, sites/*, models/*, workers/*, mcp-servers/*, packages/*:
36
+ ```
37
+
38
+ | Target Type | Required Files |
39
+ |-------------|---------------|
40
+ | Next.js app (`apps/*` with next.config) | `package.json`, `CLAUDE.md`, `PUBLISH.md`, `tsconfig.json` |
41
+ | Vite SPA (`models/*`, `sites/*` with vite.config) | `package.json`, `CLAUDE.md`, `PUBLISH.md`, `vite.config.js` or `.ts`, `dist/` |
42
+ | Static site (`sites/*` no vite/next) | `index.html`, `CLAUDE.md`, `PUBLISH.md` |
43
+ | Worker (`workers/*`) | `package.json`, `CLAUDE.md`, `wrangler.toml`, `src/index.ts` |
44
+ | MCP server (`mcp-servers/*`) | `package.json`, `CLAUDE.md`, `ARCHITECTURE.md`, `PUBLISH.md` |
45
+ | Package (`packages/*`) | `package.json`, `CLAUDE.md`, `tsconfig.json`, `src/` |
46
+
47
+ Report: `PASS` / `MISSING: <file list>` per target.
48
+
49
+ **With `--fix`:** Scaffold missing CLAUDE.md files using package.json description + src/ inspection (same pattern as the 2026-06-08 audit). Do NOT auto-create PUBLISH.md (requires domain knowledge).
50
+
51
+ ### 2. PUBLISH.md URL Validation
52
+
53
+ For every PUBLISH.md that exists:
54
+
55
+ 1. Parse frontmatter: extract `entity_slug`, `environments`, `status`
56
+ 2. Query `app_deployments` for the slug:
57
+ ```sql
58
+ SELECT app_slug, environment, url, host_type FROM app_deployments WHERE app_slug = '<slug>';
59
+ ```
60
+ 3. Cross-reference: any URL mentioned in the PUBLISH.md body/notes/SURFACE blocks must match the `app_deployments.url` for that environment
61
+ 4. Check domain convention compliance (per `.claude/rules/domain-conventions.md`):
62
+ - Real estate projects → `*.dev.place.fund` (dev) / `*.place.fund` (prod)
63
+ - Class-A brands → `dev.<brand>` (dev) / `<brand>` (prod)
64
+ - Internal tools → `*.dev.regendevcorp.com` (dev) / `*.regendevcorp.com` (prod)
65
+ 5. Flag mismatches: `MISMATCH: PUBLISH.md says <X>, app_deployments says <Y>`
66
+
67
+ **With `--fix`:** Update PUBLISH.md URLs to match app_deployments (the DB is the source of truth).
68
+
69
+ ### 3. CLAUDE.md Freshness Check
70
+
71
+ For each package with a CLAUDE.md:
72
+ 1. Get CLAUDE.md last modified date
73
+ 2. Get latest src/ modification date
74
+ 3. If src/ changed after CLAUDE.md by >30 days, flag: `STALE: CLAUDE.md older than src/ by <N> days`
75
+ 4. Check if new exports were added to `src/index.ts` that aren't mentioned in CLAUDE.md
76
+
77
+ **With `--fix`:** Re-scaffold CLAUDE.md from current src/ state.
78
+
79
+ ### 4. Package.json Health
80
+
81
+ For each package:
82
+ 1. Check `version` — flag `0.0.0` or `0.1.0` on packages with >5 src files as potentially stale
83
+ 2. Check `exports` field exists (required for monorepo packages)
84
+ 3. Check `name` matches `@regen/<dir-name>` or `@lifeai/<dir-name>` convention
85
+ 4. Flag name mismatches between directory and package.json
86
+
87
+ ### 5. Places Compliance
88
+
89
+ For each directory under `places/`:
90
+ 1. Check PLACE.md exists with valid frontmatter (`schema_version`, `prt_slug`, `project_type`, `research_status`)
91
+ 2. Check HISTORY.md exists (required for real-estate project types per `.claude/rules/history-md-convention.md`)
92
+ 3. Check `corpus/INDEX.md` exists
93
+ 4. Check `tracker/` directory exists with DECISIONS.md + MILESTONES.md
94
+ 5. Check `artifacts/` directory exists
95
+
96
+ **With `--fix`:** Scaffold missing PLACE.md from HISTORY.md frontmatter, create missing tracker/corpus dirs.
97
+
98
+ ### 6. Orphan Detection
99
+
100
+ 1. **Empty/stub directories:** Any target dir with <3 files and no package.json → flag for removal
101
+ 2. **Standalone repo drift:** Check `C:/Dev/` for repos that have monorepo copies and compare versions
102
+ 3. **Dead app_deployments rows:** Query for slugs with `status='down'` or `status='broken'`
103
+
104
+ ### 7. Stale Coolify Apps on .dev URLs
105
+
106
+ Query Coolify API for apps serving `.dev.*` URLs — these should be on PM2 per domain conventions:
107
+ ```bash
108
+ TOKEN=$(curl -s http://127.0.0.1:52437/v/coolify-api)
109
+ curl -s -H "Authorization: Bearer $TOKEN" "https://deploy.regendevcorp.com/api/v1/applications" | \
110
+ python3 -c "import sys,json; [print(a['name'], a.get('fqdn','')) for a in json.load(sys.stdin) if '.dev.' in (a.get('fqdn',''))]"
111
+ ```
112
+
113
+ Flag any .dev apps still on Coolify.
114
+
115
+ ### 8. Media CDN Hotlink Allowlist
116
+
117
+ Read `workers/media-cdn/src/index.ts` ALLOWED_SUFFIXES. Cross-reference against all class-A brand domains from `app_deployments`:
118
+ ```sql
119
+ SELECT DISTINCT url FROM app_deployments WHERE host_type = 'coolify' AND url NOT LIKE '%.place.fund' AND url NOT LIKE '%.regendevcorp.com';
120
+ ```
121
+
122
+ Flag any class-A domain NOT in ALLOWED_SUFFIXES.
123
+
124
+ **With `--fix`:** Add missing suffixes to ALLOWED_SUFFIXES and redeploy the worker.
125
+
126
+ ### 9. Report
127
+
128
+ Write to `.rdc/reports/YYYY-MM-DD-housekeeping.md`:
129
+
130
+ ```markdown
131
+ # Housekeeping Report — YYYY-MM-DD
132
+
133
+ ## Summary
134
+ | Check | Pass | Fail | Fixed |
135
+ |-------|------|------|-------|
136
+
137
+ ## Directory Structure
138
+ <table of targets with issues>
139
+
140
+ ## PUBLISH.md URL Validation
141
+ <table of mismatches>
142
+
143
+ ## CLAUDE.md Freshness
144
+ <stale entries>
145
+
146
+ ## Package Health
147
+ <version/exports/naming issues>
148
+
149
+ ## Places Compliance
150
+ <incomplete places>
151
+
152
+ ## Orphans
153
+ <empty dirs, dead deployments>
154
+
155
+ ## Media CDN
156
+ <missing allowlist entries>
157
+
158
+ ## Verdict: CLEAN / HAS_ISSUES
159
+ ```
160
+
161
+ ## Lessons triage (weekly)
162
+
163
+ Read all `.rdc/lessons/*.md` with `status: open` (schema + procedure: `.rdc/guides/lessons-learned-spec.md` § Triage procedure). Cluster by `area` + root-cause similarity (dedupe repeats into one fix). For each cluster:
164
+
165
+ - `scope: simple` → apply the fix directly (rule line, skill-doc edit, config, guard), commit it, set the lesson(s) `status: applied` with the commit linked.
166
+ - `scope: architectural` → do NOT edit. Present the issue + options via `AskUserQuestion` (per `.claude/rules/architectural-change-approval.md`). On approval, apply via the correct lifecycle (rdc-skills tag/push for skills; cited commit for rules) and set `status: applied`. If deferred, set `status: triaged` and spawn a `work_item`.
167
+ - Not worth fixing → `status: wont-fix` with a one-line reason.
168
+
169
+ Never delete lesson files — `applied` and `wont-fix` stay as the audit trail. Report captured / applied / escalated / deferred counts in the housekeeping report.
170
+
171
+ ## Rules
172
+ - Never run `pnpm build` — not needed for this audit
173
+ - Never modify app_deployments — the DB is the source of truth; PUBLISH.md conforms to it
174
+ - The `--fix` flag only auto-remediates safe issues (CLAUDE.md scaffold, missing dirs, URL alignment)
175
+ - Architectural changes (name mismatches, dead package removal) are always flagged, never auto-fixed
176
+ - This skill is read-heavy, write-light — most runs are audit-only
@@ -0,0 +1,338 @@
1
+ ---
2
+ name: lifeai-brochure-author
3
+ version: 0.1.0
4
+ description: |
5
+ The mandatory contract for authoring brochure JSX using @lifeai/brochure-kit. Use this skill EVERY TIME any AI engine (Claude, Cursor, Copilot, /design, Cowork, v0) generates JSX intended for the Brochurify pipeline — whether the user says "write a brochure," "make a one-pager," "draft a PDF report," or any equivalent. Also trigger when a file imports from @lifeai/brochure-kit. Failing to read this skill before authoring is a defect.
6
+
7
+ triggers:
8
+ - "write a brochure"
9
+ - "make a one-pager"
10
+ - "draft a PDF report"
11
+ - "design a brochure"
12
+ - "create an investor doc"
13
+ - "generate a fact sheet"
14
+ - "brochurify"
15
+ - "@lifeai/brochure-kit"
16
+ - any JSX file under apps/*/brochures/ or packages/brochure-*/
17
+
18
+ required_validators:
19
+ - command: pnpm bk-lint
20
+ blocking: true
21
+ ---
22
+
23
+ # LIFEAI Brochure Authoring Contract
24
+
25
+ This is the contract every AI engine obeys when generating brochure JSX. The contract is non-negotiable. If you cannot generate output that complies, **stop and ask for clarification rather than emit non-compliant code.**
26
+
27
+ ## The Core Rule
28
+
29
+ Every brochure is a tree composed exclusively of components from `@lifeai/brochure-kit`. Raw HTML elements (`div`, `span`, `section`, etc.) are forbidden in the page tree. There are no exceptions.
30
+
31
+ ```tsx
32
+ // ❌ WRONG
33
+ <div className="flex flex-col gap-4">
34
+ <h1 style={{color: '#2d5a3f'}}>Title</h1>
35
+ <p>Body text...</p>
36
+ </div>
37
+
38
+ // ✅ RIGHT
39
+ <Stack gap="md">
40
+ <Heading level={1} variant="accent">Title</Heading>
41
+ <Prose>Body text...</Prose>
42
+ </Stack>
43
+ ```
44
+
45
+ If you find yourself reaching for a `<div>`, the answer is one of: `<Stack>`, `<Cluster>`, `<Section>`, `<Columns>`, or `<Brochure>`. There is always a kit primitive for what you want.
46
+
47
+ ## The Allowed Components
48
+
49
+ Exactly these. No others.
50
+
51
+ ### Layout primitives
52
+ - `<Brochure>` — root wrapper. Required. Carries `theme`, `pageSize`, `mode`.
53
+ - `<Page>` — explicit page boundary. Use sparingly; prefer Sections.
54
+ - `<Section>` — semantic grouping. Carries `level`, `id`, `affinity`.
55
+ - `<Cluster>` — tightly-coupled children (heading + intro + image). Stays together when possible.
56
+ - `<Stack>` — loose vertical flow. The default container.
57
+ - `<Columns>` — multi-column block. Carries `count`, `gap`.
58
+ - `<Spacer>` — explicit air. Declared in named sizes only.
59
+
60
+ ### Content primitives
61
+ - `<Prose>` — body text. Wraps paragraphs. Required for any flowing copy.
62
+ - `<Heading>` — section heading. Carries `level` (1-6), `variant`.
63
+ - `<Quote>` — pull quote. Carries `attribution`, `variant`.
64
+ - `<Stat>` — single numeric callout. Carries `value`, `label`, `variant`.
65
+ - `<StatRow>` — horizontal band of Stats. Carries `count`.
66
+ - `<DataTable>` — table. Carries `headers`, `rows`, `splitPolicy`.
67
+ - `<List>` — typed list. Carries `kind` (bullet, number, check, none).
68
+ - `<Definition>` — term + definition pair.
69
+
70
+ ### Visual primitives
71
+ - `<Figure>` — image with caption. Carries `src`, `alt`, `caption`, `width`, `height`, `crop`, `bleed`.
72
+ - `<Hero>` — page-anchored hero. Carries `src`, `alt`, `placement`.
73
+ - `<Divider>` — explicit separator. Carries `variant`.
74
+
75
+ ### Meta primitives
76
+ - `<Cover>` — first page, page-locked.
77
+ - `<TableOfContents>` — auto-generated from `<Heading>`s.
78
+ - `<Footnote>` — page-anchored footnote. Carries `id`, `marker`.
79
+
80
+ ## The Allowed HTML (inside `<Prose>` only)
81
+
82
+ Inside `<Prose>`, these inline HTML elements are allowed:
83
+ - `<em>`, `<strong>` — emphasis
84
+ - `<a>` — links (with `href`)
85
+ - `<code>` — inline code
86
+ - `<sub>`, `<sup>` — subscript/superscript
87
+ - `<br>` — line break (use sparingly)
88
+
89
+ Anything else inside `<Prose>` is rejected.
90
+
91
+ ## The Forbidden Patterns
92
+
93
+ These are hard-rejected by the validator. Do not emit them under any circumstance.
94
+
95
+ 1. **Raw layout HTML** — `<div>`, `<span>`, `<section>`, `<article>`, `<aside>`, `<header>`, `<footer>`, `<nav>` outside of `<Prose>`.
96
+ 2. **Inline styles** — `style={{...}}` on any element. Use variant props instead.
97
+ 3. **Color literals** — Hex codes, rgb(), hsl() in JSX. Use theme tokens via variants.
98
+ 4. **Viewport units** — `vh`, `vw`, `vmin`, `vmax` anywhere. Pages have fixed dimensions; viewport units break pagination.
99
+ 5. **Flexbox utility classes** — `flex`, `flex-col`, `justify-*`, `items-*` directly in className. Use kit primitives that handle layout.
100
+ 6. **Tailwind sizing literals** — `w-64`, `h-32`, `min-h-screen`. Use kit props.
101
+ 7. **Empty containers** — `<Stack></Stack>` with no children is rejected. Use `<Spacer>` for explicit air.
102
+ 8. **Nested `<Page>`** — Pages cannot contain Pages.
103
+ 9. **`<Figure>` without dimensions** — Every Figure must declare `width` and `height` (in inches or as a kit named size: `xs`, `sm`, `md`, `lg`, `xl`, `full`, `bleed`).
104
+ 10. **External CSS imports** — No `import './foo.css'` in brochure files. Theming is via tokens.
105
+
106
+ ## The Required Props
107
+
108
+ Every brochure must:
109
+
110
+ 1. Have exactly one `<Brochure>` root wrapper
111
+ 2. Declare `theme` on `<Brochure>` (one of: `prt`, `place-fund`, `zoen`, `evergreen`, `editorial-neutral`)
112
+ 3. Declare `pageSize` on `<Brochure>` (one of: `letter`, `a4`, `legal`, `digest`, `tabloid`)
113
+ 4. Declare `mode` on `<Brochure>` (one of: `read-only`, `cosmetic`, `editorial`, `creative`)
114
+
115
+ ## The Token System
116
+
117
+ All styling derives from `@lifeai/brochure-tokens`. You reference tokens via variant props, never via raw values.
118
+
119
+ ```tsx
120
+ // ✅ Variant references resolve to tokens
121
+ <Heading variant="accent">...</Heading> // → color: token.color.accent
122
+ <Stat variant="emphasis">...</Stat> // → typography.scale.emphasis
123
+ <Stack gap="md">...</Stack> // → spacing.scale.md
124
+ <Figure width="lg" height="md">...</Figure> // → kit-named sizes
125
+
126
+ // ❌ Literal references fail
127
+ <Heading style={{color: '#2d5a3f'}}>...</Heading> // hard-rejected
128
+ <Stack style={{gap: '24px'}}>...</Stack> // hard-rejected
129
+ ```
130
+
131
+ Available variant tokens depend on the theme. Common ones: `default`, `muted`, `accent`, `accent2`, `emphasis`, `serif`, `mono`. The theme file (in `packages/brochure-tokens/src/themes/`) is the authoritative list.
132
+
133
+ ## Pagination Affinities
134
+
135
+ Components declare how they want to paginate. You don't manage page breaks manually except via `<Page>`. The engine does it.
136
+
137
+ | Component | Default affinity |
138
+ |---|---|
139
+ | `<Heading level=1|2>` | `preferTopOfPage` + `keepWithNext` |
140
+ | `<Heading level=3-6>` | `keepWithNext` |
141
+ | `<Cluster>` | `preferKeepTogether` |
142
+ | `<Stack>` | `breakable` |
143
+ | `<Quote>` | `preferKeepTogether` |
144
+ | `<Stat>`, `<StatRow>` | `atomic` (never split) |
145
+ | `<DataTable>` | `splitWithRepeatedHeaders` (min 3 rows per fragment) |
146
+ | `<Figure>` | `keepWithCaption` |
147
+ | `<Hero>` | `preferStandalone` page |
148
+ | `<Footnote>` | sticks to anchor page |
149
+
150
+ You can override per-instance with the `affinity` prop on most components: `affinity="breakable"`, `affinity="keepTogether"`, `affinity="hardBreakBefore"`, `affinity="hardBreakAfter"`, `affinity="preferStandalone"`.
151
+
152
+ ## Worked Example 1: Investor One-Pager (Read-Only Mode)
153
+
154
+ ```tsx
155
+ import {
156
+ Brochure, Cover, Section, Cluster, Stack, Heading, Prose,
157
+ Stat, StatRow, Figure, Footnote
158
+ } from '@lifeai/brochure-kit';
159
+
160
+ export const PrtOnePager = () => (
161
+ <Brochure theme="prt" pageSize="letter" mode="read-only">
162
+ <Cover>
163
+ <Heading level={1} variant="accent">Planetary Regenerative Trust</Heading>
164
+ <Heading level={3} variant="muted">Q3 2026 Fund Update</Heading>
165
+ <Figure
166
+ src="prt-cover.jpg"
167
+ alt="Aerial view of Sky Mesa South Ranch"
168
+ width="bleed"
169
+ height="lg"
170
+ affinity="preferStandalone"
171
+ />
172
+ </Cover>
173
+
174
+ <Section level={1} id="overview">
175
+ <Heading level={2}>Fund Overview</Heading>
176
+ <StatRow count={3}>
177
+ <Stat value="$200M" label="Target raise" variant="emphasis" />
178
+ <Stat value="506(c)" label="Reg D structure" />
179
+ <Stat value="3" label="Investment lanes" />
180
+ </StatRow>
181
+ <Cluster>
182
+ <Heading level={3}>Five Capitals Framework</Heading>
183
+ <Prose>
184
+ PRT operates across the Five Capitals: <strong>Natural, Social,
185
+ Financial, Built, and Human</strong>. Capital flows are gated by
186
+ place-readiness rather than calendar deadlines<Footnote id="fn1" />.
187
+ </Prose>
188
+ </Cluster>
189
+ </Section>
190
+
191
+ <Section level={1} id="lanes">
192
+ <Heading level={2}>Investment Lanes</Heading>
193
+ <Prose>
194
+ Three lanes accept capital with distinct return profiles, hold
195
+ periods, and risk parameters.
196
+ </Prose>
197
+ </Section>
198
+
199
+ <Footnote id="fn1" marker="1">
200
+ Readiness gates are defined per-place by Story of Place methodology and
201
+ reviewed by an independent stewardship council.
202
+ </Footnote>
203
+ </Brochure>
204
+ );
205
+ ```
206
+
207
+ Things to notice:
208
+ - No `<div>` anywhere. Every container is a kit primitive.
209
+ - No styles. Every visual decision is a variant prop.
210
+ - The Figure on the cover declares `width="bleed"` (a kit-named size that resolves to full bleed at PDF time)
211
+ - The Footnote is declared inline and the actual footnote content is at the end; the engine pairs them and places the content on whatever page the anchor lands on.
212
+ - `affinity="preferStandalone"` on the cover Figure ensures the cover image doesn't fight with body content on page 1.
213
+
214
+ ## Worked Example 2: Why-Us Document (Cosmetic Mode)
215
+
216
+ ```tsx
217
+ import {
218
+ Brochure, Cover, Section, Stack, Cluster, Heading, Prose, Quote,
219
+ Figure, List, Definition, Divider
220
+ } from '@lifeai/brochure-kit';
221
+
222
+ export const WhyUsSkyMesa = () => (
223
+ <Brochure theme="place-fund" pageSize="letter" mode="cosmetic">
224
+ <Cover>
225
+ <Heading level={1}>Why Us</Heading>
226
+ <Heading level={3} variant="muted">Sky Mesa South Ranch · Aspen, Colorado</Heading>
227
+ </Cover>
228
+
229
+ <Section level={1}>
230
+ <Heading level={2}>The Land Speaks First</Heading>
231
+ <Prose>
232
+ Before any framework or fund structure, we begin with the question:
233
+ what is this place already trying to become? Sky Mesa South Ranch sits
234
+ in the Roaring Fork watershed, on land with five generations of
235
+ ranching memory and the deep ecological imprint of high-altitude
236
+ montane ecosystems.
237
+ </Prose>
238
+ <Figure
239
+ src="sky-mesa-aerial.jpg"
240
+ alt="Sky Mesa from the eastern ridge"
241
+ caption="Sky Mesa South Ranch, photographed in late summer 2025"
242
+ width="lg"
243
+ height="md"
244
+ />
245
+ </Section>
246
+
247
+ <Divider variant="rule" />
248
+
249
+ <Section level={1}>
250
+ <Heading level={2}>Five Capitals at Sky Mesa</Heading>
251
+ <List kind="check">
252
+ <Definition term="Natural">Watershed restoration, riparian recovery, soil regeneration</Definition>
253
+ <Definition term="Social">Multi-generational ranching community, Indigenous consultation</Definition>
254
+ <Definition term="Financial">PRT Lane B with conservation easement layer</Definition>
255
+ <Definition term="Built">Adaptive reuse of existing ranching infrastructure</Definition>
256
+ <Definition term="Human">On-site stewardship apprenticeships starting Year 1</Definition>
257
+ </List>
258
+ </Section>
259
+
260
+ <Section level={1}>
261
+ <Quote attribution="Bill Reed, AIA LEED">
262
+ Regeneration is not a technology applied to a place. It is a
263
+ relationship a place enters into with the people who tend it.
264
+ </Quote>
265
+ </Section>
266
+ </Brochure>
267
+ );
268
+ ```
269
+
270
+ ## Worked Example 3: Fact Sheet (Read-Only Mode, Dense)
271
+
272
+ ```tsx
273
+ import {
274
+ Brochure, Section, Stack, Heading, Prose,
275
+ DataTable, StatRow, Stat
276
+ } from '@lifeai/brochure-kit';
277
+
278
+ export const FundFactSheet = () => (
279
+ <Brochure theme="prt" pageSize="letter" mode="read-only">
280
+ <Section level={1}>
281
+ <Heading level={1} variant="accent">PRT Fund Fact Sheet</Heading>
282
+ <Heading level={3} variant="muted">As of Q3 2026</Heading>
283
+ </Section>
284
+
285
+ <Section level={2}>
286
+ <Heading level={2}>Performance</Heading>
287
+ <StatRow count={4}>
288
+ <Stat value="$185M" label="Committed capital" />
289
+ <Stat value="$92M" label="Deployed" />
290
+ <Stat value="12" label="Active places" />
291
+ <Stat value="8.4%" label="Net IRR (LTM)" variant="emphasis" />
292
+ </StatRow>
293
+ </Section>
294
+
295
+ <Section level={2}>
296
+ <Heading level={2}>Capital by Lane</Heading>
297
+ <DataTable
298
+ headers={["Lane", "Commitment", "Deployed", "Net IRR"]}
299
+ rows={[
300
+ ["A — Production", "$80M", "$48M", "10.2%"],
301
+ ["B — Place Capital", "$70M", "$32M", "7.8%"],
302
+ ["C — Stewardship", "$35M", "$12M", "5.4%"],
303
+ ]}
304
+ splitPolicy="repeat-headers"
305
+ />
306
+ </Section>
307
+ </Brochure>
308
+ );
309
+ ```
310
+
311
+ ## Pre-Flight Checklist (Run before considering output complete)
312
+
313
+ Before declaring any brochure JSX done, verify:
314
+
315
+ - [ ] Only kit components in the page tree (no raw `<div>`, `<span>`, etc.)
316
+ - [ ] No `style={{}}` attributes anywhere
317
+ - [ ] No color, rgb, hsl literals in JSX
318
+ - [ ] No `vh`, `vw` viewport units
319
+ - [ ] Every `<Figure>` has `width` and `height`
320
+ - [ ] Exactly one `<Brochure>` root
321
+ - [ ] `theme`, `pageSize`, `mode` all set on `<Brochure>`
322
+ - [ ] All Quotes inside `<Quote>` (not raw HTML)
323
+ - [ ] All flowing text inside `<Prose>`
324
+ - [ ] No empty containers
325
+ - [ ] No nested `<Page>`
326
+ - [ ] Run `pnpm bk-lint <file>` — exit code 0
327
+
328
+ If any check fails, fix it before completing. The validator is the contract; this skill is the lookup table.
329
+
330
+ ## When Things Get Hard
331
+
332
+ If you genuinely cannot express something in kit primitives, **stop and surface the gap.** Don't reach for `<div>`. Either:
333
+
334
+ 1. The kit needs a new component (file as a Phase-2 enhancement)
335
+ 2. The content is wrong for this format (push back on the user)
336
+ 3. There's a kit primitive you missed (re-read this skill)
337
+
338
+ The first two are honorable. Reaching for `<div>` is not.
@@ -224,3 +224,7 @@ Provide the advisor with:
224
224
  - Max 2 hours per epic — if exceeded, skip and log `TIMEOUT`
225
225
  - If credential daemon goes down mid-session: write current state to overnight doc, push, exit gracefully
226
226
  - If git push fails: log the failure, attempt rebase, retry once — do not force push
227
+
228
+ ## Capture lessons (exit step)
229
+
230
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-overnight-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -250,3 +250,7 @@ Q5. What SSL path?
250
250
  ```
251
251
 
252
252
  Embed all five answers into the infra task description verbatim before handing to the agent.
253
+
254
+ ## Capture lessons (exit step)
255
+
256
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-plan-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -84,3 +84,7 @@ direction if given. If advisor cannot resolve, log and skip to next step.
84
84
  - Web search is mandatory — don't just analyze the codebase
85
85
  - Keep the doc under 200 lines — concise, not exhaustive
86
86
  - Unattended: NEVER pause for input; infer and proceed
87
+
88
+ ## Capture lessons (exit step)
89
+
90
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-preplan-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -0,0 +1,238 @@
1
+ ---
2
+ name: rdc-brochurify
3
+ version: 0.1.0
4
+ description: |
5
+ Orchestrate a Brochurify job from source ingest through delivered PDF, using six parallel-dispatched typed sub-agents and the convergence loop. Use this skill EVERY TIME the user invokes Brochurify directly via "brochurify this", "make a brochure from", "convert this to a brochure PDF", or "rdc:brochurify". Also runs automatically when a job arrives from the broker via monkey_dispatch. The skill enforces D-001 through D-016 from the brochurify DECISIONS-LOG.
6
+ triggers:
7
+ - "rdc:brochurify"
8
+ - "brochurify this"
9
+ - "make a brochure from"
10
+ - "convert to brochure PDF"
11
+ - "generate brochure from"
12
+ - monkey_dispatch payload with skill="brochurify"
13
+ ---
14
+
15
+ # rdc:brochurify Orchestrator
16
+
17
+ The orchestrator dispatches six waves of typed sub-agents in sequence. Each wave has a clear input contract, an output contract, and a parallelism profile.
18
+
19
+ ## Inputs
20
+
21
+ The orchestrator accepts a job payload:
22
+
23
+ ```json
24
+ {
25
+ "job_id": "uuid",
26
+ "source": {
27
+ "kind": "url" | "html" | "docx" | "md" | "jsx" | "corpus",
28
+ "ref": "https://..." | "file:///path/..." | "<html>..." | { corpus_query }
29
+ },
30
+ "mode": "read-only" | "cosmetic" | "editorial" | "creative",
31
+ "theme": "prt" | "place-fund" | "zoen" | "evergreen" | "editorial-neutral",
32
+ "page_size": "letter" | "a4" | "legal" | "digest" | "tabloid",
33
+ "brief": "optional natural-language brief for editorial/creative modes",
34
+ "org_id": "uuid",
35
+ "user_id": "uuid"
36
+ }
37
+ ```
38
+
39
+ ## Outputs
40
+
41
+ - A PDF in R2 (`brochurify-output` bucket) with a signed URL
42
+ - A completion record in Supabase `brochure_jobs` with:
43
+ - `pdf_r2_key`, `pdf_url`
44
+ - `final_grade`, `page_scores` (jsonb array)
45
+ - `iter` (iteration count reached)
46
+ - `trace` (jsonb log of all 6 waves × iterations)
47
+
48
+ ## The Six Waves
49
+
50
+ ### Wave 1 — Ingest
51
+
52
+ **Goal:** Normalize any source into kit-compliant JSX.
53
+
54
+ **Sub-agent:** `ingest-author` (typed agent with the `lifeai-brochure-author` skill loaded)
55
+
56
+ **Inputs:** raw source from job payload
57
+ **Outputs:** `working/draft.jsx` (kit-compliant JSX) + `working/assets/` (extracted images)
58
+
59
+ **Per-source handling:**
60
+ - `url` — fetch via Playwright (whitelist) or structural-summary mode (open web)
61
+ - `html` — direct ingest, strip scripts/iframes/ads
62
+ - `docx` — pandoc to HTML, then ingest
63
+ - `md` — render to HTML, then ingest
64
+ - `jsx` — pre-built input; skip to validate
65
+ - `corpus` — Creative mode only; corpus reader + Author-Mode-* sub-agent
66
+
67
+ **Failure mode:** if ingest cannot map content to kit primitives, raise a structured error with the unmappable content range and ask the user to clarify.
68
+
69
+ ### Wave 2 — Validate
70
+
71
+ **Goal:** Confirm the JSX passes static and structural validation before render.
72
+
73
+ **Sub-agent:** none — runs `pnpm bk-lint working/draft.jsx` directly
74
+
75
+ **Behavior:**
76
+ - If pass → Wave 3
77
+ - If fail → return errors to Wave 1 agent, retry once
78
+ - If fail twice → escalate to orchestrator: try a different ingest strategy, page-size change, or surface to user
79
+
80
+ **Every failure here writes to `enhancement-log.jsonl`** with:
81
+ - `src: "ingest-author"`
82
+ - `fail_layer: "static"` or `fail_layer: "structural"`
83
+ - The specific rule violated
84
+
85
+ ### Wave 3 — Render
86
+
87
+ **Goal:** Produce a first-iteration PDF and per-page screenshots.
88
+
89
+ **Sub-agent:** none — runs Paged.js via Playwright headless
90
+
91
+ **Process:**
92
+ 1. Build the kit + theme bundle into `working/bundle.html`
93
+ 2. Open with Paged.js polyfill
94
+ 3. Wait for `pagedjs:rendered` event
95
+ 4. Snapshot DOM after pagination → `working/paged.html`
96
+ 5. Per-page screenshot at 150 DPI → `working/pages/page-{N}.png`
97
+ 6. Render to PDF → `working/iter-{i}.pdf`
98
+
99
+ **Failure mode:** if Paged.js fails to converge (rare; usually a kit bug), fall back to print-to-PDF without paged-media polyfill, flag as low-quality iteration, continue.
100
+
101
+ ### Wave 4 — Grade (Vision, Parallel)
102
+
103
+ **Goal:** Score each page against the 7-dimension rubric.
104
+
105
+ **Sub-agent:** `vision-grader` — dispatched **once per page in parallel**.
106
+
107
+ **Per-page inputs:**
108
+ - The page screenshot
109
+ - The source JSX for that page (extracted by walking the paginated DOM)
110
+ - The rubric (R1-R7 with weights and target ranges)
111
+
112
+ **Per-page outputs (structured):**
113
+ ```json
114
+ {
115
+ "page": 3,
116
+ "grade": 82,
117
+ "dimensions": {
118
+ "R1_margin_integrity": 95,
119
+ "R2_bottom_slack": 70,
120
+ "R3_heading_breathing": 85,
121
+ "R4_widows_orphans": 100,
122
+ "R5_image_placement": 80,
123
+ "R6_table_integrity": 100,
124
+ "R7_text_density": 75
125
+ },
126
+ "issues": [
127
+ {"dim": "R2", "desc": "tail gap 1.1in below last paragraph", "fix_hint": "compress paragraph or push next-page content"}
128
+ ]
129
+ }
130
+ ```
131
+
132
+ **Document grade:** `min(page_grades)` per D-013.
133
+
134
+ **Convergence:**
135
+ - Grade ≥ 75 → Wave 6 (Deliver)
136
+ - Grade < 75 AND iter < 10 → Wave 5 (Patch)
137
+ - iter = 10 → Wave 6 with `partial=true` flag
138
+
139
+ ### Wave 5 — Patch (Parallel)
140
+
141
+ **Goal:** Produce a corrected JSX that addresses the issues from Wave 4.
142
+
143
+ **Sub-agent:** `patch-author` — dispatched **once per low-graded page in parallel**.
144
+
145
+ **Mode restrictions:**
146
+ - `read-only` — only break, sizing, spacing patches allowed
147
+ - `cosmetic` — read-only patches + image resize, caption compression, paragraph splits at sentence boundaries
148
+ - `editorial` — cosmetic + paragraph rewrites within 15% character or 25% word reduction
149
+ - `creative` — editorial + free composition (the authoring sub-agent fully active)
150
+
151
+ **Patch types:**
152
+ - `force-break-before` — insert page break before an element
153
+ - `adjust-spacing` — change Stack/Cluster gap variant
154
+ - `resize-figure` — change Figure width/height variant
155
+ - `compress-paragraph` — drop or merge a sentence (cosmetic+ only)
156
+ - `rewrite-paragraph` — full rewrite (editorial+ only)
157
+ - `rebalance-cluster` — split a Cluster onto two pages
158
+ - `change-affinity` — adjust an affinity prop
159
+
160
+ Each patch is applied to `working/draft.jsx`, the validator re-runs, then Wave 3 renders again.
161
+
162
+ **Edit tracking (editorial mode):** every paragraph rewrite is logged with before/after to `working/edits.jsonl`. The completion record includes this log.
163
+
164
+ ### Wave 6 — Deliver
165
+
166
+ **Goal:** Final PDF, signed URL, completion record.
167
+
168
+ **Process:**
169
+ 1. Upload final PDF to R2 with key `brochurify-output/{org_id}/{job_id}.pdf`
170
+ 2. Generate 7-day signed URL
171
+ 3. Update `brochure_jobs` row:
172
+ ```sql
173
+ UPDATE brochure_jobs SET
174
+ status = 'completed',
175
+ iter = $iter,
176
+ current_grade = $grade,
177
+ page_scores = $pageScoresJson,
178
+ pdf_r2_key = $r2Key,
179
+ pdf_url = $signedUrl,
180
+ completed_at = now()
181
+ WHERE id = $jobId;
182
+ ```
183
+ 4. Send SSE event `{type:"complete", url, grade, iter}` to broker
184
+ 5. Append enhancement log entries from this run to `enhancement-log.jsonl`
185
+
186
+ ## Trace Logging
187
+
188
+ Every wave appends to `working/trace.jsonl`:
189
+
190
+ ```jsonl
191
+ {"ts":"...","wave":1,"agent":"ingest-author","iter":1,"status":"start"}
192
+ {"ts":"...","wave":1,"agent":"ingest-author","iter":1,"status":"complete","blocks":127}
193
+ {"ts":"...","wave":2,"iter":1,"status":"complete","errors":0}
194
+ {"ts":"...","wave":3,"iter":1,"status":"complete","pages":8,"render_ms":2340}
195
+ {"ts":"...","wave":4,"iter":1,"page":1,"grade":85,"status":"complete"}
196
+ {"ts":"...","wave":4,"iter":1,"page":2,"grade":68,"status":"complete","issues":2}
197
+ ...
198
+ ```
199
+
200
+ This trace is stored in `brochure_jobs.payload.trace` for forensic review.
201
+
202
+ ## Cost Profile
203
+
204
+ - **Wave 1:** 1 sub-agent call (one model invocation)
205
+ - **Wave 2:** 0 model calls (deterministic validator)
206
+ - **Wave 3:** 0 model calls (deterministic render)
207
+ - **Wave 4:** N parallel model calls (N = page count)
208
+ - **Wave 5:** M parallel model calls (M = pages needing patch; usually 0-3)
209
+ - **Wave 6:** 0 model calls
210
+
211
+ Typical 8-page brochure, 2 iterations: ~1 + 16 + 4 = ~21 model calls total. All on Max plan. Zero per-job API cost.
212
+
213
+ ## Hard Caps
214
+
215
+ - **Max iterations:** 10 (per D-006)
216
+ - **Max wall-clock:** 15 minutes per job
217
+ - **Max page count:** 50 (anything larger is split into multiple jobs)
218
+ - **Max source size:** 5MB raw HTML, 25MB docx, 50MB total assets
219
+
220
+ Exceeding any cap → job fails with structured error; no partial billing.
221
+
222
+ ## Failure Recovery
223
+
224
+ | Failure | Recovery |
225
+ |---|---|
226
+ | Validator fails repeatedly | Try page-size change (Letter → Legal → Digest) before failing job |
227
+ | Vision agent disagrees with itself | Lock grade after 3 iterations of same page; mark "best-effort" |
228
+ | Convergence not reached at iter=10 | Ship best version, flag low-graded pages, log to enhancement |
229
+ | Paged.js render fails | Fall back to direct PDF; flag low-quality iteration |
230
+ | R2 upload fails | Retry 3x then fall back to Supabase storage URL |
231
+
232
+ ## When to invoke
233
+
234
+ Direct user invocation: `rdc:brochurify <source-url-or-path> [--mode] [--theme] [--page-size]`
235
+
236
+ Programmatic invocation: a `monkey_dispatch` job arriving with `skill="brochurify"` and the job payload as `args`.
237
+
238
+ Either path executes the same 6-wave loop. Direct user invocation also returns the trace and the PDF URL to the calling session.
@@ -0,0 +1,189 @@
1
+ ---
2
+ name: rdc-extract-verifier-rules
3
+ version: 0.1.0
4
+ description: |
5
+ Read recent enhancement-log entries, cluster failures by pattern, generate candidate verifier rules, test them against the known-good corpus and the failure corpus, and propose pull requests adding the highest-confidence rules to forbidden-patterns.json. Use this skill on a nightly cadence (3 AM PT), or manually when the user says "extract verifier rules", "promote enhancement log", "what new rules should we add", or after a significant brochure run produced many failures.
6
+ triggers:
7
+ - "rdc:extract-verifier-rules"
8
+ - "extract verifier rules"
9
+ - "promote enhancement log"
10
+ - "what new rules should we add"
11
+ - "verifier corpus update"
12
+ - nightly cron at 3:00 AM PT
13
+ ---
14
+
15
+ # rdc:extract-verifier-rules
16
+
17
+ The self-learning loop. The verifier corpus is the moat (per `DECISIONS-LOG.md` D-009). This skill is how the corpus grows.
18
+
19
+ ## What it does
20
+
21
+ 1. Read `enhancement-log.jsonl` entries since last run timestamp
22
+ 2. Cluster entries by fingerprint similarity + reason text
23
+ 3. For each cluster with `N >= 3` occurrences:
24
+ - Generate a candidate regex or AST pattern
25
+ - Test the pattern against the **known-good corpus** (last 100 successful brochures) for false positives
26
+ - Test the pattern against the **failure cluster** for recall
27
+ - If false-positive rate = 0 AND recall ≥ 80%, mark as `propose`
28
+ 4. For each `propose` candidate:
29
+ - Open a PR on `regen-root` adding the rule to `verifiers/forbidden-patterns.json`
30
+ - Auto-merge if confidence ≥ 95% AND a maintainer's auto-merge flag is enabled
31
+ - Otherwise, await human review
32
+ 5. Write a markdown summary to `.rdc/reports/verifier-{YYYY-MM-DD}.md`
33
+
34
+ ## Cluster algorithm
35
+
36
+ Two-stage clustering:
37
+
38
+ **Stage 1 — Fingerprint clustering:**
39
+ - Each enhancement-log entry has an `input_fingerprint` (sha256 of the offending JSX block)
40
+ - Entries with identical fingerprints cluster trivially (same exact mistake)
41
+
42
+ **Stage 2 — Semantic clustering:**
43
+ - For unique fingerprints, embed the `reason` and `pattern` fields with `@xenova/transformers` (384-dim, local — no API)
44
+ - Cosine similarity ≥ 0.85 → same cluster
45
+ - Use HDBSCAN with min_samples=3 to identify real clusters vs. noise
46
+
47
+ ## Candidate rule generation
48
+
49
+ For each cluster, generate one of:
50
+
51
+ ### Regex candidate
52
+ - Take all `pattern` strings in the cluster
53
+ - Find common substring or template
54
+ - Generalize literal values to character classes
55
+ - Validate the regex is well-formed and not catastrophic
56
+
57
+ Example:
58
+ ```
59
+ Cluster patterns:
60
+ <div className="flex flex-col gap-4">
61
+ <div className="flex flex-col gap-6">
62
+ <div className="flex flex-row items-center">
63
+
64
+ Generated regex:
65
+ <div[^>]*className="[^"]*\\bflex\\b
66
+ ```
67
+
68
+ ### AST candidate
69
+ - For cluster entries with rich AST context, build an AST query string
70
+ - Test with @typescript-eslint/parser
71
+
72
+ Example:
73
+ ```
74
+ AST candidate:
75
+ JSXOpeningElement[name.name='div'] > JSXAttribute[name.name='className'] CallExpression[callee.name='clsx']
76
+ ```
77
+
78
+ ## False-positive check
79
+
80
+ Run the candidate against the known-good corpus:
81
+ - The 12 Phase 1 reference brochures
82
+ - All design-partner brochures with `final_grade >= 85`
83
+ - Any brochure tagged `corpus:reference` in Supabase
84
+
85
+ If the candidate matches any known-good output → reject the candidate. False positives in the verifier corpus are unacceptable because they break working flows.
86
+
87
+ ## Recall check
88
+
89
+ Run the candidate against the failure cluster:
90
+ - Must match ≥ 80% of cluster entries
91
+ - Below 80%, the candidate is too specific; widen and retry
92
+
93
+ ## PR generation
94
+
95
+ For each promoted candidate, create a PR on `LIFEAI/regen-root`:
96
+
97
+ ```
98
+ Title: [verifier-corpus] Add rule FP0{N} — {short description}
99
+
100
+ Body:
101
+ This rule was generated by rdc:extract-verifier-rules on {date}.
102
+
103
+ **Cluster size:** {N} occurrences over {time span}
104
+ **False positive rate:** {rate}
105
+ **Recall:** {percent}
106
+
107
+ **Sample failures:**
108
+ {3-5 example enhancement-log entries}
109
+
110
+ **Generated rule:**
111
+ ```json
112
+ {rule JSON}
113
+ ```
114
+
115
+ **Reviewer checklist:**
116
+ - [ ] Verify the rule doesn't match any known-good brochure
117
+ - [ ] Verify the suggested fix is reasonable
118
+ - [ ] Confirm severity level
119
+ - [ ] Confirm category
120
+
121
+ Auto-merging: {yes/no based on confidence}
122
+ ```
123
+
124
+ ## Auto-merge policy
125
+
126
+ Auto-merge if **all** are true:
127
+ - False-positive rate = 0
128
+ - Recall ≥ 95%
129
+ - Cluster size ≥ 10
130
+ - The rule pattern is a strict subset of an existing pattern (not a fundamentally new category)
131
+ - A maintainer's auto-merge flag is enabled in `.rdc/config.json`
132
+
133
+ Otherwise, await human review.
134
+
135
+ ## Output: nightly report
136
+
137
+ `.rdc/reports/verifier-{YYYY-MM-DD}.md`:
138
+
139
+ ```markdown
140
+ # Verifier Corpus Update — {date}
141
+
142
+ ## Summary
143
+
144
+ - Enhancement log entries since last run: {N}
145
+ - Clusters identified: {C}
146
+ - Rules proposed: {R}
147
+ - Rules auto-merged: {A}
148
+ - Rules awaiting review: {W}
149
+
150
+ ## Top clusters
151
+
152
+ | Cluster | Size | Pattern | Status |
153
+ |---|---|---|---|
154
+ | ...
155
+
156
+ ## Open PRs
157
+
158
+ - #{N}: FP0{X} — {description}
159
+ - ...
160
+
161
+ ## False-positive rejections
162
+
163
+ Candidates that failed the known-good test:
164
+ - {summary}
165
+
166
+ ## Corpus growth
167
+
168
+ - Total rules in forbidden-patterns.json: {before} → {after}
169
+ - Total component-allowlist entries: unchanged
170
+ - Pagination rules: unchanged
171
+ ```
172
+
173
+ ## Manual invocation
174
+
175
+ A maintainer can run this skill manually after a significant brochure run to immediately promote lessons learned:
176
+
177
+ ```
178
+ rdc:extract-verifier-rules --since "2026-05-27" --auto-merge=false
179
+ ```
180
+
181
+ The `--auto-merge=false` flag forces human review on all proposals regardless of confidence.
182
+
183
+ ## Why this matters
184
+
185
+ The verifier corpus is the asset. Anyone can copy the kit. Anyone can copy the ESLint plugin. **Replicating 12 months of customer-tested failure patterns is the moat.** This skill is how that moat compounds. Every brochure run feeds it. Every nightly run grows it.
186
+
187
+ After 12 months at moderate scale, the corpus will contain ~500-2,000 rules, calibrated against real customer documents, with each rule's hit count visible. New competitors entering this category will face a starting position 12 months behind.
188
+
189
+ That is the point.
@@ -109,3 +109,7 @@ rdc-skills-install --profile core
109
109
  ```
110
110
 
111
111
  Use `--profile lifeai` only on a workstation that intentionally has the LIFEAI project layout and services.
112
+
113
+ ## Capture lessons (exit step)
114
+
115
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-release-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.
@@ -146,3 +146,7 @@ description: "Usage `rdc:review [--unattended]` — Post-build quality gate: tsc
146
146
  - Each fix is a separate commit (not batched)
147
147
  - Always push fixes to origin after committing *(skip if `$RDC_TEST=1` — echo `[RDC_TEST] skipping git push` instead)*
148
148
  - Unattended: NEVER pause for input
149
+
150
+ ## Capture lessons (exit step)
151
+
152
+ Before the final verdict line, follow `.rdc/guides/lessons-learned-spec.md` § Capture procedure. If this run taught something non-obvious — a first root-cause theory that turned out wrong, the documented/standard path not working, a missing gate or check that cost a round, or a surprising tool/infra behavior — write one `.rdc/lessons/<YYYY-MM-DD>-review-<short-slug>.md` per lesson using the schema in that spec. Set `scope` (`simple` | `architectural`) and `status` (`open`, or `applied` if you shipped the fix in this same run, with the commit linked). Commit the lesson file(s) on `develop` alongside the run's other commits, and note "N lessons captured" in your verdict/summary. A run that taught nothing writes nothing — absence is the default.