From claude-factory
Scaffold a Claude Code agent (subagent) from a natural language description. Use when creating agent .md files, specialized subagents, or AI personas. Triggers on /factory:agent.
npx claudepluginhub lingelo/marketplace-claude-code --plugin claude-factoryThis skill is limited to using the following tools:
Official specification: @../../references/agent-spec.md
Generates markdown agent files with YAML frontmatter for Claude Code, configuring system prompts, tools, and isolation for autonomous task delegation in plugins.
Guides creation of autonomous agents for Claude Code plugins, covering file structure, YAML frontmatter fields like name and description, system prompts, triggering conditions, tools, and best practices.
Guides creation of Claude Code agents including frontmatter fields like name, description with triggering examples, model, tools, system prompts, and file structure.
Share bugs, ideas, or general feedback.
Official specification: @../../references/agent-spec.md Template: @../../templates/agent.md
/factory:agent "description of the agent's role"
/factory:agent my-agent "description of the agent's role"
$ARGUMENTS contains the user's input. Parse to extract optional name + description.
Extract from $ARGUMENTS:
If $ARGUMENTS is empty, ask: "What role should this agent fill? Describe its responsibilities."
Check if an agent file already exists at the target location:
# Look for existing agent with the same name
ls -la <target-path>/agents/<agent-name>.md 2>/dev/null
From the description, determine:
| Property | How to Determine |
|---|---|
| Role | What persona is this agent? (reviewer, researcher, architect, tester, etc.) |
| Tools | What tools does this agent need? Read-only agents get Read, Glob, Grep. Writing agents add Write, Edit, Bash. |
| Disallowed tools | Should any tools be explicitly denied? (e.g., a reviewer should not write code) |
| Model | opus for deep reasoning/architecture, sonnet for balanced tasks, haiku for fast read-only work |
| Effort | high/max for complex analysis, medium for standard, low for simple lookups |
| Max turns | Limit for safety: 10-20 for focused tasks, 50+ for exploratory work |
| Isolation | worktree if the agent modifies files and might conflict with main work |
| Skills | Should any skills be preloaded? (list skill names) |
| Background | Should this always run in background? (true for monitoring/logging agents) |
The system prompt should:
Review what was determined in Step 2. If the description is precise enough to resolve all decisions, skip this step entirely.
Otherwise, use AskUserQuestion to ask only about decisions that remain ambiguous:
Rules:
plugins/<plugin-name>/ → <plugin-root>/agents/<agent-name>.md.claude/agents/<agent-name>.mdls -la <target-path>/<agent-name>.md 2>/dev/null
If exists: show error, suggest alternative name. Do not overwrite.
Create the agent file with:
Frontmatter: Include only fields that add value.
name: Always (kebab-case)description: Always (when Claude should delegate to this agent — this is how auto-matching works)tools: Include if restricting from default (all)disallowedTools: Include if explicitly denying toolsmodel: Include if non-defaulteffort: Include if non-defaultmaxTurns: Include for safety boundsisolation: Include if worktree neededskills: Include if preloading skillsbackground: Include if truepermissionMode: Never include for plugin agents (security restriction)hooks: Never include for plugin agents (security restriction)mcpServers: Never include for plugin agents (security restriction)System prompt body: Write a complete, high-quality system prompt. NOT placeholder text. The prompt should be:
When Step 1.5 detected an existing agent .md:
cat <target-path>/agents/<agent-name>.md
Parse the existing frontmatter and system prompt body.
Display the existing agent configuration:
Current agent: <agent-name>
Frontmatter:
model: <current>
tools: <current>
maxTurns: <current>
...
System prompt: <first 3-5 lines preview>
Use AskUserQuestion to ask:
Edit (not Write) to apply only the approved modificationsDisplay:
Agent updated: <agent-name>
Location: <full-path>/agents/<agent-name>.md
Changes applied: <list of changed fields/sections>
Agent created: <agent-name>
Location: <full-path>/agents/<agent-name>.md
Model: <model>
Tools: <tools or "all">
Invocation methods:
- Automatic: Claude delegates based on description matching
- Natural language: "Use the <agent-name> agent to..."
- @-mention: @"<agent-name> (agent)"
Tip: Run /factory:audit <path> to validate.