improve-loop
Skill5 starsChanged 9 months agoMITView on GitHub
Autonomous improvement loop for any codebase. Uses git worktrees to run every experiment in isolation — the main branch is never touched until a winning change is explicitly merged. Reads .claude/autoimprove/config.md for the measurement suite, then iterates: create worktree → propose → implement in worktree → measure → merge if improved, delete if not → log → repeat.
- Reads credentials
- Deletes or force-pushes
2 other projects use a version of this.
Adopted by
Most recently taken up by
- Yco-0314/stratatheir own version, first seen Jul 7, 2026
- vatevstoil/claude-self-learning-ostheir own version, first seen Jul 4, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- vatevstoil/claude-self-learning-os★ 4same name
- Yco-0314/strata★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 17 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
Every experiment runs in an isolated git worktree.
- Distinctive: line 20
Before the first iteration, print each check as you run it:
- Very specific: line 32
Check .claude/autoimprove/config.md exists.
- Distinctive: line 33
Check git is available: git status
- Very specific: line 36
Run the worktree skill's setup step to create .claude/autoimprove/worktrees/ and update .gitignore.
- Distinctive: line 37
Run the measure skill in the main directory to get the BASELINE score.
- Very specific: line 44
After pre-flight passes, write a session header to .claude/autoimprove/log.md:
- Distinctive: line 55
If the log file doesn't exist, create it with the project header first:
- Very specific: line 72
When invoked with continue-mode parameters (from the /autoimprove:continue command), the loop behavior changes:
- Very specific: line 77
Update Planned: to the new total if it changed
- Very specific: line 78
Update Status: to IN_PROGRESS
- Distinctive: line 106
Never run more than one step without printing a progress line.
- Distinctive: line 114
Use the worktree skill to create a new isolated branch and directory:
- Very specific: line 122
All work for this iteration happens inside .claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID/.
- Distinctive: line 146
Commit the change to the experiment branch:
- Distinctive: line 156
Run the full measurement suite again from inside the worktree.
- Distinctive: line 188
No rollback needed — there was nothing to roll back.
- Very specific: line 207
After logging the iteration, update the session header's Status: line:
- Distinctive: line 211
Write the file back
- Distinctive: line 213
If the status line cannot be found, append a warning to the log and continue — the iteration records are the source of truth.
- Distinctive: line 221
After all iterations (or if the user stops early):
- Distinctive: line 223
Update the session header status to completed:
- Distinctive: line 271
Never: run deploy, publish, or push commands
- Distinctive: line 272
If the same area fails 3 iterations in a row, skip it and note in the log
- Distinctive: line 273
After 10 iterations, pause, clean up worktrees, and wait for human review
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AutoImprove Loop Skill
Every experiment runs in an isolated git worktree. The main codebase is never modified during experiments. Only winning changes get squash-merged back.
Main branch ──────────────────────────────────── (never touched mid-session)
│ │
experiment-001 experiment-002
(kept ✅ → merge) (discarded ❌ → deleted)Pre-flight checks
Before the first iteration, print each check as you run it:
━━━ Pre-flight ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ Config found
✓ Git working tree clean
✓ Base commit: abc1234
✓ Worktree directory ready
✓ Baseline score: XX/100
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━- Check
.claude/autoimprove/config.mdexists. If not, stop: "Run /autoimprove:setup first." - Check git is available:
git status - Confirm main working tree is clean. If not, stop: "Please commit or stash changes before running autoimprove."
- Record the base commit:
git rev-parse HEAD— all experiments branch from here. - Run the worktree skill's setup step to create
.claude/autoimprove/worktrees/and update.gitignore. - Run the measure skill in the main directory to get the BASELINE score.
- Report: "Baseline: XX/100. All experiments will run in isolated worktrees. Main branch is safe."
Session Header
After pre-flight passes, write a session header to .claude/autoimprove/log.md:
## Session — [ISO 8601 timestamp]
**Planned:** N iterations
**Focus:** "focus string" (or "all improvement areas" if none)
**Baseline:** XX/100
**Base commit:** [full SHA]
**Status:** IN_PROGRESS (0/N completed)If the log file doesn't exist, create it with the project header first:
# .claude/autoimprove/log.md
> Generated by [autoimprove](https://github.com/benmarte/autoimprove) — Claude Code Plugin
> Project: **[project name]** · Stack: [detected stack] · Started: [date]
---Then append the session header.
Continue Mode
When invoked with continue-mode parameters (from the /autoimprove:continue command), the loop behavior changes:
start_iteration— Start numbering from this value instead of 1total_iterations— Use this as the display total (e.g., "Iteration 5/10")session_mode— Ifcontinue, skip creating a new session header; instead update the existing one:- Update
**Planned:**to the new total if it changed - Update
**Status:**toIN_PROGRESS
- Update
baseline_score— If provided, skip baseline measurement and use this valueexperiment_offset— Start experiment numbering from this value to avoid branch name collisions
In continue mode, the pre-flight still runs (clean tree, config check, worktree setup) but skips creating a new session header and optionally skips baseline measurement.
Progress Updates
CRITICAL: At the start of every step, you MUST output a visible progress line to the user. Do not silently run tools — always print status first. Use this format:
━━━ Iteration N/TOTAL ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔬 STEP_NAME: brief description of what's happeningExample progress lines:
━━━ Iteration 1/5 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔬 PROPOSE: Targeting error handling in src/api/client.ts
🔬 SNAPSHOT: Measuring BEFORE score...
🔬 IMPLEMENT: Adding try/catch to unhandled async calls
🔬 MEASURE: Measuring AFTER score...
🔬 DECIDE: 85 → 89 (+4 pts) — KEPT ✅
🔬 LOG: Recorded to .claude/autoimprove/log.mdNever run more than one step without printing a progress line. The user must always know what iteration you're on and what phase you're in.
The Loop
Step 1 — CREATE WORKTREE
Use the worktree skill to create a new isolated branch and directory:
EXPERIMENT_ID=$(printf "%03d" $N)
git worktree add -b "autoimprove/experiment-$EXPERIMENT_ID" \
".claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID"All work for this iteration happens inside .claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID/.
The main directory is not touched.
Step 2 — PROPOSE
If a FOCUS string was provided: Every iteration targets that specific focus. Break the focus into file-by-file or function-by-function sub-tasks and tackle one per iteration. Do not rotate to other areas — stay on the focus until all iterations are used or the focus is fully addressed.
If no FOCUS was provided: Choose one focused improvement from the Improvement Areas in .claude/autoimprove/config.md. Rotate areas — don't repeat an area that failed last time.
State the hypothesis explicitly:
"I will [specific change] in [file(s)] because I expect [metric] to improve by ~[X] points."
Step 3 — SNAPSHOT (BEFORE score)
Measure from inside the worktree directory (same commands, different cwd):
cd .claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID
# run measurement suite from .claude/autoimprove/config.mdRecord as BEFORE.
Step 4 — IMPLEMENT
Make the change inside the worktree. The main directory is untouched. Commit the change to the experiment branch:
cd .claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID
git add -A
git commit -m "experiment($EXPERIMENT_ID): $HYPOTHESIS_ONE_LINE"Step 5 — MEASURE (AFTER score)
Run the full measurement suite again from inside the worktree. Record as AFTER.
Step 6 — DECIDE
If AFTER > BEFORE — KEEP ✅
Squash-merge the experiment back to main:
cd [main project root]
git merge --squash "autoimprove/experiment-$EXPERIMENT_ID"
git commit -m "autoimprove($EXPERIMENT_ID): $HYPOTHESIS_ONE_LINE
Score: $BEFORE → $AFTER (+$DELTA pts)
Files changed: $FILES"
# Clean up
git worktree remove ".claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID"
git branch -D "autoimprove/experiment-$EXPERIMENT_ID"If AFTER == BEFORE — KEEP ✅ only for clear readability wins, DISCARD otherwise
Same merge process as above if keeping, discard process if not.
If AFTER < BEFORE — DISCARD ❌
Main branch is already untouched. Just delete the worktree:
git worktree remove ".claude/autoimprove/worktrees/experiment-$EXPERIMENT_ID" --force
git branch -D "autoimprove/experiment-$EXPERIMENT_ID"No rollback needed — there was nothing to roll back.
Step 7 — LOG
Append to .claude/autoimprove/log.md in the main directory:
## Iteration N — [timestamp]
**Hypothesis:** [what you tried and why]
**Branch:** autoimprove/experiment-NNN
**Files changed:** [list]
**Before:** [X/100] — type: X, build: X, tests: X, lint: X
**After:** [X/100] — type: X, build: X, tests: X, lint: X
**Decision:** KEPT ✅ (merged to main) / DISCARDED ❌ (worktree deleted)
**Reason:** [one sentence]Step 7b — UPDATE SESSION STATUS
After logging the iteration, update the session header's **Status:** line:
- Read
.claude/autoimprove/log.md - Find the last line matching
**Status:** IN_PROGRESS - Replace it with
**Status:** IN_PROGRESS (N/M completed)where N is the current iteration number and M is the total planned - Write the file back
If the status line cannot be found, append a warning to the log and continue — the iteration records are the source of truth.
Step 8 — REPEAT from Step 1
Session end — cleanup
After all iterations (or if the user stops early):
Update the session header status to completed:
- Read
.claude/autoimprove/log.md - Find the last
**Status:** IN_PROGRESSline - Replace with
**Status:** COMPLETED (N/N) - Write the file back
# Remove any remaining experiment worktrees
for wt in .claude/autoimprove/worktrees/experiment-*; do
git worktree remove "$wt" --force 2>/dev/null
done
git branch | grep "autoimprove/experiment" | xargs git branch -D 2>/dev/null
rm -rf .claude/autoimprove/worktreesPrint a final summary table:
━━━ Session Complete ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Score: BASELINE → FINAL (+/- DELTA)
🔁 Iterations: N total — X kept ✅, Y discarded ❌
📝 Merged commits:
• abc1234 autoimprove(001): description
• def5678 autoimprove(003): description
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Universal Improvement Areas
Rotate through these (add language-specific ones from .claude/autoimprove/config.md):
- Type safety — fix type errors, replace
any/interface{}/untyped constructs - Error handling — unhandled promises, bare
catch {}, swallowed errors - Dead code — unused imports, variables, unreachable branches
- Code duplication — extract repeated logic (3+ occurrences) into shared utilities
- Naming & readability — cryptic names, functions over ~50 lines
- Performance — N+1 query patterns, missing memoization, unnecessary allocations
- Security — hardcoded secrets, missing input validation, unguarded auth routes
- Tests — add a test for the most critical untested function, fix flaky tests
Safety Rules
- Main branch is never modified until a winning experiment is explicitly squash-merged
- Never modify lock files, generated files, migrations,
.env— in any worktree - Never run deploy, publish, or push commands
- If the same area fails 3 iterations in a row, skip it and note in the log
- After 10 iterations, pause, clean up worktrees, and wait for human review
- On any unexpected error: run the worktree skill's cleanup step, then stop and report
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
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.

