@polymorphism-tech/morph-spec 4.8.14 → 4.8.16

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 (72) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +23 -2
  3. package/bin/task-manager.js +202 -14
  4. package/claude-plugin.json +1 -1
  5. package/docs/CHEATSHEET.md +1 -1
  6. package/docs/QUICKSTART.md +1 -1
  7. package/framework/agents.json +113 -116
  8. package/framework/hooks/claude-code/post-tool-use/dispatch.js +48 -2
  9. package/framework/hooks/claude-code/post-tool-use/validator-feedback.js +151 -0
  10. package/framework/hooks/claude-code/pre-tool-use/enforce-phase-writes.js +6 -0
  11. package/framework/hooks/claude-code/pre-tool-use/protect-spec-files.js +6 -0
  12. package/framework/hooks/claude-code/session-start/inject-morph-context.js +27 -0
  13. package/framework/hooks/claude-code/stop/validate-completion.js +17 -2
  14. package/framework/hooks/claude-code/teammate-idle/teammate-idle.js +87 -0
  15. package/framework/hooks/claude-code/user-prompt/set-terminal-title.js +58 -0
  16. package/framework/hooks/shared/phase-utils.js +1 -1
  17. package/framework/hooks/shared/state-reader.js +1 -0
  18. package/framework/skills/README.md +1 -0
  19. package/framework/skills/level-0-meta/brainstorming/SKILL.md +2 -0
  20. package/framework/skills/level-0-meta/code-review/SKILL.md +16 -0
  21. package/framework/skills/level-0-meta/code-review/references/review-guidelines.md +100 -0
  22. package/framework/skills/level-0-meta/code-review/scripts/scan-csharp.mjs +36 -6
  23. package/framework/skills/level-0-meta/code-review-nextjs/SKILL.md +16 -0
  24. package/framework/skills/level-0-meta/code-review-nextjs/scripts/scan-nextjs.mjs +189 -0
  25. package/framework/skills/level-0-meta/frontend-review/SKILL.md +359 -0
  26. package/framework/skills/level-0-meta/frontend-review/scripts/scan-accessibility.mjs +376 -0
  27. package/framework/skills/level-0-meta/morph-checklist/SKILL.md +1 -1
  28. package/framework/skills/level-0-meta/morph-init/SKILL.md +3 -2
  29. package/framework/skills/level-0-meta/morph-replicate/SKILL.md +10 -8
  30. package/framework/skills/level-0-meta/morph-replicate/references/blazor-html-mapping.md +70 -0
  31. package/framework/skills/level-0-meta/post-implementation/SKILL.md +315 -0
  32. package/framework/skills/level-0-meta/post-implementation/scripts/detect-dev-server.mjs +153 -0
  33. package/framework/skills/level-0-meta/post-implementation/scripts/detect-stack.mjs +234 -0
  34. package/framework/skills/level-0-meta/terminal-title/SKILL.md +61 -0
  35. package/framework/skills/level-0-meta/terminal-title/scripts/set_title.sh +65 -0
  36. package/framework/skills/level-0-meta/tool-usage-guide/SKILL.md +13 -206
  37. package/framework/skills/level-0-meta/tool-usage-guide/references/tools-per-phase.md +213 -0
  38. package/framework/skills/level-0-meta/verification-before-completion/SKILL.md +2 -0
  39. package/framework/skills/level-1-workflows/phase-clarify/SKILL.md +4 -7
  40. package/framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md +1 -1
  41. package/framework/skills/level-1-workflows/phase-design/SKILL.md +16 -110
  42. package/framework/skills/level-1-workflows/phase-design/references/architecture-analysis-guide.md +89 -0
  43. package/framework/skills/level-1-workflows/phase-design/references/spec-authoring-guide.md +55 -0
  44. package/framework/skills/level-1-workflows/phase-implement/SKILL.md +153 -118
  45. package/framework/skills/level-1-workflows/phase-implement/references/vsa-implementation-guide.md +92 -0
  46. package/framework/skills/level-1-workflows/phase-setup/SKILL.md +1 -2
  47. package/framework/skills/level-1-workflows/phase-tasks/SKILL.md +11 -158
  48. package/framework/skills/level-1-workflows/phase-tasks/references/task-planning-patterns.md +172 -0
  49. package/framework/skills/level-1-workflows/phase-uiux/SKILL.md +42 -3
  50. package/framework/squad-templates/backend-only.json +14 -1
  51. package/framework/squad-templates/frontend-only.json +14 -1
  52. package/framework/squad-templates/full-stack.json +25 -8
  53. package/framework/standards/STANDARDS.json +631 -86
  54. package/framework/standards/frontend/design-system/aesthetic-direction.md +213 -0
  55. package/framework/templates/project/validate.js +122 -0
  56. package/framework/workflows/configs/zero-touch.json +7 -0
  57. package/package.json +1 -1
  58. package/src/commands/agents/dispatch-agents.js +53 -10
  59. package/src/commands/state/advance-phase.js +56 -0
  60. package/src/commands/state/index.js +2 -1
  61. package/src/commands/state/phase-runner.js +215 -0
  62. package/src/commands/tasks/task.js +23 -2
  63. package/src/core/paths/output-schema.js +1 -1
  64. package/src/lib/generators/recap-generator.js +16 -0
  65. package/src/lib/orchestration/team-orchestrator.js +171 -89
  66. package/src/lib/phase-chain/eligibility-checker.js +243 -0
  67. package/src/lib/standards/digest-builder.js +231 -0
  68. package/src/lib/validators/blazor/blazor-concurrency-analyzer.js +39 -0
  69. package/src/lib/validators/nextjs/next-component-validator.js +2 -0
  70. package/src/lib/validators/validation-runner.js +2 -2
  71. package/src/utils/file-copier.js +2 -0
  72. 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
@@ -129,212 +129,19 @@ Critério: se a leitura de arquivo B não depende do CONTEÚDO de arquivo A, lei
129
129
 
130
130
  ## Tools Per Phase
131
131
 
132
- ### Phase 0 Proposal
133
-
134
- **Goal:** Understand the feature request and create proposal.md
135
-
136
- | Action | Tool | Why |
137
- |--------|------|-----|
138
- | Read project context | **Read** `.morph/context/README.md` | Single known file |
139
- | Read config | **Read** `.morph/config.json` | Single known file |
140
- | Find existing features | **Glob** `.morph/features/*/0-proposal/proposal.md` | Pattern search |
141
- | Detect project stack | **Read** `.morph/framework/agents.json` match keywords → **Bash** `npx morph-spec state add-agent` | agents.json is the source of truth |
142
- | Research external requirement | **WebSearch** | Current information needed |
143
- | Render proposal template | **Bash** `npx morph-spec template render docs/proposal ...` | CLI command |
144
- | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
145
-
146
- **MCPs used:** None typically. GitHub MCP if feature comes from an issue.
147
-
148
- **Anti-patterns:**
149
- - ❌ Task agent to read proposal template (just use Read)
150
- - ❌ Bash `cat` to read files (use Read tool)
151
- - ❌ Bash `find` to locate files (use Glob tool)
152
-
153
- ---
154
-
155
- ### Phase 1 — Setup
156
-
157
- **Goal:** Load context, detect stack, activate agents
158
-
159
- | Action | Tool | Why |
160
- |--------|------|-----|
161
- | Verify feature state | **Bash** `npx morph-spec state get {feature}` | CLI command |
162
- | 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 |
163
- | Read project context | **Read** `.morph/context/README.md` | Single file |
164
- | Read config | **Read** `.morph/config.json` | Single file |
165
- | Scan project structure | **Glob** `src/**/*.{ts,tsx,cs}` | Understand codebase layout |
166
- | Get repo metadata | **GitHub MCP** `get_repo()` | Structured repo info (if MCP available) |
167
- | Get dispatch config for next phases | **Bash** `npx morph-spec dispatch-agents {feature} design` | Shows which agents will be dispatched in design phase |
168
- | Update state | **Bash** `npx morph-spec state set ...` | CLI command |
169
-
170
- **MCPs used:** GitHub (optional — for repo metadata).
171
-
172
- **Anti-patterns:**
173
- - ❌ Calling `detect-agents` CLI (it doesn't exist — read `.morph/framework/agents.json` directly)
174
- - ❌ Task agent to detect project stack inline (keyword matching is fast enough directly)
175
- - ❌ WebSearch for project info (it's local, use Read/Glob)
176
-
177
- ---
178
-
179
- ### Phase 1.5 — UI/UX Design
180
-
181
- **Goal:** Create UI mockups, design system, component specs, user flows
182
-
183
- | Action | Tool | Why |
184
- |--------|------|-----|
185
- | Check existing design system | **Read** `.morph/context/design-system.md` | Single file |
186
- | Read user-provided screenshots | **Read** (image files) | Claude Code reads images natively |
187
- | Search for existing CSS variables | **Grep** `--root:` or `--color-` in `*.css,*.scss` | Find existing design tokens |
188
- | Find existing UI components | **Glob** `**/Components/**/*.razor` or `**/components/**/*.tsx` | Existing patterns |
189
- | Get Figma design tokens | **Figma MCP** `get_file({ fileKey })` | Extract colors, typography from Figma |
190
- | Look up component library API | **Context7 MCP** `query_docs({ libraryId, query })` | Accurate component props/events |
191
- | Preview de página existente | **Playwright MCP** `browser_navigate()` + `browser_take_screenshot()` | **WebFetch** URL |
192
- | Inspecionar estrutura da página | **Playwright MCP** `browser_snapshot()` | **WebFetch** + parse manual |
193
- | Testar layout responsivo | **Playwright MCP** `browser_resize()` + `browser_take_screenshot()` | Manual testing |
194
- | Search for design references | **WebSearch** + **WebFetch** | External inspiration |
195
- | Render UI templates | **Bash** `npx morph-spec template render docs/ui-mockups ...` | CLI command |
196
- | Generate design system from CSS | **Bash** `npx morph-spec generate design-system --scan` | CLI command |
197
- | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
198
-
199
- **MCPs used:** Figma (design tokens), Playwright (live preview, page inspection), Context7 (component docs).
200
-
201
- **Anti-patterns:**
202
- - ❌ WebSearch for MudBlazor docs (use Context7 MCP — more accurate)
203
- - ❌ Task agent to read a single screenshot (just use Read tool on the image)
204
- - ❌ Manually guessing component props (use Context7 to get real API)
205
-
206
- ---
207
-
208
- ### Phase 2 — Design (Technical Spec)
209
-
210
- **Goal:** Analyze schema, create spec.md, contracts-level{N}.cs, decisions.md
211
-
212
- | Action | Tool | Why |
213
- |--------|------|-----|
214
- | Read proposal + UI specs | **Read** output files | Single known files |
215
- | **Get dispatch config** | **Bash** `npx morph-spec dispatch-agents {feature} design` | Which agents to spawn + their task prompts |
216
- | **Dispatch domain-architect** (parallel) | **Task** subagent with prompt from dispatch config | Analyze DDD complexity independently |
217
- | **Dispatch tech leads** (parallel) | **Task** subagents (dotnet-senior, nextjs-expert, etc.) | Validate architecture independently |
218
- | Get database schema | **Supabase MCP** `list_tables()`, `get_table_schema()` | **PREFERRED** — real schema data |
219
- | Get table relationships | **Supabase MCP** `get_relationships()` | Real FK/constraint data |
220
- | Get RLS policies | **Supabase MCP** `query()` with pg_policies | Security analysis |
221
- | **Fallback:** Find query files | **Grep** `\.from\(` or `\.select\(` in `*.ts,*.tsx,*.js,*.cs` | When no DB MCP available |
222
- | **Fallback:** Find type definitions | **Glob** `src/**/types/**/*.ts` or `**/Entities/**/*.cs` | When no DB MCP available |
223
- | **Fallback:** Read query/type files | **Read** each matched file | Extract field names manually |
224
- | Look up library for ADR | **Context7 MCP** `query_docs()` | Compare library capabilities |
225
- | Check existing code patterns | **GitHub MCP** `search_code()` | Find patterns in large repos |
226
- | **Fallback:** Search codebase | **Grep** patterns across project | When no GitHub MCP |
227
- | Render contracts template (detected level) | **Bash** `npx morph-spec template render code/dotnet/contracts/contracts-level{N}.cs ...` where N = level detected | CLI command |
228
- | Render spec template | **Bash** `npx morph-spec template render docs/spec ...` | CLI command |
229
- | Render decisions template | **Bash** `npx morph-spec template render docs/decisions ...` | CLI command |
230
- | Create schema-analysis.md | **Write** to output directory | Document findings |
231
- | Update state | **Bash** `npx morph-spec state mark-output ...` | CLI command |
232
-
233
- **MCPs used:** Supabase (schema analysis), Context7 (library research), GitHub (code search).
234
-
235
- **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.
236
-
237
- **Anti-patterns:**
238
- - ❌ Guessing field names without checking schema (use MCP or Grep first!)
239
- - ❌ Task agent to read a single spec file (use Read directly)
240
- - ❌ WebSearch for database schema (use Supabase MCP or code analysis)
241
- - ❌ Manually writing contracts-level{N}.cs from scratch (use template render)
242
- - ❌ Running domain analysis and schema analysis sequentially (they're independent — run in parallel)
243
-
244
- ---
245
-
246
- ### Phase 3 — Clarify
247
-
248
- **Goal:** Identify ambiguities, ask clarification questions, update spec
249
-
250
- | Action | Tool | Why |
251
- |--------|------|-----|
252
- | Read spec.md in detail | **Read** spec.md | Full content analysis |
253
- | Read contracts.cs | **Read** contracts.cs | Check contract consistency |
254
- | Read schema-analysis.md | **Read** schema-analysis.md | Cross-reference with spec |
255
- | Verify library capabilities | **Context7 MCP** `query_docs()` | Confirm feasibility of spec requirements |
256
- | Check known issues/limitations | **GitHub MCP** `search_issues()` | Library bugs affecting design |
257
- | Research edge case behavior | **WebSearch** | External knowledge for edge cases |
258
- | Update spec with clarifications | **Edit** spec.md | Preserve existing content, add sections |
259
- | Create clarifications.md | **Bash** `npx morph-spec template render docs/clarifications ...` | Use template |
260
- | Update state | **Bash** `npx morph-spec state mark-output ... clarifications` | CLI command |
261
-
262
- **MCPs used:** Context7 (validate feasibility), GitHub (known issues).
263
-
264
- **Anti-patterns:**
265
- - ❌ Task agent to read spec (just Read it directly)
266
- - ❌ Rewriting spec from scratch (use Edit to update sections)
267
- - ❌ Skipping schema-analysis.md cross-reference (critical for accuracy)
268
-
269
- ---
270
-
271
- ### Phase 4 — Tasks
272
-
273
- **Goal:** Break spec into tasks, define dependencies, set checkpoints
274
-
275
- | Action | Tool | Why |
276
- |--------|------|-----|
277
- | Read spec + contracts + decisions | **Read** all output files | Full context needed |
278
- | **Get dispatch config** | **Bash** `npx morph-spec dispatch-agents {feature} tasks` | Which domain experts to consult |
279
- | Analyze implementation complexity | **Grep** patterns in existing code | Estimate effort from codebase size |
280
- | Count existing similar patterns | **Glob** `**/Services/**/*.cs` | Understand scope |
281
- | **Dispatch domain experts** (when spec is complex) | **Task** subagents per domain | Parallel per-domain task planning |
282
- | Look up implementation patterns | **Context7 MCP** `query_docs()` | Estimate task complexity accurately |
283
- | Create GitHub issues from tasks | **GitHub MCP** `create_issue()` | Sync tasks to project management |
284
- | **Fallback:** Create issues via CLI | **Bash** `gh issue create ...` | When no GitHub MCP |
285
- | Render tasks template | **Bash** `npx morph-spec template render docs/tasks ...` | CLI command |
286
- | Update state with task count | **Bash** `npx morph-spec state set ... tasks.total N` | CLI command |
287
-
288
- **MCPs used:** Context7 (complexity estimation), GitHub (issue creation).
289
-
290
- **Anti-patterns:**
291
- - ❌ Task agent to break down a simple 1-domain spec (do it directly)
292
- - ✅ Task agent for complex multi-domain specs (backend + frontend + infra = 3 independent planners)
293
- - ✅ Task agent when spec has 20+ requirements across multiple bounded contexts
294
- - ❌ Manually writing tasks.json without reading all outputs first
295
-
296
- ---
297
-
298
- ### Phase 5 — Implement
299
-
300
- **Goal:** Implement tasks, checkpoint every 3, create recap
301
-
302
- | Action | Tool | Why |
303
- |--------|------|-----|
304
- | Read task details | **Read** tasks.json, spec.md, contracts.cs | Implementation reference |
305
- | **Check parallelization viability** | **Bash** `npx morph-spec dispatch-agents {feature} implement` | Whether to dispatch parallel implementers |
306
- | **Dispatch per-domain implementers** (when viable) | **Task** subagents — one per domain group | Backend tasks + frontend tasks run in parallel |
307
- | Create new files | **Write** new source files | New entities, services, pages |
308
- | Modify existing files | **Edit** existing source files | Add features to existing code |
309
- | Look up API during coding | **Context7 MCP** `query_docs()` | Accurate library usage |
310
- | Run database migrations | **Supabase MCP** `query()` | DDL statements directly |
311
- | **Fallback:** Run migrations | **Bash** `npx supabase migration ...` or `dotnet ef ...` | CLI tools |
312
- | Build project | **Bash** `dotnet build` or `npm run build` | Verify compilation |
313
- | Run tests | **Bash** `dotnet test` or `npm test` | Verify implementation |
314
- | Checkpoint validation | **Bash** `npx morph-spec checkpoint ...` | Every 3 tasks |
315
- | Create RLS policies | **Supabase MCP** `query()` | Security policies |
316
- | Create infrastructure | **Bash** `az bicep ...` or Bicep files via Write | IaC |
317
- | Create PR | **GitHub MCP** `create_pull_request()` or **Bash** `gh pr create` | Ship code |
318
- | Mark task done | **Bash** `npx morph-spec task done T001` | State tracking |
319
- | Smoke test feature no browser | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | Manual testing |
320
- | Verificar erros de console | **Playwright MCP** `browser_console_messages()` | Browser DevTools |
321
- | Screenshot para recap.md | **Playwright MCP** `browser_take_screenshot()` | Manual screenshot |
322
- | Update state | **Bash** `npx morph-spec state set ...` | CLI command |
323
-
324
- **MCPs used:** Supabase (migrations, RLS), Context7 (API lookup), GitHub (PRs), Playwright (smoke test, verification).
325
-
326
- **Parallel dispatch threshold:**
327
- - `tasks.total ≥ 6` AND feature spans 2+ domains (e.g. `dotnet-senior` + `nextjs-expert`) → dispatch parallel implementers
328
- - Each subagent gets its own task group (backend T001-T005, frontend T006-T009) with isolated file scope
329
-
330
- **Anti-patterns:**
331
- - ❌ Task agent for a single file edit (use Edit directly)
332
- - ✅ Task agent for implementing a full service layer across 5+ files
333
- - ✅ Task agent for each domain group when feature has 6+ tasks across multiple domains
334
- - ❌ Bash `cat` to create files (use Write tool)
335
- - ❌ Bash `sed` to modify code (use Edit tool)
336
- - ❌ Implementing without reading contracts.cs first (contracts are the source of truth)
337
- - ❌ Implementing backend and frontend tasks sequentially when they have no cross-dependencies
132
+ > Para detalhes de ferramentas por fase, veja `references/tools-per-phase.md`
133
+
134
+ **Resumo rápido por fase:**
135
+
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) |
338
145
 
339
146
  ---
340
147
 
@@ -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
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 3 (Clarify). Reviews spec.md for ambiguities, gene
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep
7
- cliVersion: "4.8.14"
7
+ cliVersion: "4.8.16"
8
8
  ---
9
9
 
10
10
  # MORPH Clarify - FASE 3
@@ -35,8 +35,8 @@ Identifique ambiguidades na especificação e faça perguntas de clarificação
35
35
  | Pesquisar edge cases externos | **WebSearch** | — |
36
36
  | Verificar comportamento UI existente | **Playwright MCP** `browser_navigate()` + `browser_snapshot()` | **WebFetch** URL |
37
37
  | Atualizar spec com clarificações | **Edit** spec.md | — |
38
- | Criar clarifications.md | **Bash** `npx morph-spec template render docs/clarifications ...` | — |
39
- | Atualizar state | **Bash** `npx morph-spec state mark-output ... clarifications` | — |
38
+ | Criar clarifications.md | **Bash** `npx morph-spec template render docs/clarifications .morph/features/$ARGUMENTS/2-clarify/clarifications.md` | — |
39
+ | Atualizar state | **Bash** `npx morph-spec state mark-output $ARGUMENTS clarifications` | — |
40
40
 
41
41
  **MCPs desta fase:** Context7 (validar viabilidade), GitHub (issues conhecidas), Playwright (verificar UI existente).
42
42
 
@@ -157,16 +157,13 @@ Documente no spec como lidar com cada edge case identificado:
157
157
 
158
158
  ### Passo 7: Atualizar State
159
159
 
160
- ```bash
161
- npx morph-spec state set $ARGUMENTS phase clarify
162
- ```
163
-
164
160
  ## Outputs Gerados/Atualizados
165
161
 
166
162
  - `.morph/features/$ARGUMENTS/1-design/spec.md` - Atualizado com:
167
163
  - Seção "Clarifications" com perguntas e respostas
168
164
  - Edge cases documentados
169
165
  - Requisitos mais específicos
166
+ - `.morph/features/$ARGUMENTS/2-clarify/clarifications.md` - Novo arquivo com Q&A estruturado
170
167
 
171
168
  ## Critérios de Avanço
172
169
 
@@ -3,7 +3,7 @@ name: phase-codebase-analysis
3
3
  description: MORPH-SPEC Design sub-phase that analyzes existing codebase and database schema, producing schema-analysis.md with real column names, types, relationships, and field mismatches. Use at the start of Design phase before generating contracts.cs to prevent incorrect field names or types.
4
4
  user-invocable: false
5
5
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep
6
- cliVersion: "4.8.14"
6
+ cliVersion: "4.8.16"
7
7
  ---
8
8
 
9
9
  # MORPH Codebase Analysis - Sub-fase de DESIGN