Statem logo

Statem

CommunityPopular
henryqin1997
statem

Use when a long coding or research task should be managed with statem state-machine runbooks, including creating specs, starting or resuming runs, checking current state, transitioning with goto, saving progress, and reading history.

Overview

Publisherhenryqin1997
Repositorystatem
Skill namestatem
Stars
1.4K
Forks
132
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by henryqin1997 on GitHub. Read the source before you install it.

Installation

Install the Statem AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/henryqin1997/statem/tree/main/plugins/statem/skills/statem
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/henryqin1997/statem.git /tmp/statem
mkdir -p .claude/skills
cp -r /tmp/statem/plugins/statem/skills/statem .claude/skills/statem
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Statem in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Statem on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Statem is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Statem

Use statem when the task is long-running, iterative, easy to lose track of, or benefits from explicit agent state. Prefer it as a runbook, not as a rigid harness.

Workflow

  1. Find or create a statem spec such as statem.yaml.
  2. Validate it: python3 -m statem validate statem.yaml --json.
  3. Start or resume a run: python3 -m statem start statem.yaml --run-id <id> --json.
  4. Check state before acting: python3 -m statem cur --run-id <id> --json.
  5. Move only through allowed edges: python3 -m statem goto <node> --run-id <id> --json.
  6. Save progress before pausing: python3 -m statem save --run-id <id> --json.
  7. For handoff context, read recent history: python3 -m statem history --run-id <id> --tail 10 --json.

Use statem instead of python3 -m statem if the CLI is installed on PATH.

For dynamic servers, company machines, or disposable git checkouts, prefer a machine-local state directory. Set STATEM_STATE_DIR once, for example $HOME/.local/state/statem/<project>, so runtime state survives checkout replacement. After moving to a new checkout, run statem start <spec> --run-id <id> once to rebind the run to the current spec path.

Commit YAML runbooks with the repo. Do not commit runtime state; treat .statem/ or STATEM_STATE_DIR as local, copy-on-use execution data.

Context Clear

Avoid /clear in normal loops. It flushes the conversation, including any instructions that were supposed to run after it, and can lose useful intent that was not written to durable files. Prefer explicit transitions plus safe compaction.

Before a hard clear, generate a durable resume prompt:

bash
python3 -m statem prompt --run-id <id>

Paste the generated prompt immediately after /clear. The agent must recover from .statem with start, cur, and history; it should not rely on any pre-clear conversation.

Loop Compaction

For cyclic runbooks, prefer an explicit session hygiene node after a full loop. When continuing another cycle and context is noisy, generate a safe compaction instruction:

bash
python3 -m statem compact-prompt --run-id <id>

Run the generated /compact instruction through the host UI, then recover with statem cur and statem history --tail 10. Do not use hidden self-messaging to trigger compaction.

Agents may inspect the full graph with statem state; cur, next, and goto are for disciplined execution and attention anchoring, not for hiding the runbook.

Auto Loop Hook

When the host supports a Stop hook, users may opt into auto-loop behavior with integrations/hooks/statem_stop_hook.py. The hook runs when the agent is about to hand control back to the user. If a statem run is active, the current node is not a terminal/handoff node, and there are outgoing transitions, it returns a continuation prompt that tells the agent to inspect statem cur and keep working from the current node.

Registration examples live in:

  • examples/hooks/README.md
  • examples/hooks/codex-stop-autoloop.hooks.json
  • examples/hooks/claude-stop-autoloop.settings.json

Merge the matching snippet into the host hook configuration and use an absolute script path if the hook is registered outside the statem repository.

Treat this as host-level glue. It must not advance state, run /clear, or hide the graph. The agent should still transition only with statem goto.

Authoring Specs

  • Keep the static spec separate from .statem/ runtime state.
  • Use natural-language checks for low-friction runbooks.
  • Use in_hook for setup after entering a node.
  • Use before_transfer for redo/check loops while still in the current node. It is a spec field, not a CLI command; statem goto runs it automatically.
  • Use out_hook to persist current-node progress before leaving.
  • Use edge hook as prepare-transfer work after out_hook and before entering the target. If a blocking edge hook fails, the pointer stays at the source so the agent can retry.
  • Use type: command for deterministic shell checks.
  • Use type: predicate for file existence, non-empty files, text matches, and JSON-path checks.
  • Use type: llm_review when another model, agent, or script should review before a transition.

Do not manually edit .statem/runs/<run-id>/state.json unless the user explicitly asks for runtime surgery.

Frequently asked questions

What does the Statem AI skill do?

Use when a long coding or research task should be managed with statem state-machine runbooks, including creating specs, starting or resuming runs, checking current state, transitioning with goto, saving progress, and reading history.

Why use Statem on TypingMind?

Because you install it once and use it with any model. Statem is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Statem in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/henryqin1997/statem/tree/main/plugins/statem/skills/statem. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Statem?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Statem?

As many as you like. As long as a model supports skills, you can use Statem with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Statem AI skill free?

Yes. It is published on GitHub by henryqin1997 under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇