---
name: delegation-check
description: Check workflow delegation prompts against agent role definitions for content separation violations. Detects conflicts, duplication, boundary leaks, and missing contracts. Triggers on "check delegation", "delegation conflict", "prompt vs role check".
allowed-tools: Read, Glob, Grep, Bash, AskUserQuestion
---
Validate that command delegation prompts (Agent() calls) and agent role definitions respect GSD content separation boundaries. Detects 7 conflict dimensions: role re-definition, domain expertise leaking into prompts, quality gate duplication, output format conflicts, process override, scope authority conflicts, and missing contracts.
Invoked when user requests "check delegation", "delegation conflict", "prompt vs role check", or when reviewing workflow skill quality.
- @.claude/skills/delegation-check/specs/separation-rules.md
## 1. Determine Scan Scope
Parse `$ARGUMENTS` to identify what to check.
| Signal | Scope |
|--------|-------|
| File path to command `.md` | Single command + its agents |
| File path to agent `.md` | Single agent + commands that spawn it |
| Directory path (e.g., `.claude/skills/team-*/`) | All commands + agents in that skill |
| "all" or no args | Scan all `.claude/commands/`, `.claude/skills/*/`, `.claude/agents/` |
If ambiguous, ask:
```
AskUserQuestion(
header: "Scan Scope",
question: "What should I check for delegation conflicts?",
options: [
{ label: "Specific skill", description: "Check one skill directory" },
{ label: "Specific command+agent pair", description: "Check one command and its spawned agents" },
{ label: "Full scan", description: "Scan all commands, skills, and agents" }
]
)
```
## 2. Discover Command-Agent Pairs
For each command file in scope:
**2a. Extract Agent() calls from commands:**
```bash
# Search both Agent() (current) and Task() (legacy GSD) patterns
grep -n "Agent(\|Task(" "$COMMAND_FILE"
grep -n "subagent_type" "$COMMAND_FILE"
```
For each `Agent()` call, extract:
- `subagent_type` → agent name
- Full prompt content between the prompt markers (the string passed as `prompt=`)
- Line range of the delegation prompt
**2b. Locate agent definitions:**
For each `subagent_type` found:
```bash
# Check standard locations
ls .claude/agents/${AGENT_NAME}.md 2>/dev/null
ls .claude/skills/*/agents/${AGENT_NAME}.md 2>/dev/null
```
**2c. Build pair map:**
```
$PAIRS = [
{
command: { path, agent_calls: [{ line, subagent_type, prompt_content }] },
agent: { path, role, sections, quality_gate, output_contract }
}
]
```
If an agent file cannot be found, record as `MISSING_AGENT` — this is itself a finding.
## 3. Parse Delegation Prompts
For each Agent() call, extract structured blocks from the prompt content:
| Block | What It Contains |
|-------|-----------------|
| `` | What to accomplish |
| `` | Input file paths |
| `` / `` / `` | Runtime parameters |
| `
- [ ] Scan scope determined and all files discovered
- [ ] All Agent() calls extracted from commands with full prompt content
- [ ] All corresponding agent definitions located and parsed
- [ ] 7 conflict dimensions checked for each command-agent pair
- [ ] No false positives on legitimate patterns (mode references, user decision passthrough, ``)
- [ ] Fix recommendations provided for every error/warning
- [ ] Summary table with per-pair dimension results displayed
- [ ] Overall verdict determined (CLEAN/REVIEW/CONFLICT)