writing-subagents
Use when creating specialized Claude Code subagents in .claude/agents/. Use when user says 'create agent', 'add reviewer', 'specialized agent', 'isolated context task'.
What this skill does
# Writing Subagents
## Overview
**Writing subagents IS creating specialized workers with isolated contexts.**
Subagents run via the Agent tool with their own context window, tools, and system prompt. Use for tasks that benefit from focused expertise.
**Core principle:** One agent, one responsibility. Bloated agents become unfocused.
**Violating the letter of the rules is violating the spirit of the rules.**
## Routing
**Pattern:** Skill Steps
**Handoff:** none
**Next:** none
## Task Initialization (MANDATORY)
Before ANY action, create task list using TaskCreate:
```
TaskCreate for EACH task below:
- Subject: "[writing-subagents] Task N: <action>"
- ActiveForm: "<doing action>"
```
**Tasks:**
0. Fetch latest official subagent spec
1. Analyze requirements
2. Document problem context
3. Design agent configuration
4. Implement agent file
5. Validate structure
6. Test invocation
7. Review and optimize
Announce: "Created 8 tasks (0–7). Starting execution..."
**Execution rules:**
1. `TaskUpdate status="in_progress"` BEFORE starting each task
2. `TaskUpdate status="completed"` ONLY after verification passes
3. If task fails → stay in_progress, diagnose, retry
4. NEVER skip to next task until current is completed
5. At end, `TaskList` to confirm all completed
## Agent Configuration Process
| Phase | Focus | What You Do |
|-------|-------|-------------|
| **Requirements** | Understanding | Identify what specialized task needs isolation |
| **Analysis** | Problem definition | Document why main agent isn't sufficient |
| **Design** | Configuration | Plan agent tools, model, and system prompt |
| **Implementation** | Creation | Write agent file with proper configuration |
| **Optimization** | Refinement | Fine-tune tools and prompts for efficiency |
## Task 0: Fetch Latest Official Spec
**Goal:** Pull the current Anthropic subagent spec before designing — never trust cached memory.
**Action:**
```
Skill tool: fetching-claude-docs
component: subagent
question: "frontmatter fields, tool inheritance, model selection,
description trigger format (PROACTIVELY, examples), context isolation"
```
**Verification:** Received YAML with `source: https://code.claude.com/docs/en/sub-agents.md` and non-empty `spec_excerpt`. Use this as the **authoritative reference** for Tasks 1–7; if any rule in this SKILL conflicts with the fetched spec, the fetched spec wins (and flag the conflict for refactoring).
## Task 1: Analyze Requirements
**Goal:** Understand what specialized task needs isolation.
**Questions to answer:**
- What specific task needs a subagent?
- Why can't the main agent do this?
- What tools does this agent need?
- Should it be proactive or manual?
**When to use subagents:**
- Task needs isolated context (code review, deep analysis)
- Task would pollute main conversation
- Task is repetitive and well-defined
- Task benefits from specialized system prompt
See [references/examples.md](references/examples.md) for subagent templates and trigger examples.
**Built-in subagent types (consider BEFORE creating custom agents):**
| Type | Model | Tools | Use Case |
|------|-------|-------|----------|
| `Explore` | Haiku | Read-only (no Write/Edit) | Fast codebase search, analysis |
| `Plan` | Inherit | Read-only | Research and planning |
| `general-purpose` | Inherit | All | Complex multi-step tasks |
**Decision:** Can a built-in type handle this? If yes, use it directly via the Agent tool — no agent file needed.
**Verification:** Can describe the agent's single responsibility in one sentence.
## Task 2: Document Problem Context
**Goal:** Clearly understand why the main agent is insufficient for this task.
**Analysis points:**
1. What specific challenges arise when using the main agent?
2. How would task isolation improve the outcome?
3. What context pollution or focus issues occur?
4. What specialized expertise would help?
**Verification:** Documented specific problems that justify creating a specialized subagent.
## Task 3: Design Agent Configuration
**Goal:** Plan the agent configuration to address the documented problems.
**Before drafting the system prompt, walk through [prompt-design-principles.md](../../references/prompt-design-principles.md):**
- 5-skeleton framework — the system prompt needs Role (agent's job, not persona), Scope (what this agent does and doesn't handle), Workflow (procedure for its task), Standards (output rules), Completion (what "done" means for this agent's output).
- Failure-mode reverse engineering — anticipate what this agent could get wrong and write rules against those specific failures.
- Conditional dispatch — if the agent handles multiple task variants, write per-variant behavior, not absolute rules.
- Creative-constraint balance — decide what axes the agent can vary on (e.g., review phrasing) vs. must stay fixed (e.g., output YAML structure).
### Agent Location
```
.claude/agents/ # Project-level
~/.claude/agents/ # User-level (global)
```
### Agent Format
```yaml
---
name: agent-name
description: What this agent does. Use proactively when [triggers].
tools: Read, Grep, Glob, Bash
model: sonnet
---
System prompt for the agent.
## Role
[Clear description of the agent's responsibility]
## Process
[Steps the agent should follow]
## Output Format
[Expected output structure]
```
### Configuration & Tools
See [references/agent-spec.md](references/agent-spec.md) for full configuration fields, model selection, context:fork guidelines, and tool permissions.
**Key rules:**
- `name`: lowercase with hyphens, matches filename
- `description`: include 2-4 concrete examples in `<example>` blocks showing triggering conditions
- `model`: specified explicitly; `inherit` is an anti-pattern in plugin agents (only project/user-level agents in `.claude/agents/` may omit)
- `color`: unique color per agent (blue, green, red, purple, yellow)
- `tools`: minimal set (principle of least privilege). Subagents cannot request permissions at runtime.
- Plugin agents do not support `hooks`, `mcpServers`, or `permissionMode`
- System prompt should encourage parallel tool calls for independent operations (e.g. "When reading N files, fire N Read calls in a single response")
| Agent Type | Recommended Tools |
|------------|-------------------|
| Code reviewer | `Read, Grep, Glob` |
| Test runner | `Read, Bash, Grep` |
| Explorer | `Read, Glob, Grep, Bash` |
| Writer | `Read, Edit, Write` |
See [references/agent-spec.md](references/agent-spec.md) for the three-layer model selection guide, isolation guide, effort guide, and Opus/Haiku constraints.
**Verification:**
- [ ] Name is lowercase with hyphens
- [ ] Description has clear trigger
- [ ] `model` explicitly specified (`inherit` = anti-pattern in plugin agents)
- [ ] Tools are minimal (principle of least privilege)
- [ ] System prompt is focused
## Task 4: Validate Structure
**Goal:** Verify agent file structure is correct.
**Checklist:**
- [ ] File is in `.claude/agents/` directory
- [ ] Frontmatter has `name` and `description`
- [ ] Name matches filename (minus .md)
- [ ] Tools are appropriate for the task
- [ ] System prompt is actionable
- [ ] No overlapping responsibility with other agents
**Verification:** All checklist items pass.
## Task 5: Test Invocation
**Goal:** Verify agent can be invoked via Agent tool.
**Test:**
```
Agent tool:
- subagent_type: "[plugin:]agent-name"
- prompt: "Test invocation"
```
**Check:**
- Agent loads correctly
- System prompt is applied
- Tool restrictions work
- Model selection honored
**Verification:** Agent invocation succeeds without errors.
## Task 6: Verify Behavior
**Goal:** Run agent on real task and verify quality.
**Process:**
1. Invoke agent with real task input
2. Observe agent follows its system prompt
3. Verify output matches expected format
4. Check agent stays within its scope
**Verification:**
- Agent produces expected output
- Agent uses only granted tools
- Agent doesn't exceed itsRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.