| name | copilot-agent |
| description | Unified skill for delegating tasks to external AI agents (Codex, Kimi, Gemini, etc.) from within Claude Code. Use when a copilot command is assigned to an external agent in the CLAUDE.md AI Role Assignment table, or when user explicitly asks to delegate a task to a specific agent. Routes to the correct adapter based on CLAUDE.md configuration.
|
copilot-agent
Delegate coding subtasks to external AI agents. Claude orchestrates; the configured agent executes. This skill supports multiple agents through a unified adapter pattern — adding a new agent only requires a new adapter file.
When to Use
- Automatic: When running copilot commands, check the AI Role Assignment table in
CLAUDE.md. Tasks with Agent column set to an external agent (codex, kimi, etc.) are delegated through this skill.
- Explicit: When the user asks to delegate a task (e.g., "let Codex handle this", "use Kimi to write tests").
Routing Logic
1. Read CLAUDE.md → AI Role Assignment table
→ Find current task → get agent name (e.g., "codex", "kimi")
2. Read adapters/{agent}.md
→ Get the command syntax for the required operation level:
- read-only (review, analyze)
- write (implement, fix, write tests)
- json (structured output)
- stdin (long prompts)
3. Read references/modes.md
→ Get the prompt template for the task type (Mode 1–10)
4. Claude pre-processes context (see Prompt Construction below)
→ Extract and inject relevant content before calling agent
5. Combine: adapter command syntax + pre-processed prompt
→ Execute via bash
Supported Agents
To add a new agent, create adapters/{name}.md following the adapter template format.
Task-to-Permission Mapping
| copilot command | Mode | Permission needed |
|---|
copilot-branch | Mode 1 | write |
copilot-design | Mode 2 | write |
copilot-review-design | Mode 3 | read-only |
copilot-dev | Mode 4 | write |
copilot-ut | Mode 5 | write |
copilot-check | Mode 6 | write |
copilot-review-code | Mode 7 | read-only |
copilot-pr | Mode 8 | write |
copilot-review-fetch | Mode 9 | read-only |
copilot-review-fix | Mode 10 | write |
Prompt Construction
Claude pre-processes and injects context before calling the agent. The agent receives a fully assembled prompt — it does not need to read files itself. This reduces agent token cost and ensures consistent context.
What Claude injects per mode
| Mode | Injected content | Source |
|---|
| 3 (review-design) | {DESIGN_MD} full content | docs/specs/{feature}/design.md |
| 3 (review-design) | {REVIEW_DESIGN_MD} full content | docs/specs/{feature}/review.md |
| 4 (dev) | {TECH_STACK} table | CLAUDE.md Tech Stack & Constraints section |
| 4 (dev) | {BANNED_PATTERNS} list | CLAUDE.md Banned Patterns section |
| 4 (dev) | {RELEVANT_FILES} content | Files inferred from design.md task list |
| 4 (dev, fix-review) | {BLOCKING_ISSUES} current round | Latest round from docs/specs/{feature}/review-code.md |
| 5 (ut) | {DESIGN_MD} relevant sections | docs/specs/{feature}/design.md |
| 5 (ut) | {SOURCE_FILES} content | Target source files passed as argument |
| 6 (check) | {TYPECHECK_CMD} {LINT_CMD} {FORMAT_CMD} | CLAUDE.md Quality Check Commands section |
| 7 (review-code) | {DIFF_CONTENT} | git diff {scope} output (split by file if >500 lines) |
| 7 (review-code) | {REVIEW_CODE_HISTORY} | Full docs/specs/{feature}/review-code.md content |
| 10 (review-fix) | {CURRENT_ROUND_BLOCKING} | Latest ## [Round N] → Blocking section from review-pr.md |
How to extract injected content
awk '/## Tech Stack/,/^---/' CLAUDE.md
awk '/## Banned Patterns/,/^---/' CLAUDE.md
awk '/## Quality Check Commands/,/^---/' CLAUDE.md
git diff {scope} --name-only | while read f; do
echo "=== $f ==="; git diff {scope} -- "$f"
done
Injection rule for Mode 4 (dev)
Critical: Claude MUST read CLAUDE.md and inject Tech Stack + Banned Patterns directly into the prompt. Do NOT rely on the agent reading CLAUDE.md itself — the injected content is the authoritative constraint.
For relevant files, parse the Task Breakdown in design.md to identify which source files each task touches, then read those files and embed their content. Do not pass the entire project — only files relevant to the current task batch.
Prompt assembly example
TECH_STACK=$(awk '/## Tech Stack/,/^---/' CLAUDE.md)
BANNED=$(awk '/## Banned Patterns/,/^---/' CLAUDE.md)
DESIGN=$(cat docs/specs/{feature}/design.md)
BLOCKING=$(awk '/## \[.*\] Round [0-9]+/{found=1} found && /### Blocking/{p=1} p && /### (Suggestions|Looks Good|Confirmed)/{p=0} p' docs/specs/{feature}/review-code.md | tail -50)
cat <<EOF | {agent_command}
{mode_template with variables substituted}
EOF
For long prompts, always prefer the stdin pattern over inline --prompt to avoid shell escaping issues.
Error Handling
if ! {agent_command}; then
echo "Agent execution failed, exit code: $?"
fi
If an agent fails:
- Report the error with exit code
- Suggest checking: authentication, CLI installation, network connectivity
- Do not fall back to a different agent automatically — let the user decide
Notes
- Serial execution: Never run Claude and an external agent writing to the same files concurrently
- Token cost: Each agent invocation consumes the respective provider's API quota
- Agent-agnostic commands: The copilot commands themselves contain no agent-specific logic — all routing happens through this skill
- Failure recovery: Report errors to user rather than retrying silently
- Mode 9 (review-fetch): This mode is typically executed by Claude directly (gh CLI calls), not delegated to an external agent. If delegated, the agent needs gh CLI access