agentleFS
dip497dip497/onmywatch/skills/statechart/SKILL.md

statechart

Skill1 starsChanged 19 days agoMITView on GitHub

Try every path through a system that moves between states, and show the shortest path to each state that breaks a rule. Use for /statechart, for a checkout, sign-up, approval, retry, sync, lock or any flow where the order of steps matters, when asked what if, can this ever happen, are all the cases covered, or to find a bug by its path. Works before any code exists. Needs only Python.

23 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ketchup-video and deslop.

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.
  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 10 projects that use this

  • SentrySkill

    deslop

    Strip AI-generated noise from the diff before pushing — extra comments a human wouldn't write, defensive try/catch in trusted code paths, casts to any, inline imports in Python, and other style inconsistencies with the surrounding file. Use this immediately before commit so the diff stays clean.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

5 rules. 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 4

    Distinctive

    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
  1. Distinctive:

    Do not use it for one function with no states over time.

    line 13
  2. Distinctive:

    Write each rule as one sentence the reader would agree to, such as "A customer is never charged twice".

    line 17
  3. Distinctive:

    Add the things that go wrong: timeouts, retries, a second click, a crash between two writes.

    line 46
  4. Distinctive:

    If a step never happened, fix the model before you trust any "holds".

    line 66
  5. Very specific:

    If the chart has more than about 20 boxes, make screen() coarser: give one word to states that the reader sees as the same.

    line 74

“Common” is measured: kept by at least 6 in 10 of the 22 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

statechart

Testing tries the cases you thought of. This tries every path. The reader decides what must always be true; the checker shows whether the design can break it.

Topic: $ARGUMENTS. If that is empty, the flow in the conversation.

Do not use it for one function with no states over time. Use a test for that.

1. Write the rules first

Write each rule as one sentence the reader would agree to, such as "A customer is never charged twice". Show the rules to the reader before you trust the result. Never weaken a rule to make it hold.

2. Write the model

A model is one small Python file. Put it in .show-me/<YYYY-MM-DD>-<topic>/model.py. Read the real code or docs first; a model of a guess proves nothing.

TITLE = "Checkout With a Retry"
START = {"phase": "cart", "charged": 0}          # or a list of start states

def you_press_pay(s):
    if s["phase"] == "cart":
        return {**s, "phase": "paying"}          # None or no return: the step cannot happen

def the_charge_times_out(s):
    if s["phase"] == "paying":                   # a list: any of these can happen
        return [{**s, "phase": "retrying"}, {**s, "phase": "retrying", "charged": s["charged"] + 1}]

STEPS = {"you press pay": you_press_pay, "the charge times out": the_charge_times_out}
RULES = {"A customer is never charged twice": lambda s: s["charged"] <= 1}

def screen(s):                                   # optional: the words on each box
    return s["phase"].title()

def is_end(s):                                   # optional: states where stopping is correct
    return s["phase"] == "paid"
  • Name each step as the person sees it: "you press pay", "the charge times out". Do not name the code.
  • Add the things that go wrong: timeouts, retries, a second click, a crash between two writes. A model with only the happy path finds nothing.
  • For things that happen at the same time, make each read and each write its own step. Every order gets tried.
  • A state must hold only plain values. Keep counts small: 2 workers and 1 retry find most bugs. A model above MAX_STATES (100,000 by default) stops and says the check is not complete.
  • examples/checkout.py is a working model.

3. Run it

python3 <this skill>/scripts/check_model.py model.py --out <folder>

It writes report.md, chart.json and chart.html to the folder. It exits 0 if every rule holds, 1 if there is a problem, and 2 if the check is not complete.

It reportsMeans
Rule brokenThe shortest path to a state that breaks the rule
Stops with no step outA dead end that is_end does not allow
Can no longer reach an endA loop or a branch the flow cannot leave
Steps that never happenedA step that can never run, so the model is probably wrong

If a step never happened, fix the model before you trust any "holds".

Then run the page check, and read the screenshots:

python3 <show-me skill>/scripts/render.py <folder>/chart.html <folder>/shots

If the chart has more than about 20 boxes, make screen() coarser: give one word to states that the reader sees as the same. Keep each state of a bug path.

4. Replay each bug against the real thing

When the model describes code that exists, run each bug path on the real code, as a test or a live repro, one step at a time. If the bug does not happen, treat the model as wrong until you show that it is not. Then fix the real bug with /fix-it-properly, and run the checker again on the fixed model.

5. Hand over

Open chart.html, and give its full path. Never put a Mermaid chart in the chat. The terminal shows it as source code. In your reply:

  • One line for each problem: the rule, and the path as numbered steps.
  • Which rules hold, and the number of states checked.
  • What the model leaves out. "Holds" means it holds in this model, on these counts, and nothing more.
  • Whether you replayed each bug on real code, and the result.

This checks what can happen, and whether an end can still be reached. It does not check timing, speed, or that a step will ever run.

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.