# Optimization-Loop

> Autonomous loop that iteratively modifies, evaluates, and selects the best version of any text resource — skills, prompts, or campaigns — using a modify-measure-keep/discard cycle.

Optimization-Loop is a paid AI agent skill on Agensi by Martin Gunderman, in Agents & Orchestration. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $19 (one-time purchase)
- Creator: [Martin Gunderman](https://www.agensi.io/creators/martin-gunderman)
- Category: [Agents & Orchestration](https://www.agensi.io/skills/agents-orchestration)
- Uses: 1
- Version: 1.1
- Last updated: 2026-06-06
- Security: scan passed (2026-06-05); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/optimization-loop
- Tags: ai-agents, optimization, iteration, evaluation, prompt-engineering, agent-tuning, karpathy-method, evolutionary

## About this skill

Auto-Optimize is an autonomous optimization loop for text-based resources such as agent skills, prompts, and campaign copy. Inspired by Andrej Karpathy's autoresearch methodology, it applies the same principle that works for training models — modify, measure, keep or discard, repeat — to the domain of text optimization.

The skill operates on files stored in a dedicated targets directory. Each optimization cycle makes exactly one targeted change, evaluates the result using either live metrics or simulated LLM-judge scoring, and logs the outcome to a results file. If the change improves the score, it's kept and becomes the new baseline. If it performs the same or worse, it's discarded via a hard git reset. This ensures the optimization path is always traceable, reversible, and never accumulates unverified changes.

The evaluation method adapts to the target type: skills are scored on task success rate through agent testing, prompts through simulated conversation scoring across multiple criteria, and campaigns through real click and conversion data. When live metrics are unavailable, the skill uses delegate_task with an evaluator LLM to simulate and score conversations based on per-target evaluation criteria.

Key constraints keep the process grounded: only one change per experiment, a simplicity criterion where removing code that performs equally is always kept, no bundling of multiple ideas, and changes must be large enough to matter but small enough to review. The loop runs continuously until interrupted by a human, and it never asks for permission to continue — it just optimizes.

## Known limitations

- Requires git for state management.
- High token usage during long loops.
- LLM-judge scoring can be subjective.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Optimization-Loop skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What specific problem does the Optimization-Loop solve?

This skill automates the 'trial and error' of prompt engineering and script refinement by applying a modify-measure-discard cycle, ensuring your agents or campaigns improve based on data rather than intuition.

### How does the loop determine if a change is actually better?

The skill supports two modes: it can integrate live performance data (like CTR) or use an LLM-judge to simulate interactions and score them against your specific success criteria.

### Can I use this to optimize resources other than just LLM prompts?

Optimization-Loop is designed to work with any text-based resource, including agent system prompts, marketing copy, and code-based skills, provided they are stored in the designated targets directory.

### What happens if the AI makes a change that degrades the performance of my resource?

It utilizes a git-based 'hard reset' mechanism, meaning if an experimental change fails to improve the score, the skill immediately reverts the file to its last known best state.

### How do I keep track of what the loop is changing while it runs autonomously?

The skill follows a strict 'one change per experiment' rule and records every iteration in a results log, allowing you to audit the entire evolutionary path of your resource.

### What is included in the purchase of this skill?

You receive the full Optimization-Loop skill package, documentation on setting up your targets directory, and example evaluation templates for both automated and human-in-the-loop scoring.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
