CLI Commands
This page lists available commands for managing agentic workflows with the GitHub CLI extension gh aw.
Installation
Section titled “Installation”gh extension install githubnext/gh-awQuick Start
Section titled “Quick Start”# Show version and helpgh aw versiongh aw --help
# Basic workflow lifecyclegh aw init # Initialize repository (first-time setup)gh aw add githubnext/agentics/ci-doctor # Add workflow and compile to GitHub Actionsgh aw compile # Recompile to GitHub Actionsgh aw trial githubnext/agentics/ci-doctor # Test workflow safely before addinggh aw trial ./my-workflow.md --use-local-secrets # Test local workflow with local API keysgh aw update # Update all workflows with source fieldgh aw status # Check statusgh aw run daily-perf # Execute workflowgh aw run daily-perf daily-plan # Execute multiple workflowsgh aw run daily-perf --repeat 10 # Execute workflow 10 timesgh aw logs daily-perf # View execution logsgh aw audit 12345678 # Audit a specific rungh aw pr transfer https://github.com/owner/repo/pull/123 # Transfer PR between repositoriesGlobal Flags
Section titled “Global Flags”--verbose/-v: Enable verbose output with debugging details--help/-h: Show help information
Debug Logging
Section titled “Debug Logging”Enable detailed debug logs using the DEBUG environment variable with pattern matching:
# Enable all debug logsDEBUG=* gh aw compile
# Enable specific package logs (e.g., CLI operations)DEBUG=cli:* gh aw compile
# Enable compiler logsDEBUG=workflow:* gh aw compile
# Enable multiple packagesDEBUG=cli:*,workflow:* gh aw compile
# Exclude specific patternsDEBUG=*,-workflow:test gh aw compile
# Disable colors (auto-disabled when piping)DEBUG_COLORS=0 DEBUG=* gh aw compileDebug logs show:
- Namespace: Category of the log (e.g.,
cli:compile_command,workflow:compiler) - Message: Debug information
- Time diff: Elapsed time since last log (e.g.,
+50ms,+2.5s) - Colors: Automatic color coding for each namespace (when in terminal)
When to use:
- Use
DEBUGfor internal diagnostic information and performance insights - Use
--verbosefor user-facing operational details - Debug logs are zero-overhead when disabled (no performance impact)
📝 Workflow Creation and Management
Section titled “📝 Workflow Creation and Management”The add and new commands help you create and manage agentic workflows, from templates and samples to completely custom workflows.
Repository Initialization
Section titled “Repository Initialization”The init command prepares your repository for agentic workflows by configuring .gitattributes and creating GitHub Copilot custom instructions:
gh aw initgh aw init --mcp # Configure GitHub Copilot Agent MCP integrationWhat it does:
- Configures
.gitattributesto mark.lock.ymlfiles as generated - Creates GitHub Copilot custom instructions at
.github/instructions/github-agentic-workflows.instructions.md - Creates the
/create-agentic-workflowprompt at.github/prompts/create-agentic-workflow.prompt.md
With --mcp flag:
- Creates
.github/workflows/copilot-setup-steps.ymlwith steps to install the gh-aw extension - Creates
.vscode/mcp.jsonwith gh-aw MCP server configuration - Enables the gh-aw MCP server in GitHub Copilot Agent, providing tools like
status,compile,logs, andaudit
After initialization, start a chat with an AI agent and use the following prompt to create a new workflow:
activate @.github/prompts/create-agentic-workflow.prompt.mdAlternatively, add pre-built workflows from the catalog using gh aw add <workflow-name>.
Workflow Management
Section titled “Workflow Management”# Create new workflowsgh aw new my-custom-workflowgh aw new issue-handler --force
# Add workflows from samples repositorygh aw add githubnext/agentics/ci-doctorgh aw add githubnext/agentics/ci-doctor --name my-custom-doctor --pr --engine copilotgh aw add githubnext/agentics/ci-doctor --number 3 # Create 3 copiesgh aw add githubnext/agentics/ci-doctor --append "Extra content" # Append custom content
# Remove workflowsgh aw remove WorkflowNamegh aw remove WorkflowName --keep-orphans # Keep shared includesWorkflow Updates:
Update workflows from external repositories using the source field in frontmatter:
gh aw update # Update all workflows with source fieldgh aw update ci-doctor issue-triage # Update specific workflowsgh aw update ci-doctor --major --force # Allow major version updatesgh aw update --verbose --engine copilot # Override engineUpdate Logic:
Updates based on the source field format: owner/repo/path/to/workflow.md@ref
- Semantic Version Tags (
v1.2.3): Updates within same major version (use--majorfor major updates) - Branch References (
main): Fetches latest commit from specified branch - No Reference: Uses repository’s default branch
The update performs a 3-way merge using git merge-file, preserving local modifications while applying upstream changes. When conflicts occur, diff3-style markers are added for manual resolution, and recompilation is skipped until resolved.
🔧 Workflow Recompilation
Section titled “🔧 Workflow Recompilation”Transforms markdown workflow files into executable GitHub Actions YAML files:
# Core compilationgh aw compile # Compile all workflowsgh aw compile ci-doctor daily-plan # Compile specific workflowsgh aw compile --validate --no-emit # Validate schema and containers without generating filesgh aw compile --strict --engine copilot # Strict mode with custom enginegh aw compile --purge # Remove orphaned .lock.yml files
# Development featuresgh aw compile --watch --verbose # Auto-recompile on changesgh aw compile --workflows-dir custom/ # Custom workflows directory
# Security scanninggh aw compile --zizmor # Run security scanner on compiled workflowsgh aw compile --strict --zizmor # Strict mode with security scanning (fails on findings)
# Dependency managementgh aw compile --dependabot # Generate dependency manifestsgh aw compile --dependabot --force # Force overwrite existing files
# Security scanninggh aw compile --zizmor # Run zizmor security scanner on compiled workflowsgh aw compile --strict --zizmor # Strict mode: treat zizmor findings as errorsValidation:
The --validate flag enables GitHub Actions workflow schema validation and container image validation. By default, validation is disabled for faster compilation. Enable it when you need to verify workflow correctness or validate that container images exist and are accessible.
Security Scanning:
The --zizmor flag runs the zizmor security scanner on generated .lock.yml files after compilation. Zizmor identifies security issues such as template injection vulnerabilities, dangerous permissions, and other workflow security risks. When findings are detected, they are displayed with file locations and descriptions, but compilation succeeds by default. Use with --strict to treat security findings as compilation errors.
Strict Mode:
Enables enhanced security validation requiring timeouts, explicit network configuration, and blocking write permissions. When combined with --zizmor, strict mode treats any zizmor security findings as compilation errors, requiring workflows to have zero security warnings before they can be deployed. Use --strict flag or strict: true in frontmatter.
Repository Feature Validation:
The compile command validates that workflows using create-discussion, create-issue, or add-comment with discussions are compatible with the target repository. Compilation fails if:
- Workflows use
create-discussionbut the repository doesn’t have discussions enabled - Workflows use
create-issuebut the repository doesn’t have issues enabled
Enable discussions or issues in repository settings, or remove the incompatible safe-outputs from workflows.
Dependency Manifest Generation:
The --dependabot flag scans workflows for package dependencies and generates manifest files for automated security updates:
- npm: Creates
package.jsonandpackage-lock.jsonfor packages used withnpx(requires npm in PATH) - pip: Creates
requirements.txtfor Python packages installed viapip installorpip3 install - Go: Creates
go.modfor Go packages installed viago installorgo get
The command creates or updates .github/dependabot.yml to enable Dependabot monitoring for all detected ecosystems. Existing manifests are merged intelligently to preserve manual entries. Use --force to overwrite the Dependabot configuration file if needed.
# Scan workflows and generate manifests for detected dependenciesgh aw compile --dependabot
# Force overwrite of existing dependabot.yml configurationgh aw compile --dependabot --forceSecurity Scanning with Zizmor:
The --zizmor flag runs the zizmor security scanner on generated .lock.yml files to identify potential security vulnerabilities in compiled workflows. Zizmor analyzes workflows for excessive permissions, insecure practices, workflow misconfigurations, and supply chain risks.
Security findings are displayed in IDE-parseable format with clickable file locations and documentation URLs:
./.github/workflows/workflow.lock.yml:7:5: warning: [Medium] excessive-permissions: overly broad permissions (https://docs.zizmor.sh/audits/#excessive-permissions)5 | steps:6 | - uses: actions/checkout@v47 | permissions: ^^^^^^^^^^^^^8 | contents: write9 | issues: writeEach finding includes a direct link to the zizmor documentation explaining the security issue and how to resolve it.
Verbose Output:
When using --verbose with --zizmor, the Docker command used to run zizmor is displayed before execution, enabling manual reproduction:
gh aw compile --zizmor --verboseExample verbose output:
ℹ Run zizmor directly: docker run --rm -v "/repo:/workdir" -w /workdir ghcr.io/zizmorcore/zizmor:latest --format json .github/workflows/workflow.lock.ymlStrict Mode Enforcement:
When combined with --strict, security findings block compilation, ensuring workflows meet security standards before deployment:
# Security scanning with enforcementgh aw compile --strict --zizmor # Fails if security issues foundIn non-strict mode, findings are reported as warnings but do not prevent compilation.
Requirements:
- Docker must be installed and running
- The scanner runs
ghcr.io/zizmorcore/zizmor:latestin a container - Scans each generated
.lock.ymlfile independently
⚙️ Workflow Operations on GitHub Actions
Section titled “⚙️ Workflow Operations on GitHub Actions”These commands control the execution and state of your compiled agentic workflows within GitHub Actions.
Workflow Execution
Section titled “Workflow Execution”gh aw run WorkflowName # Run single workflowgh aw run WorkflowName1 WorkflowName2 # Run multiple workflowsgh aw run WorkflowName --repeat 3 # Run 3 times totalgh aw run workflow --use-local-secrets # Use local API keys for executiongh aw run weekly-research --enable-if-needed --input priority=highTrial Mode
Section titled “Trial Mode”Test workflows safely in a temporary private repository without affecting your target repository:
gh aw trial githubnext/agentics/ci-doctor # Test from source repogh aw trial ./my-local-workflow.md # Test local filegh aw trial workflow1 workflow2 # Compare multiple workflowsgh aw trial ./workflow.md --use-local-secrets # Use local API keys for trialgh aw trial ./workflow.md --logical-repo myorg/myrepo --host-repo myorg/host-repo # Act as if in a different logical repo. Uses PAT to see issues/PRsgh aw trial ./workflow.md --clone-repo myorg/myrepo --host-repo myorg/host-repo # Copy the code of the clone repo for into host repo. Agentic will see the codebase of clone repo but not the issues/PRs.gh aw trial ./workflow.md --append "Extra content" # Append custom content to workflow
# Test issue-triggered workflows with contextgh aw trial ./issue-workflow.md --trigger-context https://github.com/owner/repo/issues/123gh aw trial githubnext/agentics/issue-triage --trigger-context "#456"
Other flags: --engine ENGINE # Override engine (default: from frontmatter) --auto-merge-prs # Auto-merge PRs created during trial --use-local-secrets # Use local environment API keys (pushes/cleans up secrets) --repeat N # Repeat N times --force-delete-host-repo-before # Force delete existing host repo BEFORE start --delete-host-repo-after # Delete host repo AFTER trial --append TEXT # Append extra content to workflow filesTrial results are saved to trials/ directory and captured in the trial repository for inspection. Set GH_AW_GITHUB_TOKEN to override authentication. See the Security Guide.
When using gh aw trial --logical-repo, the agentic workflow operates as if it is running in the specified logical repository, allowing it to read issues, pull requests, and other repository data from that context. This is useful for testing workflows that interact with repository data without needing to run them in the actual target repository. In this mode, to recompile workflows in the trial repository, use gh aw compile --trial --logical-repo owner/repo.
When using gh aw trial --clone-repo, the agentic workflow uses the codebase from the specified clone repository while still interacting with issues and pull requests from the host repository. This allows for testing how the workflow would behave with a different codebase while maintaining access to the relevant repository data.
Using Local API Keys
Section titled “Using Local API Keys”Both run and trial commands support the --use-local-secrets flag to automatically push required API key secrets from your local environment to the repository before execution:
gh aw run my-workflow --use-local-secrets # Use local API keys for rungh aw trial ./workflow.md --use-local-secrets # Use local API keys for trialHow it works:
- Reads API keys from environment variables (
ANTHROPIC_API_KEY,OPENAI_API_KEY,COPILOT_CLI_TOKEN, etc.) - Temporarily pushes the required secrets to the repository before workflow execution
- Automatically cleans up (deletes) the secrets after completion
- Only pushes secrets that are actually needed by the workflow’s AI engine
When to use:
- Testing workflows that require AI engine secrets not yet configured in the repository
- Trial mode when you want to test with your local API keys
- Development environments where you don’t want to permanently store secrets
Security notes:
- Secrets are only pushed temporarily and are cleaned up automatically
- Use with caution in shared or production repositories
- Consider using repository secrets for permanent deployments
Workflow State Management
Section titled “Workflow State Management”gh aw status [WorkflowPrefix] # Show workflow statusgh aw enable [WorkflowPrefix] # Enable workflowsgh aw disable [WorkflowPrefix] # Disable and cancel workflowsStatus shows workflow names, enabled/disabled state, execution status, and compilation status. Enable/disable commands support pattern matching.
Log Analysis and Monitoring
Section titled “Log Analysis and Monitoring”Download and analyze workflow execution history with performance metrics, cost tracking, and error analysis:
gh aw logs [workflow-name] -o ./analysis # Download logsgh aw logs -c 10 --start-date -1w --end-date -1dgh aw logs --engine claude --branch maingh aw logs --after-run-id 1000 --before-run-id 2000gh aw logs --no-staged --tool-graph # Exclude staged runs, generate Mermaid graphgh aw logs --parse --verbose --json # Parse logs to markdown, output JSONgh aw logs --timeout 60 # Limit execution to 60 secondsTimeout Option:
The --timeout flag limits log download execution time (in seconds). When the timeout is reached, the command processes already-downloaded runs and returns partial results. Set to 0 for no timeout (default). The MCP server uses a 50-second default timeout automatically.
Caching and Performance:
Downloaded runs are cached with a run_summary.json file in each run folder. Subsequent logs commands reuse cached data for faster reprocessing (~10-100x faster), unless the CLI version changes.
Metrics include execution duration, token consumption, costs, success/failure rates, and resource usage trends.
Log Parsing and JSON Output:
--parse: Generateslog.mdandfirewall.mdfiles with tool calls, reasoning, execution details, and network access patterns extracted by engine-specific parsers--json: Outputs structured JSON with summary metrics, runs, tool usage, missing tools, MCP failures, access logs, and firewall analysis
Single Run Audit
Section titled “Single Run Audit”Generate concise markdown reports for individual workflow runs with smart permission handling:
gh aw audit 12345678 # By run IDgh aw audit https://github.com/owner/repo/actions/runs/123 # By URL from any repogh aw audit https://github.example.com/org/repo/runs/456 # GitHub Enterprise URLgh aw audit 12345678 -o ./audit-reports -vgh aw audit 12345678 --parse # Parse logs to markdownURL Support:
The audit command accepts workflow run URLs from any repository and GitHub instance:
- Standard URLs:
https://github.com/owner/repo/actions/runs/12345 - Workflow run URLs:
https://github.com/owner/repo/runs/12345 - Job URLs:
https://github.com/owner/repo/actions/runs/12345/job/98765 - GitHub Enterprise:
https://github.example.com/org/repo/actions/runs/99999
Options:
--parse: Generates detailedlog.mdandfirewall.mdfiles with tool calls, reasoning, and network access patterns extracted by engine-specific parsers
The audit command checks local cache first (logs/run-{id}), then attempts download. On permission errors, it provides MCP server instructions for artifact downloads. Reports include overview, metrics, tool usage, MCP failures, firewall analysis, and available artifacts.
MCP Server Management
Section titled “MCP Server Management”Discover, list, inspect, and add Model Context Protocol (MCP) servers. See MCPs Guide and MCP Server Guide.
# Discovery and listinggh aw mcp list [workflow-name] [--verbose]gh aw mcp list-tools github [ci-doctor] [--verbose]
# Inspection and testinggh aw mcp inspect [workflow-name] [--server server-name] [--tool tool-name]gh aw mcp inspect workflow-name --inspector # Launch web inspector
# Add from registrygh aw mcp add # List available serversgh aw mcp add ci-doctor makenotion/notion-mcp-server --transport stdio --tool-id my-notiongh aw mcp add ci-doctor server-name --registry https://custom.registry.com/v1Features include server connection testing, tool capability analysis, multi-protocol support (stdio, Docker, HTTP), and automatic compilation.
🔄 Repository Utilities
Section titled “🔄 Repository Utilities”Pull Request Transfer
Section titled “Pull Request Transfer”Transfer pull requests between repositories, preserving code changes, title, and description:
# Transfer PR to current repositorygh aw pr transfer https://github.com/source-owner/source-repo/pull/234
# Transfer PR to specific repositorygh aw pr transfer https://github.com/source-owner/source-repo/pull/234 --repo target-owner/target-repo
# Verbose output for debugginggh aw pr transfer https://github.com/source-owner/source-repo/pull/234 --verboseHow it works:
- Fetches PR details - Title, body/description, author, and code changes
- Creates patch - Uses
gh pr diffto generate a unified patch file - Applies changes - Creates new branch in target repository with squashed commit
- Creates PR - New pull request with original title, description, and attribution
Requirements:
- GitHub CLI (
gh) must be authenticated - Write access to target repository (for creating branches and PRs)
- Read access to source repository (for fetching PR details)
The transferred PR includes attribution showing the original PR URL and author in the description.
MCP Server for gh aw
Section titled “MCP Server for gh aw”Run gh-aw as an MCP server exposing CLI commands (status, compile, logs, audit) as tools for AI agents:
gh aw mcp-server # stdio transport (local CLI)gh aw mcp-server --port 3000 # HTTP/SSE transport (workflows)gh aw mcp-server --cmd ./gh-aw --port 3000Uses subprocess architecture for token isolation. Import with shared/mcp/gh-aw.md in workflows. See MCP Server Guide.
👀 Watch Mode for Development
Section titled “👀 Watch Mode for Development”Auto-recompile workflows on file changes. See Authoring in VS Code.
gh aw compile --watch [--verbose]Related Documentation
Section titled “Related Documentation”- Packaging and Updating - Complete guide to adding, updating, and importing workflows
- Workflow Structure - Directory layout and file organization
- Frontmatter - Configuration options for workflows
- Safe Outputs - Secure output processing including issue updates
- Tools - GitHub and MCP server configuration
- Imports - Modularizing workflows with includes