Meddev State Machines logo

Meddev State Machines

Community
AminAlam
meddev-state-machines

Define explicit, testable state machines with safe states, controlled transitions, and error handling suited to medical device safety classes. Use when working on state machines in medical device software.

Overview

PublisherAminAlam
Repositorymeddev-agent-skills
Skill namemeddev-state-machines
Stars
40
Forks
8
Bundled files
Instructions only
LicenseMIT
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 AminAlam on GitHub. Read the source before you install it.

Installation

Install the Meddev State Machines 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/AminAlam/meddev-agent-skills/tree/main/skills/meddev-state-machines
  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/AminAlam/meddev-agent-skills.git /tmp/meddev-agent-skills
mkdir -p .claude/skills
cp -r /tmp/meddev-agent-skills/skills/meddev-state-machines .claude/skills/meddev-state-machines
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Meddev State Machines 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 Meddev State Machines 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 Meddev State Machines 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.

Medical Device State Machine Design

Purpose

Define explicit, testable state machines with safe states, controlled transitions, and error handling suited to medical device safety classes.

When to Apply

  • Control logic, therapy delivery flows, connectivity/session management, alarm handling.
  • Any feature with discrete modes and safety-relevant transitions.

Requirements (testable)

  1. Explicit States: Enumerate states, including safe/error states; no implicit fall-through. Rationale: determinism.
  2. Guarded Transitions: Define entry/exit criteria and guards for each transition; reject invalid transitions. Rationale: prevent unsafe paths.
  3. Safe State: Define and implement a safe state reachable from any error condition; ensure outputs are rendered safe. Rationale: bounded failure.
  4. Timeout Handling: Include timeouts for blocking/wait states; transition to safe/error with annunciation. Rationale: avoid hangs.
  5. Reset/Recovery: Define recovery paths and conditions to re-enter operational states safely. Rationale: controlled restart.
  6. Traceability: Tag states/transitions with requirement and risk IDs; test each transition. Rationale: verification coverage.

Recommended Practices

  • Use table-driven or hierarchical state machines to reduce branching complexity.
  • Keep side effects on exit/entry functions; avoid scattered effects.
  • Include instrumentation for state transition logging (with debounce to avoid log storms).
  • Use static analysis to catch incomplete switch/enum handling.

Patterns

Table-driven state machine (C):

c
// REQ-SM-10, HZ-07, RISK-CTRL-19
typedef enum { ST_IDLE, ST_PRIME, ST_RUN, ST_ALARM, ST_SAFE } state_t;

typedef state_t (*handler_fn)(void);
typedef struct { state_t state; handler_fn fn; } state_entry_t;

static state_t handle_idle(void)  { /* ... */ return ST_PRIME; }
static state_t handle_prime(void) { /* ... */ return ST_RUN; }
static state_t handle_run(void)   { if (fault()) return ST_SAFE; return ST_RUN; }
static state_t handle_alarm(void) { /* annunciate */ return ST_SAFE; }
static state_t handle_safe(void)  { stop_outputs(); return ST_SAFE; }

static const state_entry_t table[] = {
    {ST_IDLE, handle_idle},
    {ST_PRIME, handle_prime},
    {ST_RUN, handle_run},
    {ST_ALARM, handle_alarm},
    {ST_SAFE, handle_safe},
};

Invalid transition guard:

c
// REQ-SM-21; TEST-SM-05
bool can_transition(state_t from, state_t to) {
    switch (from) {
        case ST_RUN: return (to == ST_ALARM || to == ST_SAFE);
        case ST_IDLE: return (to == ST_PRIME);
        default: return to == ST_SAFE; // fallback to safe only
    }
}

Timeout to safe state:

c
// REQ-SM-30; TEST-SM-08
if (timer_expired(&t_wait)) {
    set_state(ST_SAFE);
    alarm_timeout();
}

Anti-Patterns (risks)

  • Implicit default transitions in switch without handling all states -> risk: undefined behavior.
  • No safe state or unreachable safe transitions -> risk: uncontrolled outputs.
  • Mixing side effects in multiple places instead of entry/exit -> risk: inconsistent behavior.
  • Lack of timeout handling -> risk: hang in unsafe intermediate mode.

Verification Checklist

  • States enumerated (including safe/error) and documented.
  • Guards defined for all transitions; invalid transitions rejected.
  • Safe state reachable from any error; outputs rendered safe.
  • Timeouts implemented for wait states; alarm/annunciation verified.
  • Recovery/reset paths defined and tested.
  • Tests cover each state and transition; traceability tags present.
  • Static analysis/lint checks ensure exhaustive switch over states.

Traceability

  • Map REQ-SM-### to states/transitions and TEST-SM-### to transition coverage.
  • Log state transitions with IDs to support post-incident analysis.

References

  • IEC 62304 expectations for state control (design/implementation discipline).
  • ISO 14971 linkage for hazard controls via safe states.

Changelog

  • 1.0.0 (2026-01-04): Initial state machine skill with guarded transitions, safe state patterns, and coverage checklist.

Audit History

  • 2026-01-04: Audit performed. Verified:
    • State machine patterns are technically sound
    • Safe state concepts align with IEC 62304 and ISO 14971 hazard control principles
    • Code examples compile correctly (C11 compliant)

Frequently asked questions

What does the Meddev State Machines AI skill do?

Define explicit, testable state machines with safe states, controlled transitions, and error handling suited to medical device safety classes. Use when working on state machines in medical device software.

Why use Meddev State Machines on TypingMind?

Because you install it once and use it with any model. Meddev State Machines 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 Meddev State Machines in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/AminAlam/meddev-agent-skills/tree/main/skills/meddev-state-machines. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Meddev State Machines?

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 Meddev State Machines?

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

Is the Meddev State Machines AI skill free?

Yes. It is published on GitHub by AminAlam under the MIT 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 👇