@sienklogic/plan-build-run 2.3.1 → 2.4.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +54 -20
  3. package/dashboard/src/services/dashboard.service.js +24 -1
  4. package/dashboard/src/services/milestone.service.js +68 -17
  5. package/package.json +1 -1
  6. package/plugins/copilot-pbr/CHANGELOG.md +19 -0
  7. package/plugins/copilot-pbr/README.md +129 -0
  8. package/plugins/copilot-pbr/agents/codebase-mapper.agent.md +109 -0
  9. package/plugins/copilot-pbr/agents/debugger.agent.md +169 -0
  10. package/plugins/copilot-pbr/agents/executor.agent.md +237 -0
  11. package/plugins/copilot-pbr/agents/general.agent.md +88 -0
  12. package/plugins/copilot-pbr/agents/integration-checker.agent.md +88 -0
  13. package/plugins/copilot-pbr/agents/plan-checker.agent.md +199 -0
  14. package/plugins/copilot-pbr/agents/planner.agent.md +181 -0
  15. package/plugins/copilot-pbr/agents/researcher.agent.md +163 -0
  16. package/plugins/copilot-pbr/agents/synthesizer.agent.md +102 -0
  17. package/plugins/copilot-pbr/agents/verifier.agent.md +194 -0
  18. package/plugins/copilot-pbr/hooks/hooks.json +144 -0
  19. package/plugins/copilot-pbr/plugin.json +30 -0
  20. package/plugins/copilot-pbr/references/agent-anti-patterns.md +25 -0
  21. package/plugins/copilot-pbr/references/agent-interactions.md +135 -0
  22. package/plugins/copilot-pbr/references/agent-teams.md +55 -0
  23. package/plugins/copilot-pbr/references/checkpoints.md +158 -0
  24. package/plugins/copilot-pbr/references/common-bug-patterns.md +14 -0
  25. package/plugins/copilot-pbr/references/config-reference.md +442 -0
  26. package/plugins/copilot-pbr/references/continuation-format.md +213 -0
  27. package/plugins/copilot-pbr/references/deviation-rules.md +113 -0
  28. package/plugins/copilot-pbr/references/git-integration.md +227 -0
  29. package/plugins/copilot-pbr/references/integration-patterns.md +118 -0
  30. package/plugins/copilot-pbr/references/model-profiles.md +100 -0
  31. package/plugins/copilot-pbr/references/model-selection.md +32 -0
  32. package/plugins/copilot-pbr/references/pbr-rules.md +194 -0
  33. package/plugins/copilot-pbr/references/plan-authoring.md +182 -0
  34. package/plugins/copilot-pbr/references/plan-format.md +288 -0
  35. package/plugins/copilot-pbr/references/planning-config.md +214 -0
  36. package/plugins/copilot-pbr/references/questioning.md +215 -0
  37. package/plugins/copilot-pbr/references/reading-verification.md +128 -0
  38. package/plugins/copilot-pbr/references/stub-patterns.md +161 -0
  39. package/plugins/copilot-pbr/references/subagent-coordination.md +120 -0
  40. package/plugins/copilot-pbr/references/ui-formatting.md +462 -0
  41. package/plugins/copilot-pbr/references/verification-patterns.md +199 -0
  42. package/plugins/copilot-pbr/references/wave-execution.md +96 -0
  43. package/plugins/copilot-pbr/rules/pbr-workflow.mdc +48 -0
  44. package/plugins/copilot-pbr/setup.ps1 +93 -0
  45. package/plugins/copilot-pbr/setup.sh +92 -0
  46. package/plugins/copilot-pbr/skills/begin/SKILL.md +566 -0
  47. package/plugins/copilot-pbr/skills/begin/templates/PROJECT.md.tmpl +34 -0
  48. package/plugins/copilot-pbr/skills/begin/templates/REQUIREMENTS.md.tmpl +19 -0
  49. package/plugins/copilot-pbr/skills/begin/templates/STATE.md.tmpl +50 -0
  50. package/plugins/copilot-pbr/skills/begin/templates/config.json.tmpl +64 -0
  51. package/plugins/copilot-pbr/skills/begin/templates/researcher-prompt.md.tmpl +20 -0
  52. package/plugins/copilot-pbr/skills/begin/templates/roadmap-prompt.md.tmpl +31 -0
  53. package/plugins/copilot-pbr/skills/begin/templates/synthesis-prompt.md.tmpl +17 -0
  54. package/plugins/copilot-pbr/skills/build/SKILL.md +901 -0
  55. package/plugins/copilot-pbr/skills/config/SKILL.md +253 -0
  56. package/plugins/copilot-pbr/skills/continue/SKILL.md +159 -0
  57. package/plugins/copilot-pbr/skills/dashboard/SKILL.md +31 -0
  58. package/plugins/copilot-pbr/skills/debug/SKILL.md +511 -0
  59. package/plugins/copilot-pbr/skills/debug/templates/continuation-prompt.md.tmpl +17 -0
  60. package/plugins/copilot-pbr/skills/debug/templates/initial-investigation-prompt.md.tmpl +28 -0
  61. package/plugins/copilot-pbr/skills/discuss/SKILL.md +343 -0
  62. package/plugins/copilot-pbr/skills/discuss/templates/CONTEXT.md.tmpl +62 -0
  63. package/plugins/copilot-pbr/skills/discuss/templates/decision-categories.md +10 -0
  64. package/plugins/copilot-pbr/skills/do/SKILL.md +66 -0
  65. package/plugins/copilot-pbr/skills/explore/SKILL.md +374 -0
  66. package/plugins/copilot-pbr/skills/health/SKILL.md +218 -0
  67. package/plugins/copilot-pbr/skills/health/templates/check-pattern.md.tmpl +31 -0
  68. package/plugins/copilot-pbr/skills/health/templates/output-format.md.tmpl +64 -0
  69. package/plugins/copilot-pbr/skills/help/SKILL.md +152 -0
  70. package/plugins/copilot-pbr/skills/import/SKILL.md +498 -0
  71. package/plugins/copilot-pbr/skills/milestone/SKILL.md +703 -0
  72. package/plugins/copilot-pbr/skills/milestone/templates/audit-report.md.tmpl +49 -0
  73. package/plugins/copilot-pbr/skills/milestone/templates/stats-file.md.tmpl +31 -0
  74. package/plugins/copilot-pbr/skills/note/SKILL.md +227 -0
  75. package/plugins/copilot-pbr/skills/pause/SKILL.md +246 -0
  76. package/plugins/copilot-pbr/skills/pause/templates/continue-here.md.tmpl +72 -0
  77. package/plugins/copilot-pbr/skills/plan/SKILL.md +649 -0
  78. package/plugins/copilot-pbr/skills/plan/templates/checker-prompt.md.tmpl +22 -0
  79. package/plugins/copilot-pbr/skills/plan/templates/gap-closure-prompt.md.tmpl +33 -0
  80. package/plugins/copilot-pbr/skills/plan/templates/planner-prompt.md.tmpl +39 -0
  81. package/plugins/copilot-pbr/skills/plan/templates/researcher-prompt.md.tmpl +20 -0
  82. package/plugins/copilot-pbr/skills/plan/templates/revision-prompt.md.tmpl +24 -0
  83. package/plugins/copilot-pbr/skills/quick/SKILL.md +351 -0
  84. package/plugins/copilot-pbr/skills/resume/SKILL.md +399 -0
  85. package/plugins/copilot-pbr/skills/review/SKILL.md +648 -0
  86. package/plugins/copilot-pbr/skills/review/templates/debugger-prompt.md.tmpl +61 -0
  87. package/plugins/copilot-pbr/skills/review/templates/gap-planner-prompt.md.tmpl +41 -0
  88. package/plugins/copilot-pbr/skills/review/templates/verifier-prompt.md.tmpl +116 -0
  89. package/plugins/copilot-pbr/skills/scan/SKILL.md +301 -0
  90. package/plugins/copilot-pbr/skills/scan/templates/mapper-prompt.md.tmpl +202 -0
  91. package/plugins/copilot-pbr/skills/setup/SKILL.md +250 -0
  92. package/plugins/copilot-pbr/skills/shared/commit-planning-docs.md +36 -0
  93. package/plugins/copilot-pbr/skills/shared/config-loading.md +103 -0
  94. package/plugins/copilot-pbr/skills/shared/context-budget.md +41 -0
  95. package/plugins/copilot-pbr/skills/shared/context-loader-task.md +87 -0
  96. package/plugins/copilot-pbr/skills/shared/digest-select.md +80 -0
  97. package/plugins/copilot-pbr/skills/shared/domain-probes.md +126 -0
  98. package/plugins/copilot-pbr/skills/shared/error-reporting.md +80 -0
  99. package/plugins/copilot-pbr/skills/shared/gate-prompts.md +389 -0
  100. package/plugins/copilot-pbr/skills/shared/phase-argument-parsing.md +46 -0
  101. package/plugins/copilot-pbr/skills/shared/progress-display.md +54 -0
  102. package/plugins/copilot-pbr/skills/shared/revision-loop.md +82 -0
  103. package/plugins/copilot-pbr/skills/shared/state-loading.md +63 -0
  104. package/plugins/copilot-pbr/skills/shared/state-update.md +162 -0
  105. package/plugins/copilot-pbr/skills/shared/universal-anti-patterns.md +34 -0
  106. package/plugins/copilot-pbr/skills/status/SKILL.md +362 -0
  107. package/plugins/copilot-pbr/skills/todo/SKILL.md +256 -0
  108. package/plugins/copilot-pbr/templates/CONTEXT.md.tmpl +53 -0
  109. package/plugins/copilot-pbr/templates/INTEGRATION-REPORT.md.tmpl +152 -0
  110. package/plugins/copilot-pbr/templates/RESEARCH-SUMMARY.md.tmpl +98 -0
  111. package/plugins/copilot-pbr/templates/ROADMAP.md.tmpl +41 -0
  112. package/plugins/copilot-pbr/templates/SUMMARY.md.tmpl +82 -0
  113. package/plugins/copilot-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  114. package/plugins/copilot-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  115. package/plugins/copilot-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  116. package/plugins/copilot-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  117. package/plugins/copilot-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  118. package/plugins/copilot-pbr/templates/codebase/STACK.md.tmpl +78 -0
  119. package/plugins/copilot-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  120. package/plugins/copilot-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  121. package/plugins/copilot-pbr/templates/continue-here.md.tmpl +74 -0
  122. package/plugins/copilot-pbr/templates/prompt-partials/phase-project-context.md.tmpl +38 -0
  123. package/plugins/copilot-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  124. package/plugins/copilot-pbr/templates/research/STACK.md.tmpl +71 -0
  125. package/plugins/copilot-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  126. package/plugins/copilot-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  127. package/plugins/copilot-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  128. package/plugins/copilot-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  129. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +13 -3
  130. package/plugins/cursor-pbr/skills/dashboard/SKILL.md +14 -4
  131. package/plugins/cursor-pbr/skills/milestone/SKILL.md +10 -7
  132. package/plugins/cursor-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  133. package/plugins/cursor-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  134. package/plugins/cursor-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  135. package/plugins/cursor-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  136. package/plugins/cursor-pbr/templates/codebase/STACK.md.tmpl +78 -0
  137. package/plugins/cursor-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  138. package/plugins/cursor-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  139. package/plugins/cursor-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  140. package/plugins/cursor-pbr/templates/research/STACK.md.tmpl +71 -0
  141. package/plugins/cursor-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  142. package/plugins/cursor-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  143. package/plugins/cursor-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  144. package/plugins/cursor-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  145. package/plugins/pbr/.claude-plugin/plugin.json +7 -2
  146. package/plugins/pbr/skills/milestone/SKILL.md +10 -7
@@ -0,0 +1,100 @@
1
+ <!-- canonical: ../../pbr/references/model-profiles.md -->
2
+ # Model Profiles Reference
3
+
4
+ How Plan-Build-Run maps agents to models and how to configure model selection.
5
+
6
+ ---
7
+
8
+ ## Agent-to-Model Mapping
9
+
10
+ Each Plan-Build-Run agent has a default model specified in its agent definition frontmatter (`model:` field). These defaults are overridden by the `models` section of `config.json`.
11
+
12
+ ### Default Agent Models
13
+
14
+ | Agent | Default Model | Rationale |
15
+ |-------|---------------|-----------|
16
+ | `researcher` | `sonnet` | Research requires strong reasoning for source evaluation and synthesis |
17
+ | `planner` | `inherit` | Planning is complex; inherits the session's primary model |
18
+ | `executor` | `inherit` | Execution needs the full capability of the session model |
19
+ | `verifier` | `sonnet` | Verification needs solid reasoning but not the heaviest model |
20
+ | `integration-checker` | `sonnet` | Cross-phase analysis requires strong pattern matching |
21
+ | `plan-checker` | `sonnet` | Plan quality analysis needs good analytical capability |
22
+ | `debugger` | `inherit` | Debugging is complex; inherits session model |
23
+ | `codebase-mapper` | `sonnet` | Codebase analysis requires thorough reasoning |
24
+ | `synthesizer` | `haiku` | Synthesis is mechanical combination; speed over depth |
25
+ | `general` | `inherit` | Lightweight utility; inherits session model |
26
+
27
+ The `inherit` value means the agent uses whatever model the parent session is running (typically the user's configured Claude model).
28
+
29
+ ---
30
+
31
+ ## Model Profile Presets
32
+
33
+ The `/pbr:config model-profile {preset}` command sets all agent models at once using a preset:
34
+
35
+ | Profile | Researcher | Planner | Executor | Verifier | Int-Checker | Debugger | Mapper | Synthesizer |
36
+ |---------|-----------|---------|----------|----------|-------------|----------|--------|-------------|
37
+ | `quality` | opus | opus | opus | opus | sonnet | opus | sonnet | sonnet |
38
+ | `balanced` | sonnet | inherit | inherit | sonnet | sonnet | inherit | sonnet | haiku |
39
+ | `budget` | haiku | haiku | haiku | haiku | haiku | haiku | haiku | haiku |
40
+ | `adaptive` | sonnet | sonnet | inherit | sonnet | haiku | inherit | haiku | haiku |
41
+
42
+ ### Preset Descriptions
43
+
44
+ - **quality**: Maximum capability across all agents. Best results but highest token cost. Use for critical projects or complex architectures.
45
+ - **balanced**: The default preset. Front-loads intelligence in research and verification, inherits session model for planning and execution. Good general-purpose choice.
46
+ - **budget**: All agents use haiku. Fastest and cheapest, but reduced quality for complex reasoning tasks. Suitable for well-defined, mechanical work.
47
+ - **adaptive**: Front-loads intelligence in research and planning (where decisions matter most), uses lighter models for mechanical execution and verification. Good cost-quality tradeoff.
48
+
49
+ ---
50
+
51
+ ## Configuring Models
52
+
53
+ ### Per-Agent Configuration
54
+
55
+ Set an individual agent's model via `/pbr:config`:
56
+
57
+ ```
58
+ /pbr:config model executor sonnet
59
+ /pbr:config model verifier opus
60
+ ```
61
+
62
+ Or edit `config.json` directly:
63
+
64
+ ```json
65
+ {
66
+ "models": {
67
+ "researcher": "sonnet",
68
+ "planner": "inherit",
69
+ "executor": "inherit",
70
+ "verifier": "sonnet",
71
+ "integration_checker": "sonnet",
72
+ "debugger": "inherit",
73
+ "mapper": "sonnet",
74
+ "synthesizer": "haiku"
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### Valid Model Values
80
+
81
+ | Value | Meaning |
82
+ |-------|---------|
83
+ | `sonnet` | Claude Sonnet (4.5/4.6) -- balanced speed and capability |
84
+ | `opus` | Claude Opus (4.6) -- highest capability, slower |
85
+ | `haiku` | Claude Haiku (4.5) -- fastest, lower capability |
86
+ | `inherit` | Use the session's primary model (whatever the user is running) |
87
+
88
+ Note: Claude Code 2.1.45+ supports Sonnet 4.6. Model values are abstract names — Claude Code resolves them to the latest available version.
89
+
90
+ ---
91
+
92
+ ## Model Selection in Skill Orchestration
93
+
94
+ Skills that spawn subagents use the `model` parameter in `Task()` calls. Some skills hardcode a lighter model for specific tasks:
95
+
96
+ - **Build skill**: Spawns inline verifiers with `model: "haiku"` for quick spot-checks
97
+ - **Build skill**: Spawns codebase mapper updates with `model: "haiku"` for incremental map refreshes
98
+ - **Plan skill**: Uses the configured `planner` model for main planning work
99
+
100
+ The `subagent_type` parameter automatically loads the agent definition, and the model from `config.json` takes precedence over the agent's default `model:` frontmatter field.
@@ -0,0 +1,32 @@
1
+ <!-- canonical: ../../pbr/references/model-selection.md -->
2
+ # Model Selection Reference
3
+
4
+ Plan-Build-Run uses adaptive model selection to balance cost and capability.
5
+
6
+ ## How It Works
7
+
8
+ 1. The planner annotates each task with `complexity="simple|medium|complex"`
9
+ 2. The build skill maps complexity to a model via `config.models.complexity_map`
10
+ 3. The executor agent is spawned with the selected model
11
+
12
+ ## Default Mapping
13
+
14
+ | Complexity | Model | Rationale |
15
+ |-----------|-------|-----------|
16
+ | simple | haiku | Fast, cheap — sufficient for mechanical changes |
17
+ | medium | sonnet | Good balance for standard feature work |
18
+ | complex | inherit | Uses session model — typically Opus for critical work |
19
+
20
+ ## Override Mechanisms
21
+
22
+ 1. **Per-task override**: Add `model="sonnet"` attribute to task XML in PLAN.md
23
+ 2. **Config override**: Set `models.complexity_map` in config.json to change defaults
24
+ 3. **Agent-level override**: Set `models.executor` in config.json to force a single model for all executor spawns (disables adaptive selection)
25
+
26
+ ## Heuristics
27
+
28
+ The planner uses these signals to determine complexity:
29
+ - File count and types
30
+ - Task name keywords
31
+ - Dependency count
32
+ - Whether the task introduces new patterns vs. follows established ones
@@ -0,0 +1,194 @@
1
+ <!-- canonical: ../../pbr/references/pbr-rules.md -->
2
+ # Plan-Build-Run Rules
3
+
4
+ Authoritative rules for all Plan-Build-Run skills, agents, hooks, and workflows.
5
+ Condensed from the 3,100-line `docs/DEVELOPMENT-GUIDE.md`. When in doubt, these rules govern.
6
+
7
+ ---
8
+
9
+ ## Philosophy
10
+
11
+ 1. **Context is precious.** The orchestrator stays lean (~15% usage). Delegate heavy work to subagents.
12
+ 2. **State lives on disk.** Skills and agents communicate through `.planning/` files, not messages.
13
+ 3. **Agents are black boxes.** Clear input/output contracts. Agents never read other agent definitions.
14
+ 4. **Gates provide safety.** Users control pace via config toggles. Never skip a gate.
15
+ 5. **One task, one commit.** Atomic commits for clean history and easy rollback.
16
+ 6. **Cross-platform always.** `path.join()`, CommonJS, test on Windows/macOS/Linux.
17
+ 7. **Test everything.** 70% coverage minimum. All 9 CI matrix combinations must pass.
18
+ 8. **PLAN-BUILD-RUN branding only.** Always use `PLAN-BUILD-RUN ►` prefix in banners.
19
+
20
+ ---
21
+
22
+ ## Context Budget
23
+
24
+ 9. Target 15% orchestrator context usage. Warn user at 30%.
25
+ 10. **Never** read agent definitions (`agents/*.md`) in the orchestrator — `subagent_type` auto-loads them.
26
+ 11. **Never** inline large files into `Task()` prompts — tell agents to read files from disk.
27
+ 12. **Never** read full subagent output — read frontmatter only (first 10-20 lines).
28
+ 13. Read STATE.md and config.json fully. Read ROADMAP.md by section. Read PLAN.md/SUMMARY.md/VERIFICATION.md frontmatter only.
29
+ 14. Use the `limit` parameter on Read to restrict line counts.
30
+ 15. Proactively suggest `/pbr:pause` when context gets heavy — before compaction, not after.
31
+
32
+ ---
33
+
34
+ ## State Management
35
+
36
+ 16. STATE.md is the **single source of truth** for current position.
37
+ 17. **Never** infer current phase from directory listings, git log, or conversation history.
38
+ 18. Always read STATE.md before making state-dependent decisions.
39
+ 19. Update STATE.md at: begin, plan, build, review, pause, continue, milestone.
40
+ 20. **Never** commit STATE.md mid-skill — hooks handle session persistence.
41
+ 21. Agents write artifacts (SUMMARY.md, VERIFICATION.md). Only the orchestrator writes STATE.md.
42
+ 22. Every ROADMAP.md phase must have a matching `.planning/phases/` directory, and vice versa.
43
+ 23. config.json is validated against `scripts/config-schema.json` on load.
44
+
45
+ ---
46
+
47
+ ## Agent Spawning
48
+
49
+ 24. Always use `subagent_type: "pbr:{name}"` to spawn agents.
50
+ 25. Pass file paths to agents, not file contents.
51
+ 26. Agents never read other agent definition files.
52
+ 27. Each agent gets a fresh 200k token context window — let them do the heavy reading.
53
+
54
+ ---
55
+
56
+ ## User Interaction Patterns
57
+
58
+ 28. Use `AskUserQuestion` for all structured gate checks — never plain-text "Type approved" prompts.
59
+ 29. AskUserQuestion is an orchestrator-only tool. It **cannot** be called from subagents (Task contexts).
60
+ 30. Max 4 options per AskUserQuestion call. If more options exist, split into a 2-step flow.
61
+ 31. `header` field must be max 12 characters. Keep it a single word when possible.
62
+ 32. `multiSelect` is always `false` for Plan-Build-Run gate checks.
63
+ 33. Always handle the "Other" case — users may type freeform text instead of selecting an option.
64
+ 34. Reuse patterns from `skills/shared/gate-prompts.md` by name. Do not reinvent prompts inline.
65
+ 35. Do **not** use AskUserQuestion for freeform text input (symptom gathering, Socratic discussion, open-ended questions). Use plain conversation for those.
66
+ 36. Skills that do not require user interaction (continue, health, help, pause) intentionally omit AskUserQuestion from allowed-tools.
67
+
68
+ ---
69
+
70
+ ## Skill Authoring
71
+
72
+ 37. Every SKILL.md starts with YAML frontmatter: `name`, `description`, `allowed-tools`, `argument-hint`.
73
+ 38. Skills that spawn agents **must** have a `## Context Budget` section.
74
+ 39. Mark each step as `(inline)` or `(delegate)` — inline for light work, delegate for analysis.
75
+ 40. Reference templates and references by filename — never inline them.
76
+ 41. Gate checks: read config toggle → display summary → ask user → proceed/abort/revise.
77
+ 42. Use branded UI elements from `references/ui-formatting.md`.
78
+
79
+ ---
80
+
81
+ ## Agent Authoring
82
+
83
+ 43. Every agent file starts with YAML frontmatter: `name`, `description`, `model`, `memory`, `tools`.
84
+ 44. Agent name matches the agent file name (no prefix needed).
85
+ 45. `tools` array: only include tools the agent actually uses.
86
+ 46. Agents write artifacts to disk. They never modify STATE.md or ROADMAP.md.
87
+ 47. Agent definitions are self-contained — no cross-agent references.
88
+
89
+ ---
90
+
91
+ ## Hook Development
92
+
93
+ 48. All hooks use **CommonJS** (`require`), never ES modules (`import`).
94
+ 49. All hooks call `logHook()` from `hook-logger.js`. No silent exits.
95
+ 50. Exit codes: `0` = allow/success, `2` = block (PreToolUse only), other = error (logged, non-blocking).
96
+ 51. Hooks receive JSON on stdin, write JSON to stdout.
97
+ 52. Fail gracefully: wrap in try/catch, exit 0 on parse errors.
98
+ 53. Every hook in `hooks.json` must have a `statusMessage` field (gerund form: "Validating...", keep short).
99
+ 54. Windows file deletion: use 3-attempt retry loop to handle AV/indexer locks.
100
+ 55. Every hook script must have a corresponding `tests/{name}.test.js`.
101
+
102
+ ---
103
+
104
+ ## Commits
105
+
106
+ 56. Format: `{type}({scope}): {description}`.
107
+ 57. Valid types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `wip`.
108
+ 58. Valid scopes: `{NN}-{MM}` (phase-plan), `quick-{NNN}`, `planning`, or any lowercase word.
109
+ 59. **Never** use `git add .` or `git add -A` — stage specific files only.
110
+ 60. Blocked files: `.env` (not `.env.example`), `*.key`, `*.pem`, `*.pfx`, `*.p12`, `*credential*`, `*secret*` (unless in `tests/` or `*.example`).
111
+ 61. TDD tasks: exactly 3 commits — RED (test), GREEN (feat), REFACTOR.
112
+ 62. Executors: one atomic commit per task.
113
+
114
+ ---
115
+
116
+ ## Templates
117
+
118
+ 63. Default syntax: `{variable}` placeholders for string substitution.
119
+ 64. Only use EJS (`<%= %>`, `<% %>`) when loops or conditionals are genuinely needed.
120
+ 65. Template files use `.tmpl` extension. Name matches the output file (e.g., `SUMMARY.md.tmpl` → `SUMMARY.md`).
121
+ 66. Templates live in `templates/` (global), `templates/codebase/` (scan), `templates/research/` (research), or `skills/{name}/templates/` (skill-specific).
122
+
123
+ ---
124
+
125
+ ## File Naming
126
+
127
+ 67. Skills: `plugins/pbr/skills/{skill-name}/SKILL.md` — lowercase hyphenated dir, uppercase `SKILL.md`.
128
+ 68. Agents: `plugins/pbr/agents/{name}.md` — agent name matches file name.
129
+ 69. Scripts: `plugins/pbr/scripts/{name}.js` — lowercase, hyphenated, CommonJS.
130
+ 70. References: `plugins/pbr/references/{name}.md` — lowercase, hyphenated.
131
+ 71. Tests: `tests/{script-name}.test.js` — mirrors the script name.
132
+
133
+ ---
134
+
135
+ ## Testing
136
+
137
+ 72. Test files mirror script names: `scripts/foo.js` → `tests/foo.test.js`.
138
+ 73. Use the fixture project at `tests/fixtures/fake-project/` for integration tests.
139
+ 74. Hook tests: use stdin/stdout protocol with `execSync()`, timeout 5000ms, run in temp dir.
140
+ 75. Coverage target: 70% branches/functions/lines/statements.
141
+ 76. CI matrix: Node 18/20/22 × ubuntu/macos/windows. All 9 must pass.
142
+ 77. Local pre-push: `npm run lint && npm test && npm run validate`.
143
+
144
+ ---
145
+
146
+ ## Cross-Platform
147
+
148
+ 78. **Never** hardcode `/` or `\` — always `path.join()`.
149
+ 79. Use `\n` in string literals — Node.js and Git normalize line endings.
150
+ 80. In `hooks.json`, use `${CLAUDE_PLUGIN_ROOT}` — Claude Code expands this internally on all platforms.
151
+ 81. **Never** use `$CLAUDE_PLUGIN_ROOT` (shell expansion is platform-dependent).
152
+ 82. **Never** rely on execute bits — always invoke via `node script.js`.
153
+
154
+ ---
155
+
156
+ ## Dependencies & Gates
157
+
158
+ 83. Check all `depends_on` plans have SUMMARY.md files before executing.
159
+ 84. Checkpoint tasks (`checkpoint:human-verify`) require STOP — write partial SUMMARY.md, return metadata.
160
+ 85. Respect all `gates.confirm_*` config toggles. Never auto-proceed when a gate is enabled.
161
+
162
+ ---
163
+
164
+ ## Logging
165
+
166
+ 86. Hook scripts → `logHook()` (writes to `logs/hooks.jsonl`, max 200 entries).
167
+ 87. Workflow milestones → `logEvent()` (writes to `logs/events.jsonl`, max 1,000 entries).
168
+ 88. Rule of thumb: inside a hook? `logHook()`. Tracking a high-level event? `logEvent()`.
169
+
170
+ ---
171
+
172
+ ## Gotchas
173
+
174
+ 89. JSDoc `*/` in glob patterns closes Babel comments early — use `//` line comments instead.
175
+ 90. Regex anchors: use `\b` word boundaries, not `^` anchors (misses chained commands like `cd && git commit`).
176
+ 91. Windows cwd locking in tests: use `cwd` option in `execSync()` instead of `process.chdir()`.
177
+ 92. PLAN.md frontmatter must include all required fields: `phase`, `plan`, `type`, `wave`, `depends_on`, `files_modified`, `autonomous`, `must_haves`.
178
+
179
+ ---
180
+
181
+ ## Quick Reference: Never Do This
182
+
183
+ | # | Anti-Pattern | Impact |
184
+ |---|-------------|--------|
185
+ | 1 | Read agent definitions in orchestrator | Context balloons 15% → 88% |
186
+ | 2 | Inline large files into Task() prompts | Wasted orchestrator context |
187
+ | 3 | Read full subagent output | Context bloat |
188
+ | 4 | Use non-Plan-Build-Run branding | User confusion |
189
+ | 5 | Hardcode path separators | Cross-platform breakage |
190
+ | 6 | Use ES modules in hooks | Hook fails to load |
191
+ | 7 | Skip hook logging | Silent failures |
192
+ | 8 | Modify STATE.md in agents | Race conditions, corruption |
193
+ | 9 | Use `git add .` | Sensitive data leaks |
194
+ | 10 | Skip tests for new scripts | CI failures, regressions |
@@ -0,0 +1,182 @@
1
+ <!-- canonical: ../../pbr/references/plan-authoring.md -->
2
+ # Plan Authoring Guide
3
+
4
+ Quality guidelines for writing executable plans. Used by planner and plan-checker.
5
+
6
+ ---
7
+
8
+ ## Action Writing Guidelines
9
+
10
+ The `<action>` element is the most important part of the plan. It must be specific enough that the executor agent can follow it mechanically without making design decisions.
11
+
12
+ ### Good Action
13
+ ```xml
14
+ <action>
15
+ 1. Create file `src/auth/discord.ts`
16
+ 2. Import `OAuth2Client` from `discord-oauth2` package
17
+ 3. Export async function `authenticateWithDiscord(code: string): Promise<User>`
18
+ - Create OAuth2Client with env vars: DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET
19
+ - Exchange authorization code for access token
20
+ - Fetch user profile from Discord API: GET /api/users/@me
21
+ - Return User object with fields: id, username, avatar, email
22
+ 4. Export function `getDiscordAuthUrl(): string`
23
+ - Build OAuth2 authorization URL with scopes: identify, email
24
+ - Include redirect URI from env: DISCORD_REDIRECT_URI
25
+ - Return the URL string
26
+ 5. Add to `.env.example`:
27
+ DISCORD_CLIENT_ID=
28
+ DISCORD_CLIENT_SECRET=
29
+ DISCORD_REDIRECT_URI=http://localhost:3000/auth/callback
30
+ </action>
31
+ ```
32
+
33
+ ### Bad Action
34
+ ```xml
35
+ <action>
36
+ Set up Discord OAuth authentication.
37
+ </action>
38
+ ```
39
+
40
+ ### Action Rules
41
+
42
+ 1. **Number the steps** -- executor follows them in order
43
+ 2. **Name specific files** -- never say "create necessary files"
44
+ 3. **Name specific functions/exports** -- never say "implement the auth logic"
45
+ 4. **Include type signatures** -- when the project uses TypeScript
46
+ 5. **Reference existing code** -- when modifying files, say what to modify
47
+ 6. **Include code snippets** -- for complex patterns or configurations
48
+ 7. **Specify environment variables** -- with example values
49
+ 8. **Note error handling** -- only when it's a critical part of the task
50
+
51
+ ---
52
+
53
+ ## Verify Command Guidelines
54
+
55
+ The `<verify>` element must contain commands that the executor can run to check the task is complete.
56
+
57
+ ### Good Verify
58
+ ```xml
59
+ <verify>
60
+ npx tsc --noEmit
61
+ npm run test -- --grep "discord auth"
62
+ ls -la src/auth/discord.ts
63
+ </verify>
64
+ ```
65
+
66
+ ### Bad Verify
67
+ ```xml
68
+ <verify>
69
+ Check that authentication works.
70
+ </verify>
71
+ ```
72
+
73
+ ### Verify Rules
74
+
75
+ 1. **Must be executable** -- actual shell commands, not descriptions
76
+ 2. **Must be deterministic** -- same result every time if code is correct
77
+ 3. **Prefer automated checks** -- type checking, tests, linting
78
+ 4. **Include existence checks** -- `ls` for created files
79
+ 5. **Include build checks** -- `npx tsc --noEmit` for TypeScript
80
+ 6. **Avoid interactive commands** -- no commands requiring user input
81
+
82
+ ---
83
+
84
+ ## Done Condition Guidelines
85
+
86
+ The `<done>` element describes the observable outcome, not the implementation activity.
87
+
88
+ ### Good Done
89
+ - "User can authenticate via Discord OAuth and is redirected to dashboard"
90
+ - "Auth middleware rejects invalid tokens and passes valid tokens"
91
+ - "All 12 unit tests pass for the auth module"
92
+
93
+ ### Bad Done
94
+ - "Code was written"
95
+ - "File was created"
96
+ - "Feature is implemented"
97
+
98
+ ### Done Rules
99
+
100
+ 1. **Maps to a must-have** -- every done condition traces back to a frontmatter must-have
101
+ 2. **Observable** -- describes a state of the system, not an activity
102
+ 3. **Falsifiable** -- you can check whether it's true or false
103
+ 4. **User-oriented** -- prefer "user can..." over "code does..."
104
+
105
+ ---
106
+
107
+ ## Scope Limits
108
+
109
+ ### Per-Plan Limits
110
+
111
+ | Constraint | Limit | Rationale |
112
+ |-----------|-------|-----------|
113
+ | Tasks per plan | **2-3** | Keeps plans atomic and recoverable |
114
+ | Files per plan | **5-8** | Limits blast radius of failures |
115
+ | Dependencies | **3 max** | Avoids deep dependency chains |
116
+
117
+ ### When to Split
118
+
119
+ - More than 3 tasks? Split.
120
+ - More than 8 files? Split.
121
+ - Tasks in different functional areas? Split.
122
+ - Some tasks need human checkpoints, others don't? Split into autonomous and checkpoint plans.
123
+
124
+ ### Split Signals
125
+
126
+ | Signal | Action |
127
+ |--------|--------|
128
+ | >3 tasks needed | Split by subsystem -- one plan per subsystem |
129
+ | Multiple unrelated subsystems | One plan per subsystem |
130
+ | >5 files per task | Task is too big -- break it down |
131
+ | Checkpoint + implementation in same plan | Separate the checkpoint into its own plan |
132
+ | Discovery research + implementation | Separate plans -- research plan first |
133
+
134
+ ---
135
+
136
+ ## Discovery Levels
137
+
138
+ When a plan requires research before execution, set the `discovery` field in plan frontmatter. Default is 1 for most plans.
139
+
140
+ | Level | Name | Description | Executor Behavior |
141
+ |-------|------|-------------|-------------------|
142
+ | 0 | Skip | No research needed | Execute immediately |
143
+ | 1 | Quick | Fast verification | Check official docs for 1-2 specific questions |
144
+ | 2 | Standard | Normal research | Spawn researcher for phase research |
145
+ | 3 | Deep | Extensive investigation | Full research cycle before execution |
146
+
147
+ ### Level 0 -- Skip
148
+ **When to use**: Simple refactors, documentation updates, file renames, configuration tweaks, or any task where the implementation approach is unambiguous from the plan's `<action>` steps alone.
149
+
150
+ ### Level 1 -- Quick (default)
151
+ **When to use**: Standard feature work where the technology is known but specific API signatures, config options, or version-specific behavior need a quick check.
152
+
153
+ ### Level 2 -- Standard
154
+ **When to use**: Work involving unfamiliar libraries, new integration patterns, or approaches the executor hasn't seen in this codebase before.
155
+
156
+ ### Level 3 -- Deep
157
+ **When to use**: High-risk or architecturally significant work where getting the approach wrong would require substantial rework.
158
+
159
+ ---
160
+
161
+ ## Dependency Graph Rules
162
+
163
+ ### File Conflict Detection
164
+
165
+ Two plans CONFLICT if their `files_modified` lists overlap. Conflicting plans:
166
+ - MUST be in different waves (cannot run in parallel)
167
+ - MUST have explicit `depends_on` relationship
168
+ - Later plan's `<action>` must reference what the earlier plan produces
169
+
170
+ ### Circular Dependencies
171
+
172
+ **NEVER create circular dependencies.** If you detect a potential cycle, restructure the plans to break it. Common resolution: merge the circular plans into one, or extract the shared dependency into its own plan.
173
+
174
+ ---
175
+
176
+ ## Context Fidelity Checklist
177
+
178
+ Before writing plan files, verify context compliance:
179
+
180
+ 1. **Locked decision coverage**: For each locked decision in CONTEXT.md, identify the task that implements it.
181
+ 2. **Deferred idea exclusion**: Scan all tasks -- no task should implement a deferred idea.
182
+ 3. **Discretion area handling**: Each "Claude's Discretion" item should be addressed in at least one task.