state-machine-design

state-machine-design is a skill for Claude Code, Codex from AmethystLuna/embedded-workbench. It costs 54 tokens per session (1,883 once invoked), scanned A, original, MIT.

A method for designing the step-by-step logic of embedded firmware, such as devices with microcontrollers. It focuses on states, successful and failed operations, timeouts, retries, acknowledgements, and recovery.

In plain words
What is it for?
Use it to review or fix asynchronous protocols, ACK/NACK handling, pending flags, timeout logic, and retry behavior in embedded firmware. It is not intended for general TCP, HTTP, or MQTT protocol design.
Why use it?
It helps prevent firmware from getting stuck during communication failures, retries, pauses, stops, or reconnects. It also avoids treating a low-level send result as proof that the receiving application got the message.

Skill for Claude CodeCodex

Part of the embedded-workbench plugin — 8 skills, 4 agents, 1 hook 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/amethystluna/embedded-workbench/state-machine-design
Any agent
npx skills add AmethystLuna/embedded-workbench --skill state-machine-design
Clone the repo
git clone --depth 1 https://github.com/AmethystLuna/embedded-workbench

Made for: Claude Code, Codex.

Or install embedded-workbench, the plugin that ships this one along with the rest of its 8 skills, 4 agents, 1 hook.

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-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/amethystluna/embedded-workbench/state-machine-design.svg)](https://agentmods.dev/skills/amethystluna/embedded-workbench/state-machine-design)
Your own site
<a href="https://agentmods.dev/skills/amethystluna/embedded-workbench/state-machine-design"><img src="https://agentmods.dev/badge/skills/amethystluna/embedded-workbench/state-machine-design.svg" alt="Measured on agentmods" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,883 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.00054 $0.01883
Opus 5 $0.00027 $0.00941
Sonnet 5 $0.00011 $0.00377
Haiku 4.5 $0.00005 $0.00188

Measured 5d ago against content hash c349d2f9f330, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

state-machine-design 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 5d 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.

skills/state-machine-design/SKILL.md · 191 lines

How it starts

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

State Machine Design

Core Rules

  • Fix the state model, not the symptom. Every in-progress or pending flag must have explicit success, failure, timeout, and reset exits.
  • Timeout logic must be gated on real pending work. Idle states must not trigger retry, recovery, or error transitions.
  • Do not trust a low-level send return value as proof of delivery when an application-layer ACK exists. Use the protocol's completion signal.
  • When adding retries, also define attempt timestamps, backoff rules, and cleanup paths so the state machine cannot lock up silently.
  • If pause, stop, or reconnect can interrupt the normal flow, add an explicit recovery or re-drive branch instead of assuming the old path will naturally resume.

Transition Gates

  • When a state transition depends on multiple preconditions, verify every one explicitly at the transition gate. Do not rely on implicit assumptions (e.g., "the timer expired, therefore everything must be healthy"). A single unchecked precondition is the most common source of silent state corruption.
  • If a target state's preconditions can become false while already in that state, define a reverse transition back to the source state. One-way state latches without fallback paths will eventually leak incorrect state to downstream consumers.

Transient Tolerance

  • Distinguish between genuine state-changing events and transient perturbations during mode switches, direction reversals, or re-initialization windows. The latter need a tolerance or grace window; only the former should advance the state machine or increment error counters.

Implementation Patterns

Pattern A: Per-State Handlers + Unified Error Gate

Read the full file on GitHub · 191 lines

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. 5d ago First seen · 191 lines · 54 tokens per session scan A c349d2f9f330

Subscribe to this mod's changes

state-machine-design is a skill published in the GitHub repository AmethystLuna/embedded-workbench (8 stars, last pushed today), licensed MIT. It adds 54 tokens to every session and 1,883 once invoked, about $0.0003 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-31.

Related

Other skills, from other repositories

gke-compute-classes

Configures, optimizes, and troubleshoots GKE ComputeClasses. Use when configuring Spot VMs with on-demand fallback, targeting specific accelerators (GPUs/TPUs) or machine families, restricting ComputeClass access, or debugging pending pods related to node pool auto-creation. Do not use for cluster-level Node Auto…

google/skills · 83 tokens

jetson-diagnostic

Read-only Jetson health snapshot for identity, memory, GPU, thermal, power, storage, services, and top processes.

NVIDIA/skills · 30 tokens

dsh-web-pre-push-checks

Use before pushing, opening or updating a pull request, or claiming dsh-web checks pass. Selects the required repository gates and diff-specific generation, build, and GUI evidence.

zhu1090093659/dsh-web · 45 tokens

dsh-sdk-upgrade

Safely select and install a compatible official @deepseek-ai SDK release for dsh plugin projects (dsh-web, dsh-trading, and similar monorepos) from npm using an isolated worktree, explicit cohort review, CI-equivalent validation, and controlled rollout — including syncing the project's declared DSH host-version floor…

zhu1090093659/dsh-web · 176 tokens

doca-socket-relay

Use this skill when the operator is driving the DOCA Socket Relay to bridge a socket-oriented host application onto a BlueField DPU peer without rewriting it — picking the deployment shape (in-process, sidecar, or BlueField service container), configuring the host-side socket and the DPU-side forwarding endpoint…

NVIDIA/skills · 236 tokens

offensive-z-wave

Z-Wave attack methodology — sniffing with Z-Force / EZ-Wave / RTL-SDR + ZniffMobile, S0 (legacy) network-key derivation flaw and key reuse, S2 (modern) ECDH commissioning analysis, replay/injection on unauthenticated nodes, default-key brute-force on test deployments, and home-automation hub pivots. Use when targeting…

SnailSploit/Claude-Red · 113 tokens