Agent skill

Prompt Optimize

by gaasher in gaasher/Agent-Loop-Skills

A skill your agent uses when the user has a prompt that feeds a system they can already score, and wants that prompt automatically improved to raise the score against their own evaluation command.

MITAuto-check passedAI & LLM Engineering

Install Prompt Optimize

skills CLI
$ npx skills add gaasher/Agent-Loop-Skills --skill prompt-optimize -a claude-code

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

GitHub CLI
$ gh skill install gaasher/Agent-Loop-Skills prompt-optimize --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/gaasher/Agent-Loop-Skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/loops/prompt-optimize .claude/skills/prompt-optimize && 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
prompt-optimize
GitHub stars
174
Token cost
~2.1k tokens
SKILL.md length
1,031 words
Files
2
Skills in repo
21
Repo updated
First seen
Licence
MIT

At a glance

A skill your agent uses when the user has a prompt that feeds a system they can already score, and wants that prompt automatically improved to raise the score against their own evaluation command.

  • Works in 5 steps: Diagnose. From the latest score, the… → Make one targeted edit — pick the… → Measure. Snapshot the edited prompt to… → …
  • The user has a prompt that feeds a system they can already score
  • SKILL.md covers When to use, Setup, The loop and Ledger, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Prompt Optimize is an agent skill from gaasher/Agent-Loop-Skills. Use when the user has a prompt that feeds a system they can already score, and wants that prompt automatically improved to raise the score against their own evaluation command. Makes one targeted quality edit per iteration — clarity, context, specificity, structure, examples, decomposition, guardrails — re-runs the user's eval to measure the metric, and keeps the edit only if the metric improves, else reverts; loops to a target, plateau, or budget. The metric is whatever the user's eval command prints (task…

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files (for example `examples/run.example.yaml`).

It sits in AI & LLM Engineering, covering LLM evaluation. The repository describes itself as: Loop until it's better — drop-in agentic loops (autoresearch, scientific writing, data analysis, code/SQL/prompt optimization, red-teaming) as open-standard Agent Skills… The licence is MIT.

When your agent uses it

  • The user has a prompt that feeds a system they can already score
  • Wants that prompt automatically improved to raise the score against their own evaluation command

Example prompts

  • “/prompt-optimize”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Diagnose. From the latest score, the feedback, and recent history, name the
  2. Make one targeted edit — pick the toolkit operator that addresses that weakness
  3. Measure. Snapshot the edited prompt to /iter/, run , and read the
  4. Keep or revert. Keep if the metric improves per (if the eval is stochastic,
  5. Escape local optima. If the score has not improved for a couple of iterations, stop making tiny

What it can do on your machine

Read from SKILL.md and the folder at commit f1169e6. 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.

    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

Prompt Optimize loads about 2.1k tokens when it runs. Until then it costs about 199 tokens; SKILL.md has 1,031 words of instructions outside code blocks.

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

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 gaasher/Agent-Loop-Skills at commit f1169e6, republished under its MIT licence (© gaasher). 1,031 words, ~2,099 tokens.

Download SKILL.mdSave it as .claude/skills/prompt-optimize/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
prompt-optimize
description
Use when the user has a prompt that feeds a system they can already score, and wants that prompt automatically improved to raise the score against their own evaluation command. Makes one targeted quality edit per iteration — clarity, context, specificity, structure, examples, decomposition, guardrails — re-runs the user's eval to measure the metric, and keeps the edit only if the metric improves, else reverts; loops to a target, plateau, or budget. The metric is whatever the user's eval command prints (task accuracy, an LLM-judge score, a pass rate, a tool-call success rate); the loop is metric-agnostic and never edits the eval. Not for writing a prompt from scratch, not for tuning model weights or hyperparameters, and not for one-off manual prompt edits without a score.
metadata.version
0.1.0

Prompt Optimize Loop

An evolutionary optimizer for a prompt (OpenEvolve / AlphaEvolve-style). The artifact is a prompt that feeds the user's system; the feedback signal is a scalar metric printed by the user's own evaluation command. Each iteration proposes one quality-focused edit, re-runs the eval, and keeps the edit only if the metric improves — evolving the prompt toward higher scores. The eval is a black-box oracle the loop runs but never edits, so the optimization tracks what actually matters rather than gaming a number.

When to use

Use this when the user has a prompt and a command that scores the system using it, and wants the prompt improved to raise that score. Default to diagnosing the prompt's biggest current weakness each round and applying the one operator that addresses it; if the eval feedback points elsewhere, follow the feedback. Not for authoring a prompt from nothing, tuning weights/hyperparameters, or making a single manual edit with no score to compare against.

Setup

Resolve bindings interactively. If loop.run.yaml exists in the working dir, load it, confirm the values in one line, and skip to the loop. Otherwise: on Claude Code (the AskUserQuestion tool is available) infer a likely value for each binding and present it as the recommended option; on other hosts ask each as a quoted plain-text prompt. Then write loop.run.yaml (format: examples/run.example.yaml) and confirm the values before creating any other files.

bindingmeaningdefaulthow to infer
<prompt_file>the prompt to optimize — the artifact the loop evolves—scan the working dir for the prompt/template file the eval reads
<eval_cmd>required. Command that scores the current <prompt_file>; prints the metric (see output convention below). Treated as a black box — never edited—ask the user; look for eval/score/bench scripts
<objective>maximize or minimize, plus one line on what the metric measuresmaximizeask the user
<target>optional score at which to stop early—ask the user; else leave unbound
<sandbox_root>where prompt snapshots + ledger live./sandbox—
<budget>max iterations10—
<patience>stop after N consecutive non-improving iterations (plateau)3—

Eval output convention. <eval_cmd> must print, on its last line, either a JSON object {"score": <number>, "feedback": "<optional notes/errors>", ...any extra metrics...} or a bare number. Higher is better unless <objective> is minimize. The feedback field, when present, is the richest signal — read it like AlphaEvolve's artifacts side-channel to decide the next edit.

Eval runs in the user's environment. <eval_cmd> may call an inference endpoint or any tooling the user has installed; the loop just shells out and reads the last line. If instead the prompt is executed by you (interactive development with no separate endpoint), first run the current prompt over the user's eval inputs to produce outputs, write them where <eval_cmd> reads, then run <eval_cmd> to score them.

The loop

Copy this checklist and tick items off:

  • Iteration 0 — baseline: run <eval_cmd> on <prompt_file>, record its score as the current best, snapshot the prompt.
  • Diagnose the prompt's single biggest weakness from the latest score, the eval feedback, and the history.
  • Apply one targeted edit (one operator from the toolkit) to <prompt_file>.
  • Measure: re-run <eval_cmd> and read the new score from its last line.
  • Keep if the metric improves (require a margin if the eval is stochastic), else revert to the best snapshot.
  • Append a ledger row; if stuck, branch from an earlier high-scoring variant; stop on <target>, plateau (<patience>), or <budget>.

Iteration 0 — baseline. Run <eval_cmd>, record its score as the best, snapshot <prompt_file> to <sandbox_root>/iter0/, and start the history ({iter, edit, score, feedback} per row).

Then, until stop (target, plateau, or budget):

  1. Diagnose. From the latest score, the <eval_cmd> feedback, and recent history, name the prompt's single biggest current weakness — the one thing most likely holding the metric back.

  2. Make one targeted edit — pick the toolkit operator that addresses that weakness:

    • Clarity — remove ambiguity, contradictions, and vague wording.
    • Context — supply missing domain knowledge, definitions, or background the task needs.
    • Specificity — make instructions concrete; pin down the output format; define what "good" is.
    • Structure — order the prompt into steps/sections; add a short checklist.
    • Examples — add one or two demonstrations of the desired input → output.
    • Decomposition — split a complex instruction into explicit ordered sub-steps.
    • Guardrails — state edge cases and what to avoid.

    One change per iteration, so its effect on the metric is attributable.

  3. Measure. Snapshot the edited prompt to <sandbox_root>/iter<N>/, run <eval_cmd>, and read the new score off the last line.

  4. Keep or revert. Keep if the metric improves per <objective> (if the eval is stochastic, require a small margin so noise alone does not drive a keep); otherwise revert <prompt_file> to the previous best snapshot. Append {edit, score, feedback} to the history either way.

  5. Escape local optima. If the score has not improved for a couple of iterations, stop making tiny tweaks — branch from an earlier high-scoring snapshot, or try a bolder restructuring (a different decomposition, a fresh set of examples). Diversity beats grinding the same local hill.

Show full SKILL.md (208 more words)Show less

When stopping, restore the best prompt to <prompt_file> and report the score trajectory, which edits moved the metric (and which did not), and the final prompt.

Ledger

<sandbox_root>/ledger.tsv, tab-separated, never commas in the text. Header:

iter	score	status	edit

status ∈ {baseline, keep, revert}. Example (metric = task accuracy, maximize):

iter	score	status	edit
0	0.42	baseline	original prompt
1	0.61	keep	specificity: define each output label and the exact output format
2	0.61	revert	examples: add 3 few-shot demos — no metric gain
3	0.78	keep	context: add the domain rules the task assumes but never states

Report the best iteration, not necessarily the last.

Constraints

  • The metric is the user's. Never edit <eval_cmd>, its data, or its scoring — that games the number instead of improving the prompt, and the eval is the only ground truth the loop has.
  • Optimize the prompt only, and preserve the task's intent. Improve how the task is instructed, not what is being asked; do not tailor the prompt to exploit eval quirks that would break real use.
  • One edit per iteration, and compare the metric by re-running the full <eval_cmd>, not a single sample, so each score delta is attributable to that one edit.
  • Report the best variant, not the last. The sandbox is self-contained — no ../ escapes.
  • Do not pause the loop to ask whether to continue; run until target, plateau, or budget.

Stops

  • Target — the score reaches <target> (if set).
  • Plateau — no iteration improved the best for <patience> consecutive rounds (every non-improving iteration counts toward patience; a keep resets it).
  • Budget — <budget> iterations reached.

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

Files

SKILL.md and 1 other file in loops/prompt-optimize of gaasher/Agent-Loop-Skills.

  • SKILL.md
  • examples/run.example.yaml

Open the folder on GitHubat commit f1169e6

Compare with similar skills

Prompt Optimize 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.

Prompt Optimize compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Prompt Optimize this skillgaasher/Agent-Loop-Skills174—~2.1kAutomated safety check: PassMIT
LLM Benchmarking with lm-evaluation-harnessOrchestra-Research/AI-Research-SKILLs13k8 repos~3kAutomated safety check: PassMIT
Azure AI Projects Python SDKmicrosoft/skills3.1k6 repos~2.8kAutomated safety check: PassMIT
Fine-Tuning ExpertJeffallan/claude-skills12k1 repos~1.7kAutomated safety check: PassMIT
Looperksimback/looper710—~2.7kAutomated safety check: NotesMIT
Hugging Face Local Model Evalshuggingface/skills11k2 repos~1.6kAutomated safety check: PassApache-2.0

Similar skills

  • LLM Benchmarking with lm-evaluation-harness

    Orchestra-Research/AI-Research-SKILLs

    Runs lm-evaluation-harness to benchmark language models on academic suites such as MMLU, GSM8K and HumanEval, compare models and track training checkpoints.

    13k GitHub starsUsed in 8 repos~3k tokens
    AI & LLM EngineeringAuto-check passed
  • Official

    Reference for building on Microsoft Foundry with the azure-ai-projects Python SDK: project clients, versioned agents, evaluations, connections, datasets and indexes.

    3.1k GitHub starsUsed in 6 repos~2.8k tokens
    AI & LLM EngineeringAuto-check passed
  • Fine-Tuning Expert

    Jeffallan/claude-skills

    Guides LLM fine-tuning with LoRA and QLoRA through Hugging Face PEFT, from dataset validation and training checks to adapter merging, quantization and deployment.

    12k GitHub starsUsed in 1 repo~1.7k tokens
    AI & LLM EngineeringAuto-check passed
  • Looper

    ksimback/looper

    Scaffold a well-designed agent loop with best-practice coaching and a cross-model review council.

    710 GitHub stars~2.7k tokensUpdated 2 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Official

    Runs evaluations of Hugging Face Hub models on local hardware with inspect-ai or lighteval, and helps choose between vLLM, Transformers and accelerate backends.

    11k GitHub starsUsed in 2 repos~1.6k tokens
    AI & LLM EngineeringAuto-check passed
  • Agent Eval Engineering

    langchain-ai/langchain-skills

    Official

    Builds agent evaluations in stages: inspect the repository and traces, agree a Task Spec with you, then build, audit and run a Harbor task with an independent verifier.

    1.3k GitHub stars~4k tokensUpdated 3 days ago
    AI & LLM EngineeringAuto-check passed

More from gaasher/Agent-Loop-Skills

All 21 skills in this repo
  • Alpha Evolve

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user wants to evolve an ML model/program through population-based search rather than a single sequential refine loop — a generational evolution where parallel…

    174 GitHub starsUsed in 1 repo~3.4k tokens
    Auto-check passed
  • Karpathy

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user wants the LLM to do its own ML research: a fully-autonomous loop that hacks the training code, runs it, and keeps changes that lower a single scalar metric (e.g.

    174 GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check passed
  • Tournament Autoresearch

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user wants an autonomous ML research loop that pressure-tests competing ideas before spending compute — several research subagents each propose one architecture…

    174 GitHub starsUsed in 1 repo~3k tokens
    Auto-check passed
  • Dueling Autoresearch

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user wants two approaches raced head-to-head on a single shared metric — e.g.

    174 GitHub starsUsed in 1 repo~2.6k tokens
    Auto-check: warnings
  • Anomaly Investigation

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user has a known, already-observed anomaly in their data — a metric spike or drop, an outlier, an unexpected number — and wants its root cause diagnosed, not guessed.

    174 GitHub stars~2.1k tokensUpdated 3 mo ago
    Auto-check passed
  • Blue Team

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user has concrete failing cases in code or a guardrail/classifier/filter/prompt/API they own — a red-team failure catalogue OR a CI/CD test-failure report (failing…

    174 GitHub stars~3.6k tokensUpdated 3 mo ago
    Auto-check passed

Questions about Prompt Optimize

What does Prompt Optimize do?

A skill your agent uses when the user has a prompt that feeds a system they can already score, and wants that prompt automatically improved to raise the score against their own evaluation command. Prompt Optimize is an agent skill from gaasher/Agent-Loop-Skills. Use when the user has a prompt that feeds a system they can already score, and wants that prompt automatically improved to raise the score against their own evaluation command.

When should I use Prompt Optimize?

Prompt Optimize fits situations like: the user has a prompt that feeds a system they can already score; wants that prompt automatically improved to raise the score against their own evaluation command.

How do I install Prompt Optimize in Claude Code?

Run `npx skills add gaasher/Agent-Loop-Skills --skill prompt-optimize -a claude-code`. Or copy the skill folder (loops/prompt-optimize in gaasher/Agent-Loop-Skills) into .claude/skills/prompt-optimize in your project. Claude Code loads it when a task matches its description.

How do I install Prompt Optimize in Codex?

Run `npx skills add gaasher/Agent-Loop-Skills --skill prompt-optimize -a codex`. Or copy the skill folder (loops/prompt-optimize in gaasher/Agent-Loop-Skills) into .agents/skills/prompt-optimize in your project. Codex loads it when a task matches its description.

Can I use Prompt Optimize 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 gaasher/Agent-Loop-Skills --skill prompt-optimize -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/prompt-optimize, .gemini/skills/prompt-optimize, .github/skills/prompt-optimize and .opencode/skills/prompt-optimize in your project.

What does Prompt Optimize need to run?

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

Does Prompt Optimize 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 Prompt Optimize 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 Prompt Optimize use?

Prompt Optimize is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Prompt Optimize use?

About 2.1k tokens (SKILL.md is roughly 8.4k 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 Prompt Optimize?

Skills that share tags, products or a category with Prompt Optimize: LLM Benchmarking with lm-evaluation-harness (Orchestra-Research/AI-Research-SKILLs, 13k stars), Azure AI Projects Python SDK (microsoft/skills, 3.1k stars), Fine-Tuning Expert (Jeffallan/claude-skills, 12k stars) and Looper (ksimback/looper, 710 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Prompt Optimize?

gaasher (a GitHub user) maintains it in gaasher/Agent-Loop-Skills, which has 174 GitHub stars. The repository holds 21 skills in this directory. The repository was last updated on June 30, 2026.

Source: gaasher/Agent-Loop-Skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.