Home › Embedded / firmware › ESP32 ESP-IDF firmware CLAUDE.md

ESP32 ESP-IDF firmware CLAUDE.md

CLAUDE.md for ESP32 firmware on ESP-IDF 5.x in C: components, FreeRTOS tasks, error handling, and logging.

Claude Code (CLAUDE.md)Embedded / firmware

How to use

Save this as CLAUDE.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

Note: Review and test before use. Provided as is, without warranty. See Terms.

CLAUDE.mdDownload  
# CLAUDE.md: ESP-IDF firmware (ESP32)

## Commands
- `idf.py set-target esp32s3` (once) · `idf.py build` · `idf.py -p <PORT> flash monitor` (ask before flashing a device)
- Config: `idf.py menuconfig`; commit defaults in `sdkconfig.defaults`, not the generated `sdkconfig`.
- Host unit tests (where set up): `idf.py --preview set-target linux && idf.py build` or Unity tests in `test/`.

## Structure
- `main/` holds `app_main` wiring only. Features live in `components/<name>/` with `CMakeLists.txt` (`idf_component_register(... REQUIRES ...)`) and a public header in `include/`.
- External libs through the component manager (`idf_component.yml`), pinned versions.

## Code rules
- Every ESP-IDF call returning `esp_err_t` is checked: `ESP_ERROR_CHECK` only during init where a reboot is acceptable; otherwise `ESP_RETURN_ON_ERROR`/`ESP_GOTO_ON_ERROR` and propagate.
- Logging with `ESP_LOGI/W/E(TAG, ...)` and a `static const char *TAG` per file. No `printf` in components.
- FreeRTOS: each task has a sized stack (check with `uxTaskGetStackHighWaterMark`), a priority with a reason, and blocks on queues/event groups/notifications instead of busy-waiting. Use `vTaskDelay(pdMS_TO_TICKS(ms))`.
- ISRs are short, marked `IRAM_ATTR`, use only `FromISR` APIs, and defer work to a task.
- Shared data is protected by a mutex or passed through queues; no unguarded globals across tasks.
- No dynamic allocation in hot loops; check `malloc`/`heap_caps_malloc` results.
- Wi-Fi/credentials come from NVS or provisioning, never hard-coded in source.

## Done
`idf.py build` has no new warnings and binary size is reported (`idf.py size`).

More: all Embedded / firmware rules · all Claude Code (CLAUDE.md) rules

Related rules

Embedded C (bare metal / RTOS) AGENTS.md

AGENTS.md for embedded C firmware (bare metal, Zephyr, FreeRTOS): safety-minded C rules, memory, and hardware access.

AGENTS.mdEmbedded / firmware

Arduino / PlatformIO rules

Cursor rules for microcontroller projects with PlatformIO and the Arduino framework: non-blocking loops, memory, pins.

CursorEmbedded / firmware

Solidity smart contract security CLAUDE.md

CLAUDE.md for reviewing and writing Solidity contracts safely: threat checklist, Foundry tests, and no-deploy rules.

Claude Code (CLAUDE.md)Solidity / smart contracts

Modern C++ with CMake rules

Cursor rules for modern C++ (C++20/23) projects built with CMake presets: RAII, ownership, warnings, and tests.

CursorC++

Solidity + Foundry Copilot path instructions

Path-specific Copilot instructions for Solidity 0.8.x contracts with Foundry: security patterns, fuzz tests, and gas.

GitHub CopilotSolidity / smart contracts

Zig AGENTS.md

AGENTS.md for Zig 0.15 projects: build.zig, explicit allocators, error unions, defer cleanup, and zig test.

AGENTS.mdZig

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.