Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
A direct command skips the review prompt. Inspect the source before running it.
The gh agent-task CLI extension enables creating GitHub Copilot agent sessions through the command line. An agent session is a specialized GitHub issue that triggers GitHub Copilot to perform automated code changes based on natural language instructions.
Contain natural language instructions for code changes
Trigger GitHub Copilot to autonomously execute the task
Create pull requests with the implemented changes
Provide a workflow for reviewing and merging automated code modifications
Installation
Install via GitHub CLI:
gh extension install github/agent-task
Note: This extension requires authentication with a Personal Access Token (PAT) that has appropriate permissions for creating issues and pull requests.
Core Commands
Create Agent Task
Create a new agent session from a description:
# Create task with inline description
gh agent-task create "Fix the bug in authentication flow"# Create task from file
gh agent-task create --from-file task-description.md
# Specify base branch
gh agent-task create --base develop "Implement new feature"# Create in different repository
gh agent-task create --repo owner/repo "Update documentation"
Command Parameters:
Description (positional): Natural language description of the task
--from-file <path>: Read task description from file
--base <branch>: Base branch for the pull request (default: repository default branch)
--repo <owner/repo>: Target repository (default: current repository)
Output Format:
The command outputs the URL of the created agent session:
https://github.com/owner/repo/issues/123
List Agent Tasks
List agent sessions in a repository:
# List all agent sessions
gh agent-task list
# List with filters
gh agent-task list --state open
gh agent-task list --state closed
gh agent-task list --state all
View Agent Task
View details of a specific agent session:
# View by number
gh agent-task view 123
# View by URL
gh agent-task view https://github.com/owner/repo/issues/123
Agent session descriptions should be clear, specific natural language instructions:
Good Example:
# Refactor User Authentication
Refactor the user authentication flow in `src/auth/login.js` to:
1. Use async/await instead of callbacks
2. Add proper error handling with specific error messages
3. Add input validation for email format
4. Update tests to cover the new implementation
Maintain backward compatibility with the existing API.
Poor Example:
Fix auth
Best Practices:
Be specific about what needs to change
Reference file paths when relevant
Include acceptance criteria
Specify any constraints or requirements
Mention testing expectations
Integration with GitHub Agentic Workflows
The gh agent-task extension is used by the create-agent-session safe output feature in GitHub Agentic Workflows (gh-aw).
Safe Output Configuration
safe-outputs:create-agent-session:base:main# Base branch for agent session PRtarget-repo:"owner/target-repo"# Cross-repository task creation
GH_AW_GITHUB_TOKEN - General override token (legacy)
Custom token via github-token configuration field
Note: The default GITHUB_TOKEN is not supported as it lacks required permissions. The COPILOT_CLI_TOKEN and GH_AW_COPILOT_TOKEN secrets are no longer supported as of v0.26+.
Setting Up Authentication
Store your Personal Access Token in repository secrets:
# In your repository settings, add secret:# Name: COPILOT_GITHUB_TOKEN (recommended)# Value: ghp_YourPersonalAccessToken
:::note[Backward Compatibility]
Legacy token name GH_AW_GITHUB_TOKEN is still supported for backward compatibility. The GH_AW_COPILOT_TOKEN token is no longer supported as of v0.26+.
:::
Error Handling
Authentication Errors
Error: failed to create agent session
authentication required
Solution: Configure COPILOT_GITHUB_TOKEN or legacy GH_AW_GITHUB_TOKEN with a PAT.
Permission Errors
Error: 403 Forbidden
Resource not accessible by integration
Solution: Ensure the token has contents: write, issues: write, and pull-requests: write permissions.
Repository Not Found
Error: repository not found
Solution: Verify the target repository exists and the token has access to it.
Testing in Staged Mode
When safe-outputs.staged: true, agent sessions are previewed without creation:
safe-outputs:staged:truecreate-agent-session:
Staged Output:
## 🎭 Staged Mode: Create Agent Tasks Preview
The following agent sessions would be created if staged mode was disabled:
### Task 1**Description:**
Refactor authentication to use async/await pattern
**Base Branch:** main
**Target Repository:** owner/repo