Skip to content
Skill

Optimize loop

Use when the user wants to iteratively improve an artifact under a hard correctness bound while minimizing a measured cost — refactoring a c

Install
Scripts
Python
Platforms
Claude Code, Codex, Cursor
GitHub stars
183
Last commit
5 months ago
License
MIT
Listing updated
today

When your agent uses it

Use when the user wants to iteratively improve an artifact under a hard correctness bound while minimizing a measured cost — refactoring a code module to cut complexity while its test suite stays green, OR speeding up a SQL query while it returns the same rows. Each iteration applies one focused change, checks a correctness gate that must pass, measures a metric that must drop, and keeps the change only if both hold, else reverts; loops to a plateau or budget. Not for adding features, fixing bugs, or any change that is allowed to alter behaviour or results.

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 5 files (20 KB) on GitHub on 17 November 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Install

This skill ships in the agent-loops plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add gaasher/Agent-Loop-Skills
/plugin install agent-loops@agent-loop-skills

Or copy only this skill to ~/.claude/skills/optimize-loop:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/gaasher/Agent-Loop-Skills.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/optimize-loop &&
cp -R "$tmp/loops/optimize-loop" ~/.claude/skills/optimize-loop &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/optimize-loop inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/optimize-loop to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/gaasher/Agent-Loop-Skills.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/optimize-loop &&
cp -R "$tmp/loops/optimize-loop" ~/.agents/skills/optimize-loop &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/optimize-loop inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/optimize-loop to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/gaasher/Agent-Loop-Skills.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/optimize-loop &&
cp -R "$tmp/loops/optimize-loop" ~/.cursor/skills/optimize-loop &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/optimize-loop inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/gaasher/Agent-Loop-Skills.git --path loops/optimize-loop

Or copy the folder to ~/.gemini/skills/optimize-loop yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/optimize-loop:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/gaasher/Agent-Loop-Skills.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/optimize-loop &&
cp -R "$tmp/loops/optimize-loop" ~/.copilot/skills/optimize-loop &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/optimize-loop inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/gaasher/Agent-Loop-Skills.git

Then copy Agent-Loop-Skills/loops/optimize-loop into your agent's skills folder as optimize-loop. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

Optimize loop FAQ

How do I install Optimize loop in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/optimize-loop to use it in all your projects, or to .claude/skills/optimize-loop in one project. Or install the agent-loops plugin, which includes it: /plugin marketplace add gaasher/Agent-Loop-Skills, then /plugin install agent-loops@agent-loop-skills.

Does Optimize loop run scripts?

Yes. It runs Python scripts. Its scripts contain network calls. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Optimize loop?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

More from gaasher/Agent-Loop-Skills

  1. Use when the user wants to evolve an ML model/program through population-based search rather than a single sequential refine loop — a genera

    • Open source
    • 183 GitHub stars
  2. Use when the user has a known, already-observed anomaly in their data — a metric spike or drop, an outlier, an unexpected number — and wants

    • Open source
    • 183 GitHub stars
  3. Use when the user has concrete failing cases in code or a guardrail/classifier/filter/prompt/API they own — a red-team failure catalogue OR

    • Open source
    • 183 GitHub stars
    • Developer tools
  4. Use when the user has a results draft or a set of data-backed claims and wants each one adversarially verified against the underlying datase

    • Open source
    • 183 GitHub stars
  5. Use when the user wants an iterative, self-checking exploratory analysis of a dataset — surfacing findings that are each verified by re-runn

    • Open source
    • 183 GitHub stars
    • Analytics and data
  6. Use when the user wants two approaches raced head-to-head on a single shared metric — e.g

    • Open source
    • 183 GitHub stars