The /delegate command in GitHub Copilot CLI lets you hand off complex tasks to Copilot for autonomous execution. Instead of working through problems step by step, delegation allows Copilot to work independently, creating branches, making changes, and opening pull requests on your behalf.
Understanding the Delegate Command
When you use /delegate, you are invoking the Copilot coding agent - a more powerful mode that operates asynchronously on GitHub's servers. Unlike interactive mode where you guide each step, delegation gives Copilot autonomy to complete a task from start to finish.
The coding agent can:
- Create new branches (prefixed with
copilot/) - Make multiple file changes
- Run tests to verify changes
- Open draft pull requests
- Request your review when finished
This makes delegation ideal for tasks that are well-defined but tedious to execute manually.
Syntax and Basic Usage
Start a Copilot CLI session and use the /delegate command followed by your task description:
copilot
> /delegate Add input validation to all form fields in the checkout module
After delegation:
- Copilot commits any unstaged changes to a new branch
- Opens a draft pull request on GitHub
- The coding agent works in the background
- You receive a link to monitor progress
- Copilot requests your review when complete
You can continue working locally while the delegated task runs on GitHub.
When to Use Delegation vs Interactive Mode
Use Delegation For
| Task Type | Example |
|---|---|
| Bulk changes | "Add JSDoc comments to all exported functions" |
| Test coverage | "Write unit tests for the payment processing module" |
| Refactoring | "Convert all class components to functional components" |
| Code cleanup | "Fix all ESLint errors in the src directory" |
| Documentation | "Add README files to each package in the monorepo" |
Use Interactive Mode For
| Scenario | Why |
|---|---|
| Exploratory work | You need to learn about the code first |
| Ambiguous requirements | The task needs clarification |
| Critical changes | You want to review each step |
| Quick fixes | Single-file changes are faster interactively |
Writing Effective Delegation Tasks
The quality of your delegation results depends heavily on how you describe the task.
Poor Task Descriptions
# Too vague - what bugs? where?
> /delegate Fix bugs
# No success criteria
> /delegate Improve the code
# Unclear scope
> /delegate Add tests
Effective Task Descriptions
# Specific goal, clear scope
> /delegate Fix the authentication bug where users receive 403 errors
after password reset. The issue is in src/auth/token-refresh.ts
# Clear requirements and constraints
> /delegate Add unit tests for the UserService class covering all public
methods. Use Jest and aim for 80% coverage. Follow existing test patterns
in __tests__/
# Well-defined success criteria
> /delegate Convert the Dashboard component from class to functional using
React hooks. Preserve all existing functionality and ensure existing tests
pass
Task Description Checklist
Include these elements for best results:
- What: The specific change or outcome needed
- Where: Files, directories, or modules to focus on
- How: Patterns, conventions, or approaches to follow
- Constraints: Requirements that must be met
- Success criteria: How to know when the task is complete
Monitoring Delegated Tasks
After delegation, Copilot provides a link to the draft pull request. From there you can:
On GitHub
- View commits as they are made
- Read the PR description summarizing the approach
- Check the conversation thread for agent status updates
- Review file changes in real-time
Checking Status
The pull request will show:
- Current status (working, waiting for review, blocked)
- Changes made so far
- Any errors or issues encountered
- Test results if tests were run
Interrupting and Controlling Delegated Tasks
Interrupt Locally
Press Ctrl+C during the initial delegation handoff to cancel before the task starts on GitHub.
On GitHub
Once the task is running on GitHub:
- Navigate to the draft pull request
- Close the pull request to stop the agent
- Delete the
copilot/branch if you want to start fresh
Modify Direction
You can add comments to the pull request to guide the agent:
@copilot Please also add error handling for network failures
The agent monitors PR comments and can adjust its approach based on feedback.
Reviewing Changes After Delegation
When the agent completes its work:
- Review the pull request diff on GitHub
- Run tests locally by checking out the branch
- Request changes via PR comments if needed
- Mark as ready for review when satisfied
- Merge using your normal workflow
# Checkout the delegated branch locally
git fetch origin
git checkout copilot/add-validation-to-forms
# Run tests
npm test
# Review changes
git diff main
Common Delegation Patterns
Pattern 1: Test Generation
> /delegate Generate unit tests for the OrderService class in
src/services/order.ts. Cover success cases, error handling, and edge
cases. Use the testing patterns from tests/services/user.test.ts as
a reference
Pattern 2: Refactoring
> /delegate Refactor the legacy PaymentProcessor class to use async/await
instead of callbacks. Update all callers in src/checkout/. Ensure all
existing tests pass
Pattern 3: Documentation
> /delegate Add TypeScript JSDoc comments to all exported functions in
the lib/ directory. Include @param, @returns, and @example tags where
appropriate
Pattern 4: Migration
> /delegate Migrate all styled-components in src/components/ to Tailwind
CSS. Follow the class naming conventions in our existing Button and
Card components
Limitations and When Delegation Is Not Appropriate
Technical Limitations
| Limitation | Implication |
|---|---|
| Single repository only | Cannot coordinate changes across repos |
| One PR per delegation | Complex multi-PR work needs manual coordination |
| Branch prefix required | Can only push to copilot/* branches |
| Cannot merge PRs | You must complete the merge manually |
| Cannot mark PR ready | You must change from draft to ready |
When Not to Delegate
- Security-sensitive code: Manual review is essential for auth, encryption, or access control
- Architecture decisions: Major structural changes need human judgment
- Breaking changes: API changes affecting consumers need careful coordination
- Production hotfixes: Critical fixes need immediate, controlled deployment
- Cross-repo dependencies: Changes spanning multiple repositories
Best Practices
Start Small
Test delegation with low-risk tasks before delegating critical work:
# Good first delegation
> /delegate Add type annotations to the utility functions in lib/helpers.ts
Be Specific About Conventions
Reference existing code as examples:
> /delegate Add error boundaries to all page components following the
pattern in src/pages/Dashboard.tsx
Set Clear Boundaries
Specify what should not be changed:
> /delegate Optimize the image loading in the Gallery component. Do not
modify the public API or change how images are fetched from the server
Review Thoroughly
Delegated code still needs human review. Check for:
- Logical correctness
- Edge cases
- Performance implications
- Security considerations
- Consistency with codebase conventions
Next Steps
- Learn about Copilot CLI agents for specialized local tasks
- Set up slash commands for faster workflows
- Configure MCP servers to extend agent capabilities
- Review GitHub's official delegation documentation