github/optimize-agentic-workflow
Analyze and reduce token consumption in agentic workflows — guardrail-specific entry points, measurement, and optimization techniques.
npx skills add https://github.com/github/gh-aw --skill optimize-agentic-workflow
Help users reduce the AI token usage and cost of GitHub Agentic Workflows in this repository.
Load these files from github/gh-aw (they are not available locally).
.github/aw/github-agentic-workflows.md.github/aw/token-optimization.md.github/aw/workflow-editing.md.github/aw/syntax.mdLoad these only when relevant:
.github/aw/experiments.md.github/aw/safe-outputs.mdgh aw audit <run-id> --json
gh aw audit <base-run-id> <optimized-run-id>
gh aw logs <workflow-name> --json
gh aw compile <workflow-name>
gh aw status
Ask for one of these inputs:
If the user gives a GitHub Actions run URL:
gh aw audit <run-id> --jsonagent_usage.aic, agent_usage.input_tokens, agent_usage.output_tokens, agent_usage.cache_read_tokensmax-ai-credits exceededThe workflow was stopped because it consumed more AI Credits than the configured per-run budget.
Priority checks:
token-usage.jsonl)max-daily-ai-credits exceededThe workflow is being blocked because its 24-hour AI Credits budget is exhausted.
Priority checks:
max-tool-denials exceededThe Copilot SDK hit the tool-denial threshold, indicating the prompt attempted actions outside the allowed tool policy.
Priority checks:
max-turns exceededThe agent ran out of time or turns before completing the task.
Priority checks:
max-turns or timeout-minutes be raised, or should the task be split?After measuring token usage, produce a prioritized plan:
gh aw audit <run-id> --json and summarize AI Credits and per-call token breakdowngh-proxy, cli-proxy, prompt trimmingcache-memory when cross-run reuse is useful; apply relevant recurring patterns to similar casesexperiments: entry, compare output quality first, and use metric: "aic" to choose among equivalent-quality variantsPresent the plan clearly before making any edits. Confirm with the user before applying changes.
.github/workflows/<workflow-name>.mdgh aw compile <workflow-name>.lock.ymlTake github/optimize-agentic-workflow from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.