12 agents · 23 skills · 50+ DHF documents · 16 CI workflows
English · Español
Quickstart · Getting started · Docs site · The 12 agents · Worked example · Discussions · Contributing
This kit distills the experience of a real SaMD Class B project: a team of specialized AI agents, the compliance ruleset, multi-agent workflows, the persistent memory structure, and a complete regulatory Design History File (DHF) — all generalized into ready-to-adapt templates.
This repository is not an application. It is the scaffolding and methodology so that you (and your AI coding agent, such as Claude Code) can start a SaMD from scratch without reinventing the compliance, testing, and traceability process that IEC 62304 + ISO 14971 demand.
You need: Git, Claude Code, Python 3.12 and Node ≥ 24 (for the runnable skeleton). Docker is optional (real-Postgres test tier, Dockerfile, docker-compose.yml).
git clone https://github.com/bryan-basg/samd-starter-kit my-medical-device
cd my-medical-device
rm -rf .git && git init -b main # run ONLY inside the new folder: starts your own history
bash scripts/init_kit.sh # interactive & re-runnable: fills the {{...}} placeholdersTip
Then open GETTING_STARTED.md — the guided path: classify your software (A/B/C), fill the four foundation documents in order, wire your stack, and learn the daily loop with the agent team. It tells you which of the 50+ documents actually apply to your class, so you don't drown in templates.
Note
Language. This README and GETTING_STARTED.md are in English, but the agent ruleset (CLAUDE.md, .claude/), the DHF templates and the field notes are written in Spanish, the language of the project they were extracted from. The language the agent uses when talking to you is set by the {{CHAT_LANG}} placeholder in init_kit.sh. Translations of the rules and templates are a welcome contribution.
- A skeleton that refuses to run unsafely. It won't start with public or weak secrets, and no unhandled error writes user data to the server log.
- Gates that fail when they didn't look. Coverage, doc links, code citations, placeholders, translations and the SBOM go red on an empty scan; tests pin every CI step so none can be switched off silently.
- Traceability that resolves. Every requirement cites code and a test by name, and CI checks that both exist today.
- Clinical UX guardians. Text contrast, control borders, flat design and reduced motion are tested, not just documented.
- Controls that don't depend on the AI remembering. Hooks stop subagents from running heavy processes on your machine and log every change to a clinical module, whether it came from the editor or the terminal.
- A solo founder or startup building health software who doesn't want to discover regulatory compliance the hard way.
- A medtech / medical-device company that wants a ready process scaffold (IEC 62304 + ISO 14971) with traceability by design.
- Teams working with AI agents (Claude Code) who want a crew of specialists with the SaMD rules pre-loaded.
| Piece | Path | What it is |
|---|---|---|
| Agent ruleset | CLAUDE.md |
The core: "Rule 0" (SaMD is the absolute priority) + how the agent works, empathy, boy scout, impact analysis and block closure. |
| Per-layer rules | .claude/rules/ |
The rest of the ruleset: five path-scoped rules (backend, clinical UX, testing, CI, docs) that load only when that layer is touched, plus two cross-cutting ones (hard execution rules, commands). What only the main session needs lives in the output style .claude/output-styles/orquestador.md. |
| Team of 12 agents | .claude/agents/ |
Per-layer specialists — see the team. |
| Skills & commands | .claude/skills/, .claude/commands/ |
23 reusable procedures, e.g. /samd-trace (impact analysis before declaring anything "fixed"), /anti-drift, /ola-mutation, /cierre-bloque, /ci-rojo, /tandas-agentes, /trabajo-nocturno, /revision-visual. |
| Mechanical hooks | .claude/settings.json, .claude/scripts/ |
Guardrails that don't depend on the agent remembering: a PreToolUse lock stops a subagent from running the full suite or a heavy process (mutation, fuzz, E2E) on your machine, and the clinical watcher (PostToolUse) checks what changed on disk after every edit or terminal command, logs each change to a clinical/critical module (local file, outside git), reminds the agent of the traceability it owes and hands it the layer's rules when the layer was touched from the terminal. If the watcher fails, it says so. |
| Multi-agent workflow | .claude/workflows/ |
samd-review: diff review across risk dimensions with adversarial verification. |
| Development protocol | .agents/workflows/ |
Agent-agnostic mirror of the stable process. |
| Memory | memory/MEMORY.md |
The agent's persistent memory structure. |
| Example RFCs | docs/05_design_decisions/RFC-001..003 |
Three real SaMD decisions already written (encryption at rest, JWT-only identity, external scheduler). |
| Design History File | docs/ |
50+ regulatory & process templates: ISO 14971, SaMD traceability, IEC 62304 plan, safety classification, SOUP, clinical evaluation/validation, post-market, IFU, user docs, privacy, runbooks. Also published as a docs site. |
| Working CI/CD | .github/workflows/ |
16 workflows — 11 inheritable gates (CI, security via Trivy+Semgrep, mutation via Stryker, API fuzz via schemathesis, DAST via OWASP ZAP, SBOM, Postgres tier, OpenAPI contract-drift, project-state audit, stale PRs, deploy template) + 5 kit-maintenance (docs, quality gates, placeholder guard, release, red-main alert). Reference stack: React+TS / Python+FastAPI. |
| Runnable skeleton | app/ · frontend/ · tests/ |
A minimal FastAPI + React/TS example wiring the hard rules (token-only identity, AES-256-GCM at rest, fail-safe, flat accessible UI). Runs with zero infra and ships with its own tests (pytest, vitest) that CI runs on every push. Delete it when you bring your own app. |
| Worked examples | examples/auralog/ · examples/dosificta/ |
Two fictional devices with their DHF filled in: AuraLog (Class B) and DosiFicta (Class C, an insulin-dose calculator — shows what the developer does differently when a bug can kill). |
flowchart TB
RULES["CLAUDE.md<br/>the ruleset · Rule 0"]
AGENTS[".claude/agents/<br/>12 layer specialists"]
WF[".claude/workflows/<br/>samd-review"]
CODE["app/ · frontend/ · tests/<br/>your application"]
DHF["docs/<br/>Design History File"]
CI[".github/workflows/<br/>CI gates"]
RULES --> AGENTS
AGENTS -->|build| CODE
AGENTS -->|record traceability| DHF
WF -->|adversarial review| CODE
CODE --> CI
DHF --> CI
style RULES fill:#1F6FC6,color:#fff
The ruleset configures the agents; the agents build your code and keep the DHF in sync; the review workflow and CI are the gates. New here? Start with GETTING_STARTED.md.
The core rule is Rule 0: every technical decision is subordinate to SaMD compliance. In practice, four habits the agent team enforces on its own:
- Mandatory traceability (§5.1/§5.7): every clinical/schema/security change is recorded in the DHF in the same PR.
- Demonstrable verification (§5.7): nothing is declared "green" without running the linked tests and reporting numbers.
- Explicit fail-safe (ISO 14971): when something fails, it degrades safely and predictably — never silently.
- Impact analysis before fixing (§7.4): a bug is fixed after reviewing ALL consumers of the symbol, not just the file where it was reported.
And a handful of hard rules that a better model does not override:
- No one commits or pushes without the owner's explicit OK.
- The mutation engine never runs in parallel with agents writing tests.
- Adversarial verification is mandatory on clinical/security findings before acting.
- Identity comes only from the token (JWT-only) — never
user_idfrom the client. - Errors never expose tracebacks to the user — empathetic messages + correct HTTP code.
See what each agent covers (12 specialists, one per layer)
| Agent | Layer | Use it for |
|---|---|---|
backend |
API + logic | Routers, services, schemas, auth, audit, resilience fuses, tests. |
clinical-algorithms |
Clinical (SaMD core) | Validated scales and questionnaires, scoring and severity bands, crisis network, clinical PHI, idempotency. |
frontend |
UI + client | Components, hooks, DAOs, offline-first sync, UI tests, mutation, neuro-UX. |
db-architect |
Data | Schemas, migrations, connection pool, at-rest encryption, access rules. |
cloud-ops |
Platform | Compute, managed DB, scheduler, secret manager, hosting, CI/CD, deploys. |
qa-mutation |
Testing | Mutation testing waves, mutant killers, scoped configs, score ratchet. |
e2e-integration |
E2E testing | End-to-end flows, harness and per-worker user seeding, smoke/regression workflows, environmental flaky triage. |
security-samd |
Security | SAST (Trivy+Semgrep+fuzz), encryption, key management, JWT-only, audit. |
samd-audit-trace |
Regulatory (audits) | Audits a changeset against IEC 62304 §5.1/§5.7 + ISO 14971. Reports gaps. |
docs-dhf |
Regulatory (writes) | Materializes DHF updates: Master Map, risk matrix, traceability, RFCs. |
i18n-translations |
i18n | Locales across all languages, key parity, anti "copied-untranslated" auditing, pre-certification clinical glossary. |
mobile-native |
Mobile | Packaging the web client as a native app (Capacitor/RN/equiv.), native plugins/auth/storage, push, build/sign/distribution. |
The kit isn't only templates — it carries the hard-won experience behind them. These are based on real production incidents, generalized (no product specifics):
Read the four field notes
- Startup discipline — what to prioritize in the first days: compliance before code, memory and shipping discipline, avoiding over-building before validation, empathetic UX as a clinical decision.
- Production lessons — what broke in production and what we learned: pool exhaustion masquerading as auth failures, the migration "green" that lies, env-var footguns, offline-first discipline, mutation tests as contracts.
- Reference architecture — the hybrid offline-first pattern (client + API + transactional DB + cloud) with the why behind each decision and when not to use it.
- The "Engineers' Table" method — orchestrating a team of AI agents on a regulated codebase without losing coherence: the anti-drift protocol, adversarial verification, and the hard rules a better model doesn't override.
IEC 62304 (medical software lifecycle) · ISO 14971 (risk management) · ISO 13485 (QMS) · IEC 62366 (usability) · WCAG 2.1 AA (accessibility) · GDPR + HIPAA (health data privacy/security).
Important
This kit is a process scaffold, not regulatory advice and not a guarantee of certification. Safety classification, clinical evidence, and approval of a medical device require the judgment of regulatory professionals and, depending on the market, a Notified Body or the relevant health authority.
This kit didn't start as a template. It was extracted from a real, in-production Class B SaMD platform — an offline-first health application built and operated end to end: backend, data layer, cloud, CI/CD, the regulatory DHF, and a team of AI agents driving the work. The agents, rules, workflows and lessons here are what actually survived contact with production and regulation.
Maintained by @bryan-basg. If it saves you from learning these lessons the hard way, it did its job.
Using this kit — in a clinic, a radiology department, a startup or a course? Tell us in Discussions → Show and tell. Questions go to Q&A. Real-world feedback is what shapes the next version.
See CONTRIBUTING.md. Security reports: privately, see SECURITY.md. Be kind: Code of Conduct.
MIT. Built distilling the experience of a real Class B SaMD project. Scope of what this kit is and is not: see NOTICE.md.