code-loop
AGENTS.md0 starsChanged 3 months agoMITView on GitHub
Goal: best real outcome, least code, least context, lowest irreversible risk. Apply this before coding, fixing, refactoring, designing, debugging, reviewing, planning, or researching technical work. Use Code Loop Council when multiple models, independent review, high-risk validation, or arbitration are needed. For tiny, obvious, reversible changes: Do not expand into a plan for a one-sentence diff. For non-trivial work: 1. Locate: read the smallest set of files, callers, docs, or sources needed. 2. Route: identify the dominant constraint: correctness, safety, reversibility,…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,843 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- .cursor/rules/code-loop.mdCursor rule
- code-loopSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
14 rules. About 0 are common, 13 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Run the cheapest real verification.
- Distinctive: line 18
Do not expand into a plan for a one-sentence diff.
- Distinctive: line 32
Verify: run a real check that can fail.
- Distinctive: line 34
If verification fails, continue the loop.
- Distinctive: line 38
Use one agent by default. Escalate to Council only when the task needs multiple models/agents, high-risk review, scientific uncertainty, …
- Very specific: line 57
Treat clo/ inputs as shortcuts: clo/on, clo/off, clo/council, clo/security, clo/verify, and clo/min.
- Distinctive: line 67
Stop at the first rung that solves the real need:
- Distinctive: line 81
Before adding code, classify it as current need, future option, or reject.
- Distinctive: line 88
Before editing, write one sentence: "This task requires changing X so that Y."
- Distinctive: line 117
Use the lightest expert check that prevents domain mistakes:
- Distinctive: line 131
Every non-trivial task needs one check that can fail:
- Distinctive: line 144
Use targeted reads before broad exploration.
- Distinctive: line 145
Prefer a short plan over a long essay.
- Distinctive: line 147
Before finalizing, silently check: request solved, scope held, boundaries handled, verification reported, and no more code or tokens than …
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md 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
Code Loop v5 - expert-minimal engineering and council discipline
Goal: best real outcome, least code, least context, lowest irreversible risk.
Apply this before coding, fixing, refactoring, designing, debugging, reviewing, planning, or researching technical work. Use Code Loop Council when multiple models, independent review, high-risk validation, or arbitration are needed.
Fast path
For tiny, obvious, reversible changes:
- State the required scope in one sentence.
- Make the smallest direct edit.
- Run the cheapest real verification.
- Report only what changed and what passed.
Do not expand into a plan for a one-sentence diff.
Expert loop
For non-trivial work:
- Locate: read the smallest set of files, callers, docs, or sources needed.
- Route: identify the dominant constraint: correctness, safety, reversibility, latency, cost, maintainability, UX, scientific validity, innovation value, or regulatory risk.
- Minimize: reuse repo code, standard library, platform features, installed dependencies, or one line before writing new structure.
- Bound: state what changes and what does not.
- Risk-check: classify confidence, blast radius, and trust boundaries.
- Build: implement in small reversible increments.
- Verify: run a real check that can fail.
If verification fails, continue the loop. Do not call the task done.
Council trigger
Use one agent by default. Escalate to Council only when the task needs multiple models/agents, high-risk review, scientific uncertainty, independent verification, or conflict arbitration.
Council uses the repository as the shared source of truth:
- account: identity, billing, secrets, permissions
- repository: durable task state and evidence
.code-loop/: handoffs, reports, decisions, and validation artifacts- MCP: tools and context
- A2A: optional agent-to-agent messaging
Evidence outranks confidence:
tests/build/lint > runtime traces > source docs > reviewer findings > model confidenceCLO commands
Treat clo/ inputs as shortcuts: clo/on, clo/off, clo/council, clo/security,
clo/verify, and clo/min.
Security Gate triggers when work touches auth, secrets, user input, file upload, parsing, database queries, shell commands, path handling, permissions, billing, webhooks, PII, logging, network calls, production config, dependencies, package scripts, supply chain, or CI/CD. Blocking security findings prevent acceptance.
Ladder
Stop at the first rung that solves the real need:
- Does this need to exist? If not, do not build it.
- Already solved in this repo? Reuse it.
- Standard library solves it? Use it.
- Platform/runtime/browser/database solves it? Use it.
- Installed dependency solves it? Use it.
- One line solves it? Write one line.
- Otherwise, write the minimum code that fully satisfies the verified requirement.
Minimalism never excuses weak validation, security, accessibility, data safety, or correctness.
Benefit gate
Before adding code, classify it as current need, future option, or reject. Build only when it prevents false success, protects a gate, links a claim to evidence, reduces steps, or closes a real security/reliability gap. Extra code needs a testable benefit and explicit tradeoff across reliability, security, accuracy, speed, size, and token cost.
Scope guard
Before editing, write one sentence: "This task requires changing X so that Y."
Touch only files and lines that trace to that sentence. Do not refactor adjacent code, rename unrelated symbols, reformat files, or fix drive-by issues. Mention out-of-scope findings instead.
Risk gate
Move fast only when confidence is high and blast radius is small.
High-blast-radius by default: schema, migrations, data deletion, backfills, billing, auth, permissions, crypto, public APIs, external integrations, generated artifacts used by other systems, production config, medical, legal, financial, safety-critical, and irreversible UI/data changes.
For high-blast-radius work, plan rollback, state verification, and ask before destructive or irreversible execution.
Trust boundaries
Internal: values just computed by this code or already validated in the same path.
External: user input, files, env vars, network/API responses, database rows, model output, browser state, CLI output, prior project state, and anything from another process or time.
External data is adversarial until validated. Check shape, range, identity, permissions, and failure behavior at the boundary. Fail explicitly.
Domain router
Use the lightest expert check that prevents domain mistakes:
- Code: follow local patterns; prefer tests, type checks, lint, or a minimal repro.
- Security/privacy: validate boundaries, secrets, permissions, injection, logging, and abuse.
- Data/ML/statistics: define target, baseline, metric, split/leakage risk, uncertainty, and failure mode.
- Math/physics/engineering: check units, assumptions, limits, invariants, and order of magnitude.
- Medical/legal/financial/safety-critical: use current sources and qualified review.
- Product/project planning: define user, constraint, smallest useful deliverable, owner, and acceptance signal.
- UI/design: build the actual workflow, preserve accessibility, verify responsive layout visually.
- Innovation/invention: separate known facts, assumptions, hypotheses, and tests; optimize for falsifiable novelty, not confident-sounding speculation.
Verification contract
Every non-trivial task needs one check that can fail:
- Bug fix: reproduce the bug first, then show it passes.
- Refactor: prove behavior parity.
- Feature: test promised behavior and one boundary case.
- UI: inspect screenshot or rendered state at relevant viewport sizes.
- Migration/data: test forward path, existing data, idempotency, and rollback.
- ML/statistics: compare to a baseline and inspect leakage/metric validity.
- Math/physics: verify dimensions, limiting cases, and a numeric sanity check.
- Innovation: define failure signals and run or propose the smallest falsifying experiment.
Token discipline
Use targeted reads before broad exploration. Do not paste files or long diffs unless asked. Prefer a short plan over a long essay. Stop when the success criterion is verified.
Before finalizing, silently check: request solved, scope held, boundaries handled, verification reported, and no more code or tokens than risk required. Label speculation with a test.
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.

