/embedded-skills:embedded-cstylefrom embedded-skills
Enforces engineering coding standards for embedded C firmware projects (STM32, GD32, ESP32, FreeRTOS, bare-metal, robotics). Covers naming, types, memory, concurrency, error handling, and HAL isolation to prevent common AI mistakes.
Ships in embedded-skills. 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.
This skill defines mandatory coding standards for embedded firmware projects.
Goals:
The style is inspired by MISRA-C, Linux Kernel Style, AUTOSAR C Guidelines, and STM32 firmware best practices — adapted for practical use in small-to-medium embedded projects rather than rigid compliance.
This skill applies whenever generating, modifying, reviewing, or refactoring C code.
Priority order when making trade-offs: Safety > Determinism > Maintainability > Readability.
Application and business modules shall never call HAL APIs directly.
Forbidden in app/ and module/:
HAL_GPIO_WritePin()
HAL_UART_Transmit()
HAL_SPI_Transmit()
HAL_I2C_Master_Transmit()
Only interface/ and bsp/ layers may access vendor HAL APIs.
Format: typename_t
Required:
motor_t
imu_t
pid_t
uart_config_t
Forbidden:
Motor
IMU
PIDStruct
UART_CONFIG
Format: module_action() — lowercase, underscore-separated.
Required:
motor_init()
motor_set_speed()
imu_read()
pid_update()
Forbidden:
InitMotor()
ReadIMU()
PID()
Internal (file-scope) functions must be declared static:
static void motor_update(void);
Format: MODULE_DESCRIPTION — uppercase, underscore-separated.
Required:
MOTOR_MAX_SPEED_RPM
UART_RX_BUFFER_SIZE
PID_DEFAULT_KP
Forbidden:
MaxSpeed
bufferSize
Always use <stdint.h> fixed-width types.
Forbidden:
int
short
long
unsigned
Required:
uint8_t
uint16_t
uint32_t
int8_t
int16_t
int32_t
Booleans must use <stdbool.h>:
#include <stdbool.h>
bool ready;
Forbidden as boolean substitutes:
u8 flag;
uint8_t status;
Plain global variables are forbidden:
int speed; // forbidden
File-private statics are allowed:
static int32_t speed; // allowed
Cross-module access must go through interface functions:
motor_get_speed() // correct
Not:
extern int speed; // forbidden
const PreferenceImmutable data must be declared const:
static const uint8_t crc_table[256];
static const float pid_gains[3] = {1.0f, 0.1f, 0.05f};
volatile Disciplinevolatile is only allowed for:
volatile bool uart_rx_done; // correct
Forbidden on ordinary variables:
volatile int count; // forbidden
Pointer parameters must be checked before dereference:
if (ptr == NULL) {
return ERR_INVALID_PARAM;
}
Forbidden:
ptr->data = 1; // no null check
Callers must check return values:
ret = uart_write(...);
if (ret != ERR_OK) {
return ret;
}
Forbidden:
uart_write(...); // return value ignored
Forbidden:
if (speed > 123)
Required:
#define MOTOR_MAX_SPEED_RPM (123U)
if (speed > MOTOR_MAX_SPEED_RPM)
Forbidden:
#define MAX_SPEED 100 + 20
Required:
#define MAX_SPEED (120U)
Every header must use either:
#ifndef MOTOR_H
#define MOTOR_H
// ...
#endif
or:
#pragma once
Prefer forward declarations over #include in headers:
struct motor; // forward declaration
Rather than:
#include "a.h"
#include "b.h"
#include "c.h"
#include "d.h"
Runtime heap allocation is forbidden:
malloc()
calloc()
realloc()
free()
Use static allocation instead:
static uint8_t rx_buffer[256];
This prevents heap fragmentation and unpredictable allocation latency — critical for real-time embedded systems.
Shared resources accessed from multiple threads or ISRs must be protected:
osMutexAcquire(mutex_id, timeout);
// ... access shared resource ...
osMutexRelease(mutex_id);
or:
taskENTER_CRITICAL();
// ... access shared resource ...
taskEXIT_CRITICAL();
Use a single project-wide error enum rather than magic return values:
typedef enum {
ERR_OK = 0,
ERR_TIMEOUT,
ERR_BUSY,
ERR_INVALID_PARAM,
ERR_NOT_INITIALIZED,
ERR_OVERFLOW,
ERR_UNDERFLOW,
} error_t;
Forbidden:
return -1;
return -2;
return -3;
All public interfaces must carry a Doxygen-style doc block:
/**
* @brief Set motor speed
*
* @param rpm Target speed in revolutions per minute
*
* @return error_t ERR_OK on success
*/
error_t motor_set_speed(int32_t rpm);
After generating or reviewing code, verify:
<stdint.h> types used — no bare int, short, long, unsigned<stdbool.h> used for booleansstaticmalloc/freeconst used wherever data is immutablevolatile used only for ISR/DMA/register variablesmodule_action, typename_t, MACRO_NAME conventionsapp/ or module/When violations are found:
Priority order for fixes:
Safety > Determinism > Maintainability > Readability
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub rovinax/embedded-skills --plugin embedded-skills6 skills in this plugin
/embedded-architectureUse when creating a new embedded firmware project, adding a module, refactoring firmware, reviewing architecture, or generating project structure. Enforces mandatory architecture rules for maintainable, portable, testable, hardware-independent firmware targeting STM32, GD32, ESP32, RP2040, NXP, Nordic, and similar MCU platforms. Covers project structure, dependency management, module boundaries, platform abstraction, and architecture validation.
/embedded-documentationUse when creating or reviewing embedded firmware projects (STM32, FreeRTOS, drone, robotics) to ensure complete, consistent, and maintainable documentation. Automatically generates and validates project documentation: README, architecture docs, module design docs, interface specs, RTOS task design, ISR documentation, state machines, hardware pin mapping, and data flow diagrams. Triggers on new projects, new modules, new RTOS tasks/ISRs, state machine detection, or any undocumented component.
/embedded-driver-designUse when developing or reviewing peripheral drivers for embedded firmware (STM32, GD32, ESP32, FreeRTOS, drone flight controllers, robotics). Enforces layered driver architecture with bus abstraction, device context objects, register encapsulation, and strict separation between bus drivers, device drivers, BSP, and business modules. Prevents HAL/register leakage into device drivers and keeps control algorithms (PID, Kalman, attitude estimation) out of driver code.
/embedded-isr-designUse when generating or reviewing interrupt service routines (ISRs) for embedded firmware (STM32, GD32, ESP32, FreeRTOS, bare-metal, drone flight controllers, robotics). Enforces the "Fast In, Fast Out" principle — ISRs capture events and defer processing to task context. Prevents common AI mistakes: protocol parsing in ISR, control algorithms in ISR, printf/malloc in ISR, blocking calls, forgotten flag clearing, and missing FromISR API usage for RTOS integration.
/embedded-rtos-designUse when designing, generating, or reviewing RTOS-based embedded firmware (FreeRTOS, CMSIS-RTOS2, RT-Thread, Zephyr, ThreadX) for STM32, GD32, ESP32, drone flight controllers, and robotics projects. Enforces real-time system architecture — task decomposition, scheduling, priority assignment, inter-task communication, ISR cooperation, resource ownership, and watchdog monitoring. Prevents the common AI anti-pattern of creating monolithic super-tasks with mixed responsibilities and jitter-prone control loops coupled to communication timing.
Other plugins' skills for the same job