@orderful/droid 0.25.2 → 0.27.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 (159) hide show
  1. package/.claude-plugin/marketplace.json +114 -0
  2. package/.github/workflows/ci.yml +20 -0
  3. package/AGENTS.md +75 -18
  4. package/CHANGELOG.md +73 -0
  5. package/README.md +30 -4
  6. package/dist/bin/droid.js +164 -75
  7. package/dist/index.js +68 -26
  8. package/dist/lib/migrations.d.ts +8 -0
  9. package/dist/lib/migrations.d.ts.map +1 -1
  10. package/dist/lib/skill-config.d.ts.map +1 -1
  11. package/dist/lib/skills.d.ts.map +1 -1
  12. package/dist/lib/tools.d.ts.map +1 -1
  13. package/dist/lib/types.d.ts +10 -2
  14. package/dist/lib/types.d.ts.map +1 -1
  15. package/dist/tools/README.md +1 -1
  16. package/dist/tools/brain/.claude-plugin/plugin.json +16 -0
  17. package/dist/tools/brain/TOOL.yaml +7 -5
  18. package/dist/tools/brain/commands/brain.md +17 -49
  19. package/dist/tools/brain/commands/scratchpad.md +13 -50
  20. package/{src/tools/brain/skills/droid-brain → dist/tools/brain/skills/brain}/SKILL.md +6 -6
  21. package/dist/tools/brain/skills/{droid-brain-obsidian → brain-obsidian}/SKILL.md +9 -9
  22. package/dist/tools/coach/.claude-plugin/plugin.json +16 -0
  23. package/dist/tools/coach/TOOL.yaml +4 -3
  24. package/dist/tools/coach/commands/coach.md +14 -54
  25. package/{src/tools/coach/skills/droid-coach → dist/tools/coach/skills/coach}/SKILL.md +5 -4
  26. package/dist/tools/code-review/.claude-plugin/plugin.json +16 -0
  27. package/dist/tools/code-review/TOOL.yaml +4 -3
  28. package/dist/tools/code-review/commands/code-review.md +18 -102
  29. package/dist/tools/code-review/skills/code-review/SKILL.md +154 -0
  30. package/dist/tools/codex/.claude-plugin/plugin.json +16 -0
  31. package/dist/tools/codex/TOOL.yaml +5 -4
  32. package/dist/tools/codex/commands/codex.md +18 -65
  33. package/dist/tools/codex/skills/{droid-codex → codex}/SKILL.md +64 -45
  34. package/{src/tools/codex/skills/droid-codex → dist/tools/codex/skills/codex}/references/loading.md +94 -55
  35. package/dist/tools/codex/skills/codex/scripts/git-finish-write.d.ts.map +1 -0
  36. package/dist/tools/codex/skills/codex/scripts/git-preamble.d.ts.map +1 -0
  37. package/dist/tools/codex/skills/codex/scripts/git-start-write.d.ts.map +1 -0
  38. package/dist/tools/comments/.claude-plugin/plugin.json +16 -0
  39. package/dist/tools/comments/TOOL.yaml +4 -3
  40. package/dist/tools/comments/commands/comments.md +12 -14
  41. package/{src/tools/comments/skills/droid-comments → dist/tools/comments/skills/comments}/SKILL.md +4 -2
  42. package/dist/tools/droid/.claude-plugin/plugin.json +15 -0
  43. package/dist/tools/droid/TOOL.yaml +1 -1
  44. package/dist/tools/droid/skills/droid/SKILL.md +1 -1
  45. package/dist/tools/project/.claude-plugin/plugin.json +16 -0
  46. package/dist/tools/project/TOOL.yaml +4 -3
  47. package/dist/tools/project/commands/project.md +12 -27
  48. package/dist/tools/project/skills/{droid-project → project}/SKILL.md +13 -12
  49. package/dist/tools/tech-design/.claude-plugin/plugin.json +16 -0
  50. package/dist/tools/tech-design/TOOL.yaml +19 -0
  51. package/dist/tools/tech-design/commands/tech-design.md +31 -0
  52. package/dist/tools/tech-design/skills/tech-design/SKILL.md +218 -0
  53. package/dist/tools/tech-design/skills/tech-design/references/draft.md +321 -0
  54. package/dist/tools/tech-design/skills/tech-design/references/gaps.md +328 -0
  55. package/dist/tools/tech-design/skills/tech-design/references/publish.md +409 -0
  56. package/dist/tools/tech-design/skills/tech-design/references/research-doc-template.md +129 -0
  57. package/dist/tools/tech-design/skills/tech-design/references/rollup-template.md +55 -0
  58. package/dist/tools/tech-design/skills/tech-design/references/start.md +353 -0
  59. package/dist/tools/tech-design/skills/tech-design/references/think.md +356 -0
  60. package/dist/tools/tech-design/skills/tech-design/references/thought-doc-template.md +72 -0
  61. package/package.json +3 -2
  62. package/scripts/build-plugins.ts +207 -0
  63. package/src/commands/tui/components/Badge.test.tsx +10 -4
  64. package/src/commands/tui.tsx +4 -4
  65. package/src/lib/migrations.ts +95 -4
  66. package/src/lib/skill-config.ts +95 -57
  67. package/src/lib/skills.test.ts +199 -74
  68. package/src/lib/skills.ts +57 -56
  69. package/src/lib/tools.ts +19 -12
  70. package/src/lib/types.ts +20 -5
  71. package/src/tools/README.md +1 -1
  72. package/src/tools/brain/.claude-plugin/plugin.json +16 -0
  73. package/src/tools/brain/TOOL.yaml +7 -5
  74. package/src/tools/brain/commands/brain.md +17 -49
  75. package/src/tools/brain/commands/scratchpad.md +13 -50
  76. package/{dist/tools/brain/skills/droid-brain → src/tools/brain/skills/brain}/SKILL.md +6 -6
  77. package/src/tools/brain/skills/{droid-brain-obsidian → brain-obsidian}/SKILL.md +9 -9
  78. package/src/tools/coach/.claude-plugin/plugin.json +16 -0
  79. package/src/tools/coach/TOOL.yaml +4 -3
  80. package/src/tools/coach/commands/coach.md +14 -54
  81. package/{dist/tools/coach/skills/droid-coach → src/tools/coach/skills/coach}/SKILL.md +5 -4
  82. package/src/tools/code-review/.claude-plugin/plugin.json +16 -0
  83. package/src/tools/code-review/TOOL.yaml +4 -3
  84. package/src/tools/code-review/commands/code-review.md +18 -102
  85. package/src/tools/code-review/skills/code-review/SKILL.md +154 -0
  86. package/src/tools/codex/.claude-plugin/plugin.json +16 -0
  87. package/src/tools/codex/TOOL.yaml +5 -4
  88. package/src/tools/codex/commands/codex.md +18 -65
  89. package/src/tools/codex/skills/{droid-codex → codex}/SKILL.md +64 -45
  90. package/{dist/tools/codex/skills/droid-codex → src/tools/codex/skills/codex}/references/loading.md +94 -55
  91. package/src/tools/comments/.claude-plugin/plugin.json +16 -0
  92. package/src/tools/comments/TOOL.yaml +4 -3
  93. package/src/tools/comments/commands/comments.md +12 -14
  94. package/{dist/tools/comments/skills/droid-comments → src/tools/comments/skills/comments}/SKILL.md +4 -2
  95. package/src/tools/droid/.claude-plugin/plugin.json +15 -0
  96. package/src/tools/droid/TOOL.yaml +1 -1
  97. package/src/tools/droid/skills/droid/SKILL.md +1 -1
  98. package/src/tools/project/.claude-plugin/plugin.json +16 -0
  99. package/src/tools/project/TOOL.yaml +4 -3
  100. package/src/tools/project/commands/project.md +12 -27
  101. package/src/tools/project/skills/{droid-project → project}/SKILL.md +13 -12
  102. package/src/tools/tech-design/.claude-plugin/plugin.json +16 -0
  103. package/src/tools/tech-design/TOOL.yaml +19 -0
  104. package/src/tools/tech-design/commands/tech-design.md +31 -0
  105. package/src/tools/tech-design/skills/tech-design/SKILL.md +218 -0
  106. package/src/tools/tech-design/skills/tech-design/references/draft.md +321 -0
  107. package/src/tools/tech-design/skills/tech-design/references/gaps.md +328 -0
  108. package/src/tools/tech-design/skills/tech-design/references/publish.md +409 -0
  109. package/src/tools/tech-design/skills/tech-design/references/research-doc-template.md +129 -0
  110. package/src/tools/tech-design/skills/tech-design/references/rollup-template.md +55 -0
  111. package/src/tools/tech-design/skills/tech-design/references/start.md +353 -0
  112. package/src/tools/tech-design/skills/tech-design/references/think.md +356 -0
  113. package/src/tools/tech-design/skills/tech-design/references/thought-doc-template.md +72 -0
  114. package/dist/tools/code-review/skills/droid-code-review/SKILL.md +0 -55
  115. package/dist/tools/codex/skills/droid-codex/scripts/git-finish-write.d.ts.map +0 -1
  116. package/dist/tools/codex/skills/droid-codex/scripts/git-preamble.d.ts.map +0 -1
  117. package/dist/tools/codex/skills/droid-codex/scripts/git-start-write.d.ts.map +0 -1
  118. package/src/tools/code-review/skills/droid-code-review/SKILL.md +0 -55
  119. /package/dist/tools/brain/skills/{droid-brain → brain}/references/metadata.md +0 -0
  120. /package/dist/tools/brain/skills/{droid-brain → brain}/references/naming.md +0 -0
  121. /package/dist/tools/brain/skills/{droid-brain → brain}/references/templates.md +0 -0
  122. /package/dist/tools/brain/skills/{droid-brain → brain}/references/workflows.md +0 -0
  123. /package/dist/tools/brain/skills/{droid-brain-obsidian → brain-obsidian}/references/templates.md +0 -0
  124. /package/dist/tools/brain/skills/{droid-brain-obsidian → brain-obsidian}/references/workflows.md +0 -0
  125. /package/dist/tools/codex/skills/{droid-codex → codex}/references/creating.md +0 -0
  126. /package/dist/tools/codex/skills/{droid-codex → codex}/references/decisions.md +0 -0
  127. /package/dist/tools/codex/skills/{droid-codex → codex}/references/topics.md +0 -0
  128. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-finish-write.d.ts +0 -0
  129. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-finish-write.ts +0 -0
  130. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-preamble.d.ts +0 -0
  131. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-preamble.ts +0 -0
  132. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-scripts.test.ts +0 -0
  133. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-start-write.d.ts +0 -0
  134. /package/dist/tools/codex/skills/{droid-codex → codex}/scripts/git-start-write.ts +0 -0
  135. /package/dist/tools/project/skills/{droid-project → project}/references/changelog.md +0 -0
  136. /package/dist/tools/project/skills/{droid-project → project}/references/creating.md +0 -0
  137. /package/dist/tools/project/skills/{droid-project → project}/references/loading.md +0 -0
  138. /package/dist/tools/project/skills/{droid-project → project}/references/templates.md +0 -0
  139. /package/dist/tools/project/skills/{droid-project → project}/references/updating.md +0 -0
  140. /package/dist/tools/project/skills/{droid-project → project}/references/versioning.md +0 -0
  141. /package/src/tools/brain/skills/{droid-brain → brain}/references/metadata.md +0 -0
  142. /package/src/tools/brain/skills/{droid-brain → brain}/references/naming.md +0 -0
  143. /package/src/tools/brain/skills/{droid-brain → brain}/references/templates.md +0 -0
  144. /package/src/tools/brain/skills/{droid-brain → brain}/references/workflows.md +0 -0
  145. /package/src/tools/brain/skills/{droid-brain-obsidian → brain-obsidian}/references/templates.md +0 -0
  146. /package/src/tools/brain/skills/{droid-brain-obsidian → brain-obsidian}/references/workflows.md +0 -0
  147. /package/src/tools/codex/skills/{droid-codex → codex}/references/creating.md +0 -0
  148. /package/src/tools/codex/skills/{droid-codex → codex}/references/decisions.md +0 -0
  149. /package/src/tools/codex/skills/{droid-codex → codex}/references/topics.md +0 -0
  150. /package/src/tools/codex/skills/{droid-codex → codex}/scripts/git-finish-write.ts +0 -0
  151. /package/src/tools/codex/skills/{droid-codex → codex}/scripts/git-preamble.ts +0 -0
  152. /package/src/tools/codex/skills/{droid-codex → codex}/scripts/git-scripts.test.ts +0 -0
  153. /package/src/tools/codex/skills/{droid-codex → codex}/scripts/git-start-write.ts +0 -0
  154. /package/src/tools/project/skills/{droid-project → project}/references/changelog.md +0 -0
  155. /package/src/tools/project/skills/{droid-project → project}/references/creating.md +0 -0
  156. /package/src/tools/project/skills/{droid-project → project}/references/loading.md +0 -0
  157. /package/src/tools/project/skills/{droid-project → project}/references/templates.md +0 -0
  158. /package/src/tools/project/skills/{droid-project → project}/references/updating.md +0 -0
  159. /package/src/tools/project/skills/{droid-project → project}/references/versioning.md +0 -0
@@ -0,0 +1,218 @@
1
+ ---
2
+ name: tech-design
3
+ description: "Technical design authoring with three-document approach - research doc (codebase discoveries), thought doc (design iteration), and roll-up (clean summary). Use when writing tech designs, drafting sections, exploring architectural ideas, or publishing to codex. User prompts like 'start tech design for X', 'draft the rollout section', 'let's think through the API design', 'publish this to codex'."
4
+ globs: []
5
+ alwaysApply: false
6
+ allowed-tools:
7
+ [Read, Write, Edit, Glob, Grep, Bash(gh:*), Bash(git:*), Bash(mkdir:*), Task]
8
+ ---
9
+
10
+ # Tech Design Skill
11
+
12
+ > Tech designs are where architectural decisions get made. Make them AI-friendly.
13
+
14
+ Technical design authoring for engineers using a three-document approach: research doc captures codebase discoveries, thought doc for design iteration, roll-up for reviewers. Markdown in GitHub, version-controlled, PR-reviewed.
15
+
16
+ ## Why This Matters
17
+
18
+ Tech designs are often:
19
+
20
+ - Written in Confluence (slow, disconnected from code)
21
+ - Missing key sections (no template enforcement)
22
+ - Hard to iterate on (not AI-friendly)
23
+ - Siloed (reviewer can't see the author's thinking)
24
+ - Re-discovering the same patterns every time
25
+
26
+ The `/tech-design` skill brings tech design authoring into the same AI-augmented workflow engineers already use for coding, with persistent codebase knowledge.
27
+
28
+ ## Prerequisites
29
+
30
+ Before using tech-design, verify:
31
+
32
+ 1. **Brain skill configured:** Check if `~/.droid/skills/brain/overrides.yaml` exists
33
+ 2. **Codex skill configured:** Check if `~/.droid/skills/codex/overrides.yaml` exists
34
+ 3. **gh CLI:** Required for PR workflows
35
+
36
+ If prerequisites fail, guide user to configure:
37
+
38
+ - Brain missing: Direct to `/brain` command to set up brain directory
39
+ - Codex missing: Direct to `/codex` command to set up codex repository
40
+ - gh missing: `brew install gh && gh auth login`
41
+
42
+ ## Configuration
43
+
44
+ Tech-design has no configuration of its own. It delegates to:
45
+
46
+ - **Brain skill** for research + thought doc location (`brain_dir`, `inbox_folder`)
47
+ - **Codex skill** for repository location (`codex_repo`)
48
+
49
+ ## Three-Document Approach
50
+
51
+ | Document | Created When | Purpose | Location | Audience |
52
+ | --------------- | ------------ | ----------------------------------------------- | ------------- | ----------- |
53
+ | **Research** | `/start` | Deep dive: codex project + codebase discoveries | Brain | Author + AI |
54
+ | **Thought doc** | `/start` | Design iteration: decisions, @mentions, drafts | Brain | Author + AI |
55
+ | **Roll-up** | `/publish` | Clean summary: decisions only, reviewable | Codex project | Reviewers |
56
+
57
+ **Why three documents?**
58
+
59
+ 1. **Research doc** = Persistent memory of codebase exploration
60
+ - Project-specific patterns discovered
61
+ - Existing implementations found
62
+ - Dependencies identified
63
+ - Stack/framework details
64
+ - Lives across sessions, not just context window
65
+
66
+ 2. **Thought doc** = Design workspace
67
+ - References research doc for context
68
+ - Focuses on architectural decisions
69
+ - Iterates with `@droid`/`@user` comments
70
+ - Captures the "why" behind choices
71
+
72
+ 3. **Roll-up** = Reviewer artifact
73
+ - Synthesized from thought doc
74
+ - Decision-focused, no exploration noise
75
+ - Ready for PR review
76
+
77
+ **Philosophy:** Research captures "what exists", thought doc explores "what we'll build", roll-up communicates "what we decided".
78
+
79
+ Both thought doc and roll-up are published to codex. Research doc stays in brain as project-specific knowledge base.
80
+
81
+ ## Commands
82
+
83
+ | Command | Action | Status |
84
+ | ------------------------------------------- | -------------------------------------------------------- | ------ |
85
+ | `/tech-design start --from codex:{project}` | Create research + thought docs, pull PRD/DESIGN context | v1 |
86
+ | `/tech-design draft [section]` | Auto-generate from research doc + codebase exploration | v1 |
87
+ | `/tech-design think [topic]` | Guided exploration, updates research doc with findings | v1 |
88
+ | `/tech-design gaps` | Checklist of missing/empty sections | v1 |
89
+ | `/tech-design publish` | Generate roll-up, publish thought doc + roll-up to codex | v1 |
90
+ | `/tech-design critic [persona]` | Multi-persona review with severity scoring | v2 |
91
+ | `/tech-design respond {question}` | Author tool: search thought doc to draft reply | v2 |
92
+ | `/tech-design ask {question}` | Reviewer tool: search both docs to answer questions | v2 |
93
+
94
+ ## Conversational Skill Matching
95
+
96
+ Commands are explicit entry points, but most usage will be natural conversation. Match these patterns:
97
+
98
+ | User says | Interpret as |
99
+ | -------------------------------------- | ---------------------------------------------------- |
100
+ | "Let's draft the rollout section" | `/draft rollout` - draft that section with research |
101
+ | "Can you write up the data model?" | `/draft data-model` - draft Data Model section |
102
+ | "I'm thinking about using events here" | `/think` - explore first, stress-test the idea |
103
+ | "Write that up" | After `/think`, transition to `/draft` for that idea |
104
+ | "What's missing?" | `/gaps` - show checklist of empty sections |
105
+ | "Let's think through the API" | `/think api` - guided exploration of API design |
106
+
107
+ ## Starting a Tech Design
108
+
109
+ **Trigger:** `/tech-design start --from codex:{project}` or user wants to start a new tech design
110
+
111
+ **TLDR:** Create research + thought docs in brain, pull PRD/DESIGN context from codex, perform deep codebase dive, set as active.
112
+
113
+ **Full procedure:** See `references/start.md` for detailed implementation steps, error handling, and examples.
114
+
115
+ ## Drafting Content
116
+
117
+ **Trigger:** `/tech-design draft [section]` or user wants to generate content
118
+
119
+ **TLDR:** Research doc first, then draft. Use research doc as knowledge base. Explore codebase if needed, update research doc with findings.
120
+
121
+ **Full procedure:** See `references/draft.md` for research strategies, section-specific guidance, and examples.
122
+
123
+ ## Thinking Through Ideas
124
+
125
+ **Trigger:** `/tech-design think [topic]` or user wants to explore an idea
126
+
127
+ **TLDR:** Think = explore/stress-test; Draft = write to doc. Updates research doc with findings. Often flows: think → decide → draft.
128
+
129
+ **Full procedure:** See `references/think.md` for questioning strategies, directed vs freeform modes, and examples.
130
+
131
+ **Cross-platform approach:** Use prose-based questioning (works on OpenCode + Claude Code). Don't rely on interactive prompts.
132
+
133
+ ## Gap Analysis
134
+
135
+ **Trigger:** `/tech-design gaps` or user asks "what's missing?"
136
+
137
+ **TLDR:** Show checklist of sections that are empty or missing. Offer `/think` for each.
138
+
139
+ **Full procedure:** See `references/gaps.md` for criticality logic, PRD-based inference, and examples.
140
+
141
+ ## Publishing to Codex
142
+
143
+ **Trigger:** `/tech-design publish` or user wants to create PR for review
144
+
145
+ **TLDR:** Generate clean roll-up from thought doc, publish thought doc + roll-up to codex (research doc stays in brain).
146
+
147
+ **Full procedure:** See `references/publish.md` for roll-up generation, git workflow, quality checklist, and examples.
148
+
149
+ ## Active Doc Tracking
150
+
151
+ Leverage brain's active doc tracking:
152
+
153
+ - When `/tech-design start` creates research + thought docs, thought doc becomes active
154
+ - Subsequent commands operate on active thought doc without specifying path
155
+ - Research doc is referenced by path when needed (stays as reference knowledge)
156
+ - User can also use `/brain` or `/scratchpad` to work on the thought doc
157
+
158
+ **Integration nudge:** Always remind users they can use brain commands:
159
+
160
+ - "You can add notes with `/brain add` or check comments with `/brain check`"
161
+
162
+ ## Template Philosophy
163
+
164
+ **Research doc:** Codebase discovery log - captures patterns, implementations, stack details. Project-specific knowledge base.
165
+
166
+ **Thought doc:** Start minimal (3 sections), grow as needed:
167
+
168
+ - **Background** - Why we're doing this
169
+ - **Proposal** - What we're building
170
+ - **Open Questions** - What we don't know yet
171
+
172
+ Use `/gaps` to surface what's missing. Don't overwhelm at the start.
173
+
174
+ **Roll-up:** Clean summary for reviewers - decisions only, no exploration noise.
175
+
176
+ ## Related Skills
177
+
178
+ - **Brain** - Thought doc drafting location, active doc tracking, @mention comments
179
+ - **Codex** - Context input (PRD/DESIGN), output location (TECH-DESIGN.md), PR creation
180
+ - **Project** - Personal working memory (different from shared codex knowledge)
181
+
182
+ ## V2 Features (Not Yet Implemented)
183
+
184
+ The following features are planned for v2 but not yet available:
185
+
186
+ ### Critic Personas
187
+
188
+ Run thought doc through multiple personas via parallel sub-agents:
189
+
190
+ | Persona | Focus |
191
+ | ----------------- | ----------------------------------------- |
192
+ | Security | Input validation, auth, rate limiting |
193
+ | Ops/SRE | Monitoring, alerting, runbooks |
194
+ | Junior Engineer | Clarity, documentation, "why X over Y?" |
195
+ | Product Owner | Does this solve the user problem? |
196
+ | Future Maintainer | Will someone understand this in 6 months? |
197
+
198
+ Output with severity scoring:
199
+
200
+ ```
201
+ 🔴 Security: No input validation mentioned for user-provided templates
202
+ 🔴 Ops: Missing monitoring/alerting strategy
203
+ 🟡 Future Maintainer: Decision rationale for X over Y is thin
204
+ 🟢 Product: Aligns well with PRD requirements
205
+ 🟢 Junior: Implementation plan is clear
206
+ ```
207
+
208
+ ### Interaction Tools
209
+
210
+ - `/tech-design respond {question}` - Author tool: search thought doc to draft reply to reviewer questions
211
+ - `/tech-design ask {question}` - Reviewer tool: search both docs to answer questions
212
+
213
+ ## Notes
214
+
215
+ - Only create thought docs when user explicitly starts a tech design (don't be proactive)
216
+ - Always check for existing thought doc before creating new one
217
+ - Respect user's draft location preference (don't hardcode paths)
218
+ - If codex project missing: warn but continue (common during early adoption)
@@ -0,0 +1,321 @@
1
+ # Drafting Content
2
+
3
+ **Trigger:** `/tech-design draft [section]` or user wants to generate content
4
+
5
+ **Goal:** Use research doc as knowledge base, do additional exploration if needed, draft content into thought doc.
6
+
7
+ **Security Note:** All user-provided inputs must be validated before use in shell commands. File paths and search patterns should be sanitized to prevent command injection.
8
+
9
+ ## Procedure
10
+
11
+ ### 1. Determine Scope
12
+
13
+ ```bash
14
+ if [ -z "$section" ]; then
15
+ # Whole doc - draft all three initial sections
16
+ sections=("Background" "Proposal" "Open Questions")
17
+ else
18
+ # Specific section
19
+ sections=("$section")
20
+ fi
21
+ ```
22
+
23
+ ### 2. Load Research Doc
24
+
25
+ **Research doc should exist** - created during `/tech-design start`.
26
+
27
+ - Read research doc: `tech-design-{project}-research.md`
28
+ - Extract relevant findings for the section being drafted
29
+ - Use as knowledge base to inform draft
30
+
31
+ **If research doc missing:**
32
+
33
+ - Warn user: "Research doc not found. Run `/tech-design start` first to create research + thought docs."
34
+ - Option to continue without research context
35
+
36
+ ### 3. Section-Specific Drafting
37
+
38
+ For each section, use research doc findings and do additional exploration as needed.
39
+
40
+ #### Background Section
41
+
42
+ **Sources:**
43
+
44
+ - PRD context from research doc → "Codex Context" section
45
+ - Current state from research doc → "Similar Implementations"
46
+
47
+ **Draft structure:**
48
+
49
+ ```markdown
50
+ ## Background
51
+
52
+ ### Problem
53
+
54
+ {Why we're doing this - from PRD in research doc}
55
+
56
+ ### Current State
57
+
58
+ {What exists today - from research doc discoveries}
59
+
60
+ Reference findings from research:
61
+
62
+ - Existing pattern: {file path from research}
63
+ - Current approach: {description from research}
64
+
65
+ ### Context
66
+
67
+ {Who needs this and why - from PRD}
68
+ ```
69
+
70
+ #### Proposal Section
71
+
72
+ **Sources:**
73
+
74
+ - Architecture patterns from research doc
75
+ - Integration points from research doc
76
+ - Dependencies from research doc
77
+ - Additional codebase exploration if needed
78
+
79
+ **Draft structure:**
80
+
81
+ ```markdown
82
+ ## Proposal
83
+
84
+ ### Overview
85
+
86
+ {High-level approach - informed by patterns in research doc}
87
+
88
+ ### Architecture
89
+
90
+ {How it fits - reference integration points from research}
91
+
92
+ Follows pattern from: {file path from research doc}
93
+ Integrates with: {modules/services from research doc}
94
+
95
+ ### Data Model
96
+
97
+ {Tables, schemas, types needed}
98
+
99
+ ### API Surface
100
+
101
+ {New endpoints, methods, interfaces}
102
+
103
+ ### Implementation Approach
104
+
105
+ {Step-by-step - leverage dependencies already identified in research}
106
+ ```
107
+
108
+ **Additional exploration:**
109
+
110
+ - If research doc doesn't have enough detail for a subsection, explore further
111
+ - Add new discoveries back to research doc
112
+ - Keep research doc as living knowledge base
113
+
114
+ #### Open Questions Section
115
+
116
+ **Sources:**
117
+
118
+ - Scan PRD for ambiguous requirements
119
+ - Gaps identified during proposal drafting
120
+ - Missing information from research phase
121
+
122
+ **Draft structure:**
123
+
124
+ ```markdown
125
+ ## Open Questions
126
+
127
+ - [ ] {Question from PRD ambiguity}
128
+ - [ ] {Question from technical exploration}
129
+ - [ ] {Question about integration - e.g., "How should X handle Y?"}
130
+ ```
131
+
132
+ ### 4. Write to Thought Doc
133
+
134
+ - Read existing thought doc
135
+ - Replace or populate the section being drafted
136
+ - Preserve any existing `@droid`/`@{user}` comments
137
+ - Keep content outside the target section unchanged
138
+
139
+ ### 5. Output Summary
140
+
141
+ ```
142
+ ✓ Drafted: {section}
143
+
144
+ Key points from research doc:
145
+ • {Finding 1 referenced}
146
+ • {Finding 2 referenced}
147
+
148
+ {If additional exploration was done:}
149
+ Additional discoveries:
150
+ • {New finding}
151
+ • {Added to research doc}
152
+
153
+ Next steps:
154
+ • Review and refine: Open {thought_doc_path}
155
+ • Draft another section: /tech-design draft {section-name}
156
+ • Explore an idea: /tech-design think {topic}
157
+ • Check completeness: /tech-design gaps
158
+ ```
159
+
160
+ ## Section-Specific Guidance
161
+
162
+ ### Rollout Plan
163
+
164
+ **Research doc reference:**
165
+
166
+ - Deployment patterns
167
+ - Feature flag setup (if found)
168
+ - Monitoring/observability setup
169
+
170
+ **Explore if needed:**
171
+
172
+ - How are similar features rolled out?
173
+ - What rollback mechanisms exist?
174
+
175
+ **Draft:**
176
+
177
+ ```markdown
178
+ ## Rollout Plan
179
+
180
+ ### Phases
181
+
182
+ | Phase | Audience | Timeline | Success Criteria |
183
+ | ----- | -------- | -------- | ---------------- |
184
+ | 1 | ... | ... | ... |
185
+
186
+ ### Feature Flags
187
+
188
+ {Based on feature flag patterns from research}
189
+
190
+ ### Rollback Strategy
191
+
192
+ {Based on deployment patterns from research}
193
+
194
+ ### Monitoring
195
+
196
+ {Based on observability setup from research}
197
+ ```
198
+
199
+ ### Data Model
200
+
201
+ **Research doc reference:**
202
+
203
+ - Existing database/storage patterns
204
+ - Schema conventions
205
+ - ORM/database tooling used
206
+
207
+ **Explore if needed:**
208
+
209
+ - Similar data models in codebase
210
+ - Migration patterns
211
+
212
+ **Draft:**
213
+
214
+ ```markdown
215
+ ## Data Model
216
+
217
+ ### Entities
218
+
219
+ {Based on patterns from research doc}
220
+
221
+ ### Relationships
222
+
223
+ {How entities relate}
224
+
225
+ ### Migrations
226
+
227
+ {Following migration pattern from research}
228
+ ```
229
+
230
+ ### API Surface
231
+
232
+ **Research doc reference:**
233
+
234
+ - Existing API patterns (REST, GraphQL, gRPC, etc.)
235
+ - Authentication/authorization patterns
236
+ - Rate limiting setup
237
+
238
+ **Explore if needed:**
239
+
240
+ - Similar endpoint implementations
241
+ - Validation patterns
242
+
243
+ **Draft:**
244
+
245
+ ```markdown
246
+ ## API Surface
247
+
248
+ ### Endpoints
249
+
250
+ {Following API pattern from research}
251
+
252
+ ### Authentication
253
+
254
+ {Using auth pattern from research}
255
+
256
+ ### Validation
257
+
258
+ {Based on validation patterns found}
259
+ ```
260
+
261
+ ### Security Considerations
262
+
263
+ **Research doc reference:**
264
+
265
+ - Auth patterns
266
+ - Input validation setup
267
+ - Audit logging
268
+
269
+ **Explore if needed:**
270
+
271
+ - How are similar features secured?
272
+ - What security reviews exist?
273
+
274
+ **Draft:**
275
+
276
+ ```markdown
277
+ ## Security Considerations
278
+
279
+ ### Authentication & Authorization
280
+
281
+ {Based on auth patterns from research}
282
+
283
+ ### Input Validation
284
+
285
+ {Based on validation patterns from research}
286
+
287
+ ### Audit Logging
288
+
289
+ {Based on logging patterns from research}
290
+
291
+ ### Risk Assessment
292
+
293
+ | Risk | Mitigation |
294
+ | ---- | ---------- |
295
+ | ... | ... |
296
+ ```
297
+
298
+ ## Error Handling
299
+
300
+ - **Thought doc not found:** Remind user to run `/tech-design start` first
301
+ - **Research doc not found:** Warn but offer to continue with limited context
302
+ - **Section not recognized:** List valid sections, suggest `/tech-design gaps` to see what's missing
303
+ - **Exploration fails:** Gracefully continue, note what couldn't be found
304
+
305
+ ## Example Output
306
+
307
+ ```
308
+ ✓ Loaded research doc for transaction-templates
309
+
310
+ ✓ Drafted: Proposal
311
+
312
+ Key points from research doc:
313
+ • Template storage pattern: Found in {file path}
314
+ • Validation service: Integration point at {module}
315
+ • Dependencies: {library} already available
316
+
317
+ Next steps:
318
+ • Review and refine: Open {brain_dir}/0-Inbox/plans/tech-design-transaction-templates.md
319
+ • Draft another section: /tech-design draft rollout
320
+ • Check completeness: /tech-design gaps
321
+ ```