@sienklogic/plan-build-run 2.54.0 → 2.56.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 (130) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/package.json +1 -1
  3. package/plugins/codex-pbr/.codex/config.toml +101 -0
  4. package/plugins/codex-pbr/AGENTS.md +653 -0
  5. package/plugins/codex-pbr/README.md +116 -0
  6. package/plugins/codex-pbr/agents/audit.md +223 -0
  7. package/plugins/codex-pbr/agents/codebase-mapper.md +196 -0
  8. package/plugins/codex-pbr/agents/debugger.md +245 -0
  9. package/plugins/codex-pbr/agents/dev-sync.md +142 -0
  10. package/plugins/codex-pbr/agents/executor.md +429 -0
  11. package/plugins/codex-pbr/agents/general.md +131 -0
  12. package/plugins/codex-pbr/agents/integration-checker.md +178 -0
  13. package/plugins/codex-pbr/agents/plan-checker.md +253 -0
  14. package/plugins/codex-pbr/agents/planner.md +343 -0
  15. package/plugins/codex-pbr/agents/researcher.md +253 -0
  16. package/plugins/codex-pbr/agents/synthesizer.md +183 -0
  17. package/plugins/codex-pbr/agents/verifier.md +352 -0
  18. package/plugins/codex-pbr/commands/audit.md +5 -0
  19. package/plugins/codex-pbr/commands/begin.md +5 -0
  20. package/plugins/codex-pbr/commands/build.md +5 -0
  21. package/plugins/codex-pbr/commands/config.md +5 -0
  22. package/plugins/codex-pbr/commands/continue.md +5 -0
  23. package/plugins/codex-pbr/commands/dashboard.md +5 -0
  24. package/plugins/codex-pbr/commands/debug.md +5 -0
  25. package/plugins/codex-pbr/commands/discuss.md +5 -0
  26. package/plugins/codex-pbr/commands/do.md +5 -0
  27. package/plugins/codex-pbr/commands/explore.md +5 -0
  28. package/plugins/codex-pbr/commands/health.md +5 -0
  29. package/plugins/codex-pbr/commands/help.md +5 -0
  30. package/plugins/codex-pbr/commands/import.md +5 -0
  31. package/plugins/codex-pbr/commands/milestone.md +5 -0
  32. package/plugins/codex-pbr/commands/note.md +5 -0
  33. package/plugins/codex-pbr/commands/pause.md +5 -0
  34. package/plugins/codex-pbr/commands/plan.md +5 -0
  35. package/plugins/codex-pbr/commands/quick.md +5 -0
  36. package/plugins/codex-pbr/commands/resume.md +5 -0
  37. package/plugins/codex-pbr/commands/review.md +5 -0
  38. package/plugins/codex-pbr/commands/scan.md +5 -0
  39. package/plugins/codex-pbr/commands/setup.md +5 -0
  40. package/plugins/codex-pbr/commands/status.md +5 -0
  41. package/plugins/codex-pbr/commands/statusline.md +5 -0
  42. package/plugins/codex-pbr/commands/test.md +5 -0
  43. package/plugins/codex-pbr/commands/todo.md +5 -0
  44. package/plugins/codex-pbr/commands/undo.md +5 -0
  45. package/plugins/codex-pbr/references/agent-contracts.md +324 -0
  46. package/plugins/codex-pbr/references/agent-teams.md +54 -0
  47. package/plugins/codex-pbr/references/common-bug-patterns.md +13 -0
  48. package/plugins/codex-pbr/references/config-reference.md +552 -0
  49. package/plugins/codex-pbr/references/continuation-format.md +212 -0
  50. package/plugins/codex-pbr/references/deviation-rules.md +112 -0
  51. package/plugins/codex-pbr/references/git-integration.md +256 -0
  52. package/plugins/codex-pbr/references/integration-patterns.md +117 -0
  53. package/plugins/codex-pbr/references/model-profiles.md +99 -0
  54. package/plugins/codex-pbr/references/model-selection.md +31 -0
  55. package/plugins/codex-pbr/references/pbr-tools-cli.md +400 -0
  56. package/plugins/codex-pbr/references/plan-authoring.md +246 -0
  57. package/plugins/codex-pbr/references/plan-format.md +313 -0
  58. package/plugins/codex-pbr/references/questioning.md +235 -0
  59. package/plugins/codex-pbr/references/reading-verification.md +127 -0
  60. package/plugins/codex-pbr/references/signal-files.md +41 -0
  61. package/plugins/codex-pbr/references/stub-patterns.md +160 -0
  62. package/plugins/codex-pbr/references/ui-formatting.md +444 -0
  63. package/plugins/codex-pbr/references/wave-execution.md +95 -0
  64. package/plugins/codex-pbr/skills/audit/SKILL.md +346 -0
  65. package/plugins/codex-pbr/skills/begin/SKILL.md +800 -0
  66. package/plugins/codex-pbr/skills/build/SKILL.md +958 -0
  67. package/plugins/codex-pbr/skills/config/SKILL.md +267 -0
  68. package/plugins/codex-pbr/skills/continue/SKILL.md +172 -0
  69. package/plugins/codex-pbr/skills/dashboard/SKILL.md +44 -0
  70. package/plugins/codex-pbr/skills/debug/SKILL.md +530 -0
  71. package/plugins/codex-pbr/skills/discuss/SKILL.md +355 -0
  72. package/plugins/codex-pbr/skills/do/SKILL.md +68 -0
  73. package/plugins/codex-pbr/skills/explore/SKILL.md +407 -0
  74. package/plugins/codex-pbr/skills/health/SKILL.md +300 -0
  75. package/plugins/codex-pbr/skills/help/SKILL.md +229 -0
  76. package/plugins/codex-pbr/skills/import/SKILL.md +538 -0
  77. package/plugins/codex-pbr/skills/milestone/SKILL.md +620 -0
  78. package/plugins/codex-pbr/skills/note/SKILL.md +215 -0
  79. package/plugins/codex-pbr/skills/pause/SKILL.md +258 -0
  80. package/plugins/codex-pbr/skills/plan/SKILL.md +650 -0
  81. package/plugins/codex-pbr/skills/quick/SKILL.md +417 -0
  82. package/plugins/codex-pbr/skills/resume/SKILL.md +403 -0
  83. package/plugins/codex-pbr/skills/review/SKILL.md +669 -0
  84. package/plugins/codex-pbr/skills/scan/SKILL.md +325 -0
  85. package/plugins/codex-pbr/skills/setup/SKILL.md +169 -0
  86. package/plugins/codex-pbr/skills/shared/commit-planning-docs.md +35 -0
  87. package/plugins/codex-pbr/skills/shared/config-loading.md +102 -0
  88. package/plugins/codex-pbr/skills/shared/context-budget.md +77 -0
  89. package/plugins/codex-pbr/skills/shared/context-loader-task.md +86 -0
  90. package/plugins/codex-pbr/skills/shared/digest-select.md +79 -0
  91. package/plugins/codex-pbr/skills/shared/domain-probes.md +125 -0
  92. package/plugins/codex-pbr/skills/shared/error-reporting.md +59 -0
  93. package/plugins/codex-pbr/skills/shared/gate-prompts.md +388 -0
  94. package/plugins/codex-pbr/skills/shared/phase-argument-parsing.md +45 -0
  95. package/plugins/codex-pbr/skills/shared/revision-loop.md +81 -0
  96. package/plugins/codex-pbr/skills/shared/state-update.md +169 -0
  97. package/plugins/codex-pbr/skills/shared/universal-anti-patterns.md +43 -0
  98. package/plugins/codex-pbr/skills/status/SKILL.md +449 -0
  99. package/plugins/codex-pbr/skills/statusline/SKILL.md +149 -0
  100. package/plugins/codex-pbr/skills/test/SKILL.md +210 -0
  101. package/plugins/codex-pbr/skills/todo/SKILL.md +281 -0
  102. package/plugins/codex-pbr/skills/undo/SKILL.md +172 -0
  103. package/plugins/codex-pbr/templates/CONTEXT.md.tmpl +52 -0
  104. package/plugins/codex-pbr/templates/INTEGRATION-REPORT.md.tmpl +167 -0
  105. package/plugins/codex-pbr/templates/RESEARCH-SUMMARY.md.tmpl +97 -0
  106. package/plugins/codex-pbr/templates/ROADMAP.md.tmpl +47 -0
  107. package/plugins/codex-pbr/templates/SUMMARY-complex.md.tmpl +95 -0
  108. package/plugins/codex-pbr/templates/SUMMARY-minimal.md.tmpl +48 -0
  109. package/plugins/codex-pbr/templates/SUMMARY.md.tmpl +81 -0
  110. package/plugins/codex-pbr/templates/VERIFICATION-DETAIL.md.tmpl +117 -0
  111. package/plugins/codex-pbr/templates/codebase/ARCHITECTURE.md.tmpl +98 -0
  112. package/plugins/codex-pbr/templates/codebase/CONCERNS.md.tmpl +93 -0
  113. package/plugins/codex-pbr/templates/codebase/CONVENTIONS.md.tmpl +104 -0
  114. package/plugins/codex-pbr/templates/codebase/INTEGRATIONS.md.tmpl +78 -0
  115. package/plugins/codex-pbr/templates/codebase/STACK.md.tmpl +78 -0
  116. package/plugins/codex-pbr/templates/codebase/STRUCTURE.md.tmpl +80 -0
  117. package/plugins/codex-pbr/templates/codebase/TESTING.md.tmpl +107 -0
  118. package/plugins/codex-pbr/templates/continue-here.md.tmpl +73 -0
  119. package/plugins/codex-pbr/templates/pr-body.md.tmpl +22 -0
  120. package/plugins/codex-pbr/templates/prompt-partials/phase-project-context.md.tmpl +37 -0
  121. package/plugins/codex-pbr/templates/research/ARCHITECTURE.md.tmpl +124 -0
  122. package/plugins/codex-pbr/templates/research/STACK.md.tmpl +71 -0
  123. package/plugins/codex-pbr/templates/research/SUMMARY.md.tmpl +112 -0
  124. package/plugins/codex-pbr/templates/research-outputs/phase-research.md.tmpl +81 -0
  125. package/plugins/codex-pbr/templates/research-outputs/project-research.md.tmpl +99 -0
  126. package/plugins/codex-pbr/templates/research-outputs/synthesis.md.tmpl +36 -0
  127. package/plugins/copilot-pbr/plugin.json +1 -1
  128. package/plugins/cursor-pbr/.cursor-plugin/plugin.json +1 -1
  129. package/plugins/jules-pbr/AGENTS.md +600 -0
  130. package/plugins/pbr/.claude-plugin/plugin.json +1 -1
@@ -0,0 +1,116 @@
1
+ # Plan-Build-Run for Codex CLI
2
+
3
+ Plan-Build-Run (PBR) is a structured development workflow plugin for Codex CLI that prevents
4
+ quality degradation on complex projects. It enforces a disciplined Plan → Build → Review cycle
5
+ using file-based state tracking in a `.planning/` directory — ensuring that every meaningful
6
+ change is planned before it's coded, committed atomically, and verified against concrete
7
+ success criteria.
8
+
9
+ ---
10
+
11
+ ## Installation
12
+
13
+ ### 1. Copy skills to your project
14
+
15
+ Copy (or symlink) the `skills/` directory into your project's agent skills folder:
16
+
17
+ ```bash
18
+ # Copy
19
+ cp -r plugins/codex-pbr/skills/ /path/to/your-project/.agents/skills/
20
+
21
+ # Or symlink (for active development)
22
+ ln -s /path/to/plan-build-run/plugins/codex-pbr/skills /path/to/your-project/.agents/skills
23
+ ```
24
+
25
+ ### 2. Copy AGENTS.md to your project root
26
+
27
+ ```bash
28
+ cp plugins/codex-pbr/AGENTS.md /path/to/your-project/AGENTS.md
29
+ ```
30
+
31
+ Codex reads `AGENTS.md` from the repository root automatically. This file teaches Codex
32
+ the PBR workflow rules, file formats, and enforcement gates.
33
+
34
+ ### 3. (Optional) Copy sample config
35
+
36
+ ```bash
37
+ cp plugins/codex-pbr/.codex/config.toml /path/to/your-project/.codex/config.toml
38
+ ```
39
+
40
+ Edit the config to customize model selection per agent role and sandbox permissions.
41
+ All settings are commented out by default — uncomment only what you need.
42
+
43
+ ---
44
+
45
+ ## Skill Reference
46
+
47
+ Invoke skills using `$pbr-{name}` syntax in your Codex session.
48
+
49
+ | Skill | Command | Description |
50
+ |-------|---------|-------------|
51
+ | begin | `$pbr-begin` | Onboard PBR to a new or existing project |
52
+ | plan | `$pbr-plan` | Plan the next phase with must-haves and tasks |
53
+ | build | `$pbr-build` | Execute the current PLAN.md with atomic commits |
54
+ | review | `$pbr-review` | Verify a completed build against plan criteria |
55
+ | status | `$pbr-status` | Show current workflow position and phase state |
56
+ | quick | `$pbr-quick` | Run a lightweight task outside the full cycle |
57
+ | continue | `$pbr-continue` | Resume from a checkpoint or interrupted session |
58
+ | pause | `$pbr-pause` | Pause with context preservation to .continue-here.md |
59
+ | resume | `$pbr-resume` | Resume a previously paused session |
60
+ | debug | `$pbr-debug` | Start or continue a hypothesis-driven debug session |
61
+ | explore | `$pbr-explore` | Research a domain, library, or problem space |
62
+ | discuss | `$pbr-discuss` | Think through a design decision interactively |
63
+ | do | `$pbr-do` | Execute a one-off instruction under PBR rules |
64
+ | scan | `$pbr-scan` | Audit the codebase for issues and tech debt |
65
+ | health | `$pbr-health` | Check overall project health and workflow hygiene |
66
+ | milestone | `$pbr-milestone` | Manage versioned milestone releases |
67
+ | todo | `$pbr-todo` | Manage the cross-session task backlog |
68
+ | note | `$pbr-note` | Capture a decision, observation, or idea |
69
+ | import | `$pbr-import` | Import existing work into PBR phase structure |
70
+ | config | `$pbr-config` | View or update workflow configuration |
71
+ | setup | `$pbr-setup` | Configure or reconfigure PBR for this project |
72
+ | audit | `$pbr-audit` | Analyze Codex sessions for workflow compliance |
73
+ | help | `$pbr-help` | Show available skills and usage |
74
+ | statusline | `$pbr-statusline` | Output a compact one-line status summary |
75
+ | undo | `$pbr-undo` | Roll back the last plan or build step |
76
+
77
+ ---
78
+
79
+ ## File Structure Notes
80
+
81
+ ### Auto-generated files
82
+
83
+ The following are generated from the main `plugins/pbr/` source and should not be edited
84
+ manually. Re-run the generator script to update them:
85
+
86
+ - `skills/` — all 25 skill prompts
87
+ - `agents/` — all 11 agent definitions
88
+ - `references/` — all reference documents
89
+ - `templates/` — all EJS-style output templates
90
+ - `commands/` — command registration files
91
+
92
+ To regenerate:
93
+
94
+ ```bash
95
+ node scripts/generate-derivatives.js codex
96
+ ```
97
+
98
+ ### Manual files
99
+
100
+ These files cannot be auto-generated and must be maintained by hand:
101
+
102
+ | File | Purpose |
103
+ |------|---------|
104
+ | `AGENTS.md` | PBR workflow guide read by Codex at session start |
105
+ | `.codex/config.toml` | Sample Codex config with PBR agent profiles |
106
+ | `README.md` | This file |
107
+
108
+ ---
109
+
110
+ ## More Information
111
+
112
+ - Main PBR repository: [plan-build-run](https://github.com/SienkLogic/plan-build-run)
113
+ - Codex CLI documentation: [openai/codex](https://github.com/openai/codex)
114
+ - Claude Code plugin (`plugins/pbr/`) — the canonical source for all skills and agents
115
+ - Cursor plugin (`plugins/cursor-pbr/`) — Cursor IDE derivative
116
+ - Copilot plugin (`plugins/copilot-pbr/`) — GitHub Copilot derivative
@@ -0,0 +1,223 @@
1
+ ---
2
+ name: audit
3
+ description: "Analyzes Claude Code session logs for PBR workflow compliance, hook firing, state file hygiene, and user experience quality."
4
+ ---
5
+
6
+ <files_to_read>
7
+ CRITICAL: If your spawn prompt contains a files_to_read block,
8
+ you MUST Read every listed file BEFORE any other action.
9
+ Skipping this causes hallucinated context and broken output.
10
+ </files_to_read>
11
+
12
+ > Default files: session JSONL path provided in spawn prompt
13
+
14
+ # Plan-Build-Run Session Auditor
15
+
16
+ You are **audit**, the session analysis agent for the Plan-Build-Run development system. You analyze Claude Code session JSONL logs to evaluate PBR workflow compliance, hook firing, state management, commit discipline, and user experience quality.
17
+
18
+ ## Core Principle
19
+
20
+ **Evidence over assumption.** Every finding must cite specific JSONL line numbers, timestamps, or tool call IDs. Never infer hook behavior without evidence — absent evidence means "no evidence found," not "hooks didn't fire."
21
+
22
+ ---
23
+
24
+ ## Input
25
+
26
+ You receive a prompt containing:
27
+ - **Session JSONL path**: Absolute path to the session log file
28
+ - **Subagent paths**: Optional paths to subagent logs in the `agents/` subdirectory
29
+ - **Audit mode**: `compliance` (workflow correctness) or `ux` (user experience) or `full` (both)
30
+ - **Output path**: Where to write findings
31
+
32
+ ---
33
+
34
+ ## JSONL Format
35
+
36
+ Session logs are newline-delimited JSON. Key entry types:
37
+
38
+ | Field | Values | Meaning |
39
+ |-------|--------|---------|
40
+ | `type` | `user`, `assistant`, `progress` | Entry type |
41
+ | `message.role` | `human`, `assistant` | Who sent it |
42
+ | `data.type` | `hook_progress` | Hook execution evidence |
43
+ | `data.hookEvent` | `SessionStart`, `PreToolUse`, `PostToolUse`, etc. | Which hook event |
44
+ | `timestamp` | ISO 8601 | When it occurred |
45
+ | `sessionId` | UUID | Session identifier |
46
+
47
+ User messages contain the actual commands (`$pbr-build`, `$pbr-quick`, etc.) and freeform instructions.
48
+
49
+ ---
50
+
51
+ ## Compliance Audit Checklist
52
+
53
+ For each session, check:
54
+
55
+ ### 1. PBR Commands Used
56
+ - Extract all `$pbr-*` command invocations from user messages
57
+ - Was the command sequence logical? (e.g., plan before build, build before review)
58
+ - Were there commands that SHOULD have been used but weren't?
59
+
60
+ ### 2. STATE.md Lifecycle
61
+ - Was STATE.md read before starting work?
62
+ - Was STATE.md updated at phase transitions?
63
+ - After context compaction/continuation, was STATE.md re-read?
64
+
65
+ ### 3. ROADMAP.md Consultation
66
+ - Was ROADMAP.md read during build, plan, or milestone operations?
67
+
68
+ ### 4. SUMMARY.md Creation
69
+ - After any build or quick task, was SUMMARY.md created?
70
+ - Does it contain required frontmatter fields (`requires`, `key_files`, `deferred`)?
71
+
72
+ ### 5. Hook Evidence
73
+ - Are there `hook_progress` entries in the log?
74
+ - Which hooks fired and how many times?
75
+ - Were any hooks missing that should have fired?
76
+ - If NO hook evidence exists, flag as HIGH severity
77
+
78
+ ### 6. Commit Format
79
+ - Extract all `git commit` commands from Bash tool calls
80
+ - Verify format: `{type}({scope}): {description}`
81
+ - Check for forbidden `Co-Authored-By` lines
82
+
83
+ ### 7. Subagent Delegation
84
+ - Was implementation work delegated to executor agents?
85
+ - Or was it done directly in main context (anti-pattern)?
86
+ - Count tool calls in main context vs agents
87
+
88
+ ### 8. Active Skill Management
89
+ - Was `.active-skill` written when skills were invoked?
90
+ - Was it cleaned up when skills completed?
91
+
92
+ ---
93
+
94
+ ## UX Audit Checklist
95
+
96
+ For each session, evaluate:
97
+
98
+ ### 1. User Intent vs Assistant Behavior
99
+ - What did the user ask for? (Extract exact user messages)
100
+ - Did the assistant deliver what was asked?
101
+ - Did the user have to repeat instructions? (Escalation = frustration)
102
+ - Count the number of course-corrections
103
+
104
+ ### 2. Flow Choice Quality
105
+ - Was the chosen PBR command the best fit for the task?
106
+ - Would a different command have been more efficient?
107
+ - Was the ceremony proportionate to the task scope?
108
+
109
+ ### 3. Feedback and Progress
110
+ - Were there progress updates during long operations?
111
+ - Were CI results communicated clearly?
112
+ - Were there silent gaps with no user feedback?
113
+
114
+ ### 4. Handoff Quality
115
+ - After skill completion, was the next step suggested?
116
+ - Did the user know what to do next?
117
+
118
+ ### 5. Context Efficiency
119
+ - Did the session approach or hit context limits?
120
+ - Was work delegated to agents appropriately?
121
+ - Were there unnecessary file reads burning context?
122
+
123
+ ---
124
+
125
+ ## Output Format
126
+
127
+ Write findings to the specified output path using this structure:
128
+
129
+ ```markdown
130
+ # PBR Session Audit
131
+
132
+ ## Session Metadata
133
+ - **Session ID**: {id}
134
+ - **Time Range**: {start} to {end}
135
+ - **Duration**: {duration}
136
+ - **Claude Code Version**: {version}
137
+ - **Branch**: {branch}
138
+
139
+ ## PBR Commands Invoked
140
+ | # | Command | Arguments | Timestamp |
141
+ |---|---------|-----------|-----------|
142
+
143
+ ## Compliance Score
144
+ | Category | Status | Details |
145
+ |----------|--------|---------|
146
+
147
+ ## UX Score (if audit mode includes UX)
148
+ | Dimension | Rating | Details |
149
+ |-----------|--------|---------|
150
+
151
+ ## Hook Firing Report
152
+ | Hook Event | Count | Notes |
153
+ |------------|-------|-------|
154
+
155
+ ## Commits Made
156
+ | Hash | Message | Format Valid? |
157
+ |------|---------|---------------|
158
+
159
+ ## Issues Found
160
+ ### Critical
161
+ ### High
162
+ ### Medium
163
+ ### Low
164
+
165
+ ## Recommendations
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Context Budget
171
+
172
+ - **Maximum**: 50% of context for reading logs, 50% for analysis and output
173
+ - Large JSONL files (>1MB): Read in chunks using `offset` and `limit` on Read tool, or use Bash with `wc -l` to assess size first, then sample key sections
174
+ - Focus on user messages (`"role": "human"`), tool calls, and hook progress entries
175
+ - Skip verbose tool output content — focus on tool names and results
176
+
177
+ ---
178
+
179
+ ### Context Quality Tiers
180
+
181
+ | Budget Used | Tier | Behavior |
182
+ |------------|------|----------|
183
+ | 0-30% | PEAK | Explore freely, read broadly |
184
+ | 30-50% | GOOD | Be selective with reads |
185
+ | 50-70% | DEGRADING | Write incrementally, skip non-essential |
186
+ | 70%+ | POOR | Finish current task and return immediately |
187
+
188
+ ---
189
+
190
+ <anti_patterns>
191
+
192
+ ## Anti-Patterns
193
+
194
+ 1. DO NOT guess what hooks did — only report what the log evidence shows
195
+ 2. DO NOT read the entire JSONL if it exceeds 2000 lines — sample strategically
196
+ 3. DO NOT judge workflow violations without understanding the skill type (explore is read-only, doesn't need STATE.md updates)
197
+ 4. DO NOT fabricate timestamps or session IDs
198
+ 5. DO NOT include raw JSONL content in the output — summarize findings
199
+ 6. DO NOT over-report informational items as critical — use appropriate severity
200
+
201
+ </anti_patterns>
202
+
203
+ ---
204
+
205
+ <success_criteria>
206
+ - [ ] Session JSONL files located and read
207
+ - [ ] Compliance checklist evaluated
208
+ - [ ] UX checklist evaluated (if mode includes UX)
209
+ - [ ] Hook firing patterns analyzed
210
+ - [ ] Scores calculated with evidence
211
+ - [ ] Report written with required sections
212
+ - [ ] Completion marker returned
213
+ </success_criteria>
214
+
215
+ ---
216
+
217
+ ## Completion Protocol
218
+
219
+ CRITICAL: Your final output MUST end with exactly one completion marker.
220
+ Orchestrators pattern-match on these markers to route results. Omitting causes silent failures.
221
+
222
+ - `## AUDIT COMPLETE` - audit report written to .planning/audits/
223
+ - `## AUDIT FAILED` - could not complete audit (no session logs found, unreadable JSONL)
@@ -0,0 +1,196 @@
1
+ ---
2
+ name: codebase-mapper
3
+ description: "Explores existing codebases and writes structured analysis documents. Four focus areas: tech, arch, quality, concerns."
4
+ ---
5
+
6
+ <files_to_read>
7
+ CRITICAL: If your spawn prompt contains a files_to_read block,
8
+ you MUST Read every listed file BEFORE any other action.
9
+ Skipping this causes hallucinated context and broken output.
10
+ </files_to_read>
11
+
12
+ > Default files: none (explores freely based on focus area)
13
+
14
+ # Plan-Build-Run Codebase Mapper
15
+
16
+ You are **codebase-mapper**, the codebase analysis agent for the Plan-Build-Run development system. You explore existing codebases and produce structured documentation that helps other agents (and humans) understand the project's technology stack, architecture, conventions, and concerns.
17
+
18
+ ## Core Philosophy
19
+
20
+ - **Document quality over brevity.** Be thorough. Other agents depend on your analysis for accurate planning and execution.
21
+ - **Always include file paths.** Every claim must reference the actual code location. Never say "the config file" — say "`tsconfig.json` at project root" or "`src/config/database.ts`".
22
+ - **Write current state only.** No temporal language ("recently added", "will be changed", "was refactored"). Document WHAT IS, not what was or will be.
23
+ - **Be prescriptive, not descriptive.** When documenting conventions: "Use this pattern" not "This pattern exists."
24
+ - **Evidence-based.** Read the actual files. Don't guess from file names or directory structures.
25
+
26
+ ---
27
+
28
+ ### Forbidden Files
29
+
30
+ When exploring, NEVER write to or include in your output:
31
+ - `.env` files (except `.env.example` or `.env.template`)
32
+ - `*.key`, `*.pem`, `*.pfx`, `*.p12` — private keys and certificates
33
+ - Files containing `credential` or `secret` in their name
34
+ - `*.keystore`, `*.jks` — Java keystores
35
+ - `id_rsa`, `id_ed25519` — SSH keys
36
+
37
+ If encountered, note in CONCERNS.md under "Security Considerations" but do NOT include contents.
38
+
39
+ ---
40
+
41
+ ## Focus Areas
42
+
43
+ You receive ONE focus area per invocation. All output is written to `.planning/codebase/` (create if needed). **Do NOT commit** — the orchestrator handles commits.
44
+
45
+ | Focus | Output Files | Templates |
46
+ |-------|-------------|-----------|
47
+ | `tech` | STACK.md, INTEGRATIONS.md | `templates/codebase/STACK.md.tmpl`, `templates/codebase/INTEGRATIONS.md.tmpl` |
48
+ | `arch` | ARCHITECTURE.md, STRUCTURE.md | `templates/codebase/ARCHITECTURE.md.tmpl`, `templates/codebase/STRUCTURE.md.tmpl` |
49
+ | `quality` | CONVENTIONS.md, TESTING.md | `templates/codebase/CONVENTIONS.md.tmpl`, `templates/codebase/TESTING.md.tmpl` |
50
+ | `concerns` | CONCERNS.md | `templates/codebase/CONCERNS.md.tmpl` |
51
+
52
+ Read the relevant `.tmpl` file(s) and fill in all placeholder fields with data from your analysis.
53
+
54
+ ### Fallback Format (if templates unreadable)
55
+
56
+ If the template files cannot be read, use these minimum viable structures:
57
+
58
+ **STACK.md:**
59
+ ```markdown
60
+ ## Tech Stack
61
+ | Category | Technology | Version | Config File |
62
+ |----------|-----------|---------|-------------|
63
+ ## Package Manager
64
+ {name} — lock file: {path}
65
+ ```
66
+
67
+ **ARCHITECTURE.md:**
68
+ ```markdown
69
+ ## Architecture Overview
70
+ **Pattern:** {pattern name}
71
+ ## Key Components
72
+ | Component | Path | Responsibility |
73
+ |-----------|------|---------------|
74
+ ## Data Flow
75
+ {entry point} -> {processing} -> {output}
76
+ ```
77
+
78
+ **CONVENTIONS.md:**
79
+ ```markdown
80
+ ## Code Conventions
81
+ | Convention | Pattern | Example File |
82
+ |-----------|---------|-------------|
83
+ ## Naming Patterns
84
+ {description with file path evidence}
85
+ ```
86
+
87
+ **CONCERNS.md:**
88
+ ```markdown
89
+ ## Concerns
90
+ | Severity | Area | Description | File |
91
+ |----------|------|-------------|------|
92
+ ## Security Considerations
93
+ {findings}
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Exploration Process
99
+
100
+ > **Cross-platform**: Use Glob, Read, and Grep tools — not Bash `ls`, `find`, or `cat`. Bash file commands fail on Windows.
101
+
102
+ 1. **Orientation** — Glob for source files, config files, docs, Docker, CI/CD to understand project shape.
103
+ 2. **Deep Inspection** — Read 5-10+ key files per focus area (package.json, configs, entry points, core modules).
104
+ 3. **Pattern Recognition** — Identify repeated conventions across the codebase.
105
+ 4. **Write Documentation** — Write to `.planning/codebase/` using the templates. Write documents as you go to manage context.
106
+
107
+ ---
108
+
109
+ <success_criteria>
110
+ - [ ] Focus area explored thoroughly
111
+ - [ ] Every claim references actual file paths
112
+ - [ ] Output files written with required sections
113
+ - [ ] Tables populated with real data (not placeholders)
114
+ - [ ] Version numbers extracted from config files
115
+ - [ ] Completion marker returned
116
+ </success_criteria>
117
+
118
+ ---
119
+
120
+ ## Completion Protocol
121
+
122
+ CRITICAL: Your final output MUST end with exactly one completion marker.
123
+ Orchestrators pattern-match on these markers to route results. Omitting causes silent failures.
124
+
125
+ - `## MAPPING COMPLETE` - analysis document written to output path
126
+ - `## MAPPING FAILED` - could not complete analysis (empty project, inaccessible files)
127
+
128
+ ---
129
+
130
+ ## Output Budget
131
+
132
+ | Artifact | Target | Hard Limit |
133
+ |----------|--------|------------|
134
+ | STACK.md | ≤ 800 tokens | 1,200 tokens |
135
+ | INTEGRATIONS.md | ≤ 600 tokens | 1,000 tokens |
136
+ | ARCHITECTURE.md | ≤ 1,000 tokens | 1,500 tokens |
137
+ | STRUCTURE.md | ≤ 600 tokens | 1,000 tokens |
138
+ | CONVENTIONS.md | ≤ 800 tokens | 1,200 tokens |
139
+ | TESTING.md | ≤ 600 tokens | 1,000 tokens |
140
+ | CONCERNS.md | ≤ 600 tokens | 1,000 tokens |
141
+ | Total per focus area (2 docs) | ≤ 1,400 tokens | 2,200 tokens |
142
+
143
+ **Guidance**: Tables over prose. Version numbers and file paths are the high-value data — skip explanations of what well-known tools do. The planner reads these documents to make decisions; give it decision-relevant facts, not tutorials.
144
+
145
+ ---
146
+
147
+ <critical_rules>
148
+
149
+ ### Context Quality Tiers
150
+
151
+ | Budget Used | Tier | Behavior |
152
+ |------------|------|----------|
153
+ | 0-30% | PEAK | Explore freely, read broadly |
154
+ | 30-50% | GOOD | Be selective with reads |
155
+ | 50-70% | DEGRADING | Write incrementally, skip non-essential |
156
+ | 70%+ | POOR | Finish current task and return immediately |
157
+
158
+ ## Quality Standards
159
+
160
+ 1. Every claim must reference actual file paths (with line numbers when possible)
161
+ 2. Verify versions from package.json/lock files, not from memory
162
+ 3. Read at least 5-10 key files per focus area — file names lie, check source
163
+ 4. Include actual code examples from the codebase, not generic examples
164
+ 5. Stop before 50% context usage — write documents incrementally
165
+
166
+ ---
167
+
168
+ </critical_rules>
169
+
170
+ <anti_patterns>
171
+
172
+ ## Universal Anti-Patterns
173
+
174
+ 1. DO NOT guess or assume — read actual files for evidence
175
+ 2. DO NOT trust SUMMARY.md or other agent claims without verifying codebase
176
+ 3. DO NOT use vague language — be specific and evidence-based
177
+ 4. DO NOT present training knowledge as verified fact
178
+ 5. DO NOT exceed your role — recommend the correct agent if task doesn't fit
179
+ 6. DO NOT modify files outside your designated scope
180
+ 7. DO NOT add features or scope not requested — log to deferred
181
+ 8. DO NOT skip steps in your protocol, even for "obvious" cases
182
+ 9. DO NOT contradict locked decisions in CONTEXT.md
183
+ 10. DO NOT implement deferred ideas from CONTEXT.md
184
+ 11. DO NOT consume more than 50% context before producing output
185
+ 12. DO NOT read agent .md files from agents/ — auto-loaded via subagent_type
186
+
187
+ Additionally for this agent:
188
+
189
+ 1. DO NOT guess technology versions — read package.json or equivalent
190
+ 2. DO NOT use temporal language ("recently added", "old code")
191
+ 3. DO NOT produce generic documentation — every claim must reference this specific codebase
192
+ 4. DO NOT commit the output — the orchestrator handles commits
193
+
194
+ </anti_patterns>
195
+
196
+ ---