dspy-optimize-anything

dspy-optimize-anything is a skill for Claude Code from OmidZamani/dspy-skills. It costs 36 tokens per session (2,518 once invoked), scanned A, original, MIT.

A method for using GEPA's optimize_anything interface to improve text-based artifacts such as code, prompts, agent designs, configurations, or SVGs. GEPA searches through candidate versions using scores and diagnostic feedback.

In plain words
What is it for?
Use it to optimize prompts, code, agent architectures, configurations, vector graphics, scheduling policies, or other text that an evaluator can score.
Why use it?
It provides one process for improving different kinds of text when you can measure quality. It can use examples, validation data, or a written objective to guide the search.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the dspy-skills plugin — 24 skills shipped together

Good fit Use it to optimize prompts, code, agent architectures, configurations, vector graphics, scheduling policies, or other text that an evaluator can score.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/omidzamani/dspy-skills/dspy-optimize-anything
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.

Any agent
npx skills add OmidZamani/dspy-skills --skill dspy-optimize-anything
Clone the repo
git clone --depth 1 https://github.com/OmidZamani/dspy-skills

Made for: Claude Code.

Or install dspy-skills, the plugin that ships this one along with the rest of its 24 skills.

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 dspy-optimize-anything

README.md
[![agentmods](https://agentmods.dev/badge/skills/omidzamani/dspy-skills/dspy-optimize-anything/github.svg)](https://agentmods.dev/skills/omidzamani/dspy-skills/dspy-optimize-anything)
Your own site
<a href="https://agentmods.dev/skills/omidzamani/dspy-skills/dspy-optimize-anything"><img src="https://agentmods.dev/badge/skills/omidzamani/dspy-skills/dspy-optimize-anything/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for dspy-optimize-anything

Your own site · 80×15
<a href="https://agentmods.dev/skills/omidzamani/dspy-skills/dspy-optimize-anything"><img src="https://agentmods.dev/badge/skills/omidzamani/dspy-skills/dspy-optimize-anything.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,518 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.1 $0.00036 $0.02518
Opus 5 $0.00018 $0.01259
Sonnet 5 $0.00007 $0.00504
Haiku 4.5 $0.00004 $0.00252

Measured 12d ago against content hash c5501c9d8252, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

dspy-optimize-anything scanned grade A with 1 finding 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 12d ago.

The scan reads SKILL.md. This mod also ships 1 executable file (example.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

proc = subprocess.run(
skills/dspy-optimize-anything/SKILL.md · 305 lines

How it starts

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

GEPA optimize_anything

Goal

Optimize any artifact representable as text — code, prompts, agent architectures, vector graphics, configurations — using a single declarative API powered by GEPA's reflective evolutionary search.

When to Use

  • Beyond prompt optimization — optimizing code, configs, SVGs, scheduling policies, etc.
  • Single hard problems — circle packing, kernel generation, algorithm discovery
  • Batch related problems — CUDA kernels, code generation tasks with cross-transfer
  • Generalization — agent skills, policies, or prompts that must transfer to unseen inputs
  • When you can express quality as a score and provide diagnostic feedback (ASI)

Inputs

Input Type Description
seed_candidate str | dict[str, str] | None Starting artifact text, or None for seedless mode
evaluator Callable Returns score (higher=better), optionally with ASI dict
dataset list | None Training examples (for multi-task and generalization modes)
valset list | None Validation set (for generalization mode)
objective str | None Natural language description of what to optimize for
background str | None Domain knowledge and constraints
config GEPAConfig | None Engine, reflection, and tracking settings

Outputs

Output Type Description
result.best_candidate str | dict Best optimized artifact

Workflow

Phase 1: Install

pip install -U "gepa>=0.1.1,<0.2"

Phase 2: Define Evaluator with ASI

The evaluator scores a candidate and returns Actionable Side Information (ASI) — diagnostic feedback that guides the LLM proposer during reflection.

Simple evaluator (score only):

import gepa.optimize_anything as oa
from gepa.optimize_anything import EngineConfig, GEPAConfig

config = GEPAConfig(engine=EngineConfig(max_metric_calls=100))

def evaluate(candidate: str) -> float:
    score, diagnostic = run_my_system(candidate)
    oa.log(f"Error: {diagnostic}")  # captured as ASI
    return score

Read the full file on GitHub · 305 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 12d ago First seen · 305 lines · 36 tokens per session scan A c5501c9d8252

Subscribe to this mod's changes

dspy-optimize-anything is a skill published in the GitHub repository OmidZamani/dspy-skills (123 stars, last pushed 2mo ago), licensed MIT. It adds 36 tokens to every session and 2,518 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.