/embedded-workbench:c-cpp-devfrom embedded-workbench
Provides C/C++ development guidance for 32-bit ARM embedded targets, covering structure, interfaces, and implementation rules.
Ships in embedded-workbench. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Language baseline is project-specific: respect the project's configured language standard, and don't assume a default. Check CLAUDE.md, build-system -std= flags, or compiler configuration. All rules assume 32-bit ARM target unless otherwise noted.
Sections run top-down: structure, then the contract, then implementation, then the target's specifics, then change. Settle the higher level before writing the lower one.
Structure decides where code lives and what a module may see. Everything below is detail inside those boundaries.
a.b is a direct member and fine. a.b.c across a module boundary means the boundary leaked: ask the owner to act, or to return the value.A header is a module's contract. Keep it small, complete, and free of representation.
static. Use extern in the header and exactly one definition in a single .c file.goto when it simplifies cleanup or reduces complexity, but use it as a maintenance tool, not a first choice.pragma or packing attributes only when they match a wire-format requirement and are documented clearly.Memory-mapped peripheral registers must be volatile to prevent the compiler from optimizing away repeated reads or writes. Use a volatile struct pointer (the CMSIS/HAL pattern) rather than bare casts.
// CORRECT: volatile pointer to peripheral struct
typedef struct {
volatile uint32_t SR; // Status @ offset 0x00
volatile uint32_t DR; // Data @ offset 0x04
volatile uint32_t BRR; // Baud @ offset 0x08
volatile uint32_t CR1; // Control @ offset 0x0C
} UART_Regs;
#define UART2 ((UART_Regs *)0x40004400)
// BAD: missing volatile — compiler may optimize away repeated reads
#define UART_SR (*(uint32_t *)0x40001000)
while (UART_SR & TX_BUSY); // May become infinite loop under optimization
Use __attribute__((section(...))) to place data and code in specific memory regions.
// .noinit: value preserved across watchdog/system reset (not power-on reset)
uint32_t reset_reason __attribute__((section(".noinit")));
// .ramfunc: function kept in RAM for execution during flash programming
__attribute__((section(".ramfunc")))
void flash_program_word(uint32_t addr, uint32_t data) { /* ... */ }
// DMA-accessible buffer: must not be placed in CCM (tightly-coupled memory)
uint8_t dma_buffer[1024] __attribute__((section(".dma_ram")));
Keep the ISR path minimal and use separate wrapper functions for task-context work. Never call blocking APIs from an ISR.
// ISR path: minimal, no blocking, use ISR-safe RTOS primitives
static void uart_rx_isr(void) {
BaseType_t xHigherPriorityWoken = pdFALSE;
xSemaphoreGiveFromISR(xUartSem, &xHigherPriorityWoken);
portYIELD_FROM_ISR(xHigherPriorityWoken);
}
// Task path: can block, log, allocate, parse
void uart_rx_process_task(void) {
if (xSemaphoreTake(xUartSem, portMAX_DELAY) == pdTRUE) {
parse_and_dispatch(uart_rx_buf);
}
}
The HardFault handler must be __attribute__((naked)) to prevent the compiler's prologue from corrupting the stack pointer before the exception frame can be captured.
// naked: no prologue — SP is the exact exception frame. Required for fault handlers.
__attribute__((naked)) void HardFault_Handler(void) {
__asm volatile(
"tst lr, #4\n" // Check EXC_RETURN bit 2: MSP vs PSP
"ite eq\n"
"mrseq r0, msp\n" // Thread used MSP → read from MSP
"mrsne r0, psp\n" // Thread used PSP (RTOS) → read from PSP
"b HardFault_HandlerC\n"
);
}
A refactor moves code across the boundaries above. Check the highest boundary it touches first: a file move changes the architecture, an exposed type changes the contract, anything else is implementation.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub amethystluna/embedded-workbench --plugin embedded-workbench8 skills in this plugin
/debug-methodologyUse when debugging embedded firmware issues — analyzing crash logs, investigating state machine lockups, tracing sensor/signal anomalies, or performing structured root-cause analysis after a crash has been located. For fault-register and stack-frame triage, load hardfault-triage first./embedded-firmware-devUse when writing or reviewing embedded C firmware, FreeRTOS tasks, ISR handlers, NVM/flash storage, or sensor driver state machines. NOT for documentation-only RTOS references, conceptual RTOS discussions, or bare-metal projects without an RTOS or sensor subsystem./embedded-workbenchUse when starting any non-trivial coding task — loads risk-proportional workflows, engineering policies, and principles for embedded C/C++ firmware development. NOT for trivial single-line fixes, formatting-only changes, or read-only queries./fact-checkUse when reviewing design documents, architecture specs, technical proposals, or plans that make claims about API names, file paths, enum values, counts, or mechanism feasibility — a lightweight claim-by-claim check against the codebase with evidence. Built into embedded-workbench as the fallback when the full dsh-model-everything plugin (or its predecessor logicprobe) is not installed. NOT for state machines, protocol/retry logic, or 'always'/'never' behavioral claims that need executable model verification — those require dsh-model-everything (or logicprobe)./hardfault-triageUse when triaging processor exception crashes — HardFault, MemManage, BusFault, UsageFault, data/prefetch abort, illegal instruction, or watchdog timeout. Covers fault-register interpretation, stack-frame extraction, PC-to-source resolution, and root-cause classification./keil-mdk-buildUse when building, flashing, or packaging firmware with Keil MDK (UV4 CLI, ARMCLANG), analyzing .map files for ROM/RAM optimization and memory budget, or diagnosing Keil-specific build failures. NOT for non-Keil build systems (Makefile, CMake, IAR, GCC-only). For crash triage see hardfault-triage.Other plugins' skills for the same job