Project Agent Writer
Analyze the project's structure, conventions, and automation gaps, then design an agent to solve the user's problem. Always confirm with the user via AskUserQuestion before generating any files.
Core principle: First understand the problem, then analyze the project, then design the agent, and only generate after the user confirms.
Shared principle: This skill shares the 5 common writer disciplines with project-skill-writer / project-skill-installer / project-rules-writer. See ../project-skill-writer/references/writer-discipline.md for details.
Use Cases
Trigger when:
- The user says "create an agent", "I need an agent that...", "make AI do X every time"
- The user describes an automation need ("someone to automatically...", "I want something that monitors...")
- The user wants to build a grader, comparator, analyzer, transformer, researcher, or validator
Do not trigger when:
- The user wants to install a skill → delegate to
project-skill-installer
- The user wants to create a skill → delegate to
project-skill-writer
- The user wants to create a rule → delegate to
project-rules-writer
Prerequisites
- Node.js >= 18
- The target project must have a writable directory for agent output
Workflow
[L1: Understand the problem]
↓
[L2: Project analysis]
↓
[L3: Agent design]
↓
[L4: Confirm] ← AskUserQuestion (confirmation required)
↓
[L5: Generate]
↓
[L6: Verify]
L1: Understand the Problem
Extract the user's needs—do not ask "what do you want the agent to do?" but infer from their question:
Problem Classification
| Problem pattern |
Agent type |
Example |
| "evaluate/grade/compare output" |
Grader |
Code reviewer, PR quality checker |
| "compare A and B, pick the better one" |
Comparator |
Skill version comparison, A/B tester |
| "analyze/find patterns/report insights" |
Analyzer |
Bug finder, performance diagnostics |
| "convert/transform/normalize data" |
Transformer |
Format converter, schema mapper |
| "research/gather/synthesize information" |
Researcher |
Doc lookup, best practices |
| "check/validate/enforce rules" |
Validator |
Schema checker, compliance validator |
Extract the Agent Spec
Extract from the user's question:
- Role: what the agent does (extracted from the problem description)
- Input: what triggers the agent / what data it needs
- Output: what the agent produces
- Constraints: boundaries and limitations
L2: Project Analysis
Scan the project to understand context. Use search tools in parallel:
Detection Targets
| Signal |
What to look for |
Tool |
| Language |
File extensions (.ts, .py, .swift, .go) |
Glob |
| Framework |
package.json dependencies, Podfile, go.mod, Cargo.toml |
Read |
| Existing agents |
.agents/agents/, .trae/agents/, .claude/agents/, .cursor/agents/ |
Glob |
| Existing skills |
.agents/skills/, .trae/skills/, .cursor/skills/ |
Glob |
| Automation scripts |
scripts/, tools/, Makefile targets |
Glob |
| API interfaces |
REST endpoints, GraphQL schema, gRPC protos |
Grep |
| Conventions |
Naming patterns, output formats, directory structure |
LS |
Analysis Output
Project: {name}
Language: {detected language}
Existing agents: {list or "none"}
Existing skills: {list or "none"}
Automation scripts: {list or "none"}
Integration points: {API, file patterns, tools}
Conventions: {naming, output format}
L3: Agent Design
Based on the problem (L1) + analysis (L2), design the agent:
Agent: {name}
Problem: {the problem in the user's own words}
Role: {one-sentence description}
Type: {Grader|Comparator|Analyzer|Transformer|Researcher|Validator}
Trigger: {when the agent activates}
Input: {what data the agent needs}
Process: {high-level steps}
Output: {what the agent produces + format}
Constraints: {boundaries + what it should not do}
Files to create:
- {path/to/agent.md}
L4: Confirm (AskUserQuestion required)
Critical: Present the design via AskUserQuestion before generating any files.
AskUserQuestion Call
Use AskUserQuestion:
{
"questions": [{
"question": "I've designed this agent based on your project. Should I create it?",
"header": "Agent",
"multiSelect": false,
"options": [
{
"label": "Create {agent-name} (Recommended)",
"description": "{type} agent — {one-sentence role}. Output: {path}"
},
{
"label": "Adjust design",
"description": "Let me refine the agent design before generating"
},
{
"label": "Skip",
"description": "Don't create an agent right now"
}
]
}]
}
Rules:
- Always show the designed agent's name and type
- Include the output path so the user knows where the file goes
- If multiple agent types are valid, offer alternatives:
{
"questions": [{
"question": "Your problem could be solved by different agent types. Which approach fits best?",
"header": "Agent type",
"multiSelect": false,
"options": [
{
"label": "Grader agent (Recommended)",
"description": "Evaluates outputs against expectations with pass/fail evidence"
},
{
"label": "Validator agent",
"description": "Checks correctness against rules and suggests fixes"
},
{
"label": "Skip",
"description": "Don't create an agent right now"
}
]
}]
}
- Never generate files before the user confirms
- If the user says "adjust the design", return to L3 with the feedback
L5: Generate
After the user confirms:
- Use path discovery to determine the output path
- Use
scripts/cli.cjs init to create the agent scaffold
- Fill in the role, input, process, and output from the L3 design
- Set the correct project-relative output path
- Include quality gates and constraints
Generation Command
node scripts/cli.cjs init \
--skill-dir <this-skill-dir> \
--name <agent-name> \
--role "<one-sentence-role>" \
--output-dir <project>/.agents/agents/
L6: Verify
Verify before delivery:
Delivery Report
Agent created:
Name: {agent-name}
Type: {Grader|Comparator|Analyzer|...}
Path: {project-relative path}
Usage: Launch this agent via the Task tool using its defined inputs.
Error Handling
| Problem |
Solution |
| User's question is too vague |
Infer the most likely agent type from context, confirm at L4 |
| Multiple valid agent types |
Present alternatives in AskUserQuestion and let the user choose |
| No agent directory exists |
Create .agents/agents/ |
| User requests creating a skill/rule |
Route to project-skill-writer or project-rules-writer |
| User says "adjust the design" at L4 |
Return to L3 and incorporate the feedback |
| Output path is global |
Reject, enforce a project-relative path |
| Agent conflicts with an existing one |
Show a comparison, ask the user whether to replace or rename |
Scope
This skill handles only:
- Analyzing the project for agent design context
- Designing the agent based on the user's problem
- Confirming the design via AskUserQuestion
- Generating the agent file to a project-relative path
- Verifying the generated agent
This skill does not handle:
- Creating skills →
project-skill-writer
- Installing skills →
project-skill-installer
- Creating rules →
project-rules-writer
- Global agent installation (always scoped to the project)
References
- Agent patterns — Architecture patterns (grader, comparator, analyzer, transformer, researcher, validator)
- Path discovery — Output path determination (load after the design is complete)
- Example: Grader agent — Complete walkthrough of creating a grader agent
1---2name: lwy-project-agent-writer3description: Use this skill when the user wants to create, update, or design a project-level agent (.agents/agents/*.md). Analyze the user's question and project context to design a work plan. Triggers: 'create agent', 'build an agent', 'add agent', 'design agent', 'update agent', 'project agent', 'subagent', 'worker agent', 'automated worker', or when the user describes a repetitive task that should be handled by an autonomous agent.4---5
6# Project Agent Writer
7
8Analyze the project's structure, conventions, and automation gaps, then **design** an agent to solve the user's problem. Always confirm with the user via `AskUserQuestion` before generating any files.
9
10> **Core principle**: First understand the problem, then analyze the project, then design the agent, and only generate after the user confirms.
11
12> **Shared principle:** This skill shares the 5 common writer disciplines with `project-skill-writer` / `project-skill-installer` / `project-rules-writer`. See [../project-skill-writer/references/writer-discipline.md](../project-skill-writer/references/writer-discipline.md) for details.
13
14## Use Cases
15
16**Trigger when:**
17
18- The user says "create an agent", "I need an agent that...", "make AI do X every time"
19- The user describes an automation need ("someone to automatically...", "I want something that monitors...")
20- The user wants to build a grader, comparator, analyzer, transformer, researcher, or validator
21
22**Do not trigger when:**
23
24- The user wants to **install** a skill → delegate to `project-skill-installer`
25- The user wants to **create** a skill → delegate to `project-skill-writer`
26- The user wants to **create** a rule → delegate to `project-rules-writer`
27
28## Prerequisites
29
30- Node.js >= 18
31- The target project must have a writable directory for agent output
32
33## Workflow
34
35```
36[L1: Understand the problem]
37 ↓
38[L2: Project analysis]
39 ↓
40[L3: Agent design]
41 ↓
42[L4: Confirm] ← AskUserQuestion (confirmation required)
43 ↓
44[L5: Generate]
45 ↓
46[L6: Verify]
47```
48
49## L1: Understand the Problem
50
51Extract the user's needs—do not ask "what do you want the agent to do?" but infer from their question:
52
53### Problem Classification
54
55| Problem pattern | Agent type | Example |
56|----------|------------|------|
57| "evaluate/grade/compare output" | Grader | Code reviewer, PR quality checker |
58| "compare A and B, pick the better one" | Comparator | Skill version comparison, A/B tester |
59| "analyze/find patterns/report insights" | Analyzer | Bug finder, performance diagnostics |
60| "convert/transform/normalize data" | Transformer | Format converter, schema mapper |
61| "research/gather/synthesize information" | Researcher | Doc lookup, best practices |
62| "check/validate/enforce rules" | Validator | Schema checker, compliance validator |
63
64### Extract the Agent Spec
65
66Extract from the user's question:
67- **Role**: what the agent does (extracted from the problem description)
68- **Input**: what triggers the agent / what data it needs
69- **Output**: what the agent produces
70- **Constraints**: boundaries and limitations
71
72## L2: Project Analysis
73
74Scan the project to understand context. Use search tools in parallel:
75
76### Detection Targets
77
78| Signal | What to look for | Tool |
79|------|----------|------|
80| Language | File extensions (`.ts`, `.py`, `.swift`, `.go`) | Glob |
81| Framework | package.json dependencies, Podfile, go.mod, Cargo.toml | Read |
82| Existing agents | `.agents/agents/`, `.trae/agents/`, `.claude/agents/`, `.cursor/agents/` | Glob |
83| Existing skills | `.agents/skills/`, `.trae/skills/`, `.cursor/skills/` | Glob |
84| Automation scripts | `scripts/`, `tools/`, `Makefile` targets | Glob |
85| API interfaces | REST endpoints, GraphQL schema, gRPC protos | Grep |
86| Conventions | Naming patterns, output formats, directory structure | LS |
87
88### Analysis Output
89
90```
91Project: {name}
92Language: {detected language}
93Existing agents: {list or "none"}
94Existing skills: {list or "none"}
95Automation scripts: {list or "none"}
96Integration points: {API, file patterns, tools}
97Conventions: {naming, output format}
98```
99
100## L3: Agent Design
101
102Based on the problem (L1) + analysis (L2), design the agent:
103
104```
105Agent: {name}
106Problem: {the problem in the user's own words}
107Role: {one-sentence description}
108Type: {Grader|Comparator|Analyzer|Transformer|Researcher|Validator}
109
110Trigger: {when the agent activates}
111Input: {what data the agent needs}
112Process: {high-level steps}
113Output: {what the agent produces + format}
114Constraints: {boundaries + what it should not do}
115
116Files to create:
117 - {path/to/agent.md}
118```
119
120## L4: Confirm (AskUserQuestion required)
121
122**Critical**: Present the design via `AskUserQuestion` before generating any files.
123
124### AskUserQuestion Call
125
126Use `AskUserQuestion`:
127
128```json
129{
130 "questions": [{
131 "question": "I've designed this agent based on your project. Should I create it?",
132 "header": "Agent",
133 "multiSelect": false,
134 "options": [
135 {
136 "label": "Create {agent-name} (Recommended)",
137 "description": "{type} agent — {one-sentence role}. Output: {path}"
138 },
139 {
140 "label": "Adjust design",
141 "description": "Let me refine the agent design before generating"
142 },
143 {
144 "label": "Skip",
145 "description": "Don't create an agent right now"
146 }
147 ]
148 }]
149}
150```
151
152**Rules**:
153- Always show the designed agent's name and type
154- Include the output path so the user knows where the file goes
155- If multiple agent types are valid, offer alternatives:
156
157```json
158{
159 "questions": [{
160 "question": "Your problem could be solved by different agent types. Which approach fits best?",
161 "header": "Agent type",
162 "multiSelect": false,
163 "options": [
164 {
165 "label": "Grader agent (Recommended)",
166 "description": "Evaluates outputs against expectations with pass/fail evidence"
167 },
168 {
169 "label": "Validator agent",
170 "description": "Checks correctness against rules and suggests fixes"
171 },
172 {
173 "label": "Skip",
174 "description": "Don't create an agent right now"
175 }
176 ]
177 }]
178}
179```
180
181- Never generate files before the user confirms
182- If the user says "adjust the design", return to L3 with the feedback
183
184## L5: Generate
185
186After the user confirms:
187
1881. Use [path discovery](references/path-discovery.md) to determine the output path
1892. Use `scripts/cli.cjs init` to create the agent scaffold
1903. Fill in the role, input, process, and output from the L3 design
1914. Set the correct project-relative output path
1925. Include quality gates and constraints
193
194### Generation Command
195
196```bash
197node scripts/cli.cjs init \
198 --skill-dir <this-skill-dir> \
199 --name <agent-name> \
200 --role "<one-sentence-role>" \
201 --output-dir <project>/.agents/agents/
202```
203
204## L6: Verify
205
206Verify before delivery:
207
208- [ ] The agent has a clear, specific role (not vague)
209- [ ] Inputs are clearly defined and described
210- [ ] The output schema is deterministic (JSON with known fields)
211- [ ] Constraints are enforced (what it should not do)
212- [ ] The output path is project-relative, not global
213- [ ] The agent follows the conventions from the L2 analysis
214
215### Delivery Report
216
217```
218Agent created:
219 Name: {agent-name}
220 Type: {Grader|Comparator|Analyzer|...}
221 Path: {project-relative path}
222
223Usage: Launch this agent via the Task tool using its defined inputs.
224```
225
226## Error Handling
227
228| Problem | Solution |
229|------|----------|
230| User's question is too vague | Infer the most likely agent type from context, confirm at L4 |
231| Multiple valid agent types | Present alternatives in AskUserQuestion and let the user choose |
232| No agent directory exists | Create `.agents/agents/` |
233| User requests creating a skill/rule | Route to `project-skill-writer` or `project-rules-writer` |
234| User says "adjust the design" at L4 | Return to L3 and incorporate the feedback |
235| Output path is global | Reject, enforce a project-relative path |
236| Agent conflicts with an existing one | Show a comparison, ask the user whether to replace or rename |
237
238## Scope
239
240This skill handles **only**:
241- Analyzing the project for agent design context
242- Designing the agent based on the user's problem
243- Confirming the design via AskUserQuestion
244- Generating the agent file to a project-relative path
245- Verifying the generated agent
246
247This skill does **not** handle:
248- Creating skills → `project-skill-writer`
249- Installing skills → `project-skill-installer`
250- Creating rules → `project-rules-writer`
251- Global agent installation (always scoped to the project)
252
253## References
254
255- [Agent patterns](references/agent-patterns.md) — Architecture patterns (grader, comparator, analyzer, transformer, researcher, validator)
256- [Path discovery](references/path-discovery.md) — Output path determination (load after the design is complete)
257- [Example: Grader agent](examples/grader-agent.md) — Complete walkthrough of creating a grader agent