pi-maestro-flow 0.2.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 (179) hide show
  1. package/README.md +124 -0
  2. package/agents/aggregator.md +27 -0
  3. package/agents/cli-explore-agent.md +188 -0
  4. package/agents/cross-role-reviewer.md +171 -0
  5. package/agents/delegate.md +19 -0
  6. package/agents/explorer.md +23 -0
  7. package/agents/impeccable-agent.md +99 -0
  8. package/agents/ralph-executor.md +81 -0
  9. package/agents/reference.md +24 -0
  10. package/agents/role-design-author.md +220 -0
  11. package/agents/team-supervisor.md +143 -0
  12. package/agents/team-worker.md +237 -0
  13. package/agents/ui-design-agent.md +270 -0
  14. package/agents/workflow-analyzer.md +116 -0
  15. package/agents/workflow-codebase-mapper.md +77 -0
  16. package/agents/workflow-collab-planner.md +147 -0
  17. package/agents/workflow-debugger.md +104 -0
  18. package/agents/workflow-executor.md +133 -0
  19. package/agents/workflow-external-researcher.md +86 -0
  20. package/agents/workflow-integration-checker.md +83 -0
  21. package/agents/workflow-nyquist-auditor.md +85 -0
  22. package/agents/workflow-phase-researcher.md +85 -0
  23. package/agents/workflow-plan-checker.md +100 -0
  24. package/agents/workflow-planner.md +200 -0
  25. package/agents/workflow-project-researcher.md +74 -0
  26. package/agents/workflow-research-synthesizer.md +70 -0
  27. package/agents/workflow-reviewer.md +82 -0
  28. package/agents/workflow-roadmapper.md +81 -0
  29. package/agents/workflow-verifier.md +120 -0
  30. package/package.json +58 -0
  31. package/skills/codify-to-knowhow/SKILL.md +167 -0
  32. package/skills/delegation-check/SKILL.md +297 -0
  33. package/skills/domain-add/SKILL.md +75 -0
  34. package/skills/insight-challenge/SKILL.md +226 -0
  35. package/skills/learn-decompose/SKILL.md +124 -0
  36. package/skills/learn-follow/SKILL.md +163 -0
  37. package/skills/learn-investigate/SKILL.md +160 -0
  38. package/skills/learn-second-opinion/SKILL.md +128 -0
  39. package/skills/maestro/SKILL.md +239 -0
  40. package/skills/maestro-amend/SKILL.md +169 -0
  41. package/skills/maestro-analyze/SKILL.md +173 -0
  42. package/skills/maestro-blueprint/SKILL.md +159 -0
  43. package/skills/maestro-brainstorm/SKILL.md +193 -0
  44. package/skills/maestro-collab/SKILL.md +181 -0
  45. package/skills/maestro-companion/SKILL.md +536 -0
  46. package/skills/maestro-composer/SKILL.md +192 -0
  47. package/skills/maestro-execute/SKILL.md +193 -0
  48. package/skills/maestro-fork/SKILL.md +104 -0
  49. package/skills/maestro-grill/SKILL.md +151 -0
  50. package/skills/maestro-guard/SKILL.md +124 -0
  51. package/skills/maestro-help/SKILL.md +328 -0
  52. package/skills/maestro-impeccable/SKILL.md +302 -0
  53. package/skills/maestro-init/SKILL.md +151 -0
  54. package/skills/maestro-merge/SKILL.md +90 -0
  55. package/skills/maestro-milestone-audit/SKILL.md +117 -0
  56. package/skills/maestro-milestone-complete/SKILL.md +133 -0
  57. package/skills/maestro-milestone-release/SKILL.md +131 -0
  58. package/skills/maestro-next/SKILL.md +269 -0
  59. package/skills/maestro-overlay/SKILL.md +203 -0
  60. package/skills/maestro-plan/SKILL.md +194 -0
  61. package/skills/maestro-player/SKILL.md +184 -0
  62. package/skills/maestro-quick/SKILL.md +117 -0
  63. package/skills/maestro-ralph/SKILL.md +905 -0
  64. package/skills/maestro-ralph-cli/SKILL.md +976 -0
  65. package/skills/maestro-ralph-cli-execute/SKILL.md +229 -0
  66. package/skills/maestro-ralph-execute/SKILL.md +409 -0
  67. package/skills/maestro-ralph-v2/SKILL.md +1198 -0
  68. package/skills/maestro-roadmap/SKILL.md +157 -0
  69. package/skills/maestro-swarm-workflow/SKILL.md +272 -0
  70. package/skills/maestro-tools-execute/SKILL.md +143 -0
  71. package/skills/maestro-tools-register/SKILL.md +192 -0
  72. package/skills/maestro-ui-codify/SKILL.md +127 -0
  73. package/skills/maestro-universal-workflow/SKILL.md +622 -0
  74. package/skills/maestro-update/SKILL.md +156 -0
  75. package/skills/manage-codebase-rebuild/SKILL.md +111 -0
  76. package/skills/manage-drift-realign/SKILL.md +159 -0
  77. package/skills/manage-harvest/SKILL.md +121 -0
  78. package/skills/manage-issue/SKILL.md +88 -0
  79. package/skills/manage-issue-discover/SKILL.md +104 -0
  80. package/skills/manage-kg-extractors/SKILL.md +147 -0
  81. package/skills/manage-knowhow/SKILL.md +102 -0
  82. package/skills/manage-knowhow-capture/SKILL.md +109 -0
  83. package/skills/manage-knowledge-audit/SKILL.md +147 -0
  84. package/skills/manage-status/SKILL.md +80 -0
  85. package/skills/manage-wiki/SKILL.md +104 -0
  86. package/skills/odyssey-debug/SKILL.md +344 -0
  87. package/skills/odyssey-improve/SKILL.md +423 -0
  88. package/skills/odyssey-planex/SKILL.md +542 -0
  89. package/skills/odyssey-review-test-fix/SKILL.md +392 -0
  90. package/skills/odyssey-ui/SKILL.md +388 -0
  91. package/skills/prompt-generator/SKILL.md +470 -0
  92. package/skills/quality-auto-test/SKILL.md +168 -0
  93. package/skills/quality-debug/SKILL.md +176 -0
  94. package/skills/quality-refactor/SKILL.md +108 -0
  95. package/skills/quality-retrospective/SKILL.md +134 -0
  96. package/skills/quality-review/SKILL.md +169 -0
  97. package/skills/quality-sync/SKILL.md +90 -0
  98. package/skills/quality-test/SKILL.md +183 -0
  99. package/skills/scholar-anti-ai-writing/SKILL.md +173 -0
  100. package/skills/scholar-anti-ai-writing/references/patterns-chinese.md +242 -0
  101. package/skills/scholar-anti-ai-writing/references/patterns-english.md +242 -0
  102. package/skills/scholar-citation-verify/SKILL.md +166 -0
  103. package/skills/scholar-citation-verify/references/api-usage.md +372 -0
  104. package/skills/scholar-citation-verify/references/common-errors.md +384 -0
  105. package/skills/scholar-citation-verify/references/verification-rules.md +399 -0
  106. package/skills/scholar-experiment/SKILL.md +321 -0
  107. package/skills/scholar-ideation/SKILL.md +288 -0
  108. package/skills/scholar-latex-organizer/SKILL.md +186 -0
  109. package/skills/scholar-publish/SKILL.md +220 -0
  110. package/skills/scholar-rebuttal-pro/README.md +313 -0
  111. package/skills/scholar-rebuttal-pro/SKILL.md +511 -0
  112. package/skills/scholar-review/SKILL.md +227 -0
  113. package/skills/scholar-thesis-docx/README.md +111 -0
  114. package/skills/scholar-thesis-docx/README_EN.md +108 -0
  115. package/skills/scholar-thesis-docx/SKILL.md +212 -0
  116. package/skills/scholar-thesis-docx/references/failure-patterns-and-quality-gates.md +178 -0
  117. package/skills/scholar-thesis-docx/references/figure-and-code-rules.md +33 -0
  118. package/skills/scholar-thesis-docx/references/paper-format-workflow.md +68 -0
  119. package/skills/scholar-thesis-docx/references/script-usage.md +157 -0
  120. package/skills/scholar-thesis-docx/scripts/audit_docx_ooxml.py +429 -0
  121. package/skills/scholar-thesis-docx/scripts/check_word_com.ps1 +50 -0
  122. package/skills/scholar-thesis-docx/scripts/export_word_pdf.ps1 +62 -0
  123. package/skills/scholar-thesis-docx/scripts/normalize_word_styles.ps1 +498 -0
  124. package/skills/scholar-thesis-docx/scripts/render_mermaid_figure.ps1 +148 -0
  125. package/skills/scholar-writing/SKILL.md +296 -0
  126. package/skills/security-audit/SKILL.md +244 -0
  127. package/skills/skill-generator/SKILL.md +472 -0
  128. package/skills/skill-iter-tune/SKILL.md +382 -0
  129. package/skills/skill-simplify/SKILL.md +63 -0
  130. package/skills/skill-tuning/SKILL.md +174 -0
  131. package/skills/spec-add/SKILL.md +105 -0
  132. package/skills/spec-load/SKILL.md +98 -0
  133. package/skills/spec-remove/SKILL.md +74 -0
  134. package/skills/spec-setup/SKILL.md +75 -0
  135. package/skills/team-adversarial-swarm/SKILL.md +233 -0
  136. package/skills/team-adversarial-swarm/scripts/__pycache__/pheromone.cpython-313.pyc +0 -0
  137. package/skills/team-adversarial-swarm/scripts/__pycache__/scoring.cpython-313.pyc +0 -0
  138. package/skills/team-adversarial-swarm/scripts/aco.py +473 -0
  139. package/skills/team-adversarial-swarm/scripts/pheromone.py +144 -0
  140. package/skills/team-adversarial-swarm/scripts/scoring.py +92 -0
  141. package/skills/team-adversarial-swarm/scripts/test_aco.py +475 -0
  142. package/skills/team-arch-opt/SKILL.md +158 -0
  143. package/skills/team-brainstorm/SKILL.md +171 -0
  144. package/skills/team-coordinate/SKILL.md +266 -0
  145. package/skills/team-designer/SKILL.md +160 -0
  146. package/skills/team-executor/SKILL.md +189 -0
  147. package/skills/team-frontend/SKILL.md +136 -0
  148. package/skills/team-frontend-debug/SKILL.md +198 -0
  149. package/skills/team-interactive-craft/SKILL.md +141 -0
  150. package/skills/team-issue/SKILL.md +171 -0
  151. package/skills/team-lifecycle-v4/SKILL.md +209 -0
  152. package/skills/team-motion-design/SKILL.md +142 -0
  153. package/skills/team-perf-opt/SKILL.md +175 -0
  154. package/skills/team-planex/SKILL.md +137 -0
  155. package/skills/team-quality-assurance/SKILL.md +147 -0
  156. package/skills/team-review/SKILL.md +147 -0
  157. package/skills/team-roadmap-dev/SKILL.md +169 -0
  158. package/skills/team-swarm/SKILL.md +178 -0
  159. package/skills/team-swarm/scripts/aco.py +473 -0
  160. package/skills/team-swarm/scripts/pheromone.py +144 -0
  161. package/skills/team-swarm/scripts/scoring.py +92 -0
  162. package/skills/team-swarm/scripts/test_aco.py +475 -0
  163. package/skills/team-tech-debt/SKILL.md +128 -0
  164. package/skills/team-testing/SKILL.md +143 -0
  165. package/skills/team-ui-polish/SKILL.md +141 -0
  166. package/skills/team-uidesign/SKILL.md +144 -0
  167. package/skills/team-ultra-analyze/SKILL.md +173 -0
  168. package/skills/team-ux-improve/SKILL.md +151 -0
  169. package/skills/team-visual-a11y/SKILL.md +156 -0
  170. package/skills/workflow-skill-designer/SKILL.md +496 -0
  171. package/src/extension/index.ts +222 -0
  172. package/src/extension/schemas.ts +131 -0
  173. package/src/providers/cli-tools-loader.ts +74 -0
  174. package/src/providers/provider-registry.ts +130 -0
  175. package/src/tools/delegate.ts +85 -0
  176. package/src/tools/explore.ts +134 -0
  177. package/src/tools/moa.ts +213 -0
  178. package/src/tools/status.ts +99 -0
  179. package/src/tools/wait.ts +166 -0
@@ -0,0 +1,470 @@
1
+ ---
2
+ name: prompt-generator
3
+ description: "Generate or convert Claude Code prompt files — command orchestrators, skill files, agent role definitions, or style conversion of existing files. Follows GSD-style content separation with built-in quality gates. Triggers on \"create command\", \"new command\", \"create skill\", \"new skill\", \"create agent\", \"new agent\", \"convert command\", \"convert skill\", \"convert agent\", \"prompt generator\", \"优化\"."
4
+ allowed-tools: Read Write Edit Bash Glob AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Generate or convert Claude Code prompt files with concrete, domain-specific content. Four modes:
9
+
10
+ - **Create command** — new orchestration workflow at `.claude/commands/` or `~/.claude/commands/`
11
+ - **Create skill** — new skill file at `.claude/skills/*/SKILL.md` (progressive loading, no @ refs)
12
+ - **Create agent** — new role + expertise file at `.claude/agents/`
13
+ - **Convert** — restyle existing command/skill/agent to GSD conventions with zero content loss
14
+
15
+ Content separation principle (from GSD): commands/skills own orchestration flow; agents own domain knowledge. Skills are a variant of commands but loaded progressively inline — they CANNOT use `@` file references.
16
+
17
+ Invoked when user requests "create command", "new command", "create skill", "new skill", "create agent", "new agent", "convert command", "convert skill", "convert agent", "prompt generator", or "优化".
18
+ </purpose>
19
+
20
+ <required_reading>
21
+ - @.claude/skills/prompt-generator/specs/command-design-spec.md
22
+ - @.claude/skills/prompt-generator/specs/agent-design-spec.md
23
+ - @.claude/skills/prompt-generator/specs/conversion-spec.md
24
+ - @.claude/skills/prompt-generator/templates/command-md.md
25
+ - @.claude/skills/prompt-generator/templates/agent-md.md
26
+ </required_reading>
27
+
28
+ <process>
29
+
30
+ ## Pre-load (before execution)
31
+
32
+ 1. **Codebase docs**: If `.workflow/codebase/ARCHITECTURE.md` exists, read for project context
33
+ 2. **Specs**: `maestro load --type spec --category coding` — load coding conventions
34
+ 3. **Wiki knowledge**: `maestro search "skill design optimization" --json` — top 5 entries as prior context
35
+ 4. All optional — proceed without if unavailable
36
+
37
+ ## 1. Determine Artifact Type
38
+
39
+ Parse `$ARGUMENTS` to determine what to generate.
40
+
41
+ | Signal | Type |
42
+ |--------|------|
43
+ | "command", "workflow", "orchestrator" in args | `command` |
44
+ | "skill", "SKILL.md" in args, or path contains `.claude/skills/` | `skill` |
45
+ | "agent", "role", "worker" in args | `agent` |
46
+ | "convert", "restyle", "refactor", "optimize", "优化" + file path in args | `convert` |
47
+ | Ambiguous or missing | Ask user |
48
+
49
+ **Convert mode detection:** If args contain a file path (`.md` extension) + conversion keywords, enter convert mode. Extract `$SOURCE_PATH` from args. Auto-detect source type from path:
50
+ - `.claude/commands/` → command
51
+ - `.claude/skills/*/SKILL.md` → skill
52
+ - `.claude/agents/` → agent
53
+
54
+ **Skill vs Command distinction:** Skills (`.claude/skills/*/SKILL.md`) are loaded **progressively inline** into the conversation context. They CANNOT use `@` file references — only `Read()` tool calls within process steps. See `@specs/command-design-spec.md` → "Skill Variant" section.
55
+
56
+ If ambiguous:
57
+
58
+ ```
59
+ AskUserQuestion(
60
+ header: "Artifact Type",
61
+ question: "What type of prompt file do you want to generate?",
62
+ options: [
63
+ { label: "Command", description: "New orchestration workflow — process steps, user interaction, agent spawning" },
64
+ { label: "Skill", description: "New skill file — progressive loading, no @ refs, inline Read() for external files" },
65
+ { label: "Agent", description: "New role definition — identity, domain expertise, behavioral rules" },
66
+ { label: "Convert", description: "Restyle existing command/agent/skill to GSD conventions (zero content loss)" }
67
+ ]
68
+ )
69
+ ```
70
+
71
+ Store as `$ARTIFACT_TYPE` (`command` | `skill` | `agent` | `convert`).
72
+
73
+ ## 2. Validate Parameters
74
+
75
+ **If `$ARTIFACT_TYPE` is `convert`:** Skip to Step 2c.
76
+
77
+ Extract from `$ARGUMENTS` or ask interactively:
78
+
79
+ **Common parameters (create mode):**
80
+
81
+ | Parameter | Required | Validation | Example |
82
+ |-----------|----------|------------|---------|
83
+ | `$NAME` | Yes | `/^[a-z][a-z0-9-]*$/` | `deploy`, `gsd-planner` |
84
+ | `$DESCRIPTION` | Yes | min 10 chars | `"Deploy to production with rollback"` |
85
+
86
+ **Command-specific parameters:**
87
+
88
+ | Parameter | Required | Validation | Example |
89
+ |-----------|----------|------------|---------|
90
+ | `$LOCATION` | Yes | `"project"` or `"user"` | `project` |
91
+ | `$GROUP` | No | `/^[a-z][a-z0-9-]*$/` | `issue`, `workflow` |
92
+ | `$ARGUMENT_HINT` | No | any string | `"<phase> [--skip-verify]"` |
93
+
94
+ **Agent-specific parameters:**
95
+
96
+ | Parameter | Required | Validation | Example |
97
+ |-----------|----------|------------|---------|
98
+ | `$TOOLS` | No | comma-separated tool names | `Read, Write, Bash, Glob` |
99
+ | `$SPAWNED_BY` | No | which command spawns this agent | `/plan-phase orchestrator` |
100
+
101
+ Normalize: trim + lowercase for `$NAME`, `$LOCATION`, `$GROUP`.
102
+
103
+ ## 3. Resolve Target Path
104
+
105
+ **Command:**
106
+
107
+ | Location | Base |
108
+ |----------|------|
109
+ | `project` | `.claude/commands` |
110
+ | `user` | `~/.claude/commands` |
111
+
112
+ ```
113
+ If $GROUP:
114
+ $TARGET_PATH = {base}/{$GROUP}/{$NAME}.md
115
+ Else:
116
+ $TARGET_PATH = {base}/{$NAME}.md
117
+ ```
118
+
119
+ **Skill:**
120
+
121
+ ```
122
+ $TARGET_PATH = .claude/skills/{$NAME}/SKILL.md
123
+ ```
124
+
125
+ **Agent:**
126
+
127
+ ```
128
+ $TARGET_PATH = .claude/agents/{$NAME}.md
129
+ ```
130
+
131
+ Check if `$TARGET_PATH` exists → `$FILE_EXISTS`.
132
+
133
+ ## 4. Gather Requirements
134
+
135
+ **4a. Pattern discovery** — Find 3+ similar files in the project for style reference:
136
+
137
+ ```bash
138
+ # For commands: scan existing commands
139
+ ls .claude/commands/**/*.md 2>/dev/null | head -5
140
+
141
+ # For agents: scan existing agents
142
+ ls .claude/agents/*.md 2>/dev/null | head -5
143
+ ```
144
+
145
+ Read 1-2 similar files to extract patterns: section structure, naming conventions, XML tag usage, prompt style.
146
+
147
+ **4b. Domain inference** from `$NAME`, `$DESCRIPTION`, and context:
148
+
149
+ | Signal | Extract |
150
+ |--------|---------|
151
+ | `$NAME` | Action verb → step/section naming |
152
+ | `$DESCRIPTION` | Domain keywords → content structure |
153
+ | `$ARGUMENT_HINT` | Flags → parse_input logic (command only) |
154
+ | `$SPAWNED_BY` | Upstream contract → role boundary (agent only) |
155
+
156
+ **For commands — determine complexity:**
157
+
158
+ | Complexity | Criteria | Steps |
159
+ |------------|----------|-------|
160
+ | Simple | Single action, no flags | 3-5 numbered steps |
161
+ | Standard | 1-2 flags, clear workflow | 5-8 numbered steps |
162
+ | Complex | Multiple flags, agent spawning | 8-14 numbered steps |
163
+
164
+ **For agents — determine expertise scope:**
165
+
166
+ | Scope | Criteria | Sections |
167
+ |-------|----------|----------|
168
+ | Focused | Single responsibility | `<role>` + 1-2 domain sections |
169
+ | Standard | Multi-aspect domain | `<role>` + 2-4 domain sections |
170
+ | Expert | Deep domain with rules | `<role>` + 4-6 domain sections |
171
+
172
+ If unclear, ask user with AskUserQuestion.
173
+
174
+ ## 5. Generate Content
175
+
176
+ Route to the appropriate generation logic based on `$ARTIFACT_TYPE`.
177
+
178
+ ### 5a. Command Generation
179
+
180
+ Follow `@specs/command-design-spec.md` and `@templates/command-md.md`.
181
+
182
+ Generate a complete command file with:
183
+
184
+ 1. **`<purpose>`** — 2-3 sentences: what + when + what it produces
185
+ 2. **`<required_reading>`** — @ references to context files
186
+ 3. **`<process>`** — numbered steps (GSD workflow style):
187
+ - Step 1: Initialize / parse arguments
188
+ - Steps 2-N: Domain-specific orchestration logic
189
+ - Each step: banner display, validation, agent spawning via `Agent()`, error handling
190
+ - Final step: status display + `<offer_next>` with next actions
191
+ 4. **`<success_criteria>`** — checkbox list of verifiable conditions
192
+
193
+ **Command writing rules:**
194
+ - Steps are **numbered** (`## 1.`, `## 2.`) — follow `plan-phase.md` and `new-project.md` style
195
+ - Use banners for phase transitions: `━━━ SKILL ► ACTION ━━━`
196
+ - Agent spawning uses `Agent({ subagent_type, prompt, description, run_in_background })` pattern
197
+ - Prompt to agents uses `<objective>`, `<files_to_read>`, `<output>` blocks
198
+ - Include `<offer_next>` block with formatted completion status
199
+ - Handle agent return markers: `## TASK COMPLETE`, `## TASK BLOCKED`, `## CHECKPOINT REACHED`
200
+ - Shell blocks use heredoc for multi-line, quote all variables
201
+ - Include `<auto_mode>` section if command supports `--auto` flag
202
+
203
+ ### 5a-skill. Skill Generation (variant of command)
204
+
205
+ Follow `@specs/command-design-spec.md` → "Skill Variant" section.
206
+
207
+ Skills are command-like orchestrators but loaded **progressively inline** — they CANNOT use `@` file references.
208
+
209
+ Generate a complete skill file with:
210
+
211
+ 1. **`<purpose>`** — 2-3 sentences: what + when + what it produces
212
+ 2. **NO `<required_reading>`** — skills cannot use `@` refs. External files loaded via `Read()` within process steps.
213
+ 3. **`<process>`** — numbered steps (GSD workflow style):
214
+ - Step 1: Initialize / parse arguments / set workflow preferences
215
+ - Steps 2-N: Domain-specific orchestration logic with inline `Read("phases/...")` for phase files
216
+ - Each step: validation, agent spawning via `Agent()`, error handling
217
+ - Final step: completion status or handoff to next skill via `Skill()`
218
+ 4. **`<success_criteria>`** — checkbox list of verifiable conditions
219
+
220
+ **Skill-specific writing rules:**
221
+ - **NO `<required_reading>` tag** — `@` syntax not supported in skills
222
+ - **NO `@path` references** anywhere in the file — use `Read("path")` within `<process>` steps
223
+ - Phase files loaded on-demand: `Read("phases/01-xxx.md")` within the step that needs it
224
+ - Frontmatter uses `allowed-tools:` (not `argument-hint:`)
225
+ - `<offer_next>` is optional — skills often chain via `Skill()` calls
226
+ - `<auto_mode>` can be inline within `<process>` step 1 or as standalone section
227
+
228
+ ### 5b. Agent Generation
229
+
230
+ Follow `@specs/agent-design-spec.md` and `@templates/agent-md.md`.
231
+
232
+ Generate a complete agent definition with:
233
+
234
+ 1. **YAML frontmatter** — name, description, tools, color (optional)
235
+ 2. **`<role>`** — identity + spawned-by + core responsibilities + mandatory initial read
236
+ 3. **Domain sections** (2-6 based on scope):
237
+ - `<philosophy>` — guiding principles, anti-patterns
238
+ - `<context_fidelity>` — how to honor upstream decisions
239
+ - `<task_breakdown>` / `<output_format>` — concrete output rules with examples
240
+ - `<quality_gate>` — self-check criteria before returning
241
+ - Custom domain sections as needed
242
+ 4. **Output contract** — structured return markers to orchestrator
243
+
244
+ **Agent writing rules:**
245
+ - `<role>` is ALWAYS first after frontmatter — defines identity
246
+ - Each section owns ONE concern — no cross-cutting
247
+ - Include concrete examples (good vs bad comparison tables) in every domain section
248
+ - Include decision/routing tables for conditional logic
249
+ - Quality gate uses checkbox format for self-verification
250
+ - Agent does NOT contain orchestration logic, user interaction, or argument parsing
251
+
252
+ ### 5c. Convert Mode (Restyle Existing File)
253
+
254
+ **CRITICAL: Zero content loss.** Follow `@specs/conversion-spec.md`.
255
+
256
+ **Step 5c.1: Read and inventory source file.**
257
+
258
+ Read `$SOURCE_PATH` completely. Build content inventory:
259
+
260
+ ```
261
+ $INVENTORY = {
262
+ frontmatter: { fields extracted },
263
+ sections: [ { name, tag, line_range, line_count, has_code_blocks, has_tables } ],
264
+ code_blocks: count,
265
+ tables: count,
266
+ total_lines: count
267
+ }
268
+ ```
269
+
270
+ **Step 5c.2: Classify source type.**
271
+
272
+ | Signal | Type |
273
+ |--------|------|
274
+ | Path in `.claude/skills/*/SKILL.md` | skill |
275
+ | `allowed-tools:` in frontmatter + path in `.claude/skills/` | skill |
276
+ | Contains `<process>`, `<step>`, numbered `## N.` steps | command |
277
+ | Contains `<role>`, `tools:` in frontmatter, domain sections | agent |
278
+ | Flat markdown with `## Implementation`, `## Phase N` + in skills dir | skill (unstructured) |
279
+ | Flat markdown with `## Implementation`, `## Phase N` + in commands dir | command (unstructured) |
280
+ | Flat prose with role description, no process steps | agent (unstructured) |
281
+
282
+ **Skill-specific conversion rules:**
283
+ - **NO `<required_reading>`** — skills cannot use `@` file references (progressive loading)
284
+ - **NO `@path` references** anywhere — replace with `Read("path")` within `<process>` steps
285
+ - If source has `@specs/...` or `@phases/...` refs, convert to `Read("specs/...")` / `Read("phases/...")`
286
+ - Follow `@specs/conversion-spec.md` → "Skill Conversion Rules" section
287
+
288
+ **Step 5c.3: Build conversion map.**
289
+
290
+ Map every source section to its target location. Follow `@specs/conversion-spec.md` transformation rules.
291
+
292
+ **MANDATORY**: Every line of source content must appear in the conversion map. If a source section has no clear target, keep it as a custom section.
293
+
294
+ **Step 5c.4: Generate converted content.**
295
+
296
+ Apply structural transformations while preserving ALL content verbatim:
297
+ - Rewrap into GSD XML tags
298
+ - Restructure sections to match target template ordering
299
+ - Add missing required sections (empty `<quality_gate>`, `<output_contract>`) with `TODO` markers
300
+ - Preserve all code blocks, tables, examples, shell commands exactly as-is
301
+
302
+ **Step 5c.5: Content loss verification (MANDATORY).**
303
+
304
+ Compare source and output:
305
+
306
+ | Metric | Source | Output | Pass? |
307
+ |--------|--------|--------|-------|
308
+ | Total lines | `$SRC_LINES` | `$OUT_LINES` | output >= source × 0.95 |
309
+ | Code blocks | `$SRC_BLOCKS` | `$OUT_BLOCKS` | output >= source |
310
+ | Tables | `$SRC_TABLES` | `$OUT_TABLES` | output >= source |
311
+ | Sections | `$SRC_SECTIONS` | `$OUT_SECTIONS` | output >= source |
312
+
313
+ If ANY metric fails → STOP, display diff, ask user before proceeding.
314
+
315
+ Set `$TARGET_PATH = $SOURCE_PATH` (in-place conversion) unless user specifies output path.
316
+
317
+ ### Content quality rules (both types):
318
+ - NO bracket placeholders (`[Describe...]`) — all content concrete
319
+ - NO generic instructions ("handle errors appropriately") — be specific
320
+ - Include domain-specific examples derived from `$DESCRIPTION`
321
+ - Every shell block: heredoc for multi-line, quoted variables, error exits
322
+
323
+ ## 6. Quality Gate
324
+
325
+ **MANDATORY before writing.** Read back the generated content and validate against type-specific checks.
326
+
327
+ ### 6a. Structural Validation (both types)
328
+
329
+ | Check | Pass Condition |
330
+ |-------|---------------|
331
+ | YAML frontmatter | Has `name` + `description` |
332
+ | No placeholders | Zero `[...]` or `{...}` bracket placeholders in prose |
333
+ | Concrete content | Every section has actionable content, not descriptions of what to write |
334
+ | Section count | Command: 3+ sections; Agent: 4+ sections |
335
+
336
+ ### 6b. Command-Specific Checks
337
+
338
+ | Check | Pass Condition |
339
+ |-------|---------------|
340
+ | `<purpose>` | 2-3 sentences, no placeholders |
341
+ | `<process>` with numbered steps | At least 3 `## N.` headers |
342
+ | Step 1 is initialization | Parses args or loads context |
343
+ | Last step is status/report | Displays results or routes to `<offer_next>` |
344
+ | Agent spawning (if complex) | `Agent({` call with `subagent_type` |
345
+ | Agent prompt structure | `<files_to_read>` + `<objective>` or `<output>` blocks |
346
+ | Return handling | Routes on `## TASK COMPLETE` / `## TASK BLOCKED` markers |
347
+ | `<offer_next>` | Banner + summary + next command suggestion |
348
+ | `<success_criteria>` | 4+ checkbox items, all verifiable |
349
+ | Content separation | No domain expertise embedded — only orchestration |
350
+
351
+ ### 6b-skill. Skill-Specific Checks
352
+
353
+ | Check | Pass Condition |
354
+ |-------|---------------|
355
+ | `<purpose>` | 2-3 sentences, no placeholders |
356
+ | **NO `<required_reading>`** | Must NOT contain `<required_reading>` tag |
357
+ | **NO `@` file references** | Zero `@specs/`, `@phases/`, `@./` patterns in prose |
358
+ | `<process>` with numbered steps | At least 3 `## N.` headers |
359
+ | Step 1 is initialization | Parses args, sets workflow preferences |
360
+ | Phase file loading | Uses `Read("phases/...")` within process steps (if has phases) |
361
+ | `<success_criteria>` | 4+ checkbox items, all verifiable |
362
+ | Frontmatter `allowed-tools` | Present and lists required tools |
363
+ | Content separation | No domain expertise embedded — only orchestration |
364
+
365
+ ### 6c. Agent-Specific Checks
366
+
367
+ | Check | Pass Condition |
368
+ |-------|---------------|
369
+ | YAML `tools` field | Lists tools agent needs |
370
+ | `<role>` is first section | Appears before any domain section |
371
+ | `<role>` has spawned-by | States which command spawns it |
372
+ | `<role>` has mandatory read | `<files_to_read>` instruction present |
373
+ | `<role>` has responsibilities | 3+ bullet points with verb phrases |
374
+ | Domain sections named | After domain concepts, not generic (`<rules>`, `<guidelines>`) |
375
+ | Examples present | Each domain section has 1+ comparison table or decision table |
376
+ | `<output_contract>` | Defines return markers (COMPLETE/BLOCKED/CHECKPOINT) |
377
+ | `<quality_gate>` | 3+ checkbox self-check items |
378
+ | Content separation | No `AskUserQuestion`, no banner display, no argument parsing |
379
+
380
+ ### 6d. Quality Gate Result
381
+
382
+ Count errors and warnings:
383
+
384
+ | Gate | Condition | Action |
385
+ |------|-----------|--------|
386
+ | **PASS** | 0 errors, 0-2 warnings | Proceed to write |
387
+ | **REVIEW** | 1-2 errors or 3+ warnings | Fix errors, display warnings |
388
+ | **FAIL** | 3+ errors | Re-generate from step 5 |
389
+
390
+ If FAIL and second attempt also fails:
391
+
392
+ ```
393
+ AskUserQuestion(
394
+ header: "Quality Gate Failed",
395
+ question: "Generated content failed quality checks twice. How to proceed?",
396
+ options: [
397
+ { label: "Show issues and proceed", description: "Write as-is, fix manually" },
398
+ { label: "Provide more context", description: "I'll give additional details" },
399
+ { label: "Abort", description: "Cancel generation" }
400
+ ]
401
+ )
402
+ ```
403
+
404
+ ## 7. Write and Verify
405
+
406
+ **If `$FILE_EXISTS`:** Warn user before overwriting.
407
+
408
+ ```bash
409
+ mkdir -p "$(dirname "$TARGET_PATH")"
410
+ ```
411
+
412
+ Write content to `$TARGET_PATH` using Write tool.
413
+
414
+ **Post-write verification** — Read back and confirm file integrity:
415
+ - File exists and is non-empty
416
+ - Content matches what was generated (no corruption)
417
+ - File size is reasonable (command: 50-500 lines; agent: 80-600 lines)
418
+
419
+ **If verification fails:** Fix in-place with Edit tool.
420
+
421
+ ## 8. Present Status
422
+
423
+ ```
424
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
425
+ PROMPT-GEN ► {COMMAND|AGENT} GENERATED
426
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
427
+
428
+ Type: {command | agent}
429
+ File: {$TARGET_PATH}
430
+ Name: {$NAME}
431
+
432
+ | Section | Status |
433
+ |---------|--------|
434
+ | {section 1} | concrete |
435
+ | {section 2} | concrete |
436
+ | ... | ... |
437
+
438
+ Quality Gate: {PASS | REVIEW (N warnings)}
439
+
440
+ ───────────────────────────────────────────────────────
441
+
442
+ ## Next Up
443
+
444
+ 1. Review: cat {$TARGET_PATH}
445
+ 2. Test: /{invocation}
446
+
447
+ **If command + needs an agent:**
448
+ /prompt-generator agent {agent-name} "{agent description}"
449
+
450
+ **If agent + needs a command:**
451
+ /prompt-generator command {command-name} "{command description}"
452
+
453
+ ───────────────────────────────────────────────────────
454
+ ```
455
+
456
+ </process>
457
+
458
+ <success_criteria>
459
+ - [ ] Artifact type determined (command or agent)
460
+ - [ ] All required parameters validated
461
+ - [ ] Target path resolved correctly
462
+ - [ ] 1-2 similar existing files read for pattern reference
463
+ - [ ] Domain requirements gathered from description
464
+ - [ ] Content generated with concrete, domain-specific logic
465
+ - [ ] GSD content separation respected (commands = orchestration, agents = expertise)
466
+ - [ ] Quality gate passed (structural + type-specific checks)
467
+ - [ ] No bracket placeholders in final output
468
+ - [ ] File written and post-write verified
469
+ - [ ] Status banner displayed with quality gate result
470
+ </success_criteria>
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: quality-auto-test
3
+ description: "Use when test coverage needs automated expansion or existing tests need iterative convergence Arguments: <phase> [-y] [-c N] [--max-iter N] [--layer L0|L1|L2|L3] [--dry-run] [--re-run]"
4
+ allowed-tools: Read Write Edit Bash Glob Grep AskUserQuestion
5
+ ---
6
+
7
+ <purpose>
8
+ Unified automated testing via CSV layer pipeline. Auto-selects scenario source from project state (specs / coverage gaps / code exploration), then: discover → plan → build CSV → write tests (parallel) → execute → diagnose failures (parallel) → iterate → report.
9
+
10
+ Layers L0→L3 sequential (fail-fast), scenarios within layer parallel. `--max-iter 1` = single-pass; default = full iterative cycle.
11
+ </purpose>
12
+
13
+ <required_reading>
14
+ @~/.maestro/workflows/auto-test.md
15
+ </required_reading>
16
+
17
+ <context>
18
+ Phase or task: $ARGUMENTS (required — phase number)
19
+
20
+ **Flags:**
21
+ - `-c N` — Resume from iteration N of an existing session (skips setup, resumes from last checkpoint)
22
+ - `-y` — Skip confirmation prompts for artifact registration and issue creation
23
+ - `--max-iter N` — Maximum outer iterations (default: 5). Set to 1 for single-pass generation only.
24
+ - `--layer L` — Start from or restrict to specific layer (L0|L1|L2|L3)
25
+ - `--dry-run` — Generate test plan only, do not execute
26
+ - `--re-run` — Re-run only previously failed/blocked scenarios
27
+
28
+ **Intelligent routing** (auto-detected from project state):
29
+
30
+ | Priority | Condition | Route | Reference skill |
31
+ |----------|-----------|-------|-----------------|
32
+ | 1 | Active session exists (state.json status=running) | Resume | — |
33
+ | 2 | --re-run flag + previous failures | Re-run | — |
34
+ | 3 | Spec package exists (REQ-*.md) | spec | quality-business-test (separate skill) |
35
+ | 4 | Nyquist gaps exist (verification.json) | gap | quality-test-gen (separate skill) |
36
+ | 5 | Default | code | quality-integration-test (separate skill) |
37
+
38
+ Flags, artifact context resolution, and output formats defined in workflow auto-test.md.
39
+
40
+ ### Pre-load context (before test generation)
41
+
42
+ 1. **Test specs + tools**: Run `maestro load --type spec --category test` to load test conventions (framework, patterns, naming). Apply to all generated tests.
43
+ 2. **Coding specs**: Run `maestro load --type spec --category coding` to understand coding patterns for accurate test targeting.
44
+ 3. **Role Knowledge**:
45
+ - Browse: `maestro search --category test`
46
+ - Load task-relevant entries: `maestro load --type knowhow --id <id1> [id2...]`
47
+ 4. All are optional — proceed without if unavailable.
48
+
49
+ **Output boundary**: ALL file writes MUST target `.workflow/scratch/{YYYYMMDD}-auto-test-P{N}-{slug}/` or `.workflow/state.json` only. Source code modifications are limited to test files generated by this command. NEVER modify existing production source code.
50
+ </context>
51
+
52
+ <invariants>
53
+ 1. **Test code isolation** — generated tests MUST be written to test directories following existing project conventions. NEVER modify production source code to make tests pass.
54
+ 2. **RED-GREEN integrity** — tests MUST be written to fail first (RED), then verified to pass against implementation (GREEN). NEVER write tests that pass trivially or assert nothing.
55
+ 3. **Layer ordering is strict** — L0→L3 execution is sequential and fail-fast. NEVER skip a layer or run L2 before L1 passes.
56
+ 4. **Existing tests are sacred** — NEVER modify, delete, or overwrite existing test files. New tests are additive only.
57
+ 5. **Convergence requires evidence** — pass rate and confidence score MUST be computed from actual execution results. NEVER infer or estimate pass rates without running tests.
58
+ 6. **Iteration has bounds** — outer iteration MUST NOT exceed `--max-iter` (default 5). Inner test_defect fix MUST NOT exceed 3 attempts per scenario before escalating.
59
+ 7. **Traceability is mandatory for spec source** — when route=spec, every test scenario MUST trace back to a REQ-*.md requirement. Untraceable tests are flagged.
60
+ </invariants>
61
+
62
+ <execution>
63
+ Follow '~/.maestro/workflows/auto-test.md' completely.
64
+
65
+ ### Phase Gates (MANDATORY, BLOCKING)
66
+
67
+ **GATE 1: Setup → Plan** (Route Selection → CSV Generation)
68
+ - REQUIRED: Phase resolved from artifact registry. E001/E002 if missing.
69
+ - REQUIRED: Route auto-selected (spec/gap/code) from project state.
70
+ - REQUIRED: Test infrastructure discovered (framework, patterns, conventions).
71
+ - BLOCKED if missing: cannot generate test plan without route and framework.
72
+
73
+ **GATE 2: Plan → Write** (CSV → Test Generation)
74
+ - REQUIRED: test-plan.json generated with layer distribution (L0→L3).
75
+ - REQUIRED: User confirmed plan (unless `--dry-run` stops here).
76
+ - BLOCKED if plan missing or rejected: do not write tests.
77
+
78
+ **GATE 3: Write → Execute** (Test Generation → Execution)
79
+ - REQUIRED: All planned test files written following existing patterns.
80
+ - REQUIRED: Tests follow RED-GREEN methodology.
81
+ - BLOCKED if tests incomplete: finish writing before execution.
82
+
83
+ **GATE 4: Execute → Report** (Iteration → Completion)
84
+ - REQUIRED: Progressive execution completed (L0→L3, fail-fast on critical).
85
+ - REQUIRED: Iteration engine ran (inner: test_defect fix, outer: strategy adjust).
86
+ - REQUIRED: Confidence scored with 5-dimension factor model (>= 60%).
87
+ - REQUIRED: Pressure pass completed on highest-pass-rate layer.
88
+ - BLOCKED if iteration incomplete: continue iterating before reporting.
89
+
90
+ **Command-specific extensions (not in workflow):**
91
+
92
+ **Review findings integration** (from related review artifacts):
93
+ - Extract critical/high findings as additional test scenarios, marked `source: "review_finding"`
94
+ - When review verdict is "BLOCK" and review-finding tests fail, suggest quality-debug
95
+
96
+ **Debug root cause integration** (from related debug artifacts):
97
+ - Generate regression test scenarios from confirmed root causes, marked `source: "debug_root_cause"`
98
+
99
+ **Register artifact on completion:**
100
+
101
+ Unless `-y` flag is set, confirm before writing:
102
+ ```
103
+ AskUserQuestion("Register auto-test artifact TST-{NNN} in state.json? (yes/no)")
104
+ → yes: proceed with write
105
+ → no: skip registration, continue to next-step routing
106
+ ```
107
+
108
+ ```
109
+ Append to state.json.artifacts[]:
110
+ {
111
+ id: nextArtifactId(artifacts, "test"), // TST-001
112
+ type: "test",
113
+ milestone: current_milestone,
114
+ phase: target_phase,
115
+ scope: "phase",
116
+ path: "scratch/{YYYYMMDD}-auto-test-P{N}-{slug}",
117
+ status: issues == 0 ? "completed" : "failed",
118
+ depends_on: exec_art.id,
119
+ harvested: false,
120
+ created_at: start_time,
121
+ completed_at: now()
122
+ }
123
+ ```
124
+
125
+ **Next-step routing on completion:**
126
+ - Converged (>=95%) → `/quality-review {phase}`
127
+ - All requirements verified (spec source) → `/maestro-milestone-audit`
128
+ - Bugs discovered → `/quality-debug --from-uat {phase}`
129
+ - Max iter, >80% → `/quality-test {phase}` for manual UAT
130
+ - Max iter, <80% → `/quality-debug {phase}`
131
+ - Coverage still low → `/quality-auto-test {phase} --layer {missing}`
132
+ - Re-run all pass → `/quality-review {phase}`
133
+ - Single pass, all pass → `/quality-test {phase}`
134
+ </execution>
135
+
136
+ <error_codes>
137
+ | Code | Severity | Condition | Recovery |
138
+ |------|----------|-----------|----------|
139
+ | E001 | error | Phase argument required (no active sessions) | Prompt user for phase number |
140
+ | E002 | error | Phase not found in artifact registry | Check state.json artifacts |
141
+ | E003 | error | No test framework detected | Install test framework or configure test runner |
142
+ | W001 | warning | One or more test scenarios failed | Auto-iterate or suggest fix options |
143
+ | W002 | warning | Max iterations reached without convergence | Review reflection-log.md, suggest debug |
144
+ | W003 | warning | Degraded spec mode (no full spec package) | Consider running /maestro-blueprint |
145
+ </error_codes>
146
+
147
+ <success_criteria>
148
+ - [ ] Phase resolved from artifact registry
149
+ - [ ] Route auto-selected from project state (spec/gap/code)
150
+ - [ ] Active sessions checked, resume offered if applicable
151
+ - [ ] Scenarios extracted and normalized to unified format
152
+ - [ ] Test infrastructure discovered (framework, patterns, conventions)
153
+ - [ ] test-plan.json generated with layer distribution
154
+ - [ ] User confirmed plan (or --dry-run stopped here)
155
+ - [ ] Tests written following RED-GREEN methodology and existing patterns
156
+ - [ ] Tests executed progressively (L0→L3) with fail-fast on critical
157
+ - [ ] Iteration engine ran (inner: test_defect fix, outer: strategy adjust)
158
+ - [ ] state.json, report.json, reflection-log.md written
159
+ - [ ] Test confidence scored per iteration (Step 7.5) with 5-dimension factor model
160
+ - [ ] Convergence check includes confidence >= 60% alongside pass_rate threshold
161
+ - [ ] Pressure pass completed on highest-pass-rate layer before completion
162
+ - [ ] report.json includes confidence section
163
+ - [ ] index.json updated with auto_test section
164
+ - [ ] If spec source: traceability matrix built, traceability.md written
165
+ - [ ] If failures: issues created in issues.jsonl (confirmed by user unless `-y`)
166
+ - [ ] If gap source: validation.json gaps updated (MISSING→COVERED)
167
+ - [ ] Next step routed based on convergence status
168
+ </success_criteria>