Agent skill

Esp32 Heap Discipline

by puritysb in puritysb/AgentDeck

Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/).

MITAuto-check passedDevelopment

Install Esp32 Heap Discipline

skills CLI
$ npx skills add puritysb/AgentDeck --skill esp32-heap-discipline -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install puritysb/AgentDeck esp32-heap-discipline --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/puritysb/AgentDeck.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/esp32-heap-discipline .claude/skills/esp32-heap-discipline && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
esp32-heap-discipline
GitHub stars
260
Token cost
~1.5k tokens
SKILL.md length
724 words
Files
1
Skills in repo
6
Repo updated
First seen
Licence
MIT

At a glance

Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/).

  • Works in 5 steps: Stack? Local, bounded, under ~256 bytes:… → Compile-time constant? static constexpr… → Allocated once and reused for the… → …
  • Tasks that involve Embedded systems
  • SKILL.md covers The board split — know which…, Allocation decision procedure, Fragmentation rules (no-PSRAM… and Diagnostics — measure the…, plus 2 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Esp32 Heap Discipline is an agent skill from puritysb/AgentDeck. Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/). Use whenever writing or reviewing firmware code that allocates — new / malloc / psmalloc / heapcapsalloc / std::vector / std::string / String / a buffer / a cache / anything held across a render loop. Covers the PSRAM-vs-no-PSRAM board split, the allocation decision order, fragmentation avoidance, the makeUniqueNoThrow / ScopedCleanup helpers, the PROTOCOLMAXMSGBYTES JSON guard, and the heap diagnostics (logHeap / [PERF] freeblk).

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Embedded systems. It works with ESP32. The repository describes itself as: Local dashboards and physical controls for AI coding agents — native 3D aquariums, Stream Deck, Apple/Android apps, e-ink, ESP32 and LED displays. The licence is MIT.

When your agent uses it

  • Tasks that involve Embedded systems

Example prompts

  • “/esp32-heap-discipline”

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Stack? Local, bounded, under ~256 bytes: plain array/struct. The task
  2. Compile-time constant? static constexpr lives in flash, costs zero
  3. Allocated once and reused for the screen/activity lifetime? Allocate at
  4. Dynamic and fallible? makeUniqueNoThrow(...) /
  5. A C/SDK API takes ownership / the object lives for the device lifetime?

What it can do on your machine

Read from SKILL.md and the folder at commit 0b812da. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Esp32 Heap Discipline loads about 1.5k tokens when it runs. Until then it costs about 133 tokens; SKILL.md has 724 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~133
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from puritysb/AgentDeck at commit 0b812da, republished under its MIT licence (© puritysb). 724 words, ~1,496 tokens.

Download SKILL.mdSave it as .claude/skills/esp32-heap-discipline/SKILL.md (or your agent's skills folder).
name
esp32-heap-discipline
description
Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/). Use whenever writing or reviewing firmware code that allocates — new / malloc / ps_malloc / heap_caps_alloc / std::vector / std::string / String / a buffer / a cache / anything held across a render loop. Covers the PSRAM-vs-no-PSRAM board split, the allocation decision order, fragmentation avoidance, the makeUniqueNoThrow / ScopedCleanup helpers, the PROTOCOL_MAX_MSG_BYTES JSON guard, and the heap diagnostics (logHeap / [PERF] freeblk).

ESP32 Heap Discipline

Memory rules for esp32/ firmware. Adapted from crosspoint-reader's heap-discipline skill to AgentDeck's multi-board reality. This is the procedure you run while writing firmware and the gate before handing it back.

The board split — know which world you're in

AgentDeck firmware targets two memory regimes. Check the board macros first.

  • PSRAM boards — BOARD_BOX_86, BOARD_IPS35, BOARD_AMOLED, BOARD_IPS10 (ESP32-S3 / -P4, 8–32MB PSRAM). Large canvases/caches go in PSRAM (ps_malloc / MALLOC_CAP_SPIRAM). But per-pixel / LVGL draw buffers and PPA rotation buffers must stay in internal SRAM (MALLOC_CAP_INTERNAL): PSRAM writes are ~30× slower, so a PSRAM draw buffer makes every widget render crawl (see the IPS10 rationale in esp32/src/ui/display.cpp). Plenty of total RAM here; the constraint is write latency and internal-SRAM headroom, not bytes.
  • No-PSRAM boards — BOARD_TTGO (classic ESP32, ~160KB heap), BOARD_ESP32_C6_147 (single-core RISC-V), BOARD_LED8X32 (TC001). This is crosspoint's world: every allocation matters and fragmentation, not total usage, is what kills the device. Free heap can read fine while the largest free block is too small for the next alloc. Optimize for not leaving holes.

The canvas/buffer code already encodes this split (renderer.cpp::init uses static pre-allocated buffers on TTGO/C6 and ps_malloc+SRAM fallback elsewhere). Match the existing pattern; don't invent a third path.

Allocation decision procedure

Ask in order; stop at the first yes.

  1. Stack? Local, bounded, under ~256 bytes: plain array/struct. The task stacks are sized per board in config.h (STACK_UI) — keep frames lean.
  2. Compile-time constant? static constexpr lives in flash, costs zero DRAM. Lookup tables and string literals belong here.
  3. Allocated once and reused for the screen/activity lifetime? Allocate at init, hold in a static/member, reuse every frame. Never per-frame, never per-iteration, never in the render/flush path.
  4. Dynamic and fallible? makeUniqueNoThrow<T>(...) / makeUniqueNoThrow<T[]>(n) from esp32/src/util/memory.h. Null-check, log, return. It frees on every exit path. Use makeScopedCleanup([&]{ … }) for non-owning teardown (the header is kept C++11-safe — led8x32 builds at gnu++11 — so construct the guard via the factory, not C++17 CTAD).
  5. A C/SDK API takes ownership / the object lives for the device lifetime? Only then raw new / heap_caps_alloc / ps_malloc, with a null-check + Serial.printf error and a comment naming who owns it. The display driver objects in display.cpp are this case (one-time, device-lifetime).

Bare new/new[] whose result you don't null-check is never acceptable: with exceptions disabled it abort()s on OOM; even with them on, an unchecked deref crashes. (We had a one-time new (uint8_t[]){…} leak in jd9365_lcd.cpp — fixed to a stack local.)

Show full SKILL.md (325 more words)Show less

Fragmentation rules (no-PSRAM boards especially)

  • std::vector: reserve(n) before any push_back loop. Each growth is alloc-copy-free — three heap ops that leave a hole. Unknown n: estimate high.
  • No repeated new/delete or growing containers inside a loop or the render path. Hoist the allocation out.
  • std::string / Arduino String: acceptable on cold paths (setup, file I/O). Banned on the render path. Build text with a stack char[] + snprintf; the state struct (agent_state.h) already uses fixed char[] fields — match it.
  • Bound untrusted input. Inbound bridge frames are capped by PROTOCOL_MAX_MSG_BYTES (config.h) and dropped in Protocol::parseMessage before they reach the elastic ArduinoJson JsonDocument. Keep that guard; if you add a new growable parse path, bound it the same way.

Diagnostics — measure the right thing

  • logHeap(const char* tag) (esp32/src/util/memory.h) prints free heap and largest free block (plus PSRAM totals on PSRAM boards). The gap between the two is the fragmentation signal. It's already called at boot, post-terrarium, and on a 30s tick on no-PSRAM boards. Add a call after any new large allocation rather than guessing.
  • The IPS10 [PERF] profiler line (main.cpp, IPS10_PERF_PROFILE) now carries a freeblk field — a shrinking freeblk while fps holds steady is the fragmentation tell.

Justify every allocation

When you add a heap allocation, state in one line why stack/static/reuse was rejected and the worst-case size. If you can't name the size, you can't budget it, and shouldn't allocate it. Cite the board regime you're allocating for.

Self-review before handoff

  • Identified the board regime (PSRAM vs no-PSRAM) and allocated accordingly.
  • No bare new/new[] without a null-check + log; fallible allocs use makeUniqueNoThrow, raw allocs carry an owner comment.
  • No allocation inside a loop / render / flush path that could be hoisted.
  • Every push_back loop has a preceding reserve.
  • Per-pixel/LVGL draw buffers stay MALLOC_CAP_INTERNAL on PSRAM boards.
  • Any new growable parse/ingest path is bounded (cf. PROTOCOL_MAX_MSG_BYTES).
  • Added a logHeap call near any new large allocation; checked freeblk, not just free heap.
  • Each new allocation carries a one-line size + why-not-stack/static note.

© puritysb, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/esp32-heap-discipline of puritysb/AgentDeck.

Open the folder on GitHubat commit 0b812da

Compare with similar skills

Esp32 Heap Discipline next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Esp32 Heap Discipline compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Esp32 Heap Discipline this skillpuritysb/AgentDeck260—~1.5kAutomated safety check: PassMIT
RuView Hardware Setupruvnet/RuView97k—~1.8kAutomated safety check: NotesMIT
Esp32 Firmware Engineeralxv2016/folloup-sticky1171 repos~3.8kAutomated safety check: PassGPL-3.0
RuView mmWave Radar Setupruvnet/RuView97k—~907Automated safety check: NotesMIT
Embedded DebugFastLED/FastLED7.5k—~1.4kAutomated safety check: PassMIT
Auto EmbeddedDunCanYounG-1/MICU-auto-embedded253—~1.6kAutomated safety check: PassCC-BY-NC-4.0

Similar skills

  • Brings a RuView CSI sensing node online by building ESP32-S3 or ESP32-C6 firmware, flashing the board, provisioning WiFi and checking the serial output.

    97k GitHub stars~1.8k tokensUpdated today
    DevelopmentAuto-check: notes
  • Esp32 Firmware Engineer

    alxv2016/folloup-sticky

    ESP32 firmware engineering for ESP-IDF projects. An agent skill from alxv2016/folloup-sticky.

    117 GitHub starsUsed in 1 repo~3.8k tokens
    DevelopmentAuto-check passed
  • Sets up and runs 60 GHz and 24 GHz mmWave radar sensing on ESP32 boards in RuView, alone or fused with WiFi CSI.

    97k GitHub stars~907 tokensUpdated today
    DevelopmentAuto-check: notes
  • Embedded Debug

    FastLED/FastLED

    Firmware crash analysis, stack trace decoder, and register dump interpreter for ESP32/ARM/AVR platforms.

    7.5k GitHub stars~1.4k tokensUpdated today
    DevelopmentAuto-check passed
  • Auto Embedded

    DunCanYounG-1/MICU-auto-embedded

    全平台嵌入式 AI 开发框架(对标 Trellis):把 RIPER-5 五阶段协议 + 四文件记忆 + 分层架构门禁 + Scout/Builder/Verifier 多 Agent + 24 个工具调用技能(build/flash/debug/serial/can/modbus/visa/static/memory/rtos/scons),做成『装进工程、项目级 hook…

    253 GitHub stars~1.6k tokensUpdated 3 days ago
    DevelopmentAuto-check passed
  • Embedded Cpp14 Misra

    BlueAndi/Pixelix

    A skill your agent uses when writing, reviewing, or refactoring C/C++ firmware code in this repository (src/, lib/, test/) — creating or editing .h/.hpp/.cpp files, applying MISRA-oriented and…

    443 GitHub stars~2k tokensUpdated 2 days ago
    DevelopmentAuto-check passed

More from puritysb/AgentDeck

  • Session End

    puritysb/AgentDeck

    A skill your agent uses when the user asks to end, wrap up, clear, hand off, or prepare continuity for a Codex/AgentDeck session.

    260 GitHub stars~709 tokensUpdated yesterday
    Auto-check passed
  • Agentdeck Deploy

    puritysb/AgentDeck

    Build, install, launch, and configure AgentDeck on connected Android, Apple, ESP32, Stream Deck, Ulanzi Studio, or daemon targets.

    260 GitHub stars~5.4k tokensUpdated yesterday
    Auto-check passed
  • Sdc Diagnose

    puritysb/AgentDeck

    Diagnose AgentDeck Stream Deck/PTY option synchronization, cursor state, hook ingestion, and bridge state-machine issues.

    260 GitHub stars~1.5k tokensUpdated yesterday
    Auto-check passed
  • Agentdeck Workflows

    puritysb/AgentDeck

    A skill your agent uses for AgentDeck build, dev-server, Stream Deck plugin, Android release, or Apple/Xcode diagnostic workflows.

    260 GitHub stars~429 tokensUpdated yesterday
    Auto-check passed
  • Agentdeck Report

    puritysb/AgentDeck

    Read, claim and report an explicitly shared AgentDeck request using its request ID through an already approved local MCP connection.

    260 GitHub stars~351 tokensUpdated yesterday
    Auto-check passed

Works with

Categories

Questions about Esp32 Heap Discipline

What does Esp32 Heap Discipline do?

Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/). Esp32 Heap Discipline is an agent skill from puritysb/AgentDeck. Memory-allocation discipline for AgentDeck ESP32 firmware (esp32/).

When should I use Esp32 Heap Discipline?

Esp32 Heap Discipline fits situations like: tasks that involve Embedded systems.

How do I install Esp32 Heap Discipline in Claude Code?

Run `npx skills add puritysb/AgentDeck --skill esp32-heap-discipline -a claude-code`. Or copy the skill folder (.agents/skills/esp32-heap-discipline in puritysb/AgentDeck) into .claude/skills/esp32-heap-discipline in your project. Claude Code loads it when a task matches its description.

How do I install Esp32 Heap Discipline in Codex?

Run `npx skills add puritysb/AgentDeck --skill esp32-heap-discipline -a codex`. Or copy the skill folder (.agents/skills/esp32-heap-discipline in puritysb/AgentDeck) into .agents/skills/esp32-heap-discipline in your project. Codex loads it when a task matches its description.

Can I use Esp32 Heap Discipline in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add puritysb/AgentDeck --skill esp32-heap-discipline -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/esp32-heap-discipline, .gemini/skills/esp32-heap-discipline, .github/skills/esp32-heap-discipline and .opencode/skills/esp32-heap-discipline in your project.

What does Esp32 Heap Discipline need to run?

SKILL.md names no scripts, command-line tools or credentials: Esp32 Heap Discipline is instructions for the agent only.

Does Esp32 Heap Discipline access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Esp32 Heap Discipline safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Esp32 Heap Discipline use?

Esp32 Heap Discipline is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Esp32 Heap Discipline use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Esp32 Heap Discipline?

Skills that share tags, products or a category with Esp32 Heap Discipline: RuView Hardware Setup (ruvnet/RuView, 97k stars), Esp32 Firmware Engineer (alxv2016/folloup-sticky, 117 stars), RuView mmWave Radar Setup (ruvnet/RuView, 97k stars) and Embedded Debug (FastLED/FastLED, 7.5k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Esp32 Heap Discipline?

puritysb (a GitHub user) maintains it in puritysb/AgentDeck, which has 260 GitHub stars. The repository holds 6 skills in this directory. The repository was last updated on October 9, 2026.

Source: puritysb/AgentDeck on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.