safety-critical-patterns

safety-critical-patterns is a skill for Claude Code, Codex from HermeticOrmus/LibreEmbed-Claude-Code. It costs 0 tokens per session (1,445 once invoked), scanned A, original, MIT.

A reference guide for writing C programs used in safety-critical devices, such as vehicles or medical equipment, according to MISRA C rules. These rules make code more predictable and easier to check.

In plain words
What is it for?
Choosing explicit data types, writing functions with one exit point, handling constants correctly, and applying MISRA C and safety-focused firmware patterns.
Why use it?
It helps avoid common coding patterns that can cause failures or make safety reviews harder. It also gives concrete examples of compliant and non-compliant C code.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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/hermeticormus/libreembed-claude-code/safety-critical-patterns
Any agent
npx skills add HermeticOrmus/LibreEmbed-Claude-Code --skill safety-critical-patterns
Clone the repo
git clone --depth 1 https://github.com/HermeticOrmus/LibreEmbed-Claude-Code

Made for: Claude Code, Codex.

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 safety-critical-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/hermeticormus/libreembed-claude-code/safety-critical-patterns.svg)](https://agentmods.dev/skills/hermeticormus/libreembed-claude-code/safety-critical-patterns)
Your own site
<a href="https://agentmods.dev/skills/hermeticormus/libreembed-claude-code/safety-critical-patterns"><img src="https://agentmods.dev/badge/skills/hermeticormus/libreembed-claude-code/safety-critical-patterns.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,445 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.00000 $0.01445
Opus 5 $0.00000 $0.00723
Sonnet 5 $0.00000 $0.00289
Haiku 4.5 $0.00000 $0.00145

Measured 6d ago against content hash 1d024ad6c418, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

safety-critical-patterns 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 6d 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.

plugins/safety-critical/skills/safety-critical-patterns/SKILL.md · 197 lines

How it starts

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

safety-critical-patterns

Knowledge Base

MISRA C compliance and safety-critical firmware patterns.


Pattern 1: MISRA C Compliant Type Annotations

MISRA mandates explicit types. Use <stdint.h> types throughout.

/* Non-compliant (implicit types): */
int i;
unsigned char flags;

/* MISRA compliant: */
#include <stdint.h>
#include <stdbool.h>

int32_t  i;
uint8_t  flags;
bool     enable;

/* Rule 7.1: Octal constants */
/* VIOLATION: */
uint8_t val = 010;   /* Octal 8, not decimal 10 */
/* COMPLIANT: */
uint8_t val = 0x08U;

/* Rule 7.2: Unsigned constants must have U suffix */
/* VIOLATION: */
uint32_t x = 100;
/* COMPLIANT: */
uint32_t x = 100U;

Pattern 2: Single-Exit Function Pattern (Rule 15.5)

MISRA 15.5: a function shall have a single point of exit.

/* NON-COMPLIANT: multiple returns */
int32_t process(uint8_t *buf, uint32_t len)
{
    if (buf == NULL) { return -1; }
    if (len == 0U)   { return -2; }
    /* process */
    return 0;
}

/* COMPLIANT: single exit */
int32_t process(uint8_t *buf, uint32_t len)
{
    int32_t result = 0;

    if (buf == NULL) {
        result = -1;
    } else if (len == 0U) {
        result = -2;
    } else {
        /* process */
        result = 0;
    }

    return result;
}

This is advisory in MISRA 2012 (was required in MISRA 2004), but required for DO-178C DAL-A.


Pattern 3: MISRA Suppression Comments

When a violation is justified, document it with a suppression comment and deviation record.

/* MISRA C:2012 Rule 11.5 Deviation:
   Reason: CMSIS HAL requires void* for peripheral handle cast.
   Risk: Low — type verified by HAL layer.
   Reviewed by: J.Smith, 2024-03-15, ref: DEV-2024-011 */
/*lint -e9087 */  /* PC-lint suppression */
void *handle = (void *)&hspi1;   /* PRQA S 0306 */   /* Polyspace suppression */
/*lint +e9087 */

Deviation records must be maintained in a deviation log linked to each suppression.


Pattern 4: RAM Test (March-C Algorithm)

March-C tests SRAM integrity at startup (required for IEC 61508 SIL 2+).

Read the full file on GitHub · 197 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. 6d ago First seen · 197 lines · 0 tokens per session scan A 1d024ad6c418

Subscribe to this mod's changes

safety-critical-patterns is a skill published in the GitHub repository HermeticOrmus/LibreEmbed-Claude-Code (44 stars, last pushed 3mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,445 tokens. 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-30.

Related

Other skills, from other repositories

new-cpp-lint

Create a new C++ lint rule, test it, run it across the codebase, and selectively apply fixes. Usage - /new-cpp-lint.

FastLED/FastLED · 41 tokens

expert-rmt5

ESP-IDF v5.x RMT5 API expert for LED protocols, encoders, and multi-channel control. Use when working with RMT peripheral programming, LED strip control, or migrating from RMT4 to RMT5.

FastLED/FastLED · 52 tokens

fix-int

Fix integer type definitions for specified platform. Researches correct primitive type mappings and applies fixes to platform-specific int headers.

FastLED/FastLED · 26 tokens

opengis-skills

Use when AI coding assistant needs GIS/CAD/C#/AI/IoT/3D domain expertise for 73+ open-source projects. One-stop skill index with tag-based search and on-demand loading for GDAL, GeoServer, QGIS, PostGIS, JTS, CesiumJS, FreeCAD, OpenSCAD, OCCT, NPOI, SqlSugar, Furion, Dify, SuperSplat, Go and more.

znlgis/opengis-skills · 97 tokens

qt-cpp-review

Qt6/C++ deep code review for Serial Studio. Use when asked to "review", "audit", "check", "look over", or "sanity check" C++ — or before committing. Runs the repo linter (scripts/code-verify.py) as Phase 1, then six parallel read-only analysis agents covering Qt model contracts, ownership/lifecycle, thread-safety +…

Serial-Studio/Serial-Studio · 119 tokens

cpp-compiler-flags

C++ compiler/linker flag guidance for Serial Studio's build (GCC, Clang, AppleClang, MSVC cl.exe, clang-cl, MinGW, IntelLLVM). Use when reading, changing, or reasoning about the cmake flag modules (Optimization/Hardening/Sanitizers/MiMalloc), tuning -O/-march/LTO/PGO, adding a per-toolchain branch, debugging a flag…

Serial-Studio/Serial-Studio · 160 tokens