agentleFS
mayankjain1815-commitsmayankjain1815-commits/CITADEL/skills/experiment/SKILL.md

experiment

Skill4 starsChanged 4 months agoMITView on GitHub

Automated optimization loop with scalar fitness function. Proposes changes in isolated worktrees, measures with a metric command, keeps improvements, discards failures. Supports convergence detection and diminishing returns.

27 other projects use a version of this, 3 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use eval, decide and 4 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • qtzx06Skill

    eval

    Evaluate trained YOLO model accuracy with mAP metrics and per-class error analysis. Identifies failure cases for targeted improvement. Use after training.

    Also in 4 projects that use this

  • dirienSkill

    decide

    Three-agent adversarial debate protocol for strategic decisions. Two advocates steelman opposing positions while a moderator identifies risks and synthesizes a binding consensus. Use when choosing between alternatives, evaluating tradeoffs, or making high-stakes decisions.

    Also in 3 projects that use this

  • VercelSkill

    workflow

    Creates durable, resumable workflows using Vercel's Workflow SDK. Use when building workflows that need to survive restarts, pause for external events, retry on failure, or coordinate multi-step operations over time. Triggers on mentions of "workflow", "durable functions", "resumable", "workflow sdk", "queue", "event", "push", "subscribe", or step-based orchestration.

    Also in 3 projects that use this

  • AnthropicSkill

    debug

    Structured debugging session — reproduce, isolate, diagnose, and fix. Trigger with an error message or stack trace, "this works in staging but not prod", "something broke after the deploy", or when behavior diverges from expected and the cause isn't obvious.

    Also in 4 projects that use this

  • BlockSkill

    plan

    Draft a TDD, PRD, or lightweight plan in the conversation without committing it.

    Also in 4 projects that use this

  • SentrySkill

    onboard

    Onboard a service to sentry-options. Use when integrating a new service, creating schemas, or setting up the multi-repo sentry-options workflow.

    Also in 3 projects that use this

The file

Show its rules and text

We split this skill into the rules it gives an agent

19 rules. 0 are common, 16 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 25 edited versions we read keep these.

  • 16

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If any input is missing, ask for it.

    line 28
  2. Distinctive:

    Run the metric command. Record the baseline value.

    line 35
  3. Distinctive:

    Ask the user if ambiguous.

    line 37
  4. Very specific:

    Measure: Run the metric command in the worktree (via node scripts/run-with-timeout.js 300)

    line 47
  5. Distinctive:

    Gate: Run typecheck (also via timeout wrapper).

    line 48
  6. Distinctive:

    After each iteration, check:

    line 60
  7. Very specific:

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

    line 67
  8. Distinctive:

    When you want to optimize a measurable metric (bundle size, error count, test coverage, FPS)

    line 114
  9. Distinctive:

    When you have a clear hypothesis but aren't sure which of several approaches wins

    line 115
  10. Distinctive:

    When manual A/B testing would be too slow or error-prone

    line 116
  11. Distinctive:

    NOT when the goal is subjective ("make it feel better") — the metric must be a number

    line 117
  12. Distinctive:

    NEVER modify files outside scope

    line 121
  13. Distinctive:

    ALWAYS use worktree isolation for changes

    line 122
  14. Distinctive:

    ALWAYS run typecheck before keeping a change

    line 123
  15. Distinctive:

    If the metric command fails, treat as DISCARD (not crash)

    line 125
  16. Distinctive:

    Every kept iteration improved the metric AND passed typecheck

    line 137
  17. Distinctive:

    Every discarded iteration has a logged reason

    line 138
  18. Distinctive:

    Metric command outputs nothing or non-numeric text: Treat as a metric failure.

    line 144
  19. Very specific:

    If .planning/research/ does not exist: Create it before writing the experiment report.

    line 148

“Common” is measured: kept by at least 6 in 10 of the 25 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/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}

Also log to .planning/telemetry/agent-runs.jsonl:

{"event":"experiment-complete","slug":"{slug}","baseline":0,"final":0,"improvement":"0%","kept":0,"total":0,"timestamp":"ISO"}

Common Metrics

GoalMetric Command
Reduce bundle sizenpm run build 2>&1 | grep -oP 'Total size: \K\d+'
Reduce type errorsnpx tsc --noEmit 2>&1 | grep -c 'error TS'
Increase test pass ratenpm test 2>&1 | grep -oP '\d+ passing'
Reduce file countfind src -name '*.ts' | wc -l
Reduce line countwc -l src/**/*.ts | tail -1 | awk '{print $1}'

When to Use

  • When you want to optimize a measurable metric (bundle size, error count, test coverage, FPS)
  • When you have a clear hypothesis but aren't sure which of several approaches wins
  • When manual A/B testing would be too slow or error-prone
  • NOT when the goal is subjective ("make it feel better") — the metric must be a number

Safety Rules

  • NEVER modify files outside scope
  • ALWAYS use worktree isolation for changes
  • ALWAYS run typecheck before keeping a change
  • Restore stashed changes on exit (even on error)
  • If the metric command fails, treat as DISCARD (not crash)

Contextual Gates

Disclosure: "Running experiment loop on [target] with fitness: [function]. Each iteration commits. Budget: [N iterations]." Reversibility: amber — modifies source files across iterations; each iteration is committed; undo with git revert on kept commits. Trust gates:

  • Familiar (5+ sessions): iterates and commits autonomously; novices should use /improve with manual review between steps.

Quality Gates

  • Baseline was measured before any iterations ran
  • Every kept iteration improved the metric AND passed typecheck
  • Every discarded iteration has a logged reason
  • The stop reason is one of: convergence, diminishing returns, or budget exhausted
  • The experiment report exists at .planning/research/experiment-{slug}.md with all iteration rows filled

Fringe Cases

Metric command outputs nothing or non-numeric text: Treat as a metric failure. Ask the user to provide a command that outputs a single number to stdout before starting iterations.

No worktree support (e.g., shallow clone): Fall back to branch isolation. Create a branch, run changes there, measure, then delete or merge the branch. Never modify the working tree directly.

If .planning/research/ does not exist: Create it before writing the experiment report. If .planning/ itself doesn't exist, create the full path or output the report inline.

Budget exhausted with zero kept iterations: Report outcome as "no improvement found". This is a valid result — do not continue past the budget.

Exit Protocol

---HANDOFF---
- Experiment: {description}
- Result: {baseline} → {final} ({improvement}%)
- Kept: {N}/{total} iterations
- Stop reason: {reason}
- Report: .planning/research/experiment-{slug}.md
- Reversibility: amber — undo kept iterations with `git revert` on each kept commit
---

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.