project-agent-writer
Project Agent Writer
Analyzes a project's structure, conventions, and automation gaps, then designs an agent to solve the user's problem. Always confirms with the user via AskUserQuestion before generating any files.
Core Principle: Understand the problem first, analyze the project second, design the agent third, generate only after user confirms.
When to Use
Invoke when:
- User says "create an agent", "I need an agent that...", "make AI do X every time"
- User describes automation need ("someone to automatically...", "I want something that monitors...")
- User wants to build a grader, comparator, analyzer, transformer, researcher, or validator
Do NOT invoke when:
- User wants to install a skill → delegate to
project-skill-installer - User wants to create a skill → delegate to
project-skill-writer - User wants to create a rule → delegate to
trae-rules-writer
Prerequisites
- Node.js >= 18
- Target project must have a writable directory for agent output
Workflow
[L1: Problem Understanding]
↓
[L2: Project Analysis]
↓
[L3: Agent Design]
↓
[L4: Confirmation] ← AskUserQuestion (MUST confirm)
↓
[L5: Generation]
↓
[L6: Verification]
L1: Problem Understanding
Extract what the user needs — do NOT ask "what do you want the agent to do?" Instead, infer from their problem:
Problem Classification
| Problem Pattern | Agent Type | Example |
|---|---|---|
| "Evaluate/grade/compare outputs" | Grader | Code reviewer, PR quality checker |
| "Compare A vs B, pick the better one" | Comparator | Skill version comparison, A/B tester |
| "Analyze/find patterns/report insights" | Analyzer | Bug finder, performance diagnosis |
| "Transform/convert/normalize data" | Transformer | Format converter, schema mapper |
| "Research/gather/synthesize information" | Researcher | Documentation lookup, best practices |
| "Check/validate/enforce rules" | Validator | Schema checker, compliance verifier |
Extract Agent Specifications
From the user's problem, extract:
- Role: What the agent does (from problem description)
- Inputs: What triggers the agent / what data it needs
- Outputs: 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 deps, Podfile, go.mod, Cargo.toml | Read |
| Existing Agents | .trae/agents/, .claude/agents/, .cursor/agents/ |
Glob |
| Existing Skills | .trae/skills/, .cursor/skills/ |
Glob |
| Automation Scripts | scripts/, tools/, Makefile targets |
Glob |
| API Surface | REST endpoints, GraphQL schema, gRPC protos | Grep |
| Conventions | Naming patterns, output formats, directory structure | LS |
Analysis Output
Project: {name}
Languages: {detected languages}
Existing Agents: {list or "none"}
Existing Skills: {list or "none"}
Automation Scripts: {list or "none"}
Integration Points: {APIs, file patterns, tools}
Conventions: {naming, output formats}
L3: Agent Design
Based on Problem (L1) + Analysis (L2), design the agent:
Agent: {name}
Problem: {user's problem in their words}
Role: {one-line description}
Type: {Grader|Comparator|Analyzer|Transformer|Researcher|Validator}
Triggers: {when agent should activate}
Inputs: {what data the agent needs}
Process: {high-level steps}
Outputs: {what agent produces + format}
Constraints: {boundaries + what NOT to do}
Files to create:
- {path/to/agent.md}
L4: Confirmation (MUST USE AskUserQuestion)
CRITICAL: Before generating ANY files, present the design via AskUserQuestion.
AskUserQuestion Call
Use AskUserQuestion with:
{
"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 — {1-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 name and type
- Include the output path so user knows where files go
- 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 without user confirmation
- If user says "Adjust design", loop back to L3 with feedback
L5: Generation
After user confirms:
- Determine output path using Path Discovery
- Create agent scaffold using
scripts/init_agent.cjs - Fill in role, inputs, process, outputs from L3 design
- Set correct project-relative output path
- Include quality gates and constraints
Generation Command
node scripts/init_agent.cjs \
--skill-dir <this-skill-dir> \
--name <agent-name> \
--role "<one-sentence-role>" \
--output-dir <project>/.trae/agents/
L6: Verification
Before delivery, verify:
- Agent has a clear, specific role (not vague)
- Inputs are explicitly defined with descriptions
- Output schema is deterministic (JSON with known fields)
- Constraints are enforced (what NOT to do)
- Output path is project-relative, not global
- Agent follows conventions from L2 analysis
Delivery Report
Created agent:
Name: {agent-name}
Type: {Grader|Comparator|Analyzer|...}
Path: {project-relative path}
To use: spawn this agent via the Task tool with its defined inputs.
Error Handling
| Issue | Solution |
|---|---|
| User's problem is too vague | Infer the most likely agent type from context, confirm at L4 |
| Multiple valid agent types | Show alternatives in AskUserQuestion, let user pick |
| No existing agents directory | Create .trae/agents/ (or detected IDE convention) |
| User requests skill/rule creation | Route to project-skill-writer or trae-rules-writer |
| User says "Adjust design" at L4 | Loop back to L3, incorporate feedback |
| Output path is global | Reject, enforce project-relative path |
| Agent conflicts with existing | Show comparison, ask user whether to replace or rename |
Boundary Enforcement
This skill ONLY handles:
- Analyzing project for agent design context
- Designing agents based on user problems
- Confirming design via AskUserQuestion
- Generating agent files to project-relative paths
- Verifying generated agents
This skill does NOT handle:
- Creating skills →
project-skill-writer - Installing skills →
project-skill-installer - Creating rules →
trae-rules-writer - Global agent installation (always project-scoped)
References
- Agent Patterns — Architecture patterns (Grader, Comparator, Analyzer, Transformer, Researcher, Validator)
- Path Discovery — Output path determination (load AFTER design)
- Example: Grader Agent — Full walkthrough of creating a grader agent
More from learnwy/skills
english-learner
Use this skill on EVERY user message written in English to auto-detect grammar, word choice, and expression issues — teach corrections before proceeding with the task. Also use when the user looks up a single word, asks about a phrase like 'break the ice', requests translation, or asks for quiz/review. Triggers on: any English message, single English words, idioms, '查单词', '学英语', 'what does X mean', vocabulary review. Stores vocabulary in ~/.english-learner/ with mastery tracking and spaced repetition.
312memory-manager
Cross-session memory for AI. ALWAYS load this skill at session start to read SOUL.md and USER.md. This skill should be loaded for EVERY conversation to maintain continuity. Also triggers on "save memory", "end session", "update memory" for saving. Handles session history creation, memory consolidation, and USER.md/SOUL.md updates. Memory stored in ~/.learnwy/ai/memory/.
220trae-rules-writer
Create Trae IDE rules (.trae/rules/*.md) for AI behavior constraints. Use when: create rule, set up code style, enforce naming convention, make AI always do X, configure AI behavior. NOT for skills (use project-skill-writer) or agents (use project-agent-writer).
87knowledge-consolidation
Use this skill when the user wants to save, summarize, or persist knowledge from the current AI conversation into structured documents. Captures debugging breakthroughs, architecture decisions, patterns, and lessons learned. Triggers on: '总结一下', '记录下来', 'save this knowledge', 'document this', 'we figured it out', 'that was hard to solve', 'remember this', 'write this down', or when a hard-won insight should be preserved for future sessions. Saves to .trae/knowledges/, .claude/knowledges/, or .cursor/knowledges/ based on AI IDE.
59requirement-workflow
Structured software development workflow orchestrator using Spec-Driven Development (SDD). Transforms vague requirements into spec.md → tasks.md → implementation → verification. Triggers on: '开发功能', '实现这个', 'build this feature', 'implement', 'add new module', 'fix bug', 'develop', 'create feature'.
56trae-skill-writer
Create Trae IDE skills (SKILL.md files) for reusable AI capabilities. Use when user wants to: create a skill, make a reusable workflow, automate repetitive tasks, turn a conversation into a skill, or encapsulate a process for AI to follow. Triggers on: '创建 skill', 'write a SKILL.md', 'make this reusable', '.trae/skills/', 'I keep doing the same thing every time'. Do NOT use for rules (use trae-rules-writer) or agents (use trae-agent-writer).
31