AgentSkillsCN

delegation

掌握代理委托的最佳实践,精心设计子代理提示,合理划定职责范围,确保沟通高效顺畅。

SKILL.md
--- frontmatter
name: delegation
description: Agent delegation best practices for constructing effective subagent prompts with proper scoping

Delegation Skill

Activate this skill when delegating work to subagents during orchestration execution. This skill provides the templates, rules, and patterns for constructing effective delegation prompts that produce consistent, high-quality results.

Delegation Prompt Template

Every delegation to a subagent must follow this structure:

code
Task: [One-line description of what to accomplish]

Progress: Phase [N] of [M]: [Phase Name]

Files to modify:
- /absolute/path/to/file1.ext: [Specific change required]
- /absolute/path/to/file2.ext: [Specific change required]

Files to create:
- /absolute/path/to/new-file.ext: [Purpose and key contents]

Deliverables:
- [Concrete output 1]
- [Concrete output 2]

Validation: [command to run after completion, e.g., "npm run lint && npm run test"]

Context:
[Relevant information from the design document or previous phases]

Do NOT:
- [Explicit exclusion 1]
- [Explicit exclusion 2]
- Modify any files not listed above

Scope Boundary Rules

Absolute Paths

Always provide absolute file paths. Never use relative paths or expect agents to search for files.

Specific Deliverables

Define exactly what the agent should produce. Vague instructions like "implement the feature" lead to inconsistent results. Instead: "Create UserService class with createUser(), getUserById(), and deleteUser() methods implementing the IUserService interface."

Validation Criteria

Include the exact command(s) to run after completion. The agent should run these and report results. Examples:

  • npm run lint && npm run test
  • cargo build && cargo test
  • go vet ./... && go test ./...
  • python -m pytest tests/

Exclusions

Explicitly state what the agent must NOT do:

  • Files it must not modify
  • Dependencies it must not add
  • Patterns it must not introduce
  • Scope it must not exceed

Agent Selection Guide

Task DomainAgentKey Capability
System architecture, component designarchitectRead-only analysis, architecture patterns
API contracts, endpoint designapi-designerRead-only, REST/GraphQL expertise
Feature implementation, codingcoderFull read/write/shell access
Code quality assessmentcode-reviewerRead-only, verified findings
Database schema, queries, ETLdata-engineerFull read/write/shell access
Bug investigation, root causedebuggerRead + shell for investigation
CI/CD, infrastructure, deploymentdevops-engineerFull read/write/shell access
Performance analysis, profilingperformance-engineerRead + shell for profiling
Code restructuring, modernizationrefactorRead/write, no shell
Security assessment, vulnerabilitysecurity-engineerRead + shell for scanning
Test creation, TDD, coveragetesterFull read/write/shell access
Documentation, READMEs, guidestechnical-writerRead/write, no shell

Parallel Delegation

Non-Overlapping File Ownership

When delegating to multiple agents in parallel, ensure no two agents are assigned the same file. Each file must have exactly one owner in a parallel batch.

Single-Message Invocation

Invoke all parallel agents in a single message to ensure true concurrent execution. Do not invoke them sequentially.

Batch Completion Gates

All agents in a parallel batch must complete before:

  • The next batch of phases begins
  • Shared/container files are updated
  • Validation checkpoints run

Conflict Prevention

  • Assign non-overlapping file sets to each agent
  • Reserve shared files (barrel exports, configuration, dependency manifests) for a single agent or a post-batch update step
  • If two phases must modify the same file, they cannot run in parallel — execute them sequentially

Validation Criteria Templates

For Implementation Agents (coder, data-engineer, devops-engineer)

code
Validation: [build command] && [lint command] && [test command]

For Refactoring Agents (refactor)

code
Validation: [build command] && [test command]
Verify: No behavior changes — all existing tests must still pass

For Test Agents (tester)

code
Validation: [test command]
Verify: All new tests pass, report coverage metrics

For Read-Only Agents (architect, api-designer, code-reviewer, debugger, performance-engineer, security-engineer)

code
Validation: N/A (read-only assessment)
Verify: Findings reference specific files and line numbers

For Documentation Agents (technical-writer)

code
Validation: Verify all links resolve, code examples are syntactically valid