agentleFS
sarathsomanasarathsomana/tech-skills/skills/base-state-machine-runtime/SKILL.md

base-state-machine-runtime

Skill1 starsChanged 7 months agoMITView on GitHub

A runtime guide for creating deterministic, artifact-gated state-machine skills.

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

    Every state-machine skill must define a single file:

    line 126
  2. Very specific:

    Use the canonical starter file in this skill's templates/ directory:

    line 130
  3. Very specific:

    Verify all requirements (MCPs, environment variables) defined in the YAML frontmatter are satisfied.

    line 138
  4. Very specific:

    Start from the configured initial_state.

    line 140
  5. Distinctive:

    Run every validation command or checklist assigned to the current state.

    line 143
  6. Very specific:

    Prefer explicit transition conditions over implicit prose.

    line 169
  7. Distinctive:

    If a Visionary-style architecture phase hands work to an Artisan-style implementation phase, the handoff is incomplete unless it preserves …

    line 180
  8. Distinctive:

    When an artifact is incomplete:

    line 182
  9. Distinctive:

    write the missing requirement into the artifact or notes,

    line 185
  10. Distinctive:

    run validation again after updating it.

    line 186
  11. Very specific:

    Every complete state machine must include a final quality gate before COMPLETE.

    line 190
  12. Distinctive:

    When asked to create a new phased skill, begin by copying the templates into the target skill directory and filling in the metadata, state …

    line 200

≈ “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.

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

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

  1. Verify all requirements (MCPs, environment variables) defined in the YAML frontmatter are satisfied. Fail fast if any are missing.
  2. Load the YAML frontmatter before acting.
  3. Start from the configured initial_state.
  4. Execute only the current state's responsibilities.
  5. Produce every required artifact before taking a transition that depends on it.
  6. Run every validation command or checklist assigned to the current state.
  7. Enter a critic or review state before completion.
  8. 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 0 from a test suite), not just subjective agent approval,
  • architecture handoff artifacts include context or tradeoffs_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.

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.