mcpbeat Sign in

Optimize Agentic Workflow Agent Skill

Analyze and reduce token consumption in agentic workflows — guardrail-specific entry points, measurement, and optimization techniques.

1k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
4864
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/github/gh-aw --skill optimize-agentic-workflow

The instruction itself

12 sections, as written by the author

Agentic Workflow Token Optimizer

Help users reduce the AI token usage and cost of GitHub Agentic Workflows in this repository.

Load These References First

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.md

Load these only when relevant:

  • .github/aw/experiments.md
  • .github/aw/safe-outputs.md

Available Commands

gh 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

Start the Conversation

Ask for one of these inputs:

  • a workflow run URL (or run ID) to analyze
  • a workflow name to review the source
  • the guardrail that was exceeded (max-ai-credits, max-daily-ai-credits, max-tool-denials, max-turns / timeout)

Fast Path: Run URL Provided

If the user gives a GitHub Actions run URL:

  • Extract the run ID
  • Run gh aw audit <run-id> --json
  • Inspect agent_usage.aic, agent_usage.input_tokens, agent_usage.output_tokens, agent_usage.cache_read_tokens
  • Identify the most expensive phases before asking additional questions

Guardrail-Specific Entry Points

max-ai-credits exceeded

The workflow was stopped because it consumed more AI Credits than the configured per-run budget.

Priority checks:

  • Which tool calls dominated token usage? (token-usage.jsonl)
  • Is the prompt front-loading large payloads that could be fetched on demand?
  • Are there repetitive extraction steps that sub-agents could handle cheaply?
  • Does the frontier model handle tasks that a small model could do?

max-daily-ai-credits exceeded

The workflow is being blocked because its 24-hour AI Credits budget is exhausted.

Priority checks:

  • What is the run cadence? (scheduled too frequently?)
  • Does the workflow use cheap triage before escalating to the frontier model?
  • Is batching or caching applicable to reduce run frequency?
  • Are there noop early-exits for events that do not require agent action?

max-tool-denials exceeded

The Copilot SDK hit the tool-denial threshold, indicating the prompt attempted actions outside the allowed tool policy.

Priority checks:

  • What tool was repeatedly denied? (last denied reason in the failure issue)
  • Is the tool missing from the workflow's permissions/firewall config?
  • Can the prompt be revised to avoid the denied operation entirely?
  • Would a DataOps pre-step satisfy the data need without a tool call?

Timeout / max-turns exceeded

The agent ran out of time or turns before completing the task.

Priority checks:

  • Is the task decomposable into smaller, faster sub-tasks?
  • Are there long-running tool calls that could be replaced with DataOps pre-steps?
  • Is the prompt asking the agent to do too much in one run?
  • Can max-turns or timeout-minutes be raised, or should the task be split?

Optimization Analysis Plan

After measuring token usage, produce a prioritized plan:

  • Measure — run gh aw audit <run-id> --json and summarize AI Credits and per-call token breakdown
  • Diagnose the harness — classify failures across context assembly, tool interaction, generation control, orchestration, memory management, and output processing
  • Identify top cost drivers — list the three most expensive phases/tool calls
  • Apply quick wins first — DataOps pre-steps, gh-proxy, cli-proxy, prompt trimming
  • Sub-agent delegation — identify repetitive per-item loops suitable for small-model workers
  • Reuse execution experience — preserve compact task features, configuration deltas, outcomes, costs, and diagnoses in cache-memory when cross-run reuse is useful; apply relevant recurring patterns to similar cases
  • Prompt caching — verify stable instructions and reusable experience appear before dynamic content
  • Experiment correctness first — add an experiments: entry, compare output quality first, and use metric: "aic" to choose among equivalent-quality variants
  • Validate quality — confirm the optimized run produces equivalent safe outputs

Present the plan clearly before making any edits. Confirm with the user before applying changes.

Editing Workflow

  • Edit .github/workflows/<workflow-name>.md
  • Recompile: gh aw compile <workflow-name>
  • Commit both the source and the generated .lock.yml
  • Report the estimated savings and link to the PR or commit

Other skills for the same job

different authors, same section of the catalogue
Doc Coauthoring
by anthropics
vendor ×10

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

4k tokens
File Organizer
by frostant
×10

Intelligently organizes your files and folders across your computer by understanding context, finding duplicates, suggesting better structures, and automating cleanup tasks. Reduces cognitive load and keeps your digital workspace tidy without manual effort.

3k tokens
Domain Name Brainstormer
by frostant
×8

Generates creative domain name ideas for your project and checks availability across multiple TLDs (.com, .io, .dev, .ai, etc.). Saves hours of brainstorming and manual checking.

1k tokens
Brainstorming
by ZhanlinCui
×4

You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.

626 tokens
Planning With Files
by ZhanlinCui
×3

Implements Manus-style file-based planning for complex tasks. Creates task_plan.md, findings.md, and progress.md. Use when starting complex multi-step tasks, research projects, or any task requiring >5 tool calls.

9k tokens scripts
Scientific Brainstorming
by christophacham
×3

Creative research ideation and exploration. Use for open-ended brainstorming sessions, exploring interdisciplinary connections, challenging assumptions, or identifying research gaps. Best for early-stage research planning when you do not have specific observations yet. For formulating testable hypotheses from data use hypothesis-generation.

5k tokens
GitHub Project Management
by ComeOnOliver
×3

Comprehensive GitHub project management with swarm-coordinated issue tracking, project board automation, and sprint planning

14k tokens
Grill Me
by ComeOnOliver
×3

Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".

3k tokens

How to use it

Copy the folder

Take github/optimize-agentic-workflow from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

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.