experiment

experiment is a skill for Claude Code, Codex from SethGammon/Citadel. It costs 39 tokens per session (1,578 once invoked), scanned A, original, MIT.

An automated loop that proposes code changes, measures a single-number metric, and keeps changes that improve it. It works in isolated worktrees, which are separate copies of a repository for safe experiments.

In plain words
What is it for?
Use it when you can name the files to change, provide a command that prints one metric, and set an iteration or time budget—for example, reducing bundle size or improving test performance.
Why use it?
It lets you optimize against a measurable target while preserving the starting code and discarding changes that fail checks or do not improve the result.

Skill for Claude CodeCodex

Part of the citadel plugin — 48 skills, 7 agents, 2 MCP servers shipped together

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.

agentmods
npx agentmods add skills/sethgammon/citadel/experiment
Any agent
npx skills add SethGammon/Citadel --skill experiment
Clone the repo
git clone --depth 1 https://github.com/SethGammon/Citadel

Made for: Claude Code, Codex.

Or install citadel, the plugin that ships this one along with the rest of its 48 skills, 7 agents, 2 MCP servers.

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 experiment

README.md
[![agentmods](https://agentmods.dev/badge/skills/sethgammon/citadel/experiment.svg)](https://agentmods.dev/skills/sethgammon/citadel/experiment)
Your own site
<a href="https://agentmods.dev/skills/sethgammon/citadel/experiment"><img src="https://agentmods.dev/badge/skills/sethgammon/citadel/experiment.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,578 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00039 $0.01578
Opus 5 $0.00019 $0.00789
Sonnet 5 $0.00008 $0.00316
Haiku 4.5 $0.00004 $0.00158

Measured 3d ago against content hash 3ce2d3dd5c96, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

experiment scanned grade A with 0 findings 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 3d ago.

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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/experiment/SKILL.md · 164 lines

How it starts

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

/experiment — Metric-Driven Optimization Loop

Inputs

The user provides three things:

  1. scope: Files to modify (glob pattern, e.g., "src/api/**/*.ts")
  2. metric: Shell command that outputs a single number (e.g., npm run build 2>&1 | tail -1 | grep -oP '\d+')
  3. budget: Iteration cap (default: 5) or time cap (e.g., "10 minutes")

If any input is missing, ask for it. The metric MUST output a single number to stdout.

Protocol

Step 1: BASELINE

  1. Stash any uncommitted changes (restore on exit)
  2. Run the metric command. Record the baseline value.
  3. Determine direction: does lower = better (bundle size, error count) or higher = better (FPS, test count)? Ask the user if ambiguous.
  4. Log: Baseline: {value} ({metric command})

Step 2: ITERATE

For each iteration (up to budget):

  1. Create isolation: Spawn a sub-agent in a worktree (isolation: "worktree")
  2. Propose change: The agent modifies files within scope to improve the metric. Provide context: baseline value, metric direction, scope, what previous iterations tried.
  3. Measure: Run the metric command in the worktree (via node scripts/run-with-timeout.js 300)
  4. Gate: Run typecheck (also via timeout wrapper). If it fails, discard immediately.
  5. Evaluate:
    • Improved? → KEEP. Merge the worktree branch. New baseline = new value.
    • Same or worse? → DISCARD. Delete the worktree.
  6. Log iteration:
    Iteration {N}: {value} ({delta from baseline}) → {KEEP|DISCARD}
    Change: {one-line description of what was tried}
    

Step 3: CONVERGENCE CHECK

After each iteration, check:

  • Local optimum: Last 3 iterations all discarded → stop ("no more improvements found")
  • Diminishing returns: Last kept improvement was < 0.5% → stop ("diminishing returns")
  • Budget exhausted: Iteration count or time exceeded → stop

Step 4: REPORT

Write results to .planning/research/experiment-{slug}.md:

# Experiment: {Description}

> Metric: `{command}`
> Direction: {lower|higher} is better
> Scope: {glob pattern}
> Budget: {N iterations}
> Date: {ISO date}

## Results

| Iteration | Value | Delta | Verdict | Change |
|-----------|-------|-------|---------|--------|
| baseline  | {N}   | —     | —       | —      |
| 1         | {N}   | {+/-} | KEEP    | {desc} |
| 2         | {N}   | {+/-} | DISCARD | {desc} |

## Outcome
- **Start**: {baseline}
- **End**: {final value}
- **Improvement**: {percentage}
- **Iterations**: {kept}/{total}
- **Stop reason**: {convergence|diminishing|budget}

## Kept Changes
{List of changes that were kept, with commit hashes}

Read the full file on GitHub · 164 lines

Files

What ships with it

2 files 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. 3d ago First seen · 164 lines · 39 tokens per session scan A 3ce2d3dd5c96

Subscribe to this mod's changes

experiment is a skill published in the GitHub repository SethGammon/Citadel (917 stars, last pushed 6d ago), licensed MIT. It adds 39 tokens to every session and 1,578 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

debrief

This skill should be used when the user asks to "debrief", "record what happened", "session summary", "write a debrief", or wants to capture session activity (commits, task state changes, decisions, issues) into a structured record for the next session.

spacedock-dev/spacedock · 59 tokens

refit

This skill should be used when the user asks to "refit a workflow", "upgrade a workflow", "update workflow scaffolding", or wants to bring an existing workflow's scaffolding files up to date with the current Spacedock version.

spacedock-dev/spacedock · 52 tokens

fo-dispatch-recovery

Claude dispatch failure recovery — Break-Glass Manual Dispatch (the manual Agent() template) and Context Budget Failure/Dead Ensign Handling (the budget-unavailable stderr conditions, the recovery clause, dead-ensign bookkeeping). Read ONLY at its resident triggers inside claude-fo-dispatch.md — a non-zero or…

spacedock-dev/spacedock · 137 tokens

fo-status-viewer

First-officer status query/mutate/display surface — the status command flag docs, --set field docs, canonical captain-facing invocations, the Captain-Facing State Display rendering, and the GitHub-issue-filing approval gate. Invoke at the first ad-hoc status question, --set mutation, --next-id/--resolve lookup, or…

spacedock-dev/spacedock · 87 tokens

present-gate

First-officer gate-presentation rendering — the captain-facing gate-review template and assembly rules, including workflow-owned finding labels. Invoke at the gate point after the FO has decided a stage must be presented.

spacedock-dev/spacedock · 44 tokens

agent-workflow-playbook

AI Agent Workflow & Skill Architecture Guide — turn expert work into measurable, reusable agent systems. Covers workflow discovery, skill decomposition, harness design, evaluation, human escalation, observability, cost control, and multi-agent orchestration. Includes a measured marketing-delivery case: 15 people × 3–4…

Gingiris-1031/gingiris-skills · 83 tokens