ax-agent-optimize

ax-agent-optimize is a skill for Claude Code, Codex from dosco/aithy. It costs 57 tokens per session (4,156 once invoked), scanned A, original, Apache-2.0.

Guidance for improving an AxAgent, a TypeScript framework for AI agents, through evaluation tasks. It covers judging results, measuring tool use, saving improvements, and loading them later.

In plain words
What is it for?
Use it to set up agent optimisation, choose a judge or deterministic score, evaluate tool-using behaviour, improve response wording, and save reusable optimisation results.
Why use it?
It helps you tune an already working agent against defined examples and criteria instead of changing prompts without measuring the result. The evaluation can expose trade-offs such as cost, delegation, or tool use.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/dosco/aithy/ax-agent-optimize
Any agent
npx skills add dosco/aithy --skill ax-agent-optimize
Clone the repo
git clone --depth 1 https://github.com/dosco/aithy

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ax-agent-optimize

README.md
[![agentmods](https://agentmods.dev/badge/skills/dosco/aithy/ax-agent-optimize.svg)](https://agentmods.dev/skills/dosco/aithy/ax-agent-optimize)
Your own site
<a href="https://agentmods.dev/skills/dosco/aithy/ax-agent-optimize"><img src="https://agentmods.dev/badge/skills/dosco/aithy/ax-agent-optimize.svg" alt="Measured on agentmods" height="20"></a>
Per session 57 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 4,156 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00057 $0.04156
Opus 5 $0.00028 $0.02078
Sonnet 5 $0.00011 $0.00831
Haiku 4.5 $0.00006 $0.00416

Measured today against content hash 2cee84aa66ee, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ax-agent-optimize scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/skills/ax-agent-optimize/SKILL.md · 369 lines

How it starts

The opening of the file, as written. The whole thing — 369 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AxAgent Optimize Codegen Rules (@ax-llm/ax)

Use this skill for agent.optimize(...) workflows. Prefer short, modern, copyable patterns. Do not repeat general agent-authoring guidance unless the user needs it. For generic ax(...) or flow(...) tuning with top-level optimize(...), use the ax-gepa skill instead.

Your job is to help the model choose a good optimization setup for the user's actual goal:

  • If the user wants better tool use, prefer action-aware tasks and either a deterministic metric or the built-in judge depending on how objective the scoring is.
  • If the user wants better wording only, responder optimization may be enough.
  • If the user wants reusable improvements, include artifact save/load.
  • If the user wants cost, tool-use, or child-agent delegation behavior improved, make the eval tasks expose those tradeoffs explicitly.

Use These Defaults

  • Use agent.optimize(...) only after the agent is already configured and runnable.
  • Prefer the built-in judge path first for normal agent tuning. Most users should start with tasks that include input and criteria, then let agent.optimize(...) use its default actor target and judge-based metric.
  • Keep top-level optimize(program, train, metric, options) for non-agent generators and flows; do not rewrite normal agent task-record examples to the generic helper.
  • Prefer a deterministic custom metric only when success is easy to score from the prediction and task record.
  • Add judgeAI plus judgeOptions when the judge should run on a stronger or separate model than the agent runtime model.
  • Only reach for a plain typed AxGen evaluator when the user needs LLM-as-judge behavior outside the built-in agent.optimize(...) flow.
  • Default optimize target is the actor path; do not surface target unless the user clearly wants responder-only tuning or explicit program IDs.
  • Use eval-safe tools or in-memory mocks because optimization replays tasks many times.
  • Prefer precise tool return schemas such as f.object(...) over vague f.json(...) whenever the agent must reason about returned fields.
  • Prefer task wording with canonical entity names like "the Atlas project" instead of ambiguous labels like "Atlas" when ambiguity could trigger pointless clarification.
  • Save artifacts with axSerializeOptimizedProgram(result.optimizedProgram!), then restore with axDeserializeOptimizedProgram(saved) and agent.applyOptimization(...).
  • For browser-safe persistence, let the caller store the serialized JSON anywhere they want such as localStorage, IndexedDB, or a backend.
  • If bootstrap is enabled, bootstrapped demos are persisted inside result.optimizedProgram.demos; raw failed traces are not saved in v1.
  • Auto-promoted context fields (large undeclared inputs kept runtime-only by autoUpgrade) appear in captured traces/demos as their truncated preview string, not the full value — same as declared truncate-style contextFields. This is expected; do not treat the shortened value as a bug in the saved demos.
  • For first examples, pass a plain task array instead of splitting into train and validation unless the user already has a holdout set.
  • GEPA-backed agent.optimize(...) now optimizes generic components exposed by the selected target programs; target: 'actor' only tunes actor components, target: 'responder' only tunes responder components, and target: 'all' broadens the component set.
  • result.optimizedProgram.componentMap is the canonical saved artifact for agent GEPA runs. It may include actor instructions, descriptions, tool descriptions/names, templates, or runtime primitives depending on what the selected target exposes.
  • When child-agent delegation matters, expose the child agents as named functions and tune against realistic call/no-call tasks.

Read the full file on GitHub · 369 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +8 lines 2cee84aa66ee
  2. 4d ago First seen · 361 lines · 57 tokens per session scan A 1b65e7cc0e98

Subscribe to this mod's changes

ax-agent-optimize is a skill published in the GitHub repository dosco/aithy (107 stars, last pushed 3d ago), licensed Apache-2.0. It adds 57 tokens to every session and 4,156 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.