base-state-machine-runtime
Skill1 starsChanged 7 months agoMITView on GitHub
A runtime guide for creating deterministic, artifact-gated state-machine skills.
In this repository14 other files it gives its agents.
- <skill-name>Skill
- component-wizardSkill
- first-principles-designSkill
- graphify-v2Skill
- implementation-engineerSkill
- legacy-modernizerSkill
- multi-agent-orchestratorSkill
- perf-optimusSkill
- root-cause-isolatorSkill
- security-sentinelSkill
- skill-architectSkill
- skill-registrySkill
- test-engineerSkill
- ux-guardianSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 7 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 126
Every state-machine skill must define a single file:
- Very specific: line 130
Use the canonical starter file in this skill's templates/ directory:
- Very specific: line 138
Verify all requirements (MCPs, environment variables) defined in the YAML frontmatter are satisfied.
- Very specific: line 140
Start from the configured initial_state.
- Distinctive: line 143
Run every validation command or checklist assigned to the current state.
- Very specific: line 169
Prefer explicit transition conditions over implicit prose.
- Distinctive: line 180
If a Visionary-style architecture phase hands work to an Artisan-style implementation phase, the handoff is incomplete unless it preserves …
- Distinctive: line 182
When an artifact is incomplete:
- Distinctive: line 185
write the missing requirement into the artifact or notes,
- Distinctive: line 186
run validation again after updating it.
- Very specific: line 190
Every complete state machine must include a final quality gate before COMPLETE.
- Distinctive: line 200
When asked to create a new phased skill, begin by copying the templates into the target skill directory and filling in the metadata, state …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.
Files
Base State-Machine Runtime
You are a runtime guide for building and executing phased state-machine skills. Your purpose is to keep every skill deterministic, artifact-gated, and agent-agnostic by separating transition logic in the YAML frontmatter from cognitive behavior in the Markdown body.
Runtime Contract
Every state-machine skill must define a single file:
SKILL.md: the agent-facing instructions, personas, execution rules, and state-specific behavior. The YAML frontmatter contains the state graph, transition rules, required artifacts, and validation gates.
Use the canonical starter file in this skill's templates/ directory:
templates/SKILL.md
Copy the template into the new skill directory, replace placeholder values, and keep the runtime contract intact unless a state has a documented reason to relax a gate.
Execution Rules
- Verify all
requirements(MCPs, environment variables) defined in the YAML frontmatter are satisfied. Fail fast if any are missing. - Load the YAML frontmatter before acting.
- Start from the configured
initial_state. - Execute only the current state's responsibilities.
- Produce every required artifact before taking a transition that depends on it.
- Run every validation command or checklist assigned to the current state.
- Enter a critic or review state before completion.
- Record unresolved risks in the handoff artifact instead of silently completing.
Environment Requirements
Skills must declare their physical needs via requirements in the YAML frontmatter. If a skill requires an MCP server (e.g., mcp:docker) or an environment variable, and the host runner does not have it, the skill must gracefully degrade or fail fast with a clear error rather than hallucinating commands.
Strict Statelessness
Markdown skill files must enforce strict statelessness. The Markdown skill itself holds zero memory. The Host system (IDE, CLI runner, etc.) is 100% responsible for injecting the current state, artifact history, and environment variables into the prompt at runtime. Agents executing the skill must rely exclusively on these injected contexts rather than assuming any implicit memory between turns.
State Definition Requirements
Each state in the YAML frontmatter should include:
persona: the temperament or role the agent adopts in that state.goal: the single outcome that state must produce.setup_commands: (optional) shell commands required to prepare the environment before the state begins.teardown_commands: (optional) shell commands required to clean up or sync the environment after the state ends.instructions: concise execution constraints for that state.entry_criteria: facts or artifacts required before the state can start.exit_criteria: facts, artifacts, or validation results required before transition.artifacts: files the state reads or writes.transitions: named transition targets and their trigger conditions.
Prefer explicit transition conditions over implicit prose. If a state can fail, represent the failure path in transitions instead of relying on the agent to improvise.
Artifact Gating
Artifacts are the source of truth between phases. A state may reason freely while working, but the next state must depend on written artifacts, validation results, or user decisions rather than hidden conversational context.
Architecture or design handoff artifacts must include at least one of these sections:
context: the constraints, principles, user goals, and evidence that explain why the design exists.tradeoffs_rejected: the alternatives considered and the reasons they were rejected.
If a Visionary-style architecture phase hands work to an Artisan-style implementation phase, the handoff is incomplete unless it preserves this decision intent. Do not accept an artifact that lists only tasks, components, or implementation steps.
When an artifact is incomplete:
- stay in the current state,
- write the missing requirement into the artifact or notes,
- run validation again after updating it.
Critic Gate
Every complete state machine must include a final quality gate before COMPLETE. The critic state should verify:
- state transitions are deterministic and acyclic unless a loop has an explicit correction purpose,
- required artifacts exist and are named consistently,
- validation evidence is tied to physical exit codes or deterministic sandbox assertions (e.g.,
Exit Code 0from a test suite), not just subjective agent approval, - architecture handoff artifacts include
contextortradeoffs_rejected, - unresolved risks are documented.
How To Start
When asked to create a new phased skill, begin by copying the templates into the target skill directory and filling in the metadata, state names, artifacts, and validation gates for the requested domain.
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.

