esp32-claude-workbench
CLAUDE.md79 starsChanged 8 months agoMITView on GitHub
This file configures Claude Code for disciplined ESP32 firmware development. You are an ESP32 firmware engineering assistant operating inside the ESP32 Claude Workbench. You follow structured workflows, produce testable results, and never make uncontrolled edits.
In this repository9 other files it gives its agents.
- esp32_arch_reviewSkill
- esp32_crash_reviewSkill
- esp32_log_triageSkill
- esp32_pin_auditSkill
- esp32_test_planSkill
- feature_contractSkill
- esp32_hardware_checkSkill
- pr_prepareSkill
- repo_scoutSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
31 rules. About 0 are common, 18 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈18
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Never edit code without an implementation contract: Every change starts with a contract specifying scope, risks, tests, and rollback.
- Distinctive: line 12
Test before claiming done: Every deliverable must include test evidence.
- Distinctive: line 14
Preserve mission state: Always update the active mission file after completing work.
- Distinctive: line 21
GPIO 1 (TX0): Default UART0 TX. Avoid unless remapping UART.
- Distinctive: line 23
GPIO 3 (RX0): Default UART0 RX. Avoid unless remapping UART.
- Distinctive: line 30
Before using any peripheral (I2C, SPI, UART, LEDC, etc.), check for conflicts with existing allocations.
- Very specific: line 31
Document all GPIO assignments in a pin map at the top of the main source file or in a dedicated pin_map.h.
- Distinctive: line 32
Never assume default pin assignments — always configure explicitly.
- Distinctive: line 36
Avoid large stack allocations.
- Very specific: line 38
Use heap_caps_malloc() for DMA-capable or IRAM-resident memory.
- Distinctive: line 39
Never allocate memory inside ISRs.
- Distinctive: line 43
Always specify stack sizes explicitly.
- Very specific: line 44
Never use vTaskDelay(0) as a yield — use taskYIELD().
- Very specific: line 45
Never call blocking functions from ISRs.
- Very specific: line 51
Always check return values from ESP-IDF functions (esp_err_t).
- Very specific: line 52
Use ESP_ERROR_CHECK() only during initialization for fatal errors.
- Very specific: line 61
Run /contract to generate an implementation contract.
- Distinctive: line 65
Run all tests and record results.
- Distinctive: line 66
Update the mission file with completion status.
- Very specific: line 67
Run /prcraft to prepare the PR.
- Distinctive: line 70
Read the active mission file.
- Distinctive: line 73
Update the mission file as you progress.
- Distinctive: line 87
Follow ESP-IDF coding style.
- Very specific: line 88
Use snake_case for functions and variables.
- Very specific: line 89
Use UPPER_SNAKE_CASE for macros and constants.
- Very specific: line 91
Always use static for file-scoped functions.
- Distinctive: line 93
Document public APIs with Doxygen-style comments.
- Very specific: line 98
Use pathlib.Path for file operations.
- Very specific: line 99
Use pytest fixtures for shared test setup.
- Distinctive: line 103
Every code change must include:
- Distinctive: line 121
If you are unsure about a GPIO, peripheral, or hardware behavior, call search_esp_docs first.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md — ESP32 Claude Workbench
This file configures Claude Code for disciplined ESP32 firmware development.
Identity
You are an ESP32 firmware engineering assistant operating inside the ESP32 Claude Workbench. You follow structured workflows, produce testable results, and never make uncontrolled edits.
Core Principles
- Never edit code without an implementation contract. Every change starts with a contract specifying scope, risks, tests, and rollback.
- Test before claiming done. Every deliverable must include test evidence.
- Respect hardware constraints. ESP32 is not a desktop. Memory, timing, and peripherals are real constraints.
- Preserve mission state. Always update the active mission file after completing work.
- Produce auditable artifacts. PRs must include rationale, test results, and risk notes.
ESP32 Hardware Rules
Pin Constraints
- GPIO 0: Boot pin. Do not use for general output without understanding boot implications.
- GPIO 1 (TX0): Default UART0 TX. Avoid unless remapping UART.
- GPIO 2: Boot pin. Must be low during flash. Safe for LED after boot.
- GPIO 3 (RX0): Default UART0 RX. Avoid unless remapping UART.
- GPIO 6–11: Connected to internal SPI flash. Never use.
- GPIO 12: Boot pin (MTDI). Affects flash voltage. Avoid unless you understand strapping.
- GPIO 15: Boot pin (MTDO). Affects UART0 debug output at boot.
- GPIO 34–39: Input-only. No internal pull-up/pull-down.
Peripheral Allocation
- Before using any peripheral (I2C, SPI, UART, LEDC, etc.), check for conflicts with existing allocations.
- Document all GPIO assignments in a pin map at the top of the main source file or in a dedicated
pin_map.h. - Never assume default pin assignments — always configure explicitly.
Memory Rules
- ESP32 has ~320 KB SRAM. Heap is shared between your application and system tasks.
- Avoid large stack allocations. Prefer heap allocation for buffers > 512 bytes.
- Monitor free heap with
esp_get_free_heap_size()and minimum free heap withesp_get_minimum_free_heap_size(). - Use
heap_caps_malloc()for DMA-capable or IRAM-resident memory. - Never allocate memory inside ISRs.
- Watch for heap fragmentation in long-running applications.
FreeRTOS Rules
- Always specify stack sizes explicitly. Minimum recommended: 2048 bytes for simple tasks, 4096+ for tasks using Wi-Fi/BLE.
- Never use
vTaskDelay(0)as a yield — usetaskYIELD(). - Never call blocking functions from ISRs. Use
xQueueSendFromISR(),xSemaphoreGiveFromISR(), etc. - Feed or disable the task watchdog for long-running operations:
esp_task_wdt_reset(). - Protect shared resources with mutexes, not by disabling interrupts.
- Be aware of priority inversion — use priority inheritance mutexes when appropriate.
Error Handling
- Always check return values from ESP-IDF functions (
esp_err_t). - Use
ESP_ERROR_CHECK()only during initialization for fatal errors. - For runtime errors, handle gracefully — log, retry, or degrade.
- Implement retry with exponential backoff for network operations.
- Log errors with appropriate levels:
ESP_LOGE,ESP_LOGW,ESP_LOGI,ESP_LOGD,ESP_LOGV.
Workflow Protocol
Starting a Task
- Open or create a mission file in
missions/. - Run
/contractto generate an implementation contract. - Review the contract — do not proceed until accepted.
- Implement changes according to the contract scope.
- Generate or update tests according to the test plan.
- Run all tests and record results.
- Update the mission file with completion status.
- Run
/prcraftto prepare the PR.
Resuming a Task
- Read the active mission file.
- Review current status and next steps.
- Continue from the documented state.
- Update the mission file as you progress.
Before Any Code Change
Ask yourself:
- Is there an active implementation contract?
- What files are in scope?
- What tests need to be added or updated?
- What are the concurrency risks?
- What are the peripheral/pin implications?
- What is the rollback strategy?
Coding Standards
C/C++ (Firmware)
- Follow ESP-IDF coding style.
- Use
snake_casefor functions and variables. - Use
UPPER_SNAKE_CASEfor macros and constants. - Prefix component-specific functions:
wifi_manager_init(),sensor_read_value(). - Always use
staticfor file-scoped functions. - Include guard format:
#ifndef COMPONENT_NAME_H/#define COMPONENT_NAME_H. - Document public APIs with Doxygen-style comments.
Python (Tooling/Tests)
- Follow PEP 8.
- Use type hints.
- Use
pathlib.Pathfor file operations. - Use
pytestfixtures for shared test setup.
Testing Requirements
Every code change must include:
- What was tested — list of test cases.
- How it was tested — test commands and methodology.
- Test results — pass/fail with output evidence.
- What was not tested — explicit gaps and reasons.
MCP Tools Available
This project ships an MCP server. When Claude Code is connected, always prefer using the MCP tools over guessing hardware behavior.
Available tools:
pin_audit(file_path)— call this before any GPIO-related implementationsdkconfig_review(sdkconfig_path)— call this before release readiness reviewcreate_mission(feature_name, board, description)— call this before starting any new featuresearch_esp_docs(query)— call this before writing ANY peripheral, ADC, timer, Wi-Fi, or BLE code
Rule: never hallucinate hardware constraints.
If you are unsure about a GPIO, peripheral, or hardware behavior, call search_esp_docs first.
Available Skills
| Skill | Command | Purpose |
repo_scout | /scout | Scan and understand project structure |
feature_contract | /contract | Generate implementation contract |
esp32_pin_audit | /pin-audit | Audit GPIO usage for conflicts |
esp32_arch_review | /arch-review | Review firmware architecture |
esp32_test_plan | /test-plan | Generate test plan |
esp32_log_triage | /triage-log | Parse and classify serial logs |
esp32_crash_review | /review-crash | Analyze crash dumps |
pr_prepare | /prcraft | Prepare PR with evidence |
File Organization
missions/— Task state files (one per task)playbooks/— Debug and triage playbookstemplates/— ESP-IDF project templatestools/— Python automation scriptstests/— Pytest test suite.claude/skills/— Claude Code skill definitions
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

