state-machine

state-machine is a skill for Claude Code from peteski22/agent-pragma. It costs 9 tokens per session (1,401 once invoked), scanned A, original, Apache-2.0.

A checker for state machines: code that represents states and the allowed moves between them. It examines transitions, final states, cleanup, cancellation, and whether the model matches what the program actually does.

In plain words
What is it for?
Use it to review changed code that defines statuses, transition rules, lifecycle handling, or cancellation behavior.
Why use it?
It can reveal invalid state changes or missing cleanup at the end of a process without mixing in style, security, performance, or test-coverage feedback.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: agent in frontmatter.

Part of the pragma plugin — 12 skills, 2 agents shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/peteski22/agent-pragma/state-machine
Any agent
npx skills add peteski22/agent-pragma --skill state-machine
Clone the repo
git clone --depth 1 https://github.com/peteski22/agent-pragma

Made for: Claude Code.

Or install pragma, the plugin that ships this one along with the rest of its 12 skills, 2 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for state-machine

README.md
[![agentmods](https://agentmods.dev/badge/skills/peteski22/agent-pragma/state-machine.svg)](https://agentmods.dev/skills/peteski22/agent-pragma/state-machine)
Your own site
<a href="https://agentmods.dev/skills/peteski22/agent-pragma/state-machine"><img src="https://agentmods.dev/badge/skills/peteski22/agent-pragma/state-machine.svg" alt="Measured on agentmods" height="20"></a>
Per session 9 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,401 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00009 $0.01401
Opus 5 $0.00005 $0.00700
Sonnet 5 $0.00002 $0.00280
Haiku 4.5 $0.00001 $0.00140

Measured 6d ago against content hash 86739f8378e3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

state-machine scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/pragma/skills/state-machine/SKILL.md · 202 lines

How it starts

The opening of the file, as written. The whole thing — 202 lines — stays where its author put it; the contents beside it link to each section on GitHub.

State Machine Validator

You are a deterministic state machine validation agent.

Scope Declaration

This validator checks ONLY:

  • State machine definitions (enums, consts, status fields)
  • State transition logic and guards
  • Terminal and final state classifications
  • Cleanup and cancellation enforcement at terminal transitions
  • Model-vs-runtime consistency (does the code's model match what actually happens?)

This validator MUST NOT report on:

  • Code style or formatting (handled by language-specific validators)
  • Language idioms (handled by language-specific validators)
  • Security vulnerabilities (handled by security)
  • Performance
  • Test coverage

You do NOT rewrite code unless explicitly asked. You do NOT run linters.

Your task is to validate that state machine definitions, transitions, and terminal classifications are correct and consistent with runtime behavior.


Input

Get all changed files. Combine committed, staged, and unstaged changes to capture all recent work:

{ git diff HEAD~1 HEAD --name-only --diff-filter=ACMRT 2>/dev/null; git diff --cached --name-only --diff-filter=ACMRT 2>/dev/null; git diff --name-only --diff-filter=ACMRT 2>/dev/null; } | sort -u

Filter out generated/vendor files:

grep -v -E '(node_modules|vendor|\.min\.|\.generated\.|__pycache__|\.pyc$)'

Detection Step

Before running full analysis, check whether the diff contains state-machine-relevant changes. Grep the changed files for patterns like:

  • Enum/const definitions with status/state-related names (e.g., StatusRunning, StateFinal, TIMED_OUT)
  • Terminal/final state sets or classifications (e.g., terminalStates, isFinal, isTerminal)
  • Transition functions or status-setting logic (e.g., transition, setState, updateStatus)
  • State machine libraries or patterns (e.g., StateMachine, FSM, workflow)

If no state-machine-relevant changes are detected, output a clean pass:

{
  "validator": "state-machine",
  "applied_rules": [
    "Finite State Machine design principles"
  ],
  "files_checked": [],
  "pass": true,
  "hard_violations": [],
  "should_violations": [],
  "warnings": [],
  "summary": {
    "hard_count": 0,
    "should_count": 0,
    "warning_count": 0
  },
  "note": "No state machine changes detected"
}

Read the full file on GitHub · 202 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 202 lines · 9 tokens per session scan A 86739f8378e3

Subscribe to this mod's changes

state-machine is a skill published in the GitHub repository peteski22/agent-pragma (22 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 9 tokens to every session and 1,401 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

explain-issue

Explain a GitHub issue: the background problem and the proposed solution.

dyoshikawa/rulesync · 18 tokens

simplifier

Replatform mode ("lift, tinker, and shift") — simplify a 1:1-lifted legacy system in place: modernize code and remove external dependencies, one pass at a time, each bracketed by characterization-tests replays, structure preserved. Owns the stack-neutral pass discipline; the transformation catalog and dependency…

AdamBien/airails · 0 tokens

error-handling

Apply error handling and recovery patterns in JavaScript/TypeScript or Node.js. Use when implementing error handling, retry logic, or when the user mentions domain errors, error recovery, error escalation.

metarhia/metaskills · 43 tokens

cpp-sanitizers

Use in C/C++ projects for crashes, hangs, UB, data races, memory errors. ASan/UBSan/TSan runtime checks. Build sanitizer config separately.

Redtropig/harness-anchor · 40 tokens

self-correction-loop

Use when a hook/tool returns a warning, lint/type/build error, or test failure after your edit. Iterate evidence-first; stop when verification passes.

Redtropig/harness-anchor · 35 tokens

threejs-errors-performance

Use when a Three.js scene has performance problems: low FPS, memory leaks, too many draw calls, or high GPU memory usage. Prevents the common mistake of forgetting dispose(), creating objects in the render loop, or not using InstancedMesh for repeated objects. Covers disposal patterns, draw call optimization…

Impertio-Studio/Three.js-Claude-Skill-Package · 127 tokens