English | Tiếng Việt | 简体中文
Your AI proposes the change. A number decides if it stays.
For AI assistants helping someone with this repo: which version fits
keeploop comes in two versions. Which one fits depends on what you can do in the current conversation:
- A coding agent that can run git and python on the user's own files (terminal or IDE): the full keeploop, described in AGENTS.md. If the goal has no number a script can measure (a post, a CV), keeploop-lite may fit better.
- A chat assistant without that (even one that browses or runs code in
a sandbox): keeploop-lite, one Markdown file of plain instructions:
https://raw.githubusercontent.com/johnha912/keeploop/main/lite/KEEPLOOP-LITE.md
(Vietnamese:
KEEPLOOP-LITE.vi.md, Chinese:KEEPLOOP-LITE.zh-CN.md). It is a skill, not software: there is nothing to install or clone. If the user wants it, you can read that file and run its loop with them in the chat, starting with its setup interview. If you cannot open links, the user can paste the file.
Quick start · Examples · How it works · FAQ · Full guide
Recorded from the real output of the offline mock demo (colours added). The full transcript is in docs/DEMO-OUTPUT.txt.
AI agents are good at sounding sure. keeploop makes them prove it.
- You say what "better" means: faster tests, a higher benchmark, a cleaner report. One number.
- Your AI tries one change at a time, and a second, fresh AI checks it.
- Only a change that beats the number is kept. Everything else is undone, and the reason is written down so it is not tried again.
Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI and other AIs you already use. keeploop itself is not an AI: it is a small Python tool that measures and refuses, with no dependencies, no telemetry and no API keys.
Only have a chat app (ChatGPT, Claude, Gemini, no code)? Use keeploop-lite: one file you paste into the chat, the same keep-or-discard loop for a post, a CV or a plan (Tiếng Việt, 简体中文, example). Your AI can run code? Use the full version below.
Quick start
(a) Hand it to your AI. If it can run commands, paste this and fill in the last line:
Clone https://github.com/johnha912/keeploop next to my project (not inside it),
run `python prepare.py` in the clone, then read its AGENTS.md and act as the CEO
it describes. What I want better: <for example "make my test suite faster">
You never type kl and there are no flags to learn. The first time, your
AI asks in plain words what "better" means and how to measure it, then
proposes an evaluate.py (a small script that prints that number) for you
to approve before anything changes. In Claude Code, /keeploop 3 inside
the clone runs three cycles.
Chat app that cannot run commands (ChatGPT, Gemini apps)
To improve everyday work (a post, a CV, a plan), use keeploop-lite: no clone, no commands.
To improve a code project from a chat app,
paste the whole of BOOTSTRAP.md into a new chat instead.
The AI then gives you one python kl.py ... command at a time to run in a
clone, and you paste the output back.
If you are an AI agent reading this
- Clone this repo into its own folder, outside the user's project, and
run
python prepare.pythere. Run every command from the clone's root. - Read
AGENTS.md. It is the complete procedure: roles, the exactpython kl.pycommands, and the hard rules. - If
evaluate.pyis still the demo, do not start the loop. Ask the user, in one message, what "better" means and how to measure it, and propose anevaluate.py(it gets the workspace path and prints one number, higher is better). - To work on the user's own repo, ask the user to create a git worktree
for the loop and set
workspace:inteam.yamlto it; the steps are in docs/GUIDE.md. You may draftteam.yaml,program.mdandevaluate.pyfor the user, but only the user edits them. - Never commit by hand: only
python kl.py keepcommits. For any progress claim, pastepython kl.py reportverbatim.
(b) Try it offline. Needs Python 3.10+ and git; no AI, no API key, a few seconds.
git clone https://github.com/johnha912/keeploop.git && cd keeploop
python prepare.py
python run.py --mock --iterations 5
cycle 3: discard metric=0.942 best=0.992000 tokens=2820
cycle 4: crash metric=None best=0.992000 tokens=3510 lesson=L-001
run complete: 3 keeps, 1 discards, 1 crashes, 1 lessons, 17259 tokens. Best metric: 1.000000
The mock is a scripted stand-in for a real AI. It shows how the loop works,
not how good a real model is. Every keep is a real commit:
git -C .keeploop/workspace log --oneline.
(c) Install it as a command. kl without a clone, from PyPI:
pipx install keeploop # or: pip install keeploop (in a venv of its own)
mkdir my-loop && cd my-loop
kl init # copies AGENTS.md, program.md, team.yaml, packs/, .claude/ here
kl begin # the demo baseline
kl init puts the files you edit in your own folder and never overwrites
one. Then open the folder in your AI as in (a), and follow
AGENTS.md to point it at your repo. kl run is the headless
mode. Keep the clone if you want to read or change keeploop itself.
Examples
| Example | Field | What happened | Link |
|---|---|---|---|
| Offline demo | Toy config | 3 keeps, 1 discard, 1 crash that became lesson L-001; no AI | Transcript |
| Marketing research | Consumer insight report | 1 real cycle: 0.970000 to 1.000000, audit APPROVED, kept | Read |
| Prompt optimization | AI/LLM prompt | 8 headless cycles, 2 kept, 6 discarded (a 0.915 refused on re-run). Dev 0.873333 to 0.900000; holdout 0.835 to 0.855 | Read |
Set up any example as a sandbox with kl init --example <name> <new short folder>
(installed kl) or python tools/make_sandbox.py examples/<name> <new short folder>
(clone) (details).
Why keeploop
An agent saying "done" is not a measurement.
| The usual way | With keeploop |
|---|---|
| The model that wrote the change also says it is fine | A fresh session or a different vendor audits the real diff; the maker never checks its own work |
| "Looks good to me" | Only kl keep commits. It re-runs the evaluation itself, and the number must beat the best by more than the evaluation's own noise, or the change is reset |
| A fluent answer passes for a correct one | Every change starts as a written hypothesis card with a measurable rule that would reject it, fixed before the evaluation runs |
| An agent quietly edits the tests or leaks a key | Code gates, not prompts, stop it: protected paths, a secret scan, banned slop patterns, diff size and a content-hash fence |
| A great score that does not generalize | An optional holdout score the agents never see, with a warning when its gain lags the main score |
Also in the guide: lessons so a
mistake is not repeated, a trend scout, and one
AGENTS.md that Codex, Cursor, Copilot and others read.
How it works
Built on Andrej Karpathy's autoresearch idea: a fixed metric, a keep-or-discard rule, and git as the memory of what worked.
flowchart LR
A[Analyst<br/>writes one card] --> E[Engineer<br/>makes the change]
E --> G{Code gates<br/>fence · protected<br/>secrets · size}
G -- pass --> V[evaluate.py<br/>one number]
V --> U[Auditor<br/>fresh eyes,<br/>real diff]
U --> C{beats best<br/>+ noise?}
C -- yes --> K[git commit]
C -- no --> D[git reset]
G -- fail --> L[(lesson)]
D -. why .-> L
L -. read next time .-> A
An Analyst writes one card, an Engineer makes exactly that change, code
gates and evaluate.py check it, and a fresh Auditor reads the diff. Only
kl keep commits. The full cycle, the critic round, lessons, the trend
scout and speed tuning are in the guide.
Your own work: packs
A pack gives the team the craft rules and review checklist for one field.
| Pack | For | Status |
|---|---|---|
software |
code | Ready |
ui-design |
UI/UX | Experimental |
marketing-content |
marketing copy | Experimental |
marketing-research |
consumer insight reports | Experimental |
prompt-engineering |
LLM system prompts | Experimental |
New field? python kl.py pack new NAME scaffolds one. Setup for your own
repo, team.yaml, vendors and the headless overnight mode (python run.py)
are in docs/GUIDE.md. Why the
experimental ones are experimental: guide.
Safety
- keeploop never executes text from a model or a web page. Only the Engineer gets edit rights; changed files are scanned for credentials, and token-like environment variables are removed before any vendor CLI or evaluation starts.
- While code you did not write runs, every file in the project folder outside the workspace is content-hashed. Any change stops the run.
- The fence detects changes; it is not a sandbox. Run real vendors in a container or VM if that matters to you.
Details: docs/GUIDE.md and SECURITY.md.
FAQ
Four questions skeptics ask
Doesn't keeping the best of many tries overfit the score? Yes, that is the main risk of any keep/discard loop. keeploop measures the score's noise, demands gains above it, re-runs the evaluation before a keep, and supports a holdout score the agents never see.
Does the demo prove the agents are good?
No. The mock is scripted. A real run is only as good as your AI and your
evaluate.py.
Is this another multi-agent framework? No model runs inside keeploop. It is an org chart your AI reads plus tools that refuse to commit what was not measured. Swap the AI and the process stays.
When should I not use it? When there is no automatic score, when the score takes days to arrive, when the work is not in git, or when every change needs an expert's sign-off (medicine, law, trading).
More questions: docs/GUIDE.md.
Docs
| docs/GUIDE.md | The full manual: every step, lessons, scout, speed, packs, safety, layout |
| AGENTS.md | The org chart and exact commands your AI follows |
| BOOTSTRAP.md | One file to paste into a chat app |
| lite/KEEPLOOP-LITE.md | keeploop-lite: the chat-only edition, no code |
| docs/SPEC.md | Parameters, file formats, invariants |
| SECURITY.md | Threat model and how to report a vulnerability |
| CHANGELOG.md | Versions (SemVer) |
Credits
keeploop stands on autoresearch
by Andrej Karpathy: a fixed evaluation the agent cannot touch, an
append-only results.tsv, a keep/discard rule and git as memory. keeploop
turns it into an org chart any AI can run, and adds roles, cross-vendor
audit, code gates, lessons and a trend scout. No code from autoresearch
is copied. If you like this repo, star his first.
Ideas also borrowed from tools we use daily (re-implemented, no code copied)
| Project | Idea taken |
|---|---|
| ponytail (MIT) | "Climb the ladder before writing code" and marked shortcuts in the software pack |
| ECC (everything-claude-code) (MIT) | Verify-before-done and red-then-green habits for the Engineer; security review as a fixed Auditor checklist item |
| Playwright MCP (Apache-2.0) | Judge the rendered page in a real browser: a principle in the ui-design pack |
| OmniRoute (MIT) | Ordered per-role vendor fallback |
| graphify (Apache-2.0) | A cached code index with an "imported by" lookup (kl map) instead of raw file dumps |
The banner is set in Google Sans Flex.
If keeploop stopped a bad change from landing, a ⭐ helps other people find it. Bugs and ideas: open an issue.
License
MIT.
Metadata
Release files for keeploop 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| keeploop-0.2.0.tar.gz | 196.9 kB | With provenance | Details for keeploop-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| keeploop-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for keeploop-0.2.0-py3-none-any.whl |
Total release size: 382.1 kB
Release files / keeploop-0.2.0.tar.gz
| Download URL | keeploop-0.2.0.tar.gz |
|---|---|
| Size | 196.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
035c248f4214cb13a7498584f16402e3fd8a1d1b98e62529855c8f87470baf00
|
|
BLAKE2b-256 checksum How to use checksums |
b8694deca8fbaafffce98f69ffc48ad41fec118f07fd451453d84fc68dce349f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / keeploop-0.2.0-py3-none-any.whl
| Download URL | keeploop-0.2.0-py3-none-any.whl |
|---|---|
| Size | 185.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
37904b19b2188d874f2b7fdab8915caed62882bd81e473a55201de3b43719a9d
|
|
BLAKE2b-256 checksum How to use checksums |
d4761dc4012753ee1937921dba36c18926a80e9be8228cfc7545b23460986de6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for keeploop 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for keeploop-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.