agentleFS
malinskibeniaminmalinskibeniamin/skills/bend-laws/SKILL.md

bend-laws

Skill4 starsChanged 11 days agoMITView on GitHub

Prove business rules with Bend laws and check shipped TypeScript or Go against the proven model. Use for formal proof, LAWS.bend or PROOF.bend, or acceptance criteria that must hold for every input.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When proving changed behavior or maintaining verification, read the Poteto adaptation.

    line 9
  2. Distinctive:

    Use laws for rules that decide money, access, or safety and are finite or integer arithmetic: modes, permissions, statuses, thresholds, …

    line 17
  3. Distinctive:

    Read the shipped rule and its tests.

    line 32
  4. Very specific:

    Call only the functions under test.

    line 37
  5. Very specific:

    Write imported constructors qualified and braced: case P.Yes{}:.

    line 41
  6. Very specific:

    Write oracle.bend, whose main prints the # @generated header and one <inputs> <decision> line per input, then run laws/check.sh --write.

    line 50
  7. Very specific:

    Before writing Bend, run bend guide.

    line 67
  8. Very specific:

    Keep @unsafe, def f? and foreign code out of law directories: they switch off the soundness a proof relies on.

    line 73
  9. Very specific:

    Keep the Bend version pinned in install-bend.sh.

    line 75
  10. Distinctive:

    Keep source on the machine: sending code to BendAI or publishing to the Bend hub needs explicit approval.

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

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

When proving changed behavior or maintaining verification, read the Poteto adaptation.

A law is an acceptance criterion that a proof must meet for every input. Bend checks the proofs against a reference model of the rule. A table generated from that model ties the shipped code to the laws.

Fit

Use laws for rules that decide money, access, or safety and are finite or integer arithmetic: modes, permissions, statuses, thresholds, time windows, rounding. Route strings, parsers, JSON, floats (Bend's F32 is axiomatic and there is no F64), and UI to property tests (fast-check, rapid) instead; proving them costs more than it catches.

Ownership

File in laws/<rule>/Owner
LAWS.bendHuman. The bend-laws-guard hook denies agent writes; a human opts a session in with BEND_LAWS_AUTHOR=1.
policy.bend (model), PROOF.bend, oracle.bendAgent
decisions.txtGenerated by laws/check.sh --write

Workflow

  1. Read the shipped rule and its tests. List every input and the decision it returns. Done when the input domain is enumerated (finite) or its boundaries are named.
  2. Draft the laws in a scratch directory as LAWS_draft.bend (import paths allow only letters, digits, _ and -), and prove them there. Give each law one plain-English comment. Done when the human has reviewed the draft and committed it as LAWS.bend.
    • Call only the functions under test. Define every helper a law uses inside LAWS.bend, so the model cannot weaken a law by redefining its vocabulary.
    • State what must hold. Anything a law leaves open is whatever the model does, so pair each prohibition ("never runs X") with the requirement ("runs only what declares Y").
    • Write imported constructors qualified and braced: case P.Yes{}:. A bare case Yes: on an imported type binds every value and the law passes vacuously (bendlang/bend#1328); check.sh and the hook reject it.
  3. Model the rule in policy.bend, mirroring the shipped code's branch order, and prove each law in PROOF.bend as def Laws.<law>(...). Done when bend PROOF.bend prints ALL PROOFS CHECK.
  4. Mutate the model once per law: change a branch the law guards and confirm bend PROOF.bend prints SOME PROOFS FAIL at that law; then revert. Done when every law has rejected a mutant. A law no mutant fails is vacuous.
  5. Write oracle.bend, whose main prints the # @generated header and one <inputs> <decision> line per input, then run laws/check.sh --write.
  6. Compare the shipped code: a unit test parses decisions.txt and asserts the shipped function returns every row. For a finite domain, also assert each input appears once, with the domain derived from the code's types so a new value breaks the build. For an unbounded domain, generate inputs with property tests, seed the law boundaries, and compare against the model compiled with bend -o model.mjs. Done when a mutant in the shipped code fails the test.
  7. Copy templates/install-bend.sh and templates/check.sh into laws/, then add a required CI job that runs both. Add CODEOWNERS for laws/**/LAWS.bend and laws/**/decisions.txt. Done when the job fails on a missing LAWS.bend and passes once it lands.

To change a rule: the human edits the law, the agent updates the model and proofs, runs check.sh --write, then changes the shipped code until its unit test matches. Review every decisions.txt diff as a behavior change.

Before writing Bend, run bend guide; read REFERENCE.md for the syntax traps, proof patterns, --verdict setup and upgrades.

Guardrails

  • Propose law changes to the human; never edit LAWS.bend or work around the hook.
  • Keep @unsafe, def f? and foreign code out of law directories: they switch off the soundness a proof relies on. Bend's gate and check.sh both reject them.
  • Keep the Bend version pinned in install-bend.sh; upgrade deliberately and re-prove.
  • Keep source on the machine: sending code to BendAI or publishing to the Bend hub needs explicit approval.

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.