@hanzlaa/rcode 4.0.0 → 4.1.1

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 (47) hide show
  1. package/AGENTS.md +1 -1
  2. package/README.md +2 -2
  3. package/cli/doctor.js +17 -0
  4. package/cli/github-sync.js +3 -2
  5. package/cli/index.js +16 -0
  6. package/cli/install.js +1 -0
  7. package/cli/lib/manifest.cjs +13 -0
  8. package/cli/set-mode.js +10 -0
  9. package/cli/set-profile.js +10 -0
  10. package/cli/uninstall.js +100 -39
  11. package/cli/workflow.js +97 -0
  12. package/dist/rcode.js +249 -229
  13. package/package.json +1 -1
  14. package/rcode/bin/lib/config.cjs +3 -2
  15. package/rcode/bin/rcode-tools.cjs +8 -3
  16. package/rcode/skills/SKILLS_INDEX.md +4 -3
  17. package/rcode/skills/actions/1-analysis/rcode-document-project/SKILL.md +6 -0
  18. package/rcode/skills/actions/3-solutioning/rcode-check-implementation-readiness/SKILL.md +6 -0
  19. package/rcode/skills/actions/3-solutioning/rcode-create-architecture/steps/step-01-init.md +1 -1
  20. package/rcode/skills/actions/3-solutioning/rcode-create-architecture/workflow.md +13 -1
  21. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/SKILL.md +166 -0
  22. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/references.md +136 -0
  23. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/backlog-building.md +113 -0
  24. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/composition-with-herdr.md +85 -0
  25. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/integration-branch.md +191 -0
  26. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/merge-strategy.md +113 -0
  27. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/orchestrator-rhythm.md +119 -0
  28. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/rules/wave-design.md +100 -0
  29. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/templates/BACKLOG-template.md +34 -0
  30. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/templates/STATE-template.md +40 -0
  31. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/templates/heartbeat.sh +29 -0
  32. package/rcode/skills/actions/4-implementation/rcode-herdr-orchestration/templates/wave-prompt.md +69 -0
  33. package/rcode/skills/actions/4-implementation/rcode-retrospective/workflow.md +61 -246
  34. package/rcode/templates/sprint.md +16 -0
  35. package/rcode/workflows/audit.md +3 -0
  36. package/rcode/workflows/brainstorm.md +1 -1
  37. package/rcode/workflows/council.md +8 -1
  38. package/rcode/workflows/create-architecture.md +5 -1
  39. package/rcode/workflows/create-prd.md +5 -1
  40. package/rcode/workflows/dashboard.md +5 -2
  41. package/rcode/workflows/discuss-phase.md +3 -15
  42. package/rcode/workflows/execute-sprint.md +3 -1
  43. package/rcode/workflows/plan-spawn-planner.md +96 -0
  44. package/rcode/workflows/plan.md +67 -0
  45. package/rcode/workflows/retrospective.md +5 -1
  46. package/rcode/workflows/sprint-planning.md +9 -5
  47. package/server/dashboard.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzlaa/rcode",
3
- "version": "4.0.0",
3
+ "version": "4.1.1",
4
4
  "description": "rcode — the AI team that never forgets. Persistent memory, specialist agents, and slash commands for AI IDEs. Works in Claude Code, Cursor, Gemini, VS Code, and Antigravity.",
5
5
  "main": "cli/index.js",
6
6
  "bin": {
@@ -142,12 +142,13 @@ function cmdSet(projectRoot, dottedKey, value) {
142
142
  fs.mkdirSync(path.dirname(cp), { recursive: true });
143
143
  const existing = fs.existsSync(cp) ? fs.readFileSync(cp, 'utf8') : '';
144
144
  const config = parseNestedYaml(existing);
145
- setAt(config, dottedKey, value);
145
+ const normalizedValue = stripQuotes(String(value).trim());
146
+ setAt(config, dottedKey, normalizedValue);
146
147
  const out = serialise(config);
147
148
  const tmp = cp + '.tmp';
148
149
  fs.writeFileSync(tmp, out, 'utf8');
149
150
  fs.renameSync(tmp, cp);
150
- return { ok: true, key: dottedKey, value, path: cp };
151
+ return { ok: true, key: dottedKey, value: normalizedValue, path: cp };
151
152
  }
152
153
 
153
154
  module.exports = {
@@ -3170,7 +3170,9 @@ function cmdState(subArgs) {
3170
3170
  }
3171
3171
  }
3172
3172
 
3173
- // Walk .rcode/phases/*/sprint-*.md parse sprints into state.sprints[] (issue #135).
3173
+ // Walk phase sprint artifacts into state.sprints[] (issue #135).
3174
+ // Support both legacy `sprint-1.md` and workflow-generated
3175
+ // `01-01-SPRINT.md` / `1-1-SPRINT.md` names.
3174
3176
  const phasesDir = path.join(PLANNING_DIR, 'phases');
3175
3177
  const rcodePhasesDir = path.join(RCODE_DIR, 'phases');
3176
3178
  const sprintRoot = fs.existsSync(phasesDir) ? phasesDir : (fs.existsSync(rcodePhasesDir) ? rcodePhasesDir : null);
@@ -3182,9 +3184,11 @@ function cmdState(subArgs) {
3182
3184
  const phaseNumMatch = phaseEntry.match(/^(\d+(?:\.\d+)?)/);
3183
3185
  const phaseNum = phaseNumMatch ? phaseNumMatch[1] : phaseEntry;
3184
3186
  for (const file of fs.readdirSync(phaseDir)) {
3185
- const sprintMatch = file.match(/^sprint-(\d+)\.md$/);
3187
+ const sprintMatch =
3188
+ file.match(/^sprint-(\d+)\.md$/i) ||
3189
+ file.match(/^(?:\d+(?:\.\d+)?[-_.])?(\d+)[-_.].*SPRINT\.md$/i);
3186
3190
  if (!sprintMatch) continue;
3187
- const sprintNum = sprintMatch[1];
3191
+ const sprintNum = String(parseInt(sprintMatch[1], 10));
3188
3192
  const sprintKey = `${phaseNum}/${sprintNum}`;
3189
3193
  parsed.sprints_found += 1;
3190
3194
  const sprintPath = path.join(phaseDir, file);
@@ -6795,6 +6799,7 @@ function cmdGitignore(args) {
6795
6799
  '.rcode/brain/best-practices/',
6796
6800
  '',
6797
6801
  '# Runtime noise',
6802
+ 'node_modules/',
6798
6803
  '.rcode/state.json.lock',
6799
6804
  '.planning/debug/',
6800
6805
  '.planning/_backup/',
@@ -1,6 +1,6 @@
1
1
  # rcode — Skills Index
2
2
 
3
- All 85 skills in rcode, organized by category: 23 agent skills, 37 action skills, 25 core skills, plus 2 shared modules.
3
+ All 86 skills in rcode, organized by category: 23 agent skills, 38 action skills, 25 core skills, plus 2 shared modules.
4
4
 
5
5
  ## Agent Skills (23)
6
6
 
@@ -36,7 +36,7 @@ Note: Hussain has two hats — **PM** (strategic product management) and **SM**
36
36
 
37
37
  ---
38
38
 
39
- ## Action Skills (37)
39
+ ## Action Skills (38)
40
40
 
41
41
  Invoked by agents via the capabilities table in their SKILL.md. Organized by SDLC phase.
42
42
 
@@ -63,7 +63,7 @@ Invoked by agents via the capabilities table in their SKILL.md. Organized by SDL
63
63
  - `actions/3-solutioning/rcode-check-implementation-readiness` — verify PRD/UX/arch alignment
64
64
  - `actions/3-solutioning/rcode-generate-project-context` — generate project-context.md
65
65
 
66
- ### 4 — Implementation (20)
66
+ ### 4 — Implementation (21)
67
67
  - `actions/4-implementation/rcode-dev-story` — execute a story (write tests + code)
68
68
  - `actions/4-implementation/rcode-review` — comprehensive code review
69
69
  - `actions/4-implementation/rcode-qa-generate-e2e-tests` — generate e2e test suite
@@ -84,6 +84,7 @@ Invoked by agents via the capabilities table in their SKILL.md. Organized by SDL
84
84
  - `actions/4-implementation/rcode-prove-it` — test-first development
85
85
  - `actions/4-implementation/rcode-source-truth` — cite official docs before writing framework code
86
86
  - `actions/4-implementation/rcode-trim` — code simplification
87
+ - `actions/4-implementation/rcode-herdr-orchestration` — orchestrate parallel cld agents in herdr; single-shot fan-out OR long-running autonomous wave-based fix campaign with durable backlog + integration branch + heartbeat
87
88
 
88
89
  ---
89
90
 
@@ -27,6 +27,12 @@ Analyze an existing codebase and produce documentation for both human and LLM co
27
27
 
28
28
  Follow the instructions in ./workflow.md.
29
29
 
30
+ ## When NOT to use this skill
31
+
32
+ Do NOT use for writing net-new documentation from scratch (use a write-document prompt).
33
+ Do NOT invoke when the user wants to document a single file or function — scope this skill
34
+ to whole-codebase or whole-module brownfield analysis only.
35
+
30
36
  ## Output Format
31
37
 
32
38
  - Produces multi-file documentation: README summary, ARCHITECTURE.md, CONVENTIONS.md, project-context.md
@@ -28,6 +28,12 @@ Verify that PRD, UX designs, architecture decisions, and epics/stories are all a
28
28
 
29
29
  Follow the instructions in ./workflow.md.
30
30
 
31
+ ## When NOT to use this skill
32
+
33
+ Do NOT use during active implementation — if work is already in progress, use
34
+ `rcode-correct-course` instead. Do NOT invoke for a single-artifact review (e.g. "check
35
+ this PRD"); scope this skill to cross-artifact alignment checks before a phase starts.
36
+
31
37
  ## Output Format
32
38
 
33
39
  - Produces an alignment report with checklist format
@@ -70,7 +70,7 @@ Try to discover the following:
70
70
  - Project Documentation (generally multiple documents might be found for this in the `{project_knowledge}` or `{project-root}/docs` folder.)
71
71
  - Project Context (`**/project-context.md`)
72
72
 
73
- <critical>Confirm what you have found with the user, along with asking if the user wants to provide anything else. Only after this confirmation will you proceed to follow the loading rules</critical>
73
+ <critical>If auto mode is active (--auto flag or config.mode == "yolo"): skip user confirmation — log "Auto mode: proceeding with discovered documents: [list]" and continue directly to Loading Rules. Otherwise: confirm what you have found with the user, ask if they want to provide anything else, and only proceed after confirmation.</critical>
74
74
 
75
75
  **Loading Rules:**
76
76
 
@@ -18,14 +18,26 @@ This uses **micro-file architecture** for disciplined execution:
18
18
 
19
19
  ---
20
20
 
21
+ ## AUTO MODE
22
+
23
+ **If `--auto` was passed in ARGUMENTS OR `config.mode == "yolo"`:**
24
+ - Skip all user-confirmation gates throughout the workflow.
25
+ - In step-01-init: discover input documents automatically, proceed without asking the user to confirm or add files.
26
+ - In all subsequent steps: choose the recommended option at every decision point without prompting.
27
+ - Log each auto-selected choice inline so the output is auditable.
28
+ - This flag persists for the entire workflow invocation (all steps see it).
29
+
30
+ ---
31
+
21
32
  ## INITIALIZATION
22
33
 
23
34
  ### Configuration Loading
24
35
 
25
- Load config from `{project-root}/.rcode/config.json` and resolve:
36
+ Load config from `{project-root}/.rcode/config.yaml` and resolve:
26
37
 
27
38
  - `project_name`, `output_folder`, `planning_artifacts`, `user_name`
28
39
  - `communication_language`, `document_output_language`, `user_skill_level`
40
+ - `mode` — if `yolo`, treat as `--auto` for this entire invocation
29
41
  - `date` as system-generated current datetime
30
42
  - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}`
31
43
 
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: rcode-herdr-orchestration
3
+ description: Orchestrate parallel cld agents in herdr — fan-out or autonomous wave campaign.
4
+ triggers:
5
+ # English — single-shot orchestration
6
+ - "orchestrate agents"
7
+ - "run agents in herdr"
8
+ - "parallel audit"
9
+ - "spin up agents"
10
+ - "use herdr to do"
11
+ - "split work across panes"
12
+ - "fan out work in herdr"
13
+ - "multi-agent in herdr"
14
+ # English — autonomous campaign mode
15
+ - "autonomous fix campaign"
16
+ - "auto mode"
17
+ - "auto loop"
18
+ - "run waves of agents"
19
+ - "dispatch waves"
20
+ - "100+ commits"
21
+ - "keep working until done"
22
+ - "complete site audit and fix"
23
+ # Roman Urdu / Hindi
24
+ - "herdr mein chalao"
25
+ - "parallel agents lagao"
26
+ - "panes mein todo"
27
+ - "ek saath kai agents"
28
+ - "auto mode chalao"
29
+ - "waves mein fix karo"
30
+ - "campaign chalao"
31
+ # Arabic native
32
+ - "شغّل وكلاء بالتوازي"
33
+ - "وزّع العمل على عدة وكلاء"
34
+ - "استخدم herdr"
35
+ - "حملة إصلاح تلقائية"
36
+ - "موجات من الوكلاء"
37
+ - "وضع تلقائي"
38
+ user-invocable: true
39
+ ---
40
+
41
+ # rcode-herdr-orchestration
42
+
43
+ ## Overview
44
+
45
+ Run many Claude agents in parallel inside `herdr` (terminal agent multiplexer), monitor
46
+ them, and merge their work back safely.
47
+
48
+ Two modes: **single-shot** (bounded fan-out, one sitting, merge back done) and
49
+ **autonomous campaign** (100+ commits across waves with durable backlog and integration
50
+ branch). Both share the same golden rules and pane mechanics. See `references.md` for
51
+ the full campaign workflow and deep-dive rules.
52
+
53
+ **Do NOT use for a single quick task** — invoke the work directly without herdr for that.
54
+ Orchestration overhead (worktrees, panes, monitoring) only pays off across multiple
55
+ independent agents.
56
+
57
+ ---
58
+
59
+ ## Golden rules (NON-NEGOTIABLE — apply to BOTH modes)
60
+
61
+ 1. **Use `cld`, never `claude`.** `cld` is the alias for
62
+ `claude --dangerously-skip-permissions`. Send it via `herdr pane send-text` + `send-keys Enter`
63
+ so the shell alias resolves. Do NOT use `herdr pane run` for `cld`.
64
+ 2. **If you must invoke `claude` directly** (alias unavailable): pass
65
+ `--dangerously-skip-permissions` AND run in **interactive mode** (no `-p`/`--print`).
66
+ A non-interactive `claude -p` call is invisible to herdr.
67
+ 3. **One git worktree per agent.** Never share a working tree between orchestrated agents.
68
+ 4. **Work locally, commit locally. Never push to origin or deploy** during an
69
+ orchestration run unless the user explicitly authorizes it afterward.
70
+ 5. **The orchestrator NEVER claims a wakeup it cannot fire.** `ScheduleWakeup` only
71
+ fires when `/loop` is active — clarify the heartbeat path with the user first.
72
+ 6. **Ignore stray buffer text in panes.** Leftover user text at an idle prompt is NOT
73
+ an agent question — do not Enter it.
74
+
75
+ ---
76
+
77
+ ## herdr CLI reference
78
+
79
+ ```bash
80
+ herdr workspace list
81
+ herdr tab list --workspace <wid>
82
+ herdr tab create --workspace <wid> --label "X" --cwd PATH --focus
83
+ herdr tab close <tab_id> # IDs RENUMBER after a close — re-list
84
+ herdr pane list --workspace <wid> # pane_id, label, agent_status
85
+ herdr pane split <pane_id> --direction right|down --cwd PATH --no-focus
86
+ herdr pane rename <pane_id> "Label"
87
+ herdr pane read <pane_id> --source visible|recent --lines N --format text
88
+ herdr pane send-text <pane_id> "text" # types text (no newline)
89
+ herdr pane send-keys <pane_id> Enter|C-c|BSpace
90
+ ```
91
+
92
+ `agent_status`: `working`, `blocked` (waiting on question/permission), `idle`/`done`, `unknown`.
93
+
94
+ ---
95
+
96
+ ## MODE 1 — Single-shot orchestration
97
+
98
+ Use when work is bounded and can finish in one batch.
99
+
100
+ **Steps:**
101
+ 1. Decide N areas (4 per tab default — 2×2 grid). Each area = one agent = one worktree = one branch.
102
+ 2. Create worktrees: `git worktree add ../sm-worktrees/$A -b audit-$A master` for each area.
103
+ 3. Create tab + split panes, one per worktree.
104
+ 4. Launch `cld` in every pane (`send-text "cld"` + `send-keys Enter`). Sleep 7s after.
105
+ 5. Send each agent a self-contained prompt with worktree path, branch, and task.
106
+ - Audits: diagnose-only first. Fixes: incremental edits, no rewrites, commit each fix.
107
+ 6. Monitor: `herdr pane list` every ~2 min. Unblock stuck panes via `send-keys`/`send-text`.
108
+ 7. Merge back: `git add -f .planning/audits/*.md && git commit` inside each worktree, then
109
+ `git merge <branch> --no-edit` from main repo. Verify `pnpm tsc --noEmit` count unchanged.
110
+ 8. Cleanup: `git worktree remove --force` each tree. Close herdr tab (re-list IDs first).
111
+
112
+ ---
113
+
114
+ ## MODE 2 — Autonomous campaign (summary)
115
+
116
+ Use for `100+ commits`, `keep working until done`, `complete site audit and fix`.
117
+ Full Phase 0-3 protocol, integration-branch rules, wave cadence, and anti-patterns are
118
+ in **`references.md`** (sibling file). Key constraints:
119
+
120
+ - Maintain one `campaign-integration` branch; sub-agents fork from it, never master.
121
+ - Wave size: 3-5 agents, 10-15 min per wave. ScheduleWakeup ends EVERY turn.
122
+ - Phase 3: show user the full diff + ask explicitly how to land (PR / merge / squash / leave).
123
+ - Never push to origin master without an explicit yes — per campaign, not per session.
124
+
125
+ ---
126
+
127
+ ## When NOT to use this skill
128
+
129
+ - A single, quick, one-agent task — just run it directly on the main tree, no herdr.
130
+ - Anything the user wants to step through interactively — orchestration is for parallel,
131
+ hands-off batches.
132
+
133
+ ---
134
+
135
+ ## Output Format
136
+
137
+ **Single-shot:** one worktree per agent on `audit-<area>` branch, per-area audit doc at
138
+ `.planning/audits/AUDIT-<area>.md` (committed via `git add -f`), work merged back to
139
+ calling branch with commits preserved.
140
+
141
+ **Campaign:** durable backlog at `.planning/campaign/BACKLOG.md`, state log at
142
+ `.planning/campaign/STATE.md`, one long-lived `campaign-integration` branch accumulating
143
+ wave merges — master NOT touched until Phase 3 with explicit user consent.
144
+
145
+ In both modes, orchestrator chat output is concise wave/pane status only.
146
+
147
+ ---
148
+
149
+ ## Examples
150
+
151
+ **Happy path — single-shot 4-area parallel audit:**
152
+ User: "Fan out a security audit across the auth, API, DB, and frontend areas in parallel."
153
+ Orchestrator creates 4 worktrees on branches `audit-auth`, `audit-api`, `audit-db`,
154
+ `audit-frontend`. Sends each agent: "You are in `../sm-worktrees/auth` on branch
155
+ `audit-auth`. Diagnose security issues — report findings to `.planning/audits/AUDIT-auth.md`,
156
+ no code changes yet." Monitors until all idle, merges branches, confirms TSC count stable.
157
+
158
+ **Edge case — sub-agent goes silent past wave duration:**
159
+ If `herdr pane list` shows a pane stuck `working` past 25 min: `herdr pane read <id>` —
160
+ usually an AskUserQuestion blocking. Pick the safe option via `send-keys`. If still stuck
161
+ after another 10 min, `C-c` the pane, note the partial work, revert the branch, and
162
+ re-dispatch the item in the next wave.
163
+
164
+ **Negative example — when NOT to invoke this skill:**
165
+ User: "Fix the typo in README line 4." This is a one-line edit. Invoke herdr orchestration
166
+ for this is overkill — just edit the file directly on the current branch.
@@ -0,0 +1,136 @@
1
+ # rcode-herdr-orchestration — References
2
+
3
+ Overflow content split from SKILL.md per the 200-line budget. Read SKILL.md first.
4
+
5
+ ---
6
+
7
+ ## MODE 2 — Full campaign workflow
8
+
9
+ ### Extra hard rules (rules 7-11, in addition to the 6 golden rules in SKILL.md)
10
+
11
+ 7. **Durable backlog.** Commit `.planning/campaign/BACKLOG.md` at campaign start so the
12
+ campaign survives auto-compact. Don't keep the work list in conversation memory only.
13
+ 8. **Campaign integration branch.** Maintain ONE long-lived branch (default
14
+ `campaign-integration`). Sub-agents always fork from it — never directly from master.
15
+ Wave-N merges land on the integration branch; master only sees the campaign via a
16
+ single explicit merge at Phase 3. See `rules/integration-branch.md`.
17
+ 9. **Merge into the integration branch as you go.** Wave-N branches merge into the
18
+ integration branch BEFORE wave-(N+1) dispatches.
19
+ 10. **TSC stays at integration baseline.** Capture `pnpm tsc --noEmit | grep -c "error TS"`
20
+ at campaign start. Any wave that breaks the baseline is reverted before the next wave.
21
+ 11. **No push without explicit user consent — per campaign, not per session.** Per-change
22
+ consents earlier in the session do NOT extend.
23
+
24
+ ### Wave cadence
25
+
26
+ - **Wave size**: 3-5 sub-agents. More than 5 = harder to merge, more conflicts.
27
+ - **Wave duration**: 10-15 min target. If a wave runs past 25 min, peek for stuck agents.
28
+ - **Heartbeat**: orchestrator wakes every 10-15 min. Cache-window math: 270s, 720s, 1200s.
29
+
30
+ ### Backlog pipeline
31
+
32
+ ```
33
+ .planning/audits/AUDIT-*.md ──┐
34
+ grep TODO/FIXME/HACK ──┼──▶ .planning/campaign/BACKLOG.md ──▶ wave-1, wave-2, …
35
+ existing pending P1/P2 items ──┘ ▲
36
+
37
+ wave-N findings append back ↑
38
+ ```
39
+
40
+ ### Phase 0 — Initialize (one-time)
41
+
42
+ 1. Confirm baseline: `git branch --show-current` = master, clean tree, capture TSC count.
43
+ 2. Create the campaign integration branch:
44
+ ```bash
45
+ git checkout -b campaign-integration master
46
+ ```
47
+ 3. Mine the backlog into `.planning/campaign/BACKLOG.md` from audit docs +
48
+ `grep -rn "TODO\|FIXME\|HACK\|XXX"`. Commit it on the integration branch.
49
+ 4. Start the bash heartbeat (`bash templates/heartbeat.sh &`).
50
+
51
+ ### Phase 1 — Wave dispatch
52
+
53
+ 1. Read next 3-5 items from BACKLOG.md → move to STATE.md "In flight (wave N)".
54
+ 2. Create worktree + branch **forked from integration branch**:
55
+ ```bash
56
+ git worktree add ../sm-worktrees/camp-<area> -b campaign-<area> campaign-integration
57
+ ```
58
+ 3. Create/reuse herdr tab, split panes, launch `cld --model sonnet` in each.
59
+ 4. Send each agent a wave prompt (use `templates/wave-prompt.md`):
60
+ - Worktree path + branch + parent = `campaign-integration`
61
+ - Specific backlog item + audit doc reference
62
+ - "Do not push. Do not merge. Do not touch master or the integration branch directly."
63
+ 5. **End the turn with ScheduleWakeup. Always.**
64
+
65
+ ### Phase 2 — Heartbeat loop (every 10-15 min)
66
+
67
+ 1. `herdr pane list` — count panes in `working` vs `idle`/`done`.
68
+ 2. For every branch with new commits: merge into the integration branch (NOT master).
69
+ 3. After each merge: `pnpm tsc --noEmit` regression check. Bumped count = revert from integration.
70
+ 4. Do NOT push to origin master. Do NOT touch master.
71
+ 5. Move shipped items from STATE.md "in flight" → "shipped".
72
+ 6. If BACKLOG.md still has items → dispatch wave-(N+1). Else → Phase 3.
73
+ 7. **End the turn with ScheduleWakeup** while any pane is working OR BACKLOG.md is non-empty.
74
+
75
+ ### Phase 3 — Drain & Land
76
+
77
+ 1. When BACKLOG.md empty AND all panes idle: kill heartbeat bash loop.
78
+ 2. Show user the full diff of integration branch vs master.
79
+ 3. Ask explicitly: "Campaign work is on `campaign-integration` (N commits ahead of
80
+ master). How do you want to land it?" Options:
81
+ - PR: `gh pr create --base master --head campaign-integration`
82
+ - Merge to master locally (explicit yes required)
83
+ - Squash-merge for one tidy commit
84
+ - Leave the integration branch for human review
85
+ 4. Never `git push origin master` without an explicit yes.
86
+
87
+ ---
88
+
89
+ ## Key files (campaign mode)
90
+
91
+ | File | Purpose |
92
+ |------|---------|
93
+ | `.planning/campaign/BACKLOG.md` | Durable work list. Committed at campaign start. |
94
+ | `.planning/campaign/STATE.md` | Waves shipped, in-flight, TSC drift per wave. |
95
+ | `.planning/campaign/HEARTBEAT` | `touch`ed by bash loop every 30s — mtime proves orchestrator alive. |
96
+ | `templates/BACKLOG-template.md` | Starter for the backlog file. |
97
+ | `templates/STATE-template.md` | Starter for the state file. |
98
+ | `templates/heartbeat.sh` | Background heartbeat script template. |
99
+ | `templates/wave-prompt.md` | Per-agent prompt boilerplate. |
100
+
101
+ ---
102
+
103
+ ## Rules deep-dive
104
+
105
+ - **`rules/integration-branch.md`** ← READ FIRST for campaign mode
106
+ - `rules/orchestrator-rhythm.md` — heartbeat / ScheduleWakeup decision tree
107
+ - `rules/wave-design.md` — wave sizing
108
+ - `rules/backlog-building.md` — audit mining, TODO scan, dedup
109
+ - `rules/merge-strategy.md` — TSC gate
110
+ - `rules/composition-with-herdr.md` — how campaign mode layers on single-shot mechanics
111
+
112
+ ---
113
+
114
+ ## Gotchas (field-tested, both modes)
115
+
116
+ - **herdr renumbers tab IDs on close.** Always re-list before the next close.
117
+ - **Parallel agents tangle branches** if they share a working tree — one worktree per agent always.
118
+ - **`.planning/` is often gitignored** — audit docs need `git add -f`.
119
+ - **`make brain`'s `git push` is `|| true`** — it silently fails on a diverged branch.
120
+ Never assume a deploy shipped your local commits without checking.
121
+ - **Diverged local vs origin master** is the #1 risk after a long parallel run. Do NOT
122
+ auto-resolve conflicts unattended — surface to the user.
123
+ - Capture extra `sleep` after launching `cld` — it takes ~5-7s to boot.
124
+
125
+ ---
126
+
127
+ ## Anti-patterns (campaign mode)
128
+
129
+ | Failure | Prevented by |
130
+ |---|---|
131
+ | Cross-wave merge conflicts pile up | Integration branch — every wave inherits prior waves' work |
132
+ | Orchestrator goes silent mid-campaign | Hard rule 5 + heartbeat template |
133
+ | Lost backlog after auto-compact | Phase 0 commits BACKLOG.md on integration branch |
134
+ | Silent push to master without consent | Hard rule 11 + Phase 3 ask-before-land |
135
+ | TSC drift compounds | Phase 2 regression check + revert from integration branch |
136
+ | Integration branch never lands | Phase 3 mandatory "how to land it" question |
@@ -0,0 +1,113 @@
1
+ # Backlog Building
2
+
3
+ How to build a durable, prioritized, committed campaign backlog.
4
+
5
+ ## Purpose
6
+ The backlog is the campaign's spine. Without a durable file-on-disk backlog, an auto-compact erases the work plan and the campaign collapses. This rule encodes the build + maintain pipeline.
7
+
8
+ ## Rules
9
+
10
+ ### Source priority (highest signal first)
11
+
12
+ 1. **Existing audit docs** at `.planning/audits/AUDIT-*.md` — these are human-curated and already prioritized P1/P2. Most reliable source.
13
+ 2. **`/audit-fix` skill outputs** if available — Rihal projects often have these pre-generated.
14
+ 3. **Pending items** in the project's CHANGELOG / ROADMAP / `.planning/state.md`.
15
+ 4. **Code-level TODOs**: `grep -rn -E "// *(TODO|FIXME|HACK|XXX)[: ]"` in `server/` + `src/` — lowest signal, often stale.
16
+ 5. **CI failures / open GitHub issues** — only if explicit user request.
17
+
18
+ ### Backlog format
19
+
20
+ ```markdown
21
+ # CAMPAIGN BACKLOG
22
+ Generated: <ISO timestamp>
23
+ Baseline TSC errors: <count>
24
+
25
+ ## Open items
26
+ - [ ] **<area>** (P<priority>): <one-line description>. Source: <audit-doc>:<line>
27
+ - [ ] **<area>** (P<priority>): …
28
+
29
+ ## In flight (wave N)
30
+ - [~] **<area>**: assigned to pane <pane-id>, branch <branch>, started <time>
31
+
32
+ ## Shipped
33
+ - [x] **<area>**: commit <sha>, wave <N>, finished <time>
34
+ ```
35
+
36
+ ### Dedup rules
37
+ Before adding an item to the backlog, check:
38
+ - Is there an existing master commit covering it? `git log --oneline | grep -i <keyword>`
39
+ - Is there an in-flight branch covering it? `git branch | grep -i <keyword>`
40
+ - Is it identical to another backlog item with a different file:line? Merge them.
41
+
42
+ ### Maintenance during the campaign
43
+ - Every wave merge: move items from "In flight" → "Shipped" with the commit SHA.
44
+ - Every wave dispatch: move items from "Open" → "In flight" with pane + branch.
45
+ - New findings from a sub-agent's audit phase: append to "Open" with source attribution.
46
+ - Item rejected by a wave-agent (out of scope, blocked, etc.): mark `[skip]` with reason — do not delete.
47
+
48
+ ### Commit the backlog
49
+ ```bash
50
+ git add -f .planning/campaign/BACKLOG.md .planning/campaign/STATE.md
51
+ git commit -m "chore(campaign): backlog snapshot at wave <N>"
52
+ ```
53
+ The `-f` is required if `.planning/` is gitignored (common in Rihal projects).
54
+
55
+ ## Examples
56
+
57
+ ### Building backlog from audit docs
58
+
59
+ ```bash
60
+ {
61
+ echo "# CAMPAIGN BACKLOG"
62
+ echo "Generated: $(date -u +%FT%TZ)"
63
+ echo "Baseline TSC: $(pnpm tsc --noEmit 2>&1 | grep -c 'error TS')"
64
+ echo
65
+ echo "## Open items"
66
+ for f in .planning/audits/AUDIT-*.md; do
67
+ area=$(basename "$f" .md | sed 's/^AUDIT-//')
68
+ pending=$(grep -nE "(⏳|^- \[ \]|^### P[12])" "$f" 2>/dev/null | head -5)
69
+ [ -n "$pending" ] && echo "$pending" | sed "s|^|- [ ] **$area** (from $f) |"
70
+ done
71
+ } > .planning/campaign/BACKLOG.md
72
+ ```
73
+
74
+ ### State transition
75
+
76
+ ```diff
77
+ - [ ] **call-update-flow** (P1): add Sentry capture on EventBus handler errors. Source: AUDIT-call-update-flow.md:142
78
+ + [~] **call-update-flow**: assigned to pane w65..-8, branch campaign-call-update-flow, started 2026-05-26T14:32Z
79
+ ```
80
+ later:
81
+ ```diff
82
+ - [~] **call-update-flow**: assigned to pane w65..-8, branch campaign-call-update-flow, started 2026-05-26T14:32Z
83
+ + [x] **call-update-flow**: commit 40b908d9, wave 2, finished 2026-05-26T14:51Z
84
+ ```
85
+
86
+ ## Anti-Patterns
87
+
88
+ ### Backlog only in conversation memory
89
+
90
+ **Problem**: Auto-compact wipes it; the next turn can't resume.
91
+ **Instead**: File on disk, committed.
92
+
93
+ ### Massive backlog dumped once
94
+
95
+ **Problem**: A 200-item backlog overwhelms wave selection — orchestrator picks badly because it can't see the whole context.
96
+ **Instead**: Build in chunks. Top 20-30 items as "Open"; lower-priority items as a footnote or separate file.
97
+
98
+ ### Mining TODOs from test files
99
+
100
+ **Problem**: Test TODOs are often "this case is unimplemented" — they're test scaffolding, not real bugs.
101
+ **Instead**: `grep ... | grep -v "\.test\.\|\.spec\."` to filter them out.
102
+
103
+ ### Skipping dedup
104
+
105
+ **Problem**: Same bug fixed 3 times by 3 waves because none knew the others were working on it.
106
+ **Instead**: Always check master log + in-flight branches before adding.
107
+
108
+ ## Related
109
+ - `wave-design.md` — backlog drives wave composition
110
+ - `composition-with-herdr.md` — STATE.md ties to herdr pane labels
111
+
112
+ ## Changelog
113
+ - 2026-05-26: Initial.
@@ -0,0 +1,85 @@
1
+ # Composition with herdr-orchestration
2
+
3
+ This skill is a layer ON TOP OF `herdr-orchestration`. It does not replace it.
4
+
5
+ ## Purpose
6
+ Make the boundary explicit so the orchestrator never reinvents herdr mechanics inside this skill.
7
+
8
+ ## Rules
9
+
10
+ ### Always read herdr-orchestration first
11
+ At the start of any campaign session, load the `herdr-orchestration` skill BEFORE dispatching the first wave. Its golden rules (use `cld` not `claude`, worktree per agent, no push during run, interactive mode required) apply to every wave.
12
+
13
+ ### Division of responsibility
14
+
15
+ | Concern | Skill that owns it |
16
+ |---|---|
17
+ | Worktree creation | herdr-orchestration |
18
+ | Pane splitting + naming | herdr-orchestration |
19
+ | `cld --model sonnet` launch via shell alias | herdr-orchestration |
20
+ | Sending prompts via `send-text` + `send-keys` | herdr-orchestration |
21
+ | Polling `herdr pane list` for status | herdr-orchestration |
22
+ | Reading stale buffer text, ignoring stray "merge to master" | herdr-orchestration |
23
+ | Conflict resolution (superset rule) | herdr-orchestration |
24
+ | **Wave cadence (when to dispatch / merge / pause)** | **this skill** |
25
+ | **Backlog management (BACKLOG.md, STATE.md)** | **this skill** |
26
+ | **Heartbeat (ScheduleWakeup + bash file)** | **this skill** |
27
+ | **TSC baseline gate** | **this skill** |
28
+ | **Push-to-origin policy** | **this skill** |
29
+
30
+ ### Pane status mapping → campaign action
31
+
32
+ | herdr pane status | Campaign action |
33
+ |---|---|
34
+ | `working` | Leave alone. Re-check on next heartbeat. |
35
+ | `blocked` | Read the pane, answer the menu (per herdr-orchestration), continue. |
36
+ | `idle` with commits ahead of master | Merge candidate — try to merge this wave. |
37
+ | `idle` with 0 commits | Either still warming up or wave failed — peek and decide. |
38
+ | `done` | Same as idle-with-commits. Merge if any, then clean up. |
39
+ | `unknown` | Recently created; wait one heartbeat. |
40
+
41
+ ### Worktree path convention
42
+ Use `../sm-worktrees/camp-<area>` (project-relative `../sm-worktrees`). This matches the convention in herdr-orchestration examples and keeps a single shared place for all campaign worktrees.
43
+
44
+ ### Branch naming convention
45
+ - Wave fix branches: `campaign-<area>` (e.g. `campaign-crm-pipeline`)
46
+ - Rebase pass branches: `rebase-<area>`
47
+ - Post-merge cleanup: delete the branch after push lands
48
+
49
+ ## Examples
50
+
51
+ ### Correct skill load order (start of session)
52
+
53
+ ```
54
+ 1. Load herdr-orchestration (read SKILL.md, understand golden rules)
55
+ 2. Load autonomous-fix-campaign (this skill — wave cadence + backlog)
56
+ 3. Apply both: herdr mechanics for the per-wave dispatch, this skill for the campaign loop
57
+ ```
58
+
59
+ ### Correct cld invocation (delegated to herdr-orchestration)
60
+
61
+ ```
62
+ herdr pane send-text $P "cld --model sonnet"
63
+ herdr pane send-keys $P Enter
64
+ ```
65
+ NOT `claude -p` (would be invisible to herdr; see herdr-orchestration golden rule 2).
66
+
67
+ ## Anti-Patterns
68
+
69
+ ### Reimplementing herdr mechanics inside a campaign prompt
70
+
71
+ **Problem**: Drift between this skill and the upstream herdr-orchestration rules.
72
+ **Instead**: Reference herdr-orchestration; do not duplicate.
73
+
74
+ ### Skipping the herdr golden rules because "the campaign is special"
75
+
76
+ **Problem**: Campaigns still need worktree isolation, still need `cld` alias, still need to ignore stray buffer text.
77
+ **Instead**: Treat herdr-orchestration's rules as inviolable.
78
+
79
+ ## Related
80
+ - `~/.claude/skills/herdr-orchestration/SKILL.md` (upstream skill)
81
+ - `orchestrator-rhythm.md` (this skill — campaign cadence)
82
+ - `merge-strategy.md` (this skill — conflict resolution delegates to herdr)
83
+
84
+ ## Changelog
85
+ - 2026-05-26: Initial.