copilot-cli
GitHub Copilot CLI Integration
Overview
Enable agent to autonomously use GitHub Copilot CLI for comprehensive code development, debugging, refactoring, and automated pull request workflows. This skill provides full access to Copilot CLI's capabilities including interactive sessions, non-interactive automation, permission management, model selection, and collaborative development features.
When to Use This Skill
Use GitHub Copilot CLI when you need to:
- Autonomously write, debug, or refactor code
- Implement features or fix bugs with AI assistance
- Create automated pull request workflows
- Execute complex development tasks with minimal user intervention
- Resume previous coding sessions
- Work with specific AI models for different tasks
- Integrate AI-powered development into CI/CD pipelines
- Share development sessions as documentation
Core Capabilities
1. Interactive Development Sessions
Start interactive mode for ongoing development conversations:
# Basic interactive mode
copilot
# Start with specific prompt
copilot -i "Fix authentication bug in user service"
# Resume most recent session
copilot --continue
# Resume specific session with picker
copilot --resume
# Interactive with specific model
copilot --model claude-sonnet-4.5
Use when: Complex tasks requiring multiple iterations, exploratory development, or ongoing conversations.
2. Non-Interactive Automation
Execute single prompts and exit, perfect for automation:
# Basic non-interactive execution (requires --allow-all-tools or tool permissions)
copilot -p "Fix the bug in main.js" --allow-all-tools
# Quick permission grant with --allow-all or --yolo
copilot -p "Implement user authentication" --allow-all
# Silent mode for scripting (outputs only agent response)
copilot -p "Generate API documentation" --allow-all -s
# Share results as markdown
copilot -p "Refactor database layer" --allow-all --share ./result.md
# Share to GitHub gist
copilot -p "Create test suite" --allow-all --share-gist
Use when: CI/CD pipelines, automated tasks, scripting, one-off operations.
3. Automated Pull Request Workflow
Complete workflow for autonomous PR creation (see references/pr-workflow.md for detailed examples):
# Step 1: Implement feature in non-interactive mode
copilot -p "Implement user profile feature with tests" \
--allow-all \
--share ./implementation-notes.md
# Step 2: Create PR (manual git commands or use MCP GitHub tools)
# The implementation-notes.md can be used as PR description
# Step 3: Request Copilot review
copilot -p "Review the changes in current PR and suggest improvements" \
--allow-all
When implementing autonomous PR workflows:
- Use
--allow-all-toolsor--allow-allfor full automation - Save session documentation with
--sharefor PR descriptions - Combine with GitHub CLI or MCP tools for PR creation
- Use
--resumeto continue work on the same task
4. Permission Management
Control what Copilot CLI can access and modify:
# Allow all permissions (fastest for automation)
copilot --allow-all # or --yolo
# Granular tool permissions
copilot --allow-tool write --allow-tool 'shell(git:*)'
copilot --deny-tool 'shell(git push)'
# Path permissions
copilot --add-dir ~/workspace --add-dir /tmp
copilot --allow-all-paths # Allow any path
# URL permissions
copilot --allow-url github.com --allow-url api.example.com
copilot --allow-all-urls
# Mixed permissions
copilot --allow-all-tools --deny-tool 'shell(rm *)' --add-dir ~/safe-workspace
Security best practices:
- Use
--allow-allonly in trusted, isolated environments - Grant minimal permissions for production automation
- Use
--deny-toolto exclude dangerous operations - Restrict paths with
--add-dirinstead of--allow-all-paths
5. Model Selection
Choose the appropriate AI model for different tasks:
# Use Claude Sonnet 4.5 (default, best for most coding tasks)
copilot --model claude-sonnet-4.5
# Use Claude Opus 4.5 for complex architecture decisions
copilot --model claude-opus-4.5
# Use GPT-5 for specialized tasks
copilot --model gpt-5
# Use Haiku for faster, simpler operations
copilot --model claude-haiku-4.5
Model selection guidance:
- claude-sonnet-4.5: Default, excellent for most development tasks
- claude-opus-4.5: Complex reasoning, architecture design, large refactorings
- claude-haiku-4.5: Fast responses, simple fixes, documentation
- gpt-5 variants: Alternative for specific use cases or preferences
6. Session Management
Resume and manage development sessions:
# Resume most recent session
copilot --continue
# Resume with session picker (interactive selection)
copilot --resume
# Resume specific session by ID
copilot --resume abc123
# Resume with auto-approval
copilot --continue --allow-all-tools
Use cases:
- Continue interrupted work
- Review previous implementations
- Iterate on existing solutions
- Maintain context across sessions
Workflow Patterns
Pattern 1: Autonomous Feature Implementation
For complete feature development with automated PR:
- Implement: Execute non-interactive prompt with full permissions
- Document: Save session notes for PR description
- Create PR: Use GitHub CLI or MCP tools
- Review: Optional Copilot-assisted code review
See references/pr-workflow.md for complete example.
Pattern 2: Bug Fix Automation
For automated bug fixes in CI/CD:
- Detect issue (tests, monitoring, issue tracker)
- Execute:
copilot -p "Fix <issue>" --allow-all -s - Capture output for logging/reporting
- Auto-commit and create PR if changes made
Pattern 3: Interactive Exploration
For complex problems requiring iteration:
- Start:
copilot -i "Investigate performance bottleneck" - Iteratively provide feedback and direction
- Resume if interrupted:
copilot --continue - Share results: Use in-session
/sharecommand
Pattern 4: Code Review Assistant
For reviewing existing code or PRs:
# Review specific file
copilot -p "Review src/auth.ts for security issues" --allow-all
# Review PR changes
copilot -p "Review changes in current branch and suggest improvements" --allow-all
# Generate review comments
copilot -p "Analyze test coverage in the current PR" --allow-all -s > review.md
Advanced Features
Custom Instructions
Use repository-specific instructions via AGENTS.md:
# Uses .copilot/AGENTS.md or AGENTS.md in current directory
copilot
# Disable custom instructions
copilot --no-custom-instructions
MCP Server Integration
Extend capabilities with Model Context Protocol servers:
# Enable all GitHub MCP tools
copilot --enable-all-github-mcp-tools
# Add specific GitHub MCP tools
copilot --add-github-mcp-tool create_pull_request --add-github-mcp-tool merge_pull_request
# Add custom MCP server configuration
copilot --additional-mcp-config @~/my-mcp-config.json
# Disable built-in MCP servers
copilot --disable-builtin-mcps
Logging and Debugging
Control logging for troubleshooting:
# Enable debug logging
copilot --log-level debug
# Custom log directory
copilot --log-dir ~/copilot-logs
# Disable logs
copilot --log-level none
Command Reference
For detailed documentation on all commands and options, see:
- references/commands.md - Complete command reference
- references/options.md - All CLI options and flags
- references/pr-workflow.md - Automated PR workflow examples
- references/examples.md - Common usage patterns
Best Practices
- Automation: Use
--allow-allfor trusted environments, granular permissions for production - Documentation: Always use
--sharefor non-interactive tasks to create audit trails - Session Management: Use
--continueto maintain context across interruptions - Model Selection: Match model to task complexity (Haiku for simple, Opus for complex)
- Error Handling: Capture exit codes and output in scripts for proper error handling
- Security: Never grant
--allow-all-pathsin untrusted environments - PR Workflows: Combine with GitHub CLI/MCP tools for complete automation
Quick Reference
# Most common patterns
copilot # Interactive mode
copilot -i "task" # Interactive with prompt
copilot -p "task" --allow-all # Non-interactive automation
copilot -p "task" --allow-all -s # Silent (scripting)
copilot --continue # Resume last session
copilot -p "task" --allow-all --share ./out.md # Save documentation