bare-metal-patterns

bare-metal-patterns is a skill for Claude Code, Codex from HermeticOrmus/LibreEmbed-Claude-Code. It costs 0 tokens per session (2,138 once invoked), scanned A, original, MIT.

A collection of production C programming patterns for ARM Cortex-M microcontrollers, using the arm-none-eabi-gcc compiler and the C11 language standard. Microcontrollers are small computers built into devices.

In plain words
What is it for?
Use it when writing embedded firmware for Cortex-M devices, including register bit operations and GPIO setup for hardware such as LEDs and buttons.
Why use it?
It provides consistent low-level examples for controlling hardware directly without depending on a larger hardware library.

Skill for Claude CodeCodex

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/bare-metal-patterns
Any agent
npx skills add HermeticOrmus/LibreEmbed-Claude-Code --skill bare-metal-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 bare-metal-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/hermeticormus/libreembed-claude-code/bare-metal-patterns.svg)](https://agentmods.dev/skills/hermeticormus/libreembed-claude-code/bare-metal-patterns)
Your own site
<a href="https://agentmods.dev/skills/hermeticormus/libreembed-claude-code/bare-metal-patterns"><img src="https://agentmods.dev/badge/skills/hermeticormus/libreembed-claude-code/bare-metal-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 2,138 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 $0.00000 $0.02138
Opus 5 $0.00000 $0.01069
Sonnet 5 $0.00000 $0.00428
Haiku 4.5 $0.00000 $0.00214

Measured 5d ago against content hash 89692ae8788c, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

bare-metal-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 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.

plugins/bare-metal/skills/bare-metal-patterns/SKILL.md · 235 lines

How it starts

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

bare-metal-patterns

Knowledge Base

Production bare-metal C patterns for ARM Cortex-M. All code uses arm-none-eabi-gcc, C11.


Pattern 1: Register Bit Manipulation Macros

Consistent, readable register access without HAL dependency.

/* Generic bit manipulation — safe for any 32-bit register */
#define REG_SET_BIT(reg, bit)      ((reg) |=  (1U << (bit)))
#define REG_CLR_BIT(reg, bit)      ((reg) &= ~(1U << (bit)))
#define REG_TST_BIT(reg, bit)      (((reg) >> (bit)) & 1U)

/* Set a multi-bit field: mask off old value, OR in new value */
#define REG_SET_FIELD(reg, mask, shift, val) \
    ((reg) = ((reg) & ~(mask)) | (((val) << (shift)) & (mask)))

/* Example: set USART1 baud rate divisor in BRR register */
/* BRR = fCK / baud (oversampling by 16) */
#define USART_BRR_SET(uart, fck, baud) \
    ((uart)->BRR = (uint32_t)((fck) / (baud)))

USART_BRR_SET(USART1, 84000000UL, 115200UL);  /* STM32F4 APB2 @ 84MHz */

Pattern 2: GPIO Configuration (Register Level)

Full GPIO setup for STM32F4 without HAL:

/* PA5 = LED (push-pull output), PA0 = button (input, pull-up) */
void gpio_init(void)
{
    /* 1. Enable GPIOA clock */
    RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN;
    (void)RCC->AHB1ENR;            /* Bus latency flush: read back after write */

    /* 2. PA5: General purpose output, push-pull, high speed */
    GPIOA->MODER   = (GPIOA->MODER & ~(3U << 10)) | (1U << 10);  /* MODER5 = 01 */
    GPIOA->OTYPER &= ~(1U << 5);                                  /* Push-pull */
    GPIOA->OSPEEDR|=  (3U << 10);                                 /* Very high speed */
    GPIOA->PUPDR   = (GPIOA->PUPDR & ~(3U << 10));                /* No pull */

    /* 3. PA0: Input, pull-up */
    GPIOA->MODER   = (GPIOA->MODER & ~(3U << 0));   /* MODER0 = 00: input */
    GPIOA->PUPDR   = (GPIOA->PUPDR & ~(3U << 0)) | (1U << 0);  /* Pull-up */
}

static inline void led_on(void)  { GPIOA->BSRR = (1U << 5);       }
static inline void led_off(void) { GPIOA->BSRR = (1U << (5+16));  }
static inline void led_toggle(void) { GPIOA->ODR ^= (1U << 5);    }
static inline int  btn_read(void) { return (int)((GPIOA->IDR >> 0) & 1U); }

Read the full file on GitHub · 235 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 · 235 lines · 0 tokens per session scan A 89692ae8788c

Subscribe to this mod's changes

bare-metal-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 2,138 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

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

iot-skills

Use when developing with Raspberry Pi Pico (RP2040) for GPIO, I2C, Wi-Fi, MQTT, or sensor integration using MicroPython. Index of 1 skill: KE3036 Keyes Pico learning kit.

znlgis/opengis-skills · 50 tokens

mspm0-skill

Tool-neutral CLI agent rules for TI MSPM0 development with SysConfig, DriverLib, CCS, Keil/uVision, CMake/GCC/OpenOCD, and supported board references. Use when an agent needs to inspect or modify MSPM0 projects, validate SysConfig output, package examples, or work on NUEDC embedded firmware.

Ibook000/mspm0-skill · 76 tokens

hardware-iot-bus

Low-level I2C and SPI bus peripheral control for embedded Linux boards (Orange Pi, Raspberry Pi, RISC-V).

AbdullahMalik17/malikclaw · 31 tokens

aether-iot-query

Use this skill when the user asks about a live AetherEdge runtime: channels, points, real-time values, history, alarms, rules, models, instances, routing, SHM health, service health, or system status. Use aether CLI commands to answer — do NOT inspect source code, local database files, or config YAMLs to answer…

EvanL1/AetherEdge · 82 tokens

aether-iot

Build, integrate, diagnose, or generate applications for the AetherEdge AI-native edge kernel. Use for AetherEdge onboarding, SDK compositions, device and topology clients, read-only operations UIs, MCP integration, Domain Packs, or governed IoT commands where live-state authority and physical-device safety must be…

EvanL1/AetherEdge · 68 tokens