Design and write high-quality Claude Code agents and agent prompts. Use when creating or updating .claude/agents/*.md for (1) single-purpose subagents (reviewers, implementers, researchers) and (2) workflow orchestrators (multi-phase coordinators like pr-review, feature-development, bug-fix). Covers delegation triggers, tool/permission/model choices, Task-tool orchestration, phase handoffs, aggregation, iteration gates, and output contracts. Also use when deciding between subagents vs skills vs always-on repo guidance.
From sharednpx claudepluginhub inkeep/team-skills --plugin sharedThis skill uses the workspace's default tool permissions.
references/claude-code-mechanics.mdreferences/designer-failure-modes.mdreferences/evaluation-and-iteration.mdreferences/failure-modes.mdreferences/handoff-protocol.mdreferences/personality-and-intent.mdreferences/procedural-patterns.mdreferences/prompt-structure.mdreferences/updating-existing-agents.mdreferences/workflow-orchestrators.mdscripts/validate-agent.shtemplates/skill-fork-template.mdtemplates/subagent-reviewer-template.mdtemplates/subagent-template.mdtemplates/subagent-worker-template.mdtemplates/workflow-orchestrator-template.mdGuides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Configures VPN and dedicated connections like Direct Connect, ExpressRoute, Interconnect for secure on-premises to AWS, Azure, GCP, OCI hybrid networking.
Design agents that are focused, safe, and reliable without over-constraining them.
Key principle: treat tokens and attention as a shared budget. Prefer small, high-signal prompts plus strong output contracts over long prose.
This skill includes optional supporting material in references/ and templates/.
path/to/file.md, open that file before continuing.For non-trivial agent design: Consider reading all files in this skill folder before starting. Partial context can lead to inconsistent agents or missed patterns. This is especially valuable when designing orchestrators, updating existing agents, or working in an unfamiliar domain.
These principles guide you as you write agent prompts:
Treat attention as scarce. The model's attention is O(n²) with context length. Every token competes for attention with every other token. Front-load critical instructions; move reference material to references/ files loaded on demand.
Optimize for reliability, not elegance. If a step is fragile or easy to mess up, add guardrails: a checklist, a validation loop, a "do X, not Y" constraint. Don't rely on the model inferring correct behavior.
Default to one strong path, with escape hatches. Provide a recommended default workflow. If alternatives exist, name them explicitly, but avoid option overload.
Write for execution. Use clear imperatives: "Do X. Then do Y." Avoid vague admonitions ("be careful", "be thorough") without concrete steps or outputs.
Match certainty to expression. Use "must" / "never" for hard requirements. Use "should" / "prefer" for strong defaults with exceptions. Use "consider" / "may" for suggestions. The agent parses this calibration.
Make agent prompts standalone. Assume a first-time reader with zero context. Don't rely on the agent inferring from prior conversation or parent state. For subagents specifically: don't reference other agents by name — write each as if it's the only agent that exists. (Orchestrators are the exception; they coordinate subagents by design.) If a subagent needs orchestration context, the parent passes it via handoff, not in the permanent prompt.
Use positive and negative framing appropriately. For routine guidance, positive framing ("Do X") is often clearer than prohibition ("Don't do Y"). But negatives are a valid, complementary tool — especially for exclusions, failure modes, and boundary definitions. When using negatives, make them concrete (not vague), pair with contrastive examples where helpful, and position critical constraints at section boundaries. See references/prompt-structure.md for technique details.
When asked to "create an agent" / "write a subagent" / "make a reviewer" / "make an orchestrator":
.claude/agents/<name>.md).
pr-review-output-contract)Keep explanation short. Prioritize concrete artifacts (files, templates, checklists).
Before starting any work, create a task for each step using TaskCreate with addBlockedBy to enforce ordering. Derive descriptions and completion criteria from each step's own workflow text.
Mark each task in_progress when starting and completed when its step's exit criteria are met. On re-entry, check TaskList first and resume from the first non-completed task.
Determine which you're doing:
references/updating-existing-agents.md and follow that procedureIf updating/refactoring an existing agent:
Critical: Before proceeding with any update work, you must complete Step 0: Full context loading from that file. This means reading:
write-agent/ folder (SKILL.md + all references/ + all templates/ + all scripts/)Do not skip this step. Partial context loading is the primary cause of routing drift, capability creep, and broken output contracts during updates.
Quick gate: If you're unsure whether an agent is the right mechanism at all (vs a skill or CLAUDE.md rule), jump to Step 3 first. Otherwise, pick the lightest agent pattern that fits:
| Need | Choose | Practical effect |
|---|---|---|
| One job, one output (review, implement, diagnose, summarize) | Subagent | Simple scope, easier to validate; usually no Task tool |
| Multi-phase workflow (research → plan → implement → judge → iterate) | Workflow orchestrator | Needs Task tool; coordinates phases, dispatches subagents, aggregates results |
| Isolation for a single task, but no multi-phase orchestration | Subagent (or a context: fork skill — ⚠️ unreliable for plugins, see Step 3 notes) | Avoid writing orchestration logic unless needed |
Hard constraint: Subagents cannot spawn other subagents.
So a workflow orchestrator must run as the top-level session agent (e.g., claude --agent feature-development …), not as a Task-spawned subagent.
CLI invocation note: Agents can be invoked directly via claude --agent <name> (interactive) or claude --agent <name> -p "prompt" (non-interactive). For spawning Claude Code subprocesses from within a running session (e.g., iteration loops), use the env -u CLAUDECODE -u CLAUDE_CODE_ENTRYPOINT claude -p ... pattern — this bypasses the nesting guard. Always set --dangerously-skip-permissions on subprocesses. See references/claude-code-mechanics.md for the full invocation reference including multi-level nesting.
Templates:
templates/subagent-template.md, templates/subagent-reviewer-template.md, templates/subagent-worker-template.mdtemplates/workflow-orchestrator-template.mdreferences/workflow-orchestrators.mdFill these fields. Ask questions only if missing info is blocking; otherwise assume sensible defaults and label them.
If it's a workflow orchestrator, also capture: phases, subagent roster, artifact strategy, quality gates, and iteration policy.
Load: references/workflow-orchestrators.md for the full orchestrator checklist.
If useful, copy/paste the brief template from references/prompt-structure.md.
Default starting point: Pick the closest template under templates/ and fill every [TODO] before you return the agent file.
Use this decision table to reduce both under-asking and over-asking:
| Situation | Do |
|---|---|
| Missing info that affects routing (delegation triggers), tool power, side effects, or compatibility | Ask 1-3 targeted questions before drafting. |
| User says "whatever you think is best" / signals indifference | Provide a specific recommendation plus 1-2 alternatives, then confirm the non-trivial choice. |
| Details are low-stakes and reversible (example wording, minor section names) | Use sensible defaults; list assumptions briefly so the user can correct if needed. |
Question design (when you need human input):
If you proceed with assumptions, label them as Assumptions: so they're easy to spot and correct.
Choose the lightest mechanism that reliably achieves the goal.
| If you need… | Prefer | Why |
|---|---|---|
| Always-on repo constraints (commands, conventions, non-negotiables) | CLAUDE.md / .claude/rules | Applied everywhere; no routing needed |
| Reusable instructions that should run in the main conversation context | Skill | Reuse without context isolation; easy to invoke interactively |
| A single specialized worker/reviewer with tool restrictions | Subagent | Isolated context + least-privilege tools |
| A multi-phase pipeline that coordinates other agents | Workflow orchestrator | Encodes phase order, dispatch, aggregation, iteration |
Notes:
Subagents cannot spawn other subagents. If you need multi-step specialization, orchestration must live in the top-level agent/session.
If you want a reusable workflow that runs "out of band", prefer:
context: fork, or⚠️
context: forkis unreliable (Issue #16803 — OPEN). Skills frequently run inline instead of forking, especially plugin skills (95%+ failure rate reported). If you need reliable isolation, use the Agent tool + Skill load pattern instead: spawn ageneral-purposesubagent and start its prompt with"Before doing anything, load /skill-name". The subagent loads the skill via its Skill tool and executes in isolation.
Agent prompts should hit the right altitude — specific enough to guide, general enough to generalize:
| Failure mode | Symptom | Example |
|---|---|---|
| Too rigid | Brittle enumeration; breaks on unexpected inputs | "If .ts do X. If .tsx do Y. If .js do Z..." |
| Too vague | Abstract principles without concrete signals | "Be helpful and thorough." |
| Just right | Heuristics that generalize + clear escalation | "Prioritize correctness over style. When uncertain, ask." |
Map task characteristics to strictness:
Set (verify each is present before moving on):
name: stable, hyphen-case, descriptivedescription: concrete triggers + examples; avoid over-broad routingtools / disallowedTools: least privilegepermissionMode: default unless you have a reasonmodel: haiku/sonnet/opus/inherit (choose intentionally)skills: preload needed skills explicitly (don't assume inheritance)CRITICAL: routing uses <example> blocks. Include 2–4 <example> blocks with <commentary> that teaches why delegation should (or should not) happen.
Subagents (recommended defaults):
skills: [write-docs]).Workflow orchestrators (recommended defaults):
skills: (they do not).references/workflow-orchestrators.md for dispatch, aggregation, and iteration patterns.Minimal pattern (copy/paste and customize):
---
name: my-agent
description: Use this agent when <trigger conditions>. Avoid using it when <exclusions>.
<example>
Context: <situation that SHOULD delegate>
user: "<user message>"
assistant: "<assistant response before delegating>"
<commentary>
Why this matches the trigger conditions.
</commentary>
assistant: "I'll use the my-agent agent to…"
</example>
<example>
Context: <near-miss that SHOULD NOT delegate>
user: "<user message>"
assistant: "<assistant response that stays in the main thread>"
<commentary>
Why this is a near-miss / exclusion.
</commentary>
assistant: "<continue without delegating>"
</example>
# Optional:
# tools: Read, Grep
# model: sonnet
# permissionMode: default
---
# My Agent
...
Load: references/claude-code-mechanics.md for subagent constraints, permission modes, and skills composition patterns.
Use a structure that optimizes for correct execution:
Writing the Role & mission section:
The Role & mission sets the agent's identity and judgment frame. It should:
Load: references/personality-and-intent.md for patterns on writing effective personality statements.
Quick guidance:
Orchestrator additions: If writing a workflow orchestrator, add explicit sections for phase plan, dispatch rules, aggregation rules, iteration policy, and artifact passing. See references/workflow-orchestrators.md and references/prompt-structure.md.
Style constraint: Write in second person ("You are…", "Do…"). Avoid first-person commitments ("I will edit files…") unless the agent is allowed and expected to do so.
Including failure mode awareness:
Good agent prompts don't just say what to do — they explicitly name the failure modes most likely to occur given the agent's task. This gives the agent self-correction targets.
Load: references/failure-modes.md for the full catalog of common LLM failure modes.
Include failure modes either:
Pick the 3-5 most relevant for the agent's context — don't include all of them.
Quick selection guide:
| Agent type | Commonly relevant |
|---|---|
| Reviewer | Flattening nuance, Source authority, Asserting when uncertain, Padding/burying lede |
| Implementer | Plowing through ambiguity, Downstream effects, Instruction rigidity, Assuming intent |
| Orchestrator | Plowing through ambiguity, Never escalating, Assuming intent, Over-indexing on recency |
The interpretation test (run on every instruction):
Before finalizing the prompt, verify each instruction passes these four checks:
Don't draft loosely and fix later — tighten language as you write.
Load: references/prompt-structure.md for the full prompt section breakdown.
Prompting technique notes:
references/prompt-structure.md for details.Subagents start "fresh," so don't rely on them remembering the parent chat.
Orchestrator artifact rule of thumb:
Error retention: When a subagent action fails, keep the failed action and error in the handoff context. This enables implicit belief updating — the agent learns what doesn't work without explicit "don't do X" instructions. Summarize patterns if errors accumulate, but don't strip them entirely.
Load: references/handoff-protocol.md for packet templates and iteration patterns.
Prefer guardrails that are:
Avoid:
Before returning an agent file, confirm:
name, description with 2–4 <example> blocks, and the intended tools/disallowedTools.description is neither too broad nor too narrow; examples include at least one near-miss exclusion.If workflow orchestrator, also confirm:
Designer self-check (before delivering):
If any answer is "yes," fix before delivering. Most agent underperformance traces to designer errors, not model limitations.
When emitting files, output them like this (paths + code blocks):
path/to/file.mdDo not embed additional markdown prose inside the file unless it's part of the file's content.
This index helps you quickly find the right deep-dive. In the main workflow, follow the Load: pointers.
Priority legend:
| Path | Priority | Use when | Impact if skipped |
|---|---|---|---|
references/updating-existing-agents.md | P0 | "Update" or "refactor" requests for existing agents | Intent drift; broken routing; capability creep; downstream orchestrator failures |
references/claude-code-mechanics.md | P0 | Configuring frontmatter, understanding constraints, permissions, composition, CLI invocation patterns (--agent, -p, --resume), and recursive invocation limits | Broken routing, permission errors, failed spawning, blocked recursive calls |
references/prompt-structure.md | P0 | Structuring the system prompt body; writing Role & mission, tool policies, output contracts | Missed steps, inconsistent outputs, unclear escalation |
references/failure-modes.md | P1 | Selecting which failure modes to guard against for this agent type | Agents exhibit predictable LLM blind spots |
references/personality-and-intent.md | P1 | Writing effective Role & mission statements; avoiding escape hatches | Vague identity, risky tradeoff framing |
references/workflow-orchestrators.md | P1 | Designing multi-phase orchestrators; dispatch, aggregation, iteration | Orchestrator missing key coordination patterns |
references/handoff-protocol.md | P1 | Designing handoff packets; structuring return packets; multi-phase chaining | Subagents lack needed context or return unusable results |
references/evaluation-and-iteration.md | P1 | Tuning delegation behavior; debugging over/under-triggering | Agents stay miscalibrated |
references/procedural-patterns.md | P2 | Writing validation loops, iteration policies, or error handling | Agents may infinite-loop, skip validation, or fail ungracefully |
references/designer-failure-modes.md | P2 | Debugging agent underperformance; reviewing prompts before delivery | Blame model for designer errors |
| Path | Use when |
|---|---|
templates/subagent-template.md | Starting a generic subagent |
templates/subagent-reviewer-template.md | Read-only reviewer (disallows Write/Edit) |
templates/subagent-worker-template.md | Implementation-focused worker |
templates/workflow-orchestrator-template.md | Multi-phase orchestrator (uses Task tool) |
templates/skill-fork-template.md | Skill that runs in a forked subagent context |
| Path | Purpose |
|---|---|
scripts/validate-agent.sh | Validate agent file structure; catches missing name/description and warns on missing <example> blocks |