@polymorphism-tech/morph-spec 4.8.12 → 4.8.15

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 (76) hide show
  1. package/README.md +379 -379
  2. package/bin/morph-spec.js +23 -2
  3. package/bin/{task-manager.cjs → task-manager.js} +249 -172
  4. package/claude-plugin.json +14 -14
  5. package/docs/CHEATSHEET.md +203 -203
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/agents.json +224 -140
  8. package/framework/hooks/README.md +202 -202
  9. package/framework/hooks/claude-code/post-tool-use/dispatch.js +48 -2
  10. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +151 -0
  11. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +12 -0
  12. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +6 -0
  13. package/framework/hooks/claude-code/session-start/inject-morph-context.js +34 -0
  14. package/framework/hooks/claude-code/statusline.py +6 -0
  15. package/framework/hooks/claude-code/stop/validate-completion.js +38 -4
  16. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +87 -0
  17. package/framework/hooks/claude-code/user-prompt/set-terminal-title.js +58 -0
  18. package/framework/hooks/shared/phase-utils.js +4 -1
  19. package/framework/hooks/shared/state-reader.js +1 -0
  20. package/framework/skills/README.md +1 -0
  21. package/framework/skills/level-0-meta/brainstorming/SKILL.md +2 -0
  22. package/framework/skills/level-0-meta/code-review/SKILL.md +16 -0
  23. package/framework/skills/level-0-meta/code-review/references/review-guidelines.md +100 -0
  24. package/framework/skills/level-0-meta/code-review/scripts/scan-csharp.mjs +36 -6
  25. package/framework/skills/level-0-meta/code-review-nextjs/SKILL.md +16 -0
  26. package/framework/skills/level-0-meta/code-review-nextjs/scripts/scan-nextjs.mjs +189 -0
  27. package/framework/skills/level-0-meta/frontend-review/SKILL.md +359 -0
  28. package/framework/skills/level-0-meta/frontend-review/scripts/scan-accessibility.mjs +376 -0
  29. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +1 -1
  30. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +10 -8
  31. package/framework/skills/level-0-meta/morph-replicate/references/blazor-html-mapping.md +70 -0
  32. package/framework/skills/level-0-meta/post-implementation/SKILL.md +315 -0
  33. package/framework/skills/level-0-meta/post-implementation/scripts/detect-dev-server.mjs +153 -0
  34. package/framework/skills/level-0-meta/post-implementation/scripts/detect-stack.mjs +234 -0
  35. package/framework/skills/level-0-meta/terminal-title/SKILL.md +61 -0
  36. package/framework/skills/level-0-meta/terminal-title/scripts/set_title.sh +65 -0
  37. package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +50 -188
  38. package/framework/skills/level-0-meta/tool-usage-guide/references/tools-per-phase.md +213 -0
  39. package/framework/skills/level-0-meta/verification-before-completion/SKILL.md +2 -0
  40. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +4 -7
  41. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +1 -1
  42. package/framework/skills/level-1-workflows/phase-design/SKILL.md +71 -109
  43. package/framework/skills/level-1-workflows/phase-design/references/architecture-analysis-guide.md +89 -0
  44. package/framework/skills/level-1-workflows/phase-design/references/spec-authoring-guide.md +55 -0
  45. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +171 -114
  46. package/framework/skills/level-1-workflows/phase-implement/references/vsa-implementation-guide.md +92 -0
  47. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +1 -2
  48. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +35 -159
  49. package/framework/skills/level-1-workflows/phase-tasks/references/task-planning-patterns.md +172 -0
  50. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +42 -3
  51. package/framework/squad-templates/backend-only.json +14 -1
  52. package/framework/squad-templates/frontend-only.json +14 -1
  53. package/framework/squad-templates/full-stack.json +25 -8
  54. package/framework/standards/STANDARDS.json +631 -86
  55. package/framework/standards/frontend/design-system/aesthetic-direction.md +213 -0
  56. package/framework/templates/project/validate.js +122 -0
  57. package/framework/workflows/configs/zero-touch.json +7 -0
  58. package/package.json +87 -87
  59. package/src/commands/agents/dispatch-agents.js +53 -10
  60. package/src/commands/state/advance-phase.js +88 -13
  61. package/src/commands/state/index.js +2 -1
  62. package/src/commands/state/phase-runner.js +215 -0
  63. package/src/commands/tasks/task.js +25 -4
  64. package/src/core/paths/output-schema.js +2 -1
  65. package/src/lib/detectors/design-system-detector.js +5 -4
  66. package/src/lib/generators/recap-generator.js +16 -0
  67. package/src/lib/orchestration/team-orchestrator.js +171 -89
  68. package/src/lib/phase-chain/eligibility-checker.js +243 -0
  69. package/src/lib/standards/digest-builder.js +231 -0
  70. package/src/lib/tasks/task-parser.js +94 -0
  71. package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +39 -0
  72. package/src/lib/validators/content/content-validator.js +34 -106
  73. package/src/lib/validators/nextjs/next-component-validator.js +2 -0
  74. package/src/lib/validators/validation-runner.js +2 -2
  75. package/src/utils/file-copier.js +1 -0
  76. package/src/utils/hooks-installer.js +31 -7
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: terminal-title
3
+ description: Manually set the terminal window title for the current task. Use when you need to override the automatic title set by the hook, or to set a specific descriptive title for the current work context.
4
+ argument-hint: "[title]"
5
+ user-invocable: true
6
+ allowed-tools: Bash
7
+ ---
8
+
9
+ # Terminal Title
10
+
11
+ ## Overview
12
+
13
+ Manually sets the terminal window title. The hook `set-terminal-title.js` sets titles automatically on every prompt — use this skill only for manual overrides.
14
+
15
+ ## When to Use
16
+
17
+ - Override the automatic title with something more descriptive
18
+ - Set a custom title at the start of a focused work session
19
+ - Invoke explicitly: `/terminal-title`
20
+
21
+ ## Title Format
22
+
23
+ ```
24
+ [Action]: [Specific Focus]
25
+ ```
26
+
27
+ **Good titles (max 40 chars):**
28
+ - `Fix: Auth Login Bug`
29
+ - `Build: Dashboard UI`
30
+ - `Refactor: Payment Module`
31
+ - `DB Migration: Users Table`
32
+ - `Test: Checkout Flow`
33
+
34
+ The script (`set_title.sh`) prepends the current directory name automatically:
35
+ ```
36
+ morph-spec-framework | Fix: Auth Login Bug
37
+ ```
38
+
39
+ The hook (`set-terminal-title.js`) sets the task title directly, without a directory prefix:
40
+ ```
41
+ Fix: Auth Login Bug
42
+ ```
43
+
44
+ ## Implementation
45
+
46
+ Run the title script with the desired title:
47
+
48
+ ```bash
49
+ bash .claude/skills/terminal-title/scripts/set_title.sh "Fix: Auth Login Bug"
50
+ ```
51
+
52
+ No confirmation needed — executes silently in the background.
53
+
54
+ ## Optional Custom Prefix
55
+
56
+ Set `CLAUDE_TITLE_PREFIX` in your environment to add a custom prefix:
57
+
58
+ ```bash
59
+ export CLAUDE_TITLE_PREFIX="🤖"
60
+ # Results in: 🤖 morph-spec-framework | Fix: Auth Login Bug
61
+ ```
@@ -0,0 +1,65 @@
1
+ #!/bin/bash
2
+ # Set terminal window title
3
+ # Usage: ./set_title.sh "Your Title Here"
4
+ #
5
+ # The script automatically prefixes the title with the current directory name
6
+ # (usually the repo/project name) for easy identification across multiple terminals.
7
+ #
8
+ # Optional: Set CLAUDE_TITLE_PREFIX environment variable for additional custom prefix
9
+ # Example: export CLAUDE_TITLE_PREFIX="🤖"
10
+ # Results in: "🤖 my-project | Your Title"
11
+
12
+ # Exit silently if no title provided (fail-safe behavior)
13
+ if [ -z "$1" ]; then
14
+ exit 0
15
+ fi
16
+
17
+ # Validate and sanitize input
18
+ # Remove control characters (0x00-0x1F) and limit length to 80 characters
19
+ TITLE=$(echo "$1" | tr -d '\000-\037' | head -c 80)
20
+
21
+ # Ensure title is not empty after sanitization
22
+ if [ -z "$TITLE" ]; then
23
+ exit 0
24
+ fi
25
+
26
+ # Get the current directory name (usually the repo/project name)
27
+ DIR_NAME=$(basename "$PWD")
28
+
29
+ # Build the final title with directory prefix and optional custom prefix
30
+ if [ -n "$CLAUDE_TITLE_PREFIX" ]; then
31
+ # Sanitize prefix as well
32
+ PREFIX=$(echo "$CLAUDE_TITLE_PREFIX" | tr -d '\000-\037' | head -c 20)
33
+ if [ -n "$PREFIX" ]; then
34
+ FINAL_TITLE="${PREFIX} ${DIR_NAME} | ${TITLE}"
35
+ else
36
+ FINAL_TITLE="${DIR_NAME} | ${TITLE}"
37
+ fi
38
+ else
39
+ FINAL_TITLE="${DIR_NAME} | ${TITLE}"
40
+ fi
41
+
42
+ # Store the title in a file that shell hooks can read
43
+ # This allows precmd hooks (like update_terminal_cwd) to preserve the title
44
+ # Use atomic write to prevent race conditions
45
+ TITLE_FILE="${HOME}/.claude/terminal_title"
46
+ mkdir -p "${HOME}/.claude"
47
+
48
+ # Atomic write using temp file + rename
49
+ TEMP_FILE="${TITLE_FILE}.tmp.$$"
50
+ echo "$FINAL_TITLE" > "$TEMP_FILE"
51
+ mv "$TEMP_FILE" "$TITLE_FILE" 2>/dev/null || rm -f "$TEMP_FILE"
52
+
53
+ # Set the terminal title using ANSI escape sequences
54
+ # Detect terminal type and set title accordingly
55
+ case "$TERM" in
56
+ xterm*|rxvt*|screen*|tmux*)
57
+ # Standard xterm-compatible terminals
58
+ printf '\033]0;%s\007' "$FINAL_TITLE"
59
+ ;;
60
+ *)
61
+ # Fallback: try anyway, suppress errors
62
+ # This works for iTerm2, Alacritty, and most modern terminals
63
+ printf '\033]0;%s\007' "$FINAL_TITLE" 2>/dev/null
64
+ ;;
65
+ esac
@@ -82,214 +82,66 @@ Feature with multiple active agents?
82
82
 
83
83
  ---
84
84
 
85
- ## Tools Per Phase
86
-
87
- ### Phase 0 — Proposal
88
-
89
- **Goal:** Understand the feature request and create proposal.md
85
+ ## Comunicação com o Usuário
90
86
 
91
- | Action | Tool | Why |
92
- |--------|------|-----|
93
- | Read project context | **Read** `.morph/context/README.md` | Single known file |
94
- | Read config | **Read** `.morph/config.json` | Single known file |
95
- | Find existing features | **Glob** `.morph/features/*/0-proposal/proposal.md` | Pattern search |
96
- | Detect project stack | **Read** `.morph/framework/agents.json` → match keywords → **Bash** `npx morph-spec state add-agent` | agents.json is the source of truth |
97
- | Research external requirement | **WebSearch** | Current information needed |
98
- | Render proposal template | **Bash** `npx morph-spec template render docs/proposal ...` | CLI command |
99
- | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
87
+ ### AskUserQuestion vs. Texto Livre
100
88
 
101
- **MCPs used:** None typically. GitHub MCP if feature comes from an issue.
102
-
103
- **Anti-patterns:**
104
- - Task agent to read proposal template (just use Read)
105
- - Bash `cat` to read files (use Read tool)
106
- - Bash `find` to locate files (use Glob tool)
107
-
108
- ---
89
+ | Situação | Ferramenta |
90
+ |---|---|
91
+ | ≥2 opções mutuamente exclusivas | `AskUserQuestion` (options[]) |
92
+ | Escolha binária sim/não | `AskUserQuestion` (2 options) |
93
+ | Aprovação de plano | `ExitPlanMode` |
94
+ | Explicação, progresso, confirmação | Texto direto |
109
95
 
110
- ### Phase 1 Setup
96
+ **Regra:** NUNCA apresentar opções múltiplas como texto livre. Use `AskUserQuestion` com `options[]` para garantir escolha estruturada sem ambiguidade.
111
97
 
112
- **Goal:** Load context, detect stack, activate agents
98
+ ### EnterPlanMode
113
99
 
114
- | Action | Tool | Why |
115
- |--------|------|-----|
116
- | Verify feature state | **Bash** `npx morph-spec state get {feature}` | CLI command |
117
- | Detect agents + standards | **Read** `.morph/framework/agents.json` → match keywords → **Bash** `npx morph-spec state add-agent {f} {id}` per match | Keyword matching is fast inline |
118
- | Read project context | **Read** `.morph/context/README.md` | Single file |
119
- | Read config | **Read** `.morph/config.json` | Single file |
120
- | Scan project structure | **Glob** `src/**/*.{ts,tsx,cs}` | Understand codebase layout |
121
- | Get repo metadata | **GitHub MCP** `get_repo()` | Structured repo info (if MCP available) |
122
- | Get dispatch config for next phases | **Bash** `npx morph-spec dispatch-agents {feature} design` | Shows which agents will be dispatched in design phase |
123
- | Update state | **Bash** `npx morph-spec state set ...` | CLI command |
100
+ Use **ANTES** de iniciar implementação quando:
101
+ - Refactor toca ≥5 arquivos ou muda arquitetura
102
+ - Estimativa de tasks ≥20
103
+ - Escolha entre ≥2 abordagens de design significativamente diferentes
124
104
 
125
- **MCPs used:** GitHub (optional — for repo metadata).
126
-
127
- **Anti-patterns:**
128
- - Calling `detect-agents` CLI (it doesn't exist — read `.morph/framework/agents.json` directly)
129
- - ❌ Task agent to detect project stack inline (keyword matching is fast enough directly)
130
- - ❌ WebSearch for project info (it's local, use Read/Glob)
105
+ NÃO use para:
106
+ - Correção pontual de 1-3 arquivos
107
+ - Usuário já especificou abordagem detalhada
108
+ - Fase implement com tasks.md aprovado
131
109
 
132
110
  ---
133
111
 
134
- ### Phase 1.5 UI/UX Design
135
-
136
- **Goal:** Create UI mockups, design system, component specs, user flows
137
-
138
- | Action | Tool | Why |
139
- |--------|------|-----|
140
- | Check existing design system | **Read** `.morph/context/design-system.md` | Single file |
141
- | Read user-provided screenshots | **Read** (image files) | Claude Code reads images natively |
142
- | Search for existing CSS variables | **Grep** `--root:` or `--color-` in `*.css,*.scss` | Find existing design tokens |
143
- | Find existing UI components | **Glob** `**/Components/**/*.razor` or `**/components/**/*.tsx` | Existing patterns |
144
- | Get Figma design tokens | **Figma MCP** `get_file({ fileKey })` | Extract colors, typography from Figma |
145
- | Look up component library API | **Context7 MCP** `query_docs({ libraryId, query })` | Accurate component props/events |
146
- | Preview de página existente | **Playwright MCP** `browser_navigate()` + `browser_take_screenshot()` | **WebFetch** URL |
147
- | Inspecionar estrutura da página | **Playwright MCP** `browser_snapshot()` | **WebFetch** + parse manual |
148
- | Testar layout responsivo | **Playwright MCP** `browser_resize()` + `browser_take_screenshot()` | Manual testing |
149
- | Search for design references | **WebSearch** + **WebFetch** | External inspiration |
150
- | Render UI templates | **Bash** `npx morph-spec template render docs/ui-mockups ...` | CLI command |
151
- | Generate design system from CSS | **Bash** `npx morph-spec generate design-system --scan` | CLI command |
152
- | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
153
-
154
- **MCPs used:** Figma (design tokens), Playwright (live preview, page inspection), Context7 (component docs).
155
-
156
- **Anti-patterns:**
157
- - ❌ WebSearch for MudBlazor docs (use Context7 MCP — more accurate)
158
- - ❌ Task agent to read a single screenshot (just use Read tool on the image)
159
- - ❌ Manually guessing component props (use Context7 to get real API)
160
-
161
- ---
112
+ ### Regra de Leituras Paralelas (CRÍTICO)
162
113
 
163
- ### Phase 2 Design (Technical Spec)
164
-
165
- **Goal:** Analyze schema, create spec.md, contracts-level{N}.cs, decisions.md
166
-
167
- | Action | Tool | Why |
168
- |--------|------|-----|
169
- | Read proposal + UI specs | **Read** output files | Single known files |
170
- | **Get dispatch config** | **Bash** `npx morph-spec dispatch-agents {feature} design` | Which agents to spawn + their task prompts |
171
- | **Dispatch domain-architect** (parallel) | **Task** subagent with prompt from dispatch config | Analyze DDD complexity independently |
172
- | **Dispatch tech leads** (parallel) | **Task** subagents (dotnet-senior, nextjs-expert, etc.) | Validate architecture independently |
173
- | Get database schema | **Supabase MCP** `list_tables()`, `get_table_schema()` | **PREFERRED** — real schema data |
174
- | Get table relationships | **Supabase MCP** `get_relationships()` | Real FK/constraint data |
175
- | Get RLS policies | **Supabase MCP** `query()` with pg_policies | Security analysis |
176
- | **Fallback:** Find query files | **Grep** `\.from\(` or `\.select\(` in `*.ts,*.tsx,*.js,*.cs` | When no DB MCP available |
177
- | **Fallback:** Find type definitions | **Glob** `src/**/types/**/*.ts` or `**/Entities/**/*.cs` | When no DB MCP available |
178
- | **Fallback:** Read query/type files | **Read** each matched file | Extract field names manually |
179
- | Look up library for ADR | **Context7 MCP** `query_docs()` | Compare library capabilities |
180
- | Check existing code patterns | **GitHub MCP** `search_code()` | Find patterns in large repos |
181
- | **Fallback:** Search codebase | **Grep** patterns across project | When no GitHub MCP |
182
- | Render contracts template (detected level) | **Bash** `npx morph-spec template render code/dotnet/contracts/contracts-level{N}.cs ...` where N = level detected | CLI command |
183
- | Render spec template | **Bash** `npx morph-spec template render docs/spec ...` | CLI command |
184
- | Render decisions template | **Bash** `npx morph-spec template render docs/decisions ...` | CLI command |
185
- | Create schema-analysis.md | **Write** to output directory | Document findings |
186
- | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
187
-
188
- **MCPs used:** Supabase (schema analysis), Context7 (library research), GitHub (code search).
189
-
190
- **Parallel dispatch opportunity:** Domain complexity analysis (domain-architect) and schema analysis (phase-codebase-analysis) are **independent** — run them as parallel Task subagents to cut design phase time.
191
-
192
- **Anti-patterns:**
193
- - ❌ Guessing field names without checking schema (use MCP or Grep first!)
194
- - ❌ Task agent to read a single spec file (use Read directly)
195
- - ❌ WebSearch for database schema (use Supabase MCP or code analysis)
196
- - ❌ Manually writing contracts-level{N}.cs from scratch (use template render)
197
- - ❌ Running domain analysis and schema analysis sequentially (they're independent — run in parallel)
198
-
199
- ---
114
+ Arquivos independentes = uma única mensagem com múltiplas chamadas Read.
200
115
 
201
- ### Phase 3 — Clarify
202
-
203
- **Goal:** Identify ambiguities, ask clarification questions, update spec
116
+ ```
117
+ # ERRADO (sequencial)
118
+ Read: state.json Read: spec.md Read: tasks.md # 3 round-trips
204
119
 
205
- | Action | Tool | Why |
206
- |--------|------|-----|
207
- | Read spec.md in detail | **Read** spec.md | Full content analysis |
208
- | Read contracts.cs | **Read** contracts.cs | Check contract consistency |
209
- | Read schema-analysis.md | **Read** schema-analysis.md | Cross-reference with spec |
210
- | Verify library capabilities | **Context7 MCP** `query_docs()` | Confirm feasibility of spec requirements |
211
- | Check known issues/limitations | **GitHub MCP** `search_issues()` | Library bugs affecting design |
212
- | Research edge case behavior | **WebSearch** | External knowledge for edge cases |
213
- | Update spec with clarifications | **Edit** spec.md | Preserve existing content, add sections |
214
- | Create clarifications.md | **Bash** `npx morph-spec template render docs/clarifications ...` | Use template |
215
- | Update state | **Bash** `npx morph-spec state mark-output ... clarifications` | CLI command |
120
+ # CORRETO (paralelo, 1 round-trip)
121
+ Read: state.json + Read: spec.md + Read: tasks.md
122
+ ```
216
123
 
217
- **MCPs used:** Context7 (validate feasibility), GitHub (known issues).
124
+ Critério: se a leitura de arquivo B não depende do CONTEÚDO de arquivo A, leia os dois juntos.
218
125
 
219
- **Anti-patterns:**
220
- - ❌ Task agent to read spec (just Read it directly)
221
- - ❌ Rewriting spec from scratch (use Edit to update sections)
222
- - ❌ Skipping schema-analysis.md cross-reference (critical for accuracy)
126
+ **Exemplos de independência:** spec.md ↔ decisions.md ↔ contracts.cs ↔ tasks.md (todos lidos juntos na investigação de uma fase).
223
127
 
224
128
  ---
225
129
 
226
- ### Phase 4 — Tasks
227
-
228
- **Goal:** Break spec into tasks, define dependencies, set checkpoints
229
-
230
- | Action | Tool | Why |
231
- |--------|------|-----|
232
- | Read spec + contracts + decisions | **Read** all output files | Full context needed |
233
- | **Get dispatch config** | **Bash** `npx morph-spec dispatch-agents {feature} tasks` | Which domain experts to consult |
234
- | Analyze implementation complexity | **Grep** patterns in existing code | Estimate effort from codebase size |
235
- | Count existing similar patterns | **Glob** `**/Services/**/*.cs` | Understand scope |
236
- | **Dispatch domain experts** (when spec is complex) | **Task** subagents per domain | Parallel per-domain task planning |
237
- | Look up implementation patterns | **Context7 MCP** `query_docs()` | Estimate task complexity accurately |
238
- | Create GitHub issues from tasks | **GitHub MCP** `create_issue()` | Sync tasks to project management |
239
- | **Fallback:** Create issues via CLI | **Bash** `gh issue create ...` | When no GitHub MCP |
240
- | Render tasks template | **Bash** `npx morph-spec template render docs/tasks ...` | CLI command |
241
- | Update state with task count | **Bash** `npx morph-spec state set ... tasks.total N` | CLI command |
242
-
243
- **MCPs used:** Context7 (complexity estimation), GitHub (issue creation).
130
+ ## Tools Per Phase
244
131
 
245
- **Anti-patterns:**
246
- - ❌ Task agent to break down a simple 1-domain spec (do it directly)
247
- - ✅ Task agent for complex multi-domain specs (backend + frontend + infra = 3 independent planners)
248
- - ✅ Task agent when spec has 20+ requirements across multiple bounded contexts
249
- - ❌ Manually writing tasks.json without reading all outputs first
132
+ > Para detalhes de ferramentas por fase, veja `references/tools-per-phase.md`
250
133
 
251
- ---
134
+ **Resumo rápido por fase:**
252
135
 
253
- ### Phase 5 Implement
254
-
255
- **Goal:** Implement tasks, checkpoint every 3, create recap
256
-
257
- | Action | Tool | Why |
258
- |--------|------|-----|
259
- | Read task details | **Read** tasks.json, spec.md, contracts.cs | Implementation reference |
260
- | **Check parallelization viability** | **Bash** `npx morph-spec dispatch-agents {feature} implement` | Whether to dispatch parallel implementers |
261
- | **Dispatch per-domain implementers** (when viable) | **Task** subagents one per domain group | Backend tasks + frontend tasks run in parallel |
262
- | Create new files | **Write** new source files | New entities, services, pages |
263
- | Modify existing files | **Edit** existing source files | Add features to existing code |
264
- | Look up API during coding | **Context7 MCP** `query_docs()` | Accurate library usage |
265
- | Run database migrations | **Supabase MCP** `query()` | DDL statements directly |
266
- | **Fallback:** Run migrations | **Bash** `npx supabase migration ...` or `dotnet ef ...` | CLI tools |
267
- | Build project | **Bash** `dotnet build` or `npm run build` | Verify compilation |
268
- | Run tests | **Bash** `dotnet test` or `npm test` | Verify implementation |
269
- | Checkpoint validation | **Bash** `npx morph-spec checkpoint ...` | Every 3 tasks |
270
- | Create RLS policies | **Supabase MCP** `query()` | Security policies |
271
- | Create infrastructure | **Bash** `az bicep ...` or Bicep files via Write | IaC |
272
- | Create PR | **GitHub MCP** `create_pull_request()` or **Bash** `gh pr create` | Ship code |
273
- | Mark task done | **Bash** `npx morph-spec task done T001` | State tracking |
274
- | Smoke test feature no browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual testing |
275
- | Verificar erros de console | **Playwright MCP** `browser_console_messages()` | Browser DevTools |
276
- | Screenshot para recap.md | **Playwright MCP** `browser_take_screenshot()` | Manual screenshot |
277
- | Update state | **Bash** `npx morph-spec state set ...` | CLI command |
278
-
279
- **MCPs used:** Supabase (migrations, RLS), Context7 (API lookup), GitHub (PRs), Playwright (smoke test, verification).
280
-
281
- **Parallel dispatch threshold:**
282
- - `tasks.total ≥ 6` AND feature spans 2+ domains (e.g. `dotnet-senior` + `nextjs-expert`) → dispatch parallel implementers
283
- - Each subagent gets its own task group (backend T001-T005, frontend T006-T009) with isolated file scope
284
-
285
- **Anti-patterns:**
286
- - ❌ Task agent for a single file edit (use Edit directly)
287
- - ✅ Task agent for implementing a full service layer across 5+ files
288
- - ✅ Task agent for each domain group when feature has 6+ tasks across multiple domains
289
- - ❌ Bash `cat` to create files (use Write tool)
290
- - ❌ Bash `sed` to modify code (use Edit tool)
291
- - ❌ Implementing without reading contracts.cs first (contracts are the source of truth)
292
- - ❌ Implementing backend and frontend tasks sequentially when they have no cross-dependencies
136
+ | Fase | MCPs principais | Dispatch subagents? |
137
+ |------|----------------|---------------------|
138
+ | Proposal | GitHub (opcional) | Não |
139
+ | Setup | GitHub (opcional) | Não |
140
+ | UI/UX | Playwright, Figma, Context7 | Não |
141
+ | Design | Supabase, Context7, GitHub | Sim (domain-architect + schema em paralelo) |
142
+ | Clarify | Context7, GitHub | Não |
143
+ | Tasks | Context7, GitHub | Sim (quando spec tem 20+ reqs ou 3+ domínios) |
144
+ | Implement | Supabase, Context7, Playwright, GitHub | Sim (quando tasks.total 6 e 2+ domínios) |
293
145
 
294
146
  ---
295
147
 
@@ -340,6 +192,16 @@ Before choosing a tool, ask:
340
192
  - Unknown files needing exploration → Glob/Grep, then Read
341
193
  - Complex multi-step analysis → Task subagent
342
194
 
195
+ ### Anti-Padrões Globais
196
+
197
+ - ❌ **WebFetch para URLs GitHub** → Use `gh api` ou `gh` CLI
198
+ - Correto: `gh api repos/owner/repo/git/trees/main --field recursive=1`
199
+ - Correto: `gh pr view 123`, `gh issue view 456`
200
+ - WebFetch para GitHub retorna HTML/redirect; `gh` usa a API autenticada
201
+ - ❌ **Perguntas multi-opção como texto livre** → Use `AskUserQuestion` com `options[]`
202
+ - Correto: `AskUserQuestion({ question: "Qual abordagem?", options: [{label: "A"}, {label: "B"}] })`
203
+ - Texto livre cria ambiguidade e requer parse manual da resposta
204
+
343
205
  ---
344
206
 
345
207
  ## MCP Registry
@@ -0,0 +1,213 @@
1
+ # Tools Per Phase — Detailed Reference
2
+
3
+ > Detailed tool selection tables for each MORPH-SPEC phase.
4
+ > For the decision flowchart and selection rules, see the main `SKILL.md`.
5
+
6
+ ---
7
+
8
+ ## Phase 0 — Proposal
9
+
10
+ **Goal:** Understand the feature request and create proposal.md
11
+
12
+ | Action | Tool | Why |
13
+ |--------|------|-----|
14
+ | Read project context | **Read** `.morph/context/README.md` | Single known file |
15
+ | Read config | **Read** `.morph/config.json` | Single known file |
16
+ | Find existing features | **Glob** `.morph/features/*/0-proposal/proposal.md` | Pattern search |
17
+ | Detect project stack | **Read** `.morph/framework/agents.json` → match keywords → **Bash** `npx morph-spec state add-agent` | agents.json is the source of truth |
18
+ | Research external requirement | **WebSearch** | Current information needed |
19
+ | Render proposal template | **Bash** `npx morph-spec template render docs/proposal ...` | CLI command |
20
+ | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
21
+
22
+ **MCPs used:** None typically. GitHub MCP if feature comes from an issue.
23
+
24
+ **Anti-patterns:**
25
+ - ❌ Task agent to read proposal template (just use Read)
26
+ - ❌ Bash `cat` to read files (use Read tool)
27
+ - ❌ Bash `find` to locate files (use Glob tool)
28
+
29
+ ---
30
+
31
+ ## Phase 1 — Setup
32
+
33
+ **Goal:** Load context, detect stack, activate agents
34
+
35
+ | Action | Tool | Why |
36
+ |--------|------|-----|
37
+ | Verify feature state | **Bash** `npx morph-spec state get {feature}` | CLI command |
38
+ | Detect agents + standards | **Read** `.morph/framework/agents.json` → match keywords → **Bash** `npx morph-spec state add-agent {f} {id}` per match | Keyword matching is fast inline |
39
+ | Read project context | **Read** `.morph/context/README.md` | Single file |
40
+ | Read config | **Read** `.morph/config.json` | Single file |
41
+ | Scan project structure | **Glob** `src/**/*.{ts,tsx,cs}` | Understand codebase layout |
42
+ | Get repo metadata | **GitHub MCP** `get_repo()` | Structured repo info (if MCP available) |
43
+ | Get dispatch config for next phases | **Bash** `npx morph-spec dispatch-agents {feature} design` | Shows which agents will be dispatched in design phase |
44
+ | Update state | **Bash** `npx morph-spec state set ...` | CLI command |
45
+
46
+ **MCPs used:** GitHub (optional — for repo metadata).
47
+
48
+ **Anti-patterns:**
49
+ - ❌ Calling `detect-agents` CLI (it doesn't exist — read `.morph/framework/agents.json` directly)
50
+ - ❌ Task agent to detect project stack inline (keyword matching is fast enough directly)
51
+ - ❌ WebSearch for project info (it's local, use Read/Glob)
52
+
53
+ ---
54
+
55
+ ## Phase 1.5 — UI/UX Design
56
+
57
+ **Goal:** Create UI mockups, design system, component specs, user flows
58
+
59
+ | Action | Tool | Why |
60
+ |--------|------|-----|
61
+ | Check existing design system | **Read** `.morph/context/design-system.md` | Single file |
62
+ | Read user-provided screenshots | **Read** (image files) | Claude Code reads images natively |
63
+ | Search for existing CSS variables | **Grep** `--root:` or `--color-` in `*.css,*.scss` | Find existing design tokens |
64
+ | Find existing UI components | **Glob** `**/Components/**/*.razor` or `**/components/**/*.tsx` | Existing patterns |
65
+ | Get Figma design tokens | **Figma MCP** `get_file({ fileKey })` | Extract colors, typography from Figma |
66
+ | Look up component library API | **Context7 MCP** `query_docs({ libraryId, query })` | Accurate component props/events |
67
+ | Preview de página existente | **Playwright MCP** `browser_navigate()` + `browser_take_screenshot()` | **WebFetch** URL |
68
+ | Inspecionar estrutura da página | **Playwright MCP** `browser_snapshot()` | **WebFetch** + parse manual |
69
+ | Testar layout responsivo | **Playwright MCP** `browser_resize()` + `browser_take_screenshot()` | Manual testing |
70
+ | Search for design references | **WebSearch** + **WebFetch** | External inspiration |
71
+ | Render UI templates | **Bash** `npx morph-spec template render docs/ui-mockups ...` | CLI command |
72
+ | Generate design system from CSS | **Bash** `npx morph-spec generate design-system --scan` | CLI command |
73
+ | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
74
+
75
+ **MCPs used:** Figma (design tokens), Playwright (live preview, page inspection), Context7 (component docs).
76
+
77
+ **Anti-patterns:**
78
+ - ❌ WebSearch for MudBlazor docs (use Context7 MCP — more accurate)
79
+ - ❌ Task agent to read a single screenshot (just use Read tool on the image)
80
+ - ❌ Manually guessing component props (use Context7 to get real API)
81
+
82
+ ---
83
+
84
+ ## Phase 2 — Design (Technical Spec)
85
+
86
+ **Goal:** Analyze schema, create spec.md, contracts-level{N}.cs, decisions.md
87
+
88
+ | Action | Tool | Why |
89
+ |--------|------|-----|
90
+ | Read proposal + UI specs | **Read** output files | Single known files |
91
+ | **Get dispatch config** | **Bash** `npx morph-spec dispatch-agents {feature} design` | Which agents to spawn + their task prompts |
92
+ | **Dispatch domain-architect** (parallel) | **Task** subagent with prompt from dispatch config | Analyze DDD complexity independently |
93
+ | **Dispatch tech leads** (parallel) | **Task** subagents (dotnet-senior, nextjs-expert, etc.) | Validate architecture independently |
94
+ | Get database schema | **Supabase MCP** `list_tables()`, `get_table_schema()` | **PREFERRED** — real schema data |
95
+ | Get table relationships | **Supabase MCP** `get_relationships()` | Real FK/constraint data |
96
+ | Get RLS policies | **Supabase MCP** `query()` with pg_policies | Security analysis |
97
+ | **Fallback:** Find query files | **Grep** `\.from\(` or `\.select\(` in `*.ts,*.tsx,*.js,*.cs` | When no DB MCP available |
98
+ | **Fallback:** Find type definitions | **Glob** `src/**/types/**/*.ts` or `**/Entities/**/*.cs` | When no DB MCP available |
99
+ | **Fallback:** Read query/type files | **Read** each matched file | Extract field names manually |
100
+ | Look up library for ADR | **Context7 MCP** `query_docs()` | Compare library capabilities |
101
+ | Check existing code patterns | **GitHub MCP** `search_code()` | Find patterns in large repos |
102
+ | **Fallback:** Search codebase | **Grep** patterns across project | When no GitHub MCP |
103
+ | Render contracts template (detected level) | **Bash** `npx morph-spec template render code/dotnet/contracts/contracts-level{N}.cs ...` where N = level detected | CLI command |
104
+ | Render spec template | **Bash** `npx morph-spec template render docs/spec ...` | CLI command |
105
+ | Render decisions template | **Bash** `npx morph-spec template render docs/decisions ...` | CLI command |
106
+ | Create schema-analysis.md | **Write** to output directory | Document findings |
107
+ | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
108
+
109
+ **MCPs used:** Supabase (schema analysis), Context7 (library research), GitHub (code search).
110
+
111
+ **Parallel dispatch opportunity:** Domain complexity analysis (domain-architect) and schema analysis (phase-codebase-analysis) are **independent** — run them as parallel Task subagents to cut design phase time.
112
+
113
+ **Anti-patterns:**
114
+ - ❌ Guessing field names without checking schema (use MCP or Grep first!)
115
+ - ❌ Task agent to read a single spec file (use Read directly)
116
+ - ❌ WebSearch for database schema (use Supabase MCP or code analysis)
117
+ - ❌ Manually writing contracts-level{N}.cs from scratch (use template render)
118
+ - ❌ Running domain analysis and schema analysis sequentially (they're independent — run in parallel)
119
+
120
+ ---
121
+
122
+ ## Phase 3 — Clarify
123
+
124
+ **Goal:** Identify ambiguities, ask clarification questions, update spec
125
+
126
+ | Action | Tool | Why |
127
+ |--------|------|-----|
128
+ | Read spec.md in detail | **Read** spec.md | Full content analysis |
129
+ | Read contracts.cs | **Read** contracts.cs | Check contract consistency |
130
+ | Read schema-analysis.md | **Read** schema-analysis.md | Cross-reference with spec |
131
+ | Verify library capabilities | **Context7 MCP** `query_docs()` | Confirm feasibility of spec requirements |
132
+ | Check known issues/limitations | **GitHub MCP** `search_issues()` | Library bugs affecting design |
133
+ | Research edge case behavior | **WebSearch** | External knowledge for edge cases |
134
+ | Update spec with clarifications | **Edit** spec.md | Preserve existing content, add sections |
135
+ | Create clarifications.md | **Bash** `npx morph-spec template render docs/clarifications ...` | Use template |
136
+ | Update state | **Bash** `npx morph-spec state mark-output ... clarifications` | CLI command |
137
+
138
+ **MCPs used:** Context7 (validate feasibility), GitHub (known issues).
139
+
140
+ **Anti-patterns:**
141
+ - ❌ Task agent to read spec (just Read it directly)
142
+ - ❌ Rewriting spec from scratch (use Edit to update sections)
143
+ - ❌ Skipping schema-analysis.md cross-reference (critical for accuracy)
144
+
145
+ ---
146
+
147
+ ## Phase 4 — Tasks
148
+
149
+ **Goal:** Break spec into tasks, define dependencies, set checkpoints
150
+
151
+ | Action | Tool | Why |
152
+ |--------|------|-----|
153
+ | Read spec + contracts + decisions | **Read** all output files | Full context needed |
154
+ | **Get dispatch config** | **Bash** `npx morph-spec dispatch-agents {feature} tasks` | Which domain experts to consult |
155
+ | Analyze implementation complexity | **Grep** patterns in existing code | Estimate effort from codebase size |
156
+ | Count existing similar patterns | **Glob** `**/Services/**/*.cs` | Understand scope |
157
+ | **Dispatch domain experts** (when spec is complex) | **Task** subagents per domain | Parallel per-domain task planning |
158
+ | Look up implementation patterns | **Context7 MCP** `query_docs()` | Estimate task complexity accurately |
159
+ | Create GitHub issues from tasks | **GitHub MCP** `create_issue()` | Sync tasks to project management |
160
+ | **Fallback:** Create issues via CLI | **Bash** `gh issue create ...` | When no GitHub MCP |
161
+ | Render tasks template | **Bash** `npx morph-spec template render docs/tasks ...` | CLI command |
162
+ | Update state with task count | **Bash** `npx morph-spec state set ... tasks.total N` | CLI command |
163
+
164
+ **MCPs used:** Context7 (complexity estimation), GitHub (issue creation).
165
+
166
+ **Anti-patterns:**
167
+ - ❌ Task agent to break down a simple 1-domain spec (do it directly)
168
+ - ✅ Task agent for complex multi-domain specs (backend + frontend + infra = 3 independent planners)
169
+ - ✅ Task agent when spec has 20+ requirements across multiple bounded contexts
170
+ - ❌ Manually writing tasks.json without reading all outputs first
171
+
172
+ ---
173
+
174
+ ## Phase 5 — Implement
175
+
176
+ **Goal:** Implement tasks, checkpoint every 3, create recap
177
+
178
+ | Action | Tool | Why |
179
+ |--------|------|-----|
180
+ | Read task details | **Read** tasks.json, spec.md, contracts.cs | Implementation reference |
181
+ | **Check parallelization viability** | **Bash** `npx morph-spec dispatch-agents {feature} implement` | Whether to dispatch parallel implementers |
182
+ | **Dispatch per-domain implementers** (when viable) | **Task** subagents — one per domain group | Backend tasks + frontend tasks run in parallel |
183
+ | Create new files | **Write** new source files | New entities, services, pages |
184
+ | Modify existing files | **Edit** existing source files | Add features to existing code |
185
+ | Look up API during coding | **Context7 MCP** `query_docs()` | Accurate library usage |
186
+ | Run database migrations | **Supabase MCP** `query()` | DDL statements directly |
187
+ | **Fallback:** Run migrations | **Bash** `npx supabase migration ...` or `dotnet ef ...` | CLI tools |
188
+ | Build project | **Bash** `dotnet build` or `npm run build` | Verify compilation |
189
+ | Run tests | **Bash** `dotnet test` or `npm test` | Verify implementation |
190
+ | Checkpoint validation | **Bash** `npx morph-spec checkpoint ...` | Every 3 tasks |
191
+ | Create RLS policies | **Supabase MCP** `query()` | Security policies |
192
+ | Create infrastructure | **Bash** `az bicep ...` or Bicep files via Write | IaC |
193
+ | Create PR | **GitHub MCP** `create_pull_request()` or **Bash** `gh pr create` | Ship code |
194
+ | Mark task done | **Bash** `npx morph-spec task done T001` | State tracking |
195
+ | Smoke test feature no browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual testing |
196
+ | Verificar erros de console | **Playwright MCP** `browser_console_messages()` | Browser DevTools |
197
+ | Screenshot para recap.md | **Playwright MCP** `browser_take_screenshot()` | Manual screenshot |
198
+ | Update state | **Bash** `npx morph-spec state set ...` | CLI command |
199
+
200
+ **MCPs used:** Supabase (migrations, RLS), Context7 (API lookup), GitHub (PRs), Playwright (smoke test, verification).
201
+
202
+ **Parallel dispatch threshold:**
203
+ - `tasks.total ≥ 6` AND feature spans 2+ domains (e.g. `dotnet-senior` + `nextjs-expert`) → dispatch parallel implementers
204
+ - Each subagent gets its own task group (backend T001-T005, frontend T006-T009) with isolated file scope
205
+
206
+ **Anti-patterns:**
207
+ - ❌ Task agent for a single file edit (use Edit directly)
208
+ - ✅ Task agent for implementing a full service layer across 5+ files
209
+ - ✅ Task agent for each domain group when feature has 6+ tasks across multiple domains
210
+ - ❌ Bash `cat` to create files (use Write tool)
211
+ - ❌ Bash `sed` to modify code (use Edit tool)
212
+ - ❌ Implementing without reading contracts.cs first (contracts are the source of truth)
213
+ - ❌ Implementing backend and frontend tasks sequentially when they have no cross-dependencies
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  name: verification-before-completion
3
3
  description: Phase-specific verification checklists and morph-spec validation commands for confirming MORPH-SPEC outputs are complete and correct. Use before marking any task done, before advancing to the next phase, before committing, or before creating PRs.
4
+ user-invocable: true
5
+ argument-hint: "[feature-name] [phase?]"
4
6
  ---
5
7
 
6
8
  # Verification Before Completion — MORPH-SPEC Integrated