@jgamaraalv/ts-dev-kit 1.2.0 → 2.0.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.
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +2 -2
- package/CHANGELOG.md +6 -0
- package/agent-memory/accessibility-pro/MEMORY.md +3 -0
- package/agent-memory/api-builder/MEMORY.md +3 -0
- package/agent-memory/code-reviewer/MEMORY.md +3 -0
- package/agent-memory/database-expert/MEMORY.md +3 -0
- package/agent-memory/debugger/MEMORY.md +3 -0
- package/agent-memory/docker-expert/MEMORY.md +3 -0
- package/agent-memory/performance-engineer/MEMORY.md +3 -0
- package/agent-memory/playwright-expert/MEMORY.md +3 -0
- package/agent-memory/react-specialist/MEMORY.md +3 -0
- package/agent-memory/security-scanner/MEMORY.md +3 -0
- package/agent-memory/test-generator/MEMORY.md +3 -0
- package/agent-memory/typescript-pro/MEMORY.md +3 -0
- package/agent-memory/ux-optimizer/MEMORY.md +3 -0
- package/agents/accessibility-pro.md +82 -119
- package/agents/api-builder.md +69 -104
- package/agents/code-reviewer.md +54 -175
- package/agents/database-expert.md +80 -134
- package/agents/debugger.md +95 -200
- package/agents/docker-expert.md +53 -45
- package/agents/performance-engineer.md +97 -118
- package/agents/playwright-expert.md +62 -82
- package/agents/react-specialist.md +80 -97
- package/agents/security-scanner.md +63 -83
- package/agents/test-generator.md +85 -175
- package/agents/typescript-pro.md +81 -215
- package/agents/ux-optimizer.md +60 -77
- package/package.json +3 -2
- package/skills/debug/SKILL.md +256 -0
- package/skills/debug/references/debug-dispatch.md +289 -0
- package/skills/task/SKILL.md +366 -0
- package/skills/task/references/agent-dispatch.md +156 -0
- package/skills/task/references/output-templates.md +53 -0
- package/agents/multi-agent-coordinator.md +0 -142
- package/agents/nextjs-expert.md +0 -144
- package/docs/rules/orchestration.md.template +0 -126
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: task
|
|
3
|
+
description: "Use this skill when the user wants to implement a new task in the project. Covers feature development, refactoring, bug fixes, and any code change that requires context analysis, role assignment, and structured execution. For changes under ~30 lines in a single file, implement directly without this workflow."
|
|
4
|
+
argument-hint: "[task-description or task-md-file-path]"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<trigger_examples>
|
|
8
|
+
- "Implement the search feature"
|
|
9
|
+
- "Build the user creation flow end-to-end"
|
|
10
|
+
- "Refactor the auth module to use shared schemas"
|
|
11
|
+
- "Add the notifications endpoint to the API"
|
|
12
|
+
- "Fix the pagination bug"
|
|
13
|
+
- "Execute this task"
|
|
14
|
+
</trigger_examples>
|
|
15
|
+
|
|
16
|
+
<workflow>
|
|
17
|
+
Follow each phase in order. Each one feeds the next.
|
|
18
|
+
|
|
19
|
+
<phase_1_context_analysis>
|
|
20
|
+
Before writing any code, build a mental model of the task scope.
|
|
21
|
+
|
|
22
|
+
1. Read the project CLAUDE.md and root package.json — understand the project structure, available commands, and dependency graph.
|
|
23
|
+
2. Search the codebase for existing patterns — use Grep/Glob to find related files, similar implementations, and reusable code.
|
|
24
|
+
3. Identify the affected packages/directories — determine which parts of the project will be touched and in what order.
|
|
25
|
+
</phase_1_context_analysis>
|
|
26
|
+
|
|
27
|
+
<phase_2_role_assignment>
|
|
28
|
+
Determine the full execution context: role persona, domain area, domain technologies, project context, required skills, and available MCPs.
|
|
29
|
+
|
|
30
|
+
<domain_areas>
|
|
31
|
+
Map the task to one or more domain areas AND sub-areas. Sub-areas determine the specialist agent type and skill set.
|
|
32
|
+
|
|
33
|
+
**Backend**
|
|
34
|
+
| Sub-area | Agent type | When | Key skills |
|
|
35
|
+
|----------|-----------|------|------------|
|
|
36
|
+
| Database | `database-expert` | Schema design, migrations, complex queries, indexes | drizzle-pg, postgresql |
|
|
37
|
+
| Endpoints | `api-builder` | Routes, validation, handlers, API contracts | fastify-best-practices |
|
|
38
|
+
| Queues | `general-purpose` | Job processing, workers, schedulers | bullmq, ioredis |
|
|
39
|
+
| Security | `security-scanner` | Auth flows, RBAC, input sanitization | owasp-security-review |
|
|
40
|
+
|
|
41
|
+
**Frontend**
|
|
42
|
+
| Sub-area | Agent type | When | Key skills |
|
|
43
|
+
|----------|-----------|------|------------|
|
|
44
|
+
| Components | `react-specialist` | Component architecture, hooks, state management, composition | react-best-practices, composition-patterns |
|
|
45
|
+
| Pages/routing | `general-purpose` | Pages, layouts, data fetching, RSC boundaries | nextjs-best-practices |
|
|
46
|
+
| UI/UX | `ux-optimizer` | User flows, form UX, friction reduction | ui-ux-guidelines |
|
|
47
|
+
| Accessibility | `accessibility-pro` | WCAG compliance, keyboard nav, screen readers | — |
|
|
48
|
+
| Performance | `performance-engineer` | Core Web Vitals, bundle size, re-renders | react-best-practices |
|
|
49
|
+
|
|
50
|
+
**Shared packages** — `typescript-pro` or `general-purpose` (shared types, schemas, utilities)
|
|
51
|
+
|
|
52
|
+
**Cross-cutting specialists** (use alongside any domain)
|
|
53
|
+
| Agent type | When |
|
|
54
|
+
|-----------|------|
|
|
55
|
+
| `test-generator` | Writing test suites, improving coverage |
|
|
56
|
+
| `debugger` | Investigating errors, stack traces |
|
|
57
|
+
| `docker-expert` | Dockerfiles, compose, container config |
|
|
58
|
+
| `code-reviewer` | Post-implementation review |
|
|
59
|
+
| `playwright-expert` | E2E browser tests |
|
|
60
|
+
|
|
61
|
+
A single task may require agents from multiple sub-areas. For example, "add a new resource endpoint with list UI" needs `database-expert` (schema) + `api-builder` (route) + `react-specialist` (component).
|
|
62
|
+
</domain_areas>
|
|
63
|
+
|
|
64
|
+
<domain_technologies>
|
|
65
|
+
Read the relevant package.json to identify installed packages and their versions. Use the actual versions found — do not assume.
|
|
66
|
+
</domain_technologies>
|
|
67
|
+
|
|
68
|
+
<role_persona>
|
|
69
|
+
Compose a role persona that combines the domain sub-area, project context, technologies, and task nature.
|
|
70
|
+
|
|
71
|
+
<examples>
|
|
72
|
+
- "You are a database specialist working with [ORM] and [database] on schema design for [brief project description from CLAUDE.md]"
|
|
73
|
+
- "You are a React component architect specialized in composition patterns, hooks, and state management with [React version] and [UI library]"
|
|
74
|
+
- "You are a [framework] API developer building REST endpoints with validation and type-safe request/response contracts"
|
|
75
|
+
- "You are a frontend performance engineer optimizing Core Web Vitals and bundle size for a [framework] application"
|
|
76
|
+
- "You are a queue specialist designing job flows with [queue library] and retry strategies"
|
|
77
|
+
</examples>
|
|
78
|
+
|
|
79
|
+
Discover the actual technologies and versions from package.json. Describe the project based on CLAUDE.md or README.
|
|
80
|
+
</role_persona>
|
|
81
|
+
|
|
82
|
+
<required_skills>
|
|
83
|
+
Call the Skill tool for each relevant skill before writing any code or dispatching agents. Skills inject domain-specific rules and best practices.
|
|
84
|
+
|
|
85
|
+
Identify the required skills from the domain area, then call each one:
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
Skill(skill: "fastify-best-practices")
|
|
89
|
+
Skill(skill: "drizzle-pg")
|
|
90
|
+
Skill(skill: "postgresql")
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<skill_map>
|
|
94
|
+
Match skills to the sub-area identified in domain_areas:
|
|
95
|
+
|
|
96
|
+
**Backend sub-areas:**
|
|
97
|
+
- Database → /drizzle-pg, /postgresql
|
|
98
|
+
- Endpoints → /fastify-best-practices
|
|
99
|
+
- Queues → /bullmq, /ioredis
|
|
100
|
+
- Security → /owasp-security-review
|
|
101
|
+
|
|
102
|
+
**Frontend sub-areas:**
|
|
103
|
+
- Components → /react-best-practices, /composition-patterns
|
|
104
|
+
- Pages/routing → /nextjs-best-practices
|
|
105
|
+
- UI/UX → /ui-ux-guidelines
|
|
106
|
+
- Performance → /react-best-practices
|
|
107
|
+
|
|
108
|
+
**Cross-cutting** → combine skills from each sub-area involved.
|
|
109
|
+
</skill_map>
|
|
110
|
+
|
|
111
|
+
In SINGLE-ROLE mode: call each skill yourself before starting phase 4.
|
|
112
|
+
In MULTI-ROLE mode: include explicit Skill() call instructions in each subagent prompt (see references/agent-dispatch.md).
|
|
113
|
+
</required_skills>
|
|
114
|
+
|
|
115
|
+
<available_mcps>
|
|
116
|
+
Identify MCPs that can assist execution:
|
|
117
|
+
- context7 — query up-to-date library documentation (see below)
|
|
118
|
+
- playwright — test frontend in the browser, take screenshots, verify UI
|
|
119
|
+
- chrome-devtools — inspect pages, debug network requests, check console
|
|
120
|
+
- firecrawl — fetch external documentation or references from the web
|
|
121
|
+
|
|
122
|
+
**Context7 usage**: When the task involves library APIs, version-specific patterns, or unfamiliar method signatures, use Context7 to query current documentation before writing code:
|
|
123
|
+
1. `mcp__context7__resolve-library-id` — resolve the library name (e.g., "fastify", "drizzle-orm", "next", "react", "bullmq") to its Context7 ID.
|
|
124
|
+
2. `mcp__context7__query-docs` — query with the specific API, pattern, or feature you need.
|
|
125
|
+
Check the project's package.json for installed versions first. In MULTI-ROLE mode, include these instructions in each agent prompt so agents can query docs themselves.
|
|
126
|
+
</available_mcps>
|
|
127
|
+
</phase_2_role_assignment>
|
|
128
|
+
|
|
129
|
+
<phase_2b_multi_role_decomposition>
|
|
130
|
+
When a task spans multiple domains, decompose it into separate roles with isolated execution contexts.
|
|
131
|
+
|
|
132
|
+
<when_to_decompose>
|
|
133
|
+
Decompose into multiple roles when ANY of these apply:
|
|
134
|
+
1. The task touches 2+ packages or major directories (e.g., shared code + backend + frontend).
|
|
135
|
+
2. The task involves distinct skill sets (e.g., database schema design + frontend UI).
|
|
136
|
+
3. The changes in one domain are large enough to benefit from a focused agent.
|
|
137
|
+
|
|
138
|
+
Do not decompose if:
|
|
139
|
+
1. The task is small and contained within a single package.
|
|
140
|
+
2. The cross-package changes are trivial (e.g., adding one type to shared and importing it).
|
|
141
|
+
</when_to_decompose>
|
|
142
|
+
|
|
143
|
+
<decomposition_rules>
|
|
144
|
+
<rule_1_define_roles_independently>
|
|
145
|
+
Each role gets its own persona, skill set, context files, and success criteria.
|
|
146
|
+
|
|
147
|
+
<example>
|
|
148
|
+
Role A: Database specialist (sub-area: Database). Agent: database-expert. Task: design schema + migration for the new feature. Skills: drizzle-pg, postgresql.
|
|
149
|
+
Role B: API endpoint developer (sub-area: Endpoints). Agent: api-builder. Task: build REST routes consuming the new schema. Skills: fastify-best-practices.
|
|
150
|
+
Role C: Component architect (sub-area: Components). Agent: react-specialist. Task: build the result card and list components. Skills: react-best-practices, composition-patterns.
|
|
151
|
+
Role D: Page builder (sub-area: Pages/routing). Agent: general-purpose (ad-hoc). Task: wire components into the search results page with data fetching. Skills: nextjs-best-practices.
|
|
152
|
+
Role E: TypeScript library developer. Agent: typescript-pro. Task: add shared schemas and types. Skills: none extra.
|
|
153
|
+
</example>
|
|
154
|
+
</rule_1_define_roles_independently>
|
|
155
|
+
|
|
156
|
+
<rule_2_dispatch_agents>
|
|
157
|
+
For each role, spawn a specialized subagent via the Task tool.
|
|
158
|
+
|
|
159
|
+
**Selecting the agent type:**
|
|
160
|
+
1. Check if a project agent exists in `.claude/agents/` that matches the sub-area (see domain_areas table above for the mapping).
|
|
161
|
+
2. If a matching agent exists, use its name as `subagent_type` (e.g., `database-expert`, `api-builder`, `react-specialist`).
|
|
162
|
+
3. If no matching agent exists, use `general-purpose` as `subagent_type` and embed the full role definition directly in the prompt — this creates an ad-hoc specialist without needing a .md file.
|
|
163
|
+
|
|
164
|
+
**Ad-hoc agent creation** — when `subagent_type: "general-purpose"` is used as a specialist surrogate, the prompt must include:
|
|
165
|
+
- **Role persona**: who the agent is and what it specializes in.
|
|
166
|
+
- **Domain expertise**: specific technologies, frameworks, and versions.
|
|
167
|
+
- **Project context**: how this sub-area fits into the project (discover from CLAUDE.md and package.json).
|
|
168
|
+
- **Constraints**: patterns to follow, files to reference, conventions to match.
|
|
169
|
+
- **Skills to load**: explicit `Skill(skill: "...")` calls for domain-specific rules.
|
|
170
|
+
|
|
171
|
+
<example_adhoc_agent>
|
|
172
|
+
Task(
|
|
173
|
+
description: "Implement notification worker",
|
|
174
|
+
subagent_type: "general-purpose",
|
|
175
|
+
model: "sonnet",
|
|
176
|
+
prompt: """
|
|
177
|
+
You are a queue specialist working on this project.
|
|
178
|
+
|
|
179
|
+
Your expertise: Redis-backed job queues, workers, flow producers, retry strategies, rate limiting, and graceful shutdown.
|
|
180
|
+
|
|
181
|
+
## Before writing any code
|
|
182
|
+
1. Read CLAUDE.md and relevant package.json files to understand the project structure and conventions.
|
|
183
|
+
2. Call the Skill tool to load these domain skills:
|
|
184
|
+
- Skill(skill: "bullmq")
|
|
185
|
+
- Skill(skill: "ioredis")
|
|
186
|
+
|
|
187
|
+
## Your task
|
|
188
|
+
[task details...]
|
|
189
|
+
|
|
190
|
+
## Project context
|
|
191
|
+
Discover from the codebase:
|
|
192
|
+
- Redis connection configuration (search for Redis imports)
|
|
193
|
+
- Existing queue/worker patterns (search for queue or worker files)
|
|
194
|
+
- Import conventions (check existing code for named vs default imports)
|
|
195
|
+
[...]
|
|
196
|
+
"""
|
|
197
|
+
)
|
|
198
|
+
</example_adhoc_agent>
|
|
199
|
+
|
|
200
|
+
Each agent prompt must follow the template in references/agent-dispatch.md. The agent must be able to complete its work independently.
|
|
201
|
+
</rule_2_dispatch_agents>
|
|
202
|
+
|
|
203
|
+
<rule_3_execution_order>
|
|
204
|
+
Decide the execution order based on file conflicts and dependencies:
|
|
205
|
+
- **Parallel**: roles touch independent files with no data dependency → launch multiple Task calls in one message.
|
|
206
|
+
- **Sequential**: one role's output is another's input → await the blocker first.
|
|
207
|
+
- **Worktree isolation**: roles touch overlapping files but are otherwise independent → set `isolation: "worktree"` on the Task tool.
|
|
208
|
+
</rule_3_execution_order>
|
|
209
|
+
|
|
210
|
+
<rule_4_model_selection>
|
|
211
|
+
Choose the model for each dispatched agent based on task complexity:
|
|
212
|
+
- **haiku**: simple, well-defined tasks — adding a type, writing a small utility, updating config, barrel file exports.
|
|
213
|
+
- **sonnet**: moderate tasks — implementing a feature within a single domain, writing tests, building a component.
|
|
214
|
+
- **opus**: complex tasks — cross-cutting concerns, architectural decisions, novel implementations requiring deep reasoning.
|
|
215
|
+
|
|
216
|
+
Set the `model` parameter on the Task tool call accordingly.
|
|
217
|
+
</rule_4_model_selection>
|
|
218
|
+
</decomposition_rules>
|
|
219
|
+
|
|
220
|
+
<dispatch_pattern>
|
|
221
|
+
The main session acts as the orchestrator:
|
|
222
|
+
1. Analyze the task and define roles (this phase).
|
|
223
|
+
2. Create TaskCreate entries for each role to track progress.
|
|
224
|
+
3. Dispatch the first wave of agents (those with no blockers).
|
|
225
|
+
4. When a blocking agent completes, dispatch the next wave.
|
|
226
|
+
5. After all agents complete, run the final quality gates.
|
|
227
|
+
6. Produce the completion report (see references/output-templates.md).
|
|
228
|
+
|
|
229
|
+
Constraints:
|
|
230
|
+
1. Subagents cannot spawn other subagents. All dispatch happens from the main session.
|
|
231
|
+
2. Each agent prompt must be fully self-contained — do not assume agents have conversation history.
|
|
232
|
+
3. Review each agent's output before dispatching dependents.
|
|
233
|
+
</dispatch_pattern>
|
|
234
|
+
|
|
235
|
+
<execution_mode_decision>
|
|
236
|
+
At the end of phase 2, make an explicit execution mode decision and state it to the user:
|
|
237
|
+
|
|
238
|
+
> **EXECUTION MODE: SINGLE-ROLE** — I will implement all changes directly.
|
|
239
|
+
|
|
240
|
+
OR
|
|
241
|
+
|
|
242
|
+
> **EXECUTION MODE: MULTI-ROLE** — I will act as orchestrator, dispatching specialized agents via the Task tool.
|
|
243
|
+
|
|
244
|
+
OR
|
|
245
|
+
|
|
246
|
+
> **EXECUTION MODE: PLAN** — The task is highly complex. I will enter plan mode to design a structured implementation plan before executing.
|
|
247
|
+
|
|
248
|
+
Use PLAN mode when:
|
|
249
|
+
- The task has 4+ distinct roles or implementation phases.
|
|
250
|
+
- The scope is large enough that context window management becomes a concern.
|
|
251
|
+
- The task benefits from upfront architectural planning before any code is written.
|
|
252
|
+
|
|
253
|
+
In PLAN mode: use EnterPlanMode to design the full plan. Once the user approves it, exit plan mode and execute phases sequentially as MULTI-ROLE orchestrator, with context cleanup between major phases when needed.
|
|
254
|
+
|
|
255
|
+
Follow this decision in phase 4. In MULTI-ROLE and PLAN modes, delegate application code to agents — your job is dispatch, review, integration, and quality gates.
|
|
256
|
+
</execution_mode_decision>
|
|
257
|
+
</phase_2b_multi_role_decomposition>
|
|
258
|
+
|
|
259
|
+
<phase_3_task_analysis>
|
|
260
|
+
1. Extract task-defined criteria — scan the task document for explicit:
|
|
261
|
+
- **Success criteria** (checklists, acceptance conditions)
|
|
262
|
+
- **Initial/baseline tests** (to run BEFORE changes, for comparison)
|
|
263
|
+
- **Post-change tests** (to run AFTER changes, for verification)
|
|
264
|
+
- **Performance benchmarks** (bundle size, API call counts, Lighthouse metrics)
|
|
265
|
+
|
|
266
|
+
Look for section names like: "Initial Tests", "Before Changes", "Baseline", "Post-Change Tests", "After Changes", "Success Criteria", "Acceptance Criteria", "Functionality Tests", "Performance Tests".
|
|
267
|
+
|
|
268
|
+
If found, state them to the user:
|
|
269
|
+
> **Task-defined criteria found:**
|
|
270
|
+
> - Success criteria: [list]
|
|
271
|
+
> - Baseline tests (before changes): [list or "none"]
|
|
272
|
+
> - Post-change tests (after changes): [list or "none"]
|
|
273
|
+
|
|
274
|
+
These are binding requirements that extend the default quality gates. Do not skip them.
|
|
275
|
+
|
|
276
|
+
2. Understand the request — identify what is being asked, which files will be created or modified, and what the expected outcome is.
|
|
277
|
+
3. Define success criteria — combine the task's own criteria (from step 1) with your analysis. Task-defined criteria take priority over defaults.
|
|
278
|
+
4. For questions about project libraries, use Context7 (`mcp__context7__resolve-library-id` → `mcp__context7__query-docs`) to query up-to-date documentation. If anything is ambiguous, ask the user before proceeding.
|
|
279
|
+
5. Check for helpful MCPs — does the task involve browser testing, external docs?
|
|
280
|
+
6. Plan the implementation order — determine which changes must happen first (e.g., types before lib before hooks before components before pages).
|
|
281
|
+
</phase_3_task_analysis>
|
|
282
|
+
|
|
283
|
+
<phase_4_execution>
|
|
284
|
+
Before writing any code, check the execution mode decision from phase 2.
|
|
285
|
+
|
|
286
|
+
**MULTI-ROLE → Follow <multi_role_orchestration> below.**
|
|
287
|
+
**SINGLE-ROLE → Follow <single_role_implementation> below.**
|
|
288
|
+
|
|
289
|
+
<multi_role_orchestration>
|
|
290
|
+
As orchestrator, dispatch agents, review their output, and verify integration. Do not implement application code yourself.
|
|
291
|
+
|
|
292
|
+
You may write code directly only for trivial glue (under 15 lines total):
|
|
293
|
+
- Adding an export line to a barrel file
|
|
294
|
+
- Adding a small schema to the shared package that multiple agents need
|
|
295
|
+
- Wiring an import in a top-level file after agents complete
|
|
296
|
+
|
|
297
|
+
Everything else should be delegated to an agent. For the agent prompt template and dispatch details, see references/agent-dispatch.md.
|
|
298
|
+
|
|
299
|
+
Dispatch steps:
|
|
300
|
+
1. Create TaskCreate entries for each role.
|
|
301
|
+
2. For each role, dispatch a specialized agent via the Task tool with a self-contained prompt. Set the `model` parameter according to rule_4_model_selection.
|
|
302
|
+
3. Launch independent agents in parallel. Launch dependent agents sequentially.
|
|
303
|
+
4. Each agent runs its own quality gates before reporting completion. Review the agent's output and gate results before dispatching dependents.
|
|
304
|
+
5. After all agents complete, proceed to phase 5 for the final cross-package quality gates.
|
|
305
|
+
|
|
306
|
+
If you find yourself creating application files (routes, components, services, hooks, tests) while in MULTI-ROLE mode, delegate to an agent instead.
|
|
307
|
+
</multi_role_orchestration>
|
|
308
|
+
|
|
309
|
+
<single_role_implementation>
|
|
310
|
+
Think through each step before acting. Share your reasoning at key decision points.
|
|
311
|
+
|
|
312
|
+
<build_order>
|
|
313
|
+
Work from micro to macro — build dependencies before dependents:
|
|
314
|
+
1. Shared code first — new constants, types, schemas, or enums needed by multiple packages go in the shared/common package (discover its location from the project structure).
|
|
315
|
+
2. Check for reuse — before creating a helper, hook, component, or utility, search the codebase for existing code that can be used or extended.
|
|
316
|
+
3. Implement the core change — build the feature/fix in the target package.
|
|
317
|
+
4. Wire it together — connect the pieces across packages if needed.
|
|
318
|
+
|
|
319
|
+
Decision tree:
|
|
320
|
+
- Is this code used by multiple modules? YES → Create in the shared/common package.
|
|
321
|
+
- Is this code used by multiple modules? NO → Is this component multi-file? YES → Create folder with index.tsx + related files. NO → Single file, co-located with usage.
|
|
322
|
+
</build_order>
|
|
323
|
+
|
|
324
|
+
If you created any temporary files or scripts for iteration, remove them at the end.
|
|
325
|
+
</single_role_implementation>
|
|
326
|
+
</phase_4_execution>
|
|
327
|
+
|
|
328
|
+
<phase_5_quality_gates>
|
|
329
|
+
A task is not done until all quality gates pass. Run them in order for every affected package. If any gate fails, fix the issue and re-run all gates from the beginning.
|
|
330
|
+
|
|
331
|
+
Discover the available commands from package.json scripts for each affected package. Common gates:
|
|
332
|
+
|
|
333
|
+
1. Type checking — run the project's typecheck command (e.g., `tsc`, `typecheck`)
|
|
334
|
+
2. Linting — run the project's lint command (e.g., `lint`, `eslint`)
|
|
335
|
+
3. Tests (if available) — run the project's test command (e.g., `test`, `vitest`)
|
|
336
|
+
4. Build — run the project's build command (e.g., `build`)
|
|
337
|
+
5. Self-check — review your changes against the success criteria defined in phase 3.
|
|
338
|
+
|
|
339
|
+
For monorepos, run these for each affected workspace/package. Discover the workspace command pattern from CLAUDE.md or the root package.json (e.g., `yarn workspace <name> <script>`, `pnpm --filter <name> <script>`, `npm -w <name> <script>`, `turbo run <script> --filter=<name>`).
|
|
340
|
+
|
|
341
|
+
If a gate fails:
|
|
342
|
+
- Read the error output carefully.
|
|
343
|
+
- Fix the root cause (do not suppress or ignore errors).
|
|
344
|
+
- Re-run all gates from step 1, since a fix may introduce new issues.
|
|
345
|
+
- Repeat until all gates pass cleanly.
|
|
346
|
+
</phase_5_quality_gates>
|
|
347
|
+
|
|
348
|
+
<phase_6_documentation>
|
|
349
|
+
After all quality gates pass, review whether the changes require documentation updates:
|
|
350
|
+
|
|
351
|
+
- CLAUDE.md — new commands, architecture changes, dependency graph updates, new conventions.
|
|
352
|
+
- Existing docs — new environment variables, setup steps, API contract changes.
|
|
353
|
+
|
|
354
|
+
Only update documentation directly affected by the changes. Do not create new documentation files unless the changes introduce a new package or major feature with no existing docs.
|
|
355
|
+
</phase_6_documentation>
|
|
356
|
+
</workflow>
|
|
357
|
+
|
|
358
|
+
<output>
|
|
359
|
+
When complete, produce the completion report. See references/output-templates.md for the exact format.
|
|
360
|
+
|
|
361
|
+
Do not add explanations, caveats, or follow-up suggestions unless the user explicitly asks. The report is the final output.
|
|
362
|
+
</output>
|
|
363
|
+
|
|
364
|
+
<task>
|
|
365
|
+
{{task}}
|
|
366
|
+
</task>
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Agent Dispatch Reference
|
|
2
|
+
|
|
3
|
+
## Agent prompt template
|
|
4
|
+
|
|
5
|
+
Project agents (`.claude/agents/`) already include project context, workflow, principles, quality gates, and output format in their system prompt. The dispatch prompt only needs **task-specific** information:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
## Your task
|
|
9
|
+
[Specific task scope — what to build, what files to create/modify]
|
|
10
|
+
|
|
11
|
+
## Existing patterns to follow
|
|
12
|
+
[Paste relevant code snippets, file paths, or describe the patterns the agent should match]
|
|
13
|
+
|
|
14
|
+
## Success criteria
|
|
15
|
+
[What "done" looks like — be specific]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For agents that load skills dynamically (debugger, performance-engineer), also include:
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
## Skills to load
|
|
22
|
+
Call the Skill tool before starting:
|
|
23
|
+
- Skill(skill: "[skill-1]")
|
|
24
|
+
- Skill(skill: "[skill-2]")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Preloaded skills by agent
|
|
28
|
+
|
|
29
|
+
Agents with preloaded skills (via `skills` frontmatter) do NOT need Skill() calls for their primary domain. Only include Skill() calls for additional skills beyond what the agent already has:
|
|
30
|
+
|
|
31
|
+
| Agent | Preloaded skills | Dynamic skills (add when needed) |
|
|
32
|
+
|-------|-----------------|----------------------------------|
|
|
33
|
+
| api-builder | fastify-best-practices | drizzle-pg, postgresql (if DB-heavy) |
|
|
34
|
+
| react-specialist | react-best-practices, composition-patterns | nextjs-best-practices (if page-level) |
|
|
35
|
+
| database-expert | drizzle-pg, postgresql | — |
|
|
36
|
+
| docker-expert | docker | — |
|
|
37
|
+
| security-scanner | owasp-security-review | — |
|
|
38
|
+
| ux-optimizer | ui-ux-guidelines | — |
|
|
39
|
+
| accessibility-pro | ui-ux-guidelines | — |
|
|
40
|
+
| debugger | (none) | Load based on bug domain |
|
|
41
|
+
| performance-engineer | (none) | Load based on optimization domain |
|
|
42
|
+
| code-reviewer | (none) | Read-only agent, no Write/Edit |
|
|
43
|
+
| test-generator | (none) | fastify-best-practices (for API tests) |
|
|
44
|
+
| typescript-pro | (none) | — |
|
|
45
|
+
| playwright-expert | (none) | — |
|
|
46
|
+
|
|
47
|
+
### Agent tool restrictions
|
|
48
|
+
|
|
49
|
+
| Agent | Restriction |
|
|
50
|
+
|-------|------------|
|
|
51
|
+
| code-reviewer | `disallowedTools: Write, Edit` — review only, cannot modify code |
|
|
52
|
+
| All others | Full tool access (inherited from parent) |
|
|
53
|
+
|
|
54
|
+
Plan accordingly: if a review finds issues, dispatch a separate agent to fix them.
|
|
55
|
+
|
|
56
|
+
## Model selection
|
|
57
|
+
|
|
58
|
+
Choose the model for each agent based on task complexity:
|
|
59
|
+
|
|
60
|
+
| Complexity | Model | Examples |
|
|
61
|
+
|-----------|-------|---------|
|
|
62
|
+
| Simple | `haiku` | Adding a type, writing a small utility, updating config, barrel file exports |
|
|
63
|
+
| Moderate | `sonnet` | Implementing a feature within a single domain, writing tests, building a component |
|
|
64
|
+
| Complex | `opus` | Cross-cutting concerns, architectural decisions, novel implementations requiring deep reasoning |
|
|
65
|
+
|
|
66
|
+
All agents default to `sonnet`. Override with the Task tool's `model` parameter when needed.
|
|
67
|
+
|
|
68
|
+
## Dispatch example
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
Task(
|
|
72
|
+
description: "Build resource API routes",
|
|
73
|
+
subagent_type: "api-builder",
|
|
74
|
+
model: "sonnet",
|
|
75
|
+
prompt: """
|
|
76
|
+
## Your task
|
|
77
|
+
Create REST endpoints for the [feature name]:
|
|
78
|
+
- POST /api/<resource> — create a new resource
|
|
79
|
+
- GET /api/<resource>/:id — get resource details
|
|
80
|
+
- PATCH /api/<resource>/:id — update resource
|
|
81
|
+
|
|
82
|
+
## Existing patterns to follow
|
|
83
|
+
Discover from the codebase:
|
|
84
|
+
- Route structure: look for existing route handlers and follow the same pattern
|
|
85
|
+
- Shared schemas: look for existing schema/type definitions in shared packages
|
|
86
|
+
- Use case pattern: look for existing use case or service implementations
|
|
87
|
+
|
|
88
|
+
## Success criteria
|
|
89
|
+
- All endpoints respond with correct status codes
|
|
90
|
+
- Request/response validated with shared schemas
|
|
91
|
+
- Endpoints follow the project's routing conventions
|
|
92
|
+
"""
|
|
93
|
+
)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Agent type resolution
|
|
97
|
+
|
|
98
|
+
Before dispatching, resolve the agent type for each role:
|
|
99
|
+
|
|
100
|
+
1. **Check `.claude/agents/`** — if a project agent matches the sub-area from the domain mapping (e.g., `database-expert` for DB work, `api-builder` for endpoints, `react-specialist` for components), use it as `subagent_type`.
|
|
101
|
+
2. **Use a built-in agent type** — if the Task tool has a matching built-in type (e.g., `typescript-pro`, `performance-engineer`, `security-scanner`), use it directly.
|
|
102
|
+
3. **Create an ad-hoc specialist** — if no existing agent matches, use `subagent_type: "general-purpose"` and embed the full specialist definition in the prompt.
|
|
103
|
+
|
|
104
|
+
### Ad-hoc specialist prompt structure
|
|
105
|
+
|
|
106
|
+
When no matching agent exists, the prompt must be fully self-contained — `general-purpose` has no pre-loaded domain knowledge, project context, or skills:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
You are a [specialist title] working on this project.
|
|
110
|
+
|
|
111
|
+
Your expertise: [specific technologies, frameworks, and techniques].
|
|
112
|
+
|
|
113
|
+
## Before writing any code
|
|
114
|
+
1. Read CLAUDE.md and relevant package.json files to understand the project structure, conventions, and available commands.
|
|
115
|
+
2. Call the Skill tool to load domain skills:
|
|
116
|
+
- Skill(skill: "[skill-1]")
|
|
117
|
+
- Skill(skill: "[skill-2]")
|
|
118
|
+
|
|
119
|
+
## Project context
|
|
120
|
+
Discover from CLAUDE.md and package.json:
|
|
121
|
+
- Project structure (monorepo layout, key directories, packages)
|
|
122
|
+
- Technologies and versions (frameworks, libraries, language settings)
|
|
123
|
+
- Import conventions (named vs default, module system)
|
|
124
|
+
- Code style (formatter config, linting rules)
|
|
125
|
+
[add more context specific to the task if known]
|
|
126
|
+
|
|
127
|
+
## Library documentation lookup
|
|
128
|
+
When you need to verify API signatures or version-specific behavior, use Context7:
|
|
129
|
+
1. `mcp__context7__resolve-library-id` — resolve the library name to its ID.
|
|
130
|
+
2. `mcp__context7__query-docs` — query the specific API or pattern.
|
|
131
|
+
|
|
132
|
+
## Your task
|
|
133
|
+
[task details]
|
|
134
|
+
|
|
135
|
+
## Existing patterns to follow
|
|
136
|
+
[code snippets or file references]
|
|
137
|
+
|
|
138
|
+
## Success criteria
|
|
139
|
+
[what "done" looks like]
|
|
140
|
+
|
|
141
|
+
## Quality gates
|
|
142
|
+
Run the project's type checking, linting, testing, and build commands for every package you touched. Discover available commands from package.json scripts. Fix failures before reporting done.
|
|
143
|
+
|
|
144
|
+
## Output
|
|
145
|
+
Report when done:
|
|
146
|
+
- Summary: one sentence of what was done.
|
|
147
|
+
- Files: each file created/modified.
|
|
148
|
+
- Quality gates: pass/fail for each.
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Key constraints
|
|
152
|
+
|
|
153
|
+
1. **Subagents cannot spawn other subagents.** All dispatch happens from the main session.
|
|
154
|
+
2. **Agent prompts should be concise and task-specific.** Project agents already include project context, conventions, principles, and quality gates in their system prompt. Only include information the agent doesn't already have.
|
|
155
|
+
3. **Ad-hoc prompts must be fully self-contained.** The `general-purpose` agent has no project context, so the prompt must include everything: role, project context, conventions, skills to load, quality gates, and output format.
|
|
156
|
+
4. **Review each agent's output before dispatching dependents.** If an agent failed or produced unexpected results, fix the issue before continuing.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Output Templates
|
|
2
|
+
|
|
3
|
+
## Role completion report
|
|
4
|
+
|
|
5
|
+
Each role (whether a dispatched subagent or a single-role execution) produces this report:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
Summary: one sentence of what was done.
|
|
9
|
+
Files: list each file path created/modified/deleted.
|
|
10
|
+
Skills loaded: list each Skill() call made during execution.
|
|
11
|
+
MCPs used: list each MCP called, or "none".
|
|
12
|
+
Quality gates: pass/fail for each gate (tsc, lint, test, build).
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Final orchestrator report (MULTI-ROLE only)
|
|
16
|
+
|
|
17
|
+
When all roles are complete and all quality gates pass:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
## Task complete
|
|
21
|
+
|
|
22
|
+
Summary: one sentence describing the overall outcome.
|
|
23
|
+
|
|
24
|
+
### Roles executed
|
|
25
|
+
| Role | Sub-area | Agent type | Ad-hoc? | Status | Summary |
|
|
26
|
+
|------|----------|-----------|---------|--------|---------|
|
|
27
|
+
| [role name] | [sub-area] | [subagent_type] | yes/no | pass/fail | [one-line summary] |
|
|
28
|
+
|
|
29
|
+
### Aggregated files
|
|
30
|
+
List every file created/modified/deleted across all roles.
|
|
31
|
+
|
|
32
|
+
### Quality gates (final)
|
|
33
|
+
- tsc: pass/fail (per package)
|
|
34
|
+
- lint: pass/fail (per package)
|
|
35
|
+
- test: pass/fail (count)
|
|
36
|
+
- build: pass/fail (per package)
|
|
37
|
+
|
|
38
|
+
### Task-defined test results
|
|
39
|
+
If the task document defined tests, report results here:
|
|
40
|
+
| Test | Baseline (before) | Result (after) | Delta |
|
|
41
|
+
|------|-------------------|----------------|-------|
|
|
42
|
+
| [test name] | [baseline value] | [post-change value] | [improvement or regression] |
|
|
43
|
+
|
|
44
|
+
If no task-defined tests existed, omit this section.
|
|
45
|
+
|
|
46
|
+
### Skills loaded
|
|
47
|
+
List every skill called across all roles.
|
|
48
|
+
|
|
49
|
+
### MCPs used
|
|
50
|
+
List every MCP called across all roles, or "none".
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
In SINGLE-ROLE mode, skip the "Roles executed" table — use the role completion report format directly.
|