Agent skill

Ax Refine

by dosco in dosco/aithy

A skill your agent uses when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.

Apache-2.0Auto-check passed

Install Ax Refine

skills CLI
$ npx skills add dosco/aithy --skill ax-refine -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install dosco/aithy ax-refine --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/dosco/aithy.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/ax-refine .claude/skills/ax-refine && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
ax-refine
GitHub stars
107
Token cost
~868 tokens
SKILL.md length
315 words
Files
1
Skills in repo
17
Repo updated
First seen
Licence
Apache-2.0

At a glance

A skill your agent uses when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.

  • Reviewing Ax bestOfN/refine code
  • SKILL.md covers Validation And Assertions, APIs, Reward Functions and Strategies, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Reward functions

What it does

Ax Refine is an agent skill from dosco/aithy. Use this skill when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.

Its SKILL.md is about 870 tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

The repository describes itself as: A personal AI agent that can work safely on your machine, remember useful context, and keep its data under your control. The licence is Apache-2.0.

When your agent uses it

  • Reviewing Ax bestOfN/refine code
  • Reward functions
  • Native sample selection
  • Serial attempts

Example prompts

  • “/ax-refine”

What it can do on your machine

Read from SKILL.md and the folder at commit 0c9855f. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are typescript).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Ax Refine loads about 868 tokens when it runs. Until then it costs about 47 tokens; SKILL.md has 315 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~47
When it runs · the whole SKILL.md, loaded when a task matches
~868

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from dosco/aithy at commit 0c9855f, republished under its Apache-2.0 licence (© dosco). 315 words, ~868 tokens.

Download SKILL.mdSave it as .claude/skills/ax-refine/SKILL.md (or your agent's skills folder).
name
ax-refine
description
Use this skill when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.
version
24.0.16

Ax Refine And BestOfN

Use bestOfN(...) when you can score complete outputs independently. Use refine(...) when failed rounds should produce feedback that changes the next attempt.

Validation And Assertions

Keep reward scoring, whole-output assertions, and streaming assertions separate:

  • Use schema validation for shape, types, and field-level constraints.
  • Use addAssert(...) for whole-output hard invariants. Failed assertions feed correction text into the normal retry loop.
  • Use addStreamingAssert(...) for partial streaming hard invariants. It aborts the current stream attempt as soon as the partial field fails, then feeds correction text into the normal retry loop.
  • Use bestOfN(...) for complete-candidate selection.
  • Use refine(...) for reward-scored retry rounds with generated feedback.

APIs

typescript
import { bestOfN, refine } from '@ax-llm/ax';

const selected = bestOfN(program, {
  n: 4,
  threshold: 0.8,
  rewardFn: ({ input, prediction, traces, chatLog }) => score(prediction),
});

const improved = refine(program, {
  rounds: 3,
  samplesPerRound: 2,
  threshold: 0.85,
  rewardDescription: 'Prefer complete, grounded, concise answers.',
  rewardFn: ({ prediction }) => score(prediction),
});

Rules:

  • forward(...) returns the selected prediction.
  • streamingForward(...) is unsupported; score complete outputs instead.
  • getUsage() aggregates usage across attempts.
  • getTraces() and getChatLog() return the selected attempt's diagnostics.
  • getAttempts() returns all attempt metadata, including reward, errors, and advice application.

Reward Functions

Reward functions return a number. Higher is better. A threshold marks a good-enough candidate and can stop serial attempts early.

typescript
const rewardFn = ({ prediction }) => {
  const exact = prediction.answer === 'Paris' ? 1 : 0;
  const concise = prediction.answer.length < 80 ? 0.2 : 0;
  return exact + concise;
};

Use serial strategy when the reward needs traces, chat logs, tools, or full flow behavior.

Strategies

  • strategy: "auto" uses native samples for AxGen and serial attempts for composite programs.
  • strategy: "native-samples" uses sampleCount and a reward-backed resultPicker; candidate context includes outputs, not full per-candidate traces.
  • strategy: "serial" runs isolated full-program attempts with fresh memory/session IDs.

Refine Advice

refine(...) generates advice after a below-threshold round. Advice is appended temporarily to matching kind: "instruction" components exposed by getOptimizableComponents() and applied through applyOptimizedComponents().

Rules:

  • Original instruction values are restored in finally, on success and error.
  • Programs without instruction components continue as best-of-N rounds and mark adviceApplied: false.
  • Do not add DSPy-style hint_ signature fields; Ax uses instruction-component advice.

Streaming

Do not use refine(...) for streaming. For partial-output safety, use addStreamingAssert(fieldName, fn, message?) on AxGen. Streaming assertions fail fast within the current attempt with AxStreamingAssertionError, then retry with correction feedback when retries remain.

© dosco, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .claude/skills/ax-refine of dosco/aithy.

Open the folder on GitHubat commit 0c9855f

Compare with similar skills

Ax Refine next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Ax Refine compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Ax Refine this skilldosco/aithy107—~868Automated safety check: PassApache-2.0
Agent Refinementruvnet/ruflo74k2 repos~3.5kAutomated safety check: PassMIT
Refinewindmill-labs/windmill18k—~420Automated safety check: PassCustom licence
Refiner AutomationComposioHQ/awesome-claude-skills77k3 repos~730Automated safety check: PassNone
Sparc Refineruvnet/ruflo74k—~1.5kAutomated safety check: NotesMIT
Refine Promptpenpot/penpot61k—~1.6kAutomated safety check: PassMPL-2.0

Similar skills

  • Agent Refinement

    ruvnet/ruflo

    Agent skill for refinement - invoke with $agent-refinement. An agent skill from ruvnet/ruflo.

    74k GitHub starsUsed in 2 repos~3.5k tokens
    DevelopmentAuto-check passed
  • Refine

    windmill-labs/windmill

    End-of-session reflection. An agent skill from windmill-labs/windmill.

    18k GitHub stars~420 tokensUpdated today
    Auto-check passed
  • Refiner Automation

    ComposioHQ/awesome-claude-skills

    Automate Refiner tasks via Rube MCP (Composio). An agent skill from ComposioHQ/awesome-claude-skills.

    77k GitHub starsUsed in 3 repos~730 tokens
    Productivity & AutomationAuto-check passed
  • Sparc Refine

    ruvnet/ruflo

    Run the SPARC Refinement and Completion phases — review code, improve test coverage, validate against specification, and generate documentation

    74k GitHub stars~1.5k tokensUpdated today
    Testing & QAAuto-check: notes
  • Refine Prompt

    penpot/penpot

    Refine and improve a user-supplied prompt for maximum clarity and effectiveness using prompt-engineering best practices and Penpot project context.

    61k GitHub stars~1.6k tokensUpdated today
    AI & LLM EngineeringAuto-check passed
  • Idea Refinement

    addyosmani/agent-skills

    Guides a conversation that takes a vague idea through divergent and convergent thinking and ends in a markdown one-pager covering scope and assumptions.

    103k GitHub starsUsed in 6 repos~2k tokens
    Agent WorkflowsAuto-check passed

More from dosco/aithy

All 17 skills in this repo
  • This skill helps an LLM generate correct AxAgent observability code using @ax-llm/ax.

    107 GitHub stars~4.4k tokensUpdated 1 mo ago
    Auto-check passed
  • This skill helps an LLM generate correct AxAgent tuning and evaluation code using @ax-llm/ax.

    107 GitHub stars~4.8k tokensUpdated 1 mo ago
    Auto-check passed
  • Ax Audio

    dosco/aithy

    This skill helps an LLM generate correct audio code with @ax-llm/ax.

    107 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check passed
  • Ax Gepa

    dosco/aithy

    This skill helps an LLM generate correct AxGEPA optimization code using @ax-llm/ax.

    107 GitHub stars~2.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Ax LLM

    dosco/aithy

    This skill helps with using the @ax-llm/ax TypeScript library for building LLM applications.

    107 GitHub stars~3.3k tokensUpdated 1 mo ago
    Auto-check passed
  • Ax MCP

    dosco/aithy

    This skill helps an LLM build correct native Model Context Protocol integrations with @ax-llm/ax.

    107 GitHub stars~4.4k tokensUpdated 1 mo ago
    Auto-check passed

Questions about Ax Refine

What does Ax Refine do?

A skill your agent uses when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics. Ax Refine is an agent skill from dosco/aithy. Use this skill when writing or reviewing Ax bestOfN/refine code, reward functions, thresholds, native sample selection, serial attempts, generated advice, and attempt diagnostics.

When should I use Ax Refine?

Ax Refine fits situations like: reviewing Ax bestOfN/refine code; reward functions; native sample selection; serial attempts.

How do I install Ax Refine in Claude Code?

Run `npx skills add dosco/aithy --skill ax-refine -a claude-code`. Or copy the skill folder (.claude/skills/ax-refine in dosco/aithy) into .claude/skills/ax-refine in your project. Claude Code loads it when a task matches its description.

How do I install Ax Refine in Codex?

Run `npx skills add dosco/aithy --skill ax-refine -a codex`. Or copy the skill folder (.claude/skills/ax-refine in dosco/aithy) into .agents/skills/ax-refine in your project. Codex loads it when a task matches its description.

Can I use Ax Refine in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add dosco/aithy --skill ax-refine -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/ax-refine, .gemini/skills/ax-refine, .github/skills/ax-refine and .opencode/skills/ax-refine in your project.

What does Ax Refine need to run?

SKILL.md names no scripts, command-line tools or credentials: Ax Refine is instructions for the agent only.

Does Ax Refine access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Ax Refine safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Ax Refine use?

Ax Refine is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Ax Refine use?

About 868 tokens (SKILL.md is roughly 3.5k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Ax Refine?

Skills that share tags, products or a category with Ax Refine: Agent Refinement (ruvnet/ruflo, 74k stars), Refine (windmill-labs/windmill, 18k stars), Refiner Automation (ComposioHQ/awesome-claude-skills, 77k stars) and Sparc Refine (ruvnet/ruflo, 74k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Ax Refine?

dosco (a GitHub user) maintains it in dosco/aithy, which has 107 GitHub stars. The repository holds 17 skills in this directory. The repository was last updated on August 31, 2026.

Source: dosco/aithy on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.