/resource-optimization-lowend
Resource optimization skill for constrained embedded targets. Use when reducing flash/RAM usage, analyzing stack depth, reading linker map files, or tuning size vs speed on MCUs. Activates on queries about firmware size optimization, linker map, stack usage, -Os, flash RAM
$ npx -y skills add mohitmishra786/low-level-dev-skills --skill resource-optimization-lowend --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/resource-optimization-lowend
Context preview
The summary Claude sees to decide when to auto-load this skill.
Resource optimization skill for constrained embedded targets. Use when reducing flash/RAM usage, analyzing stack depth, reading linker map files, or tuning size vs speed on MCUs. Activates on queries about firmware size optimization, linker map, stack usage, -Os, flash RAM
SKILL.md
resource-optimization-lowend.SKILL.mdname: resource-optimization-lowend
description: Resource optimization skill for constrained embedded targets. Use when reducing flash/RAM usage, analyzing stack depth, reading linker map files, or tuning size vs speed on MCUs. Activates on queries about firmware size optimization, linker map, stack usage, -Os, flash RAM budget, or bloat analysis.
Resource Optimization (Low-End Systems)
Purpose
Guide agents through flash and RAM optimization on constrained devices: compiler size flags, linker map analysis, stack usage measurement, dead code elimination, and size-vs-speed tradeoffs — for bare-metal and small RTOS images.
When to Use
- Firmware exceeds flash budget
- Stack overflow in production only
- Choosing `-Os` vs `-O2` on MCU
- Finding unexpected `.rodata` or `.bss` growth
Workflow
1. Size measurement toolchain
arm-none-eabi-size -A firmware.elf
arm-none-eabi-objdump -h firmware.elf
nm --size-sort -S firmware.elf | tail -20
2. Linker map file
/* linker.ld */
OUTPUT_FORMAT("elf32-littlearm")
ENTRY(Reset_Handler)
SECTIONS
{
/* ... */
}
/* Generate map */
/* gcc ... -Wl,-Map=firmware.map */grep -E '\.text|\.rodata|\.data|\.bss' firmware.map | head
Identify largest symbols and unexpected library pull-in.
3. Compiler flags
| Flag | Effect | |------|--------| | `-Os` | Size-first optimization | | `-ffunction-sections -fdata-sections` | Per-symbol sections | | `-Wl,--gc-sections` | Drop unused sections | | `-flto` | Cross-TU dead code elimination | | `-specs=nano.specs` | Smaller newlib (GCC ARM) |
CFLAGS += -Os -ffunction-sections -fdata-sections
LDFLAGS += -Wl,--gc-sections -Wl,--print-memory-usage
4. Stack analysis
# Static (if built with -fstack-usage)
find . -name '*.su' -exec cat {} \;
# Linker stack symbol
grep _estack firmware.mapRuntime: fill stack with pattern (`0xDEADBEEF`), run tests, scan high-water mark. FreeRTOS: `uxTaskGetStackHighWaterMark`.
5. RAM categories
| Section | Tactic | |---------|--------| | `.bss` | Shrink buffers; pool allocators | | `.data` | Move const to flash (`const` → `.rodata`) | | Heap | Avoid malloc; fixed pools | | Stack | Reduce nesting; smaller ISR stacks |
6. Size vs speed decision
Hot path in ISR or 1 kHz loop?
├── Yes → -O2 for that file (#pragma GCC optimize)
└── No → -Os globally
7. Agent usage
/resource-optimization-lowend Find top 10 flash consumers in firmware.map and suggest -gc-sections fixes
Common Problems
| Symptom | Cause | Fix | |---------|-------|-----| | printf pulls 20+ KB | Full newlib printf | `_write` retarget; tiny printf | | `--gc-sections` broke IRQ | Section collected | `KEEP()` in linker script | | Stack overflow late | Deep call + IRQ nest | Measure HW stack; increase `_estack` | | RAM zero but big ELF | `.data` not loaded | Check VMA/LMA | | LTO link fail | Mixed compiler versions | Same GCC for all objects |
Related Skills
- `skills/embedded/linker-scripts` — MEMORY/Sections layout
- `skills/baremetal/baremetal-startup` — stack symbol
- `skills/baremetal/low-power-embedded` — RAM retention
- `skills/compilers/gcc` — optimization flags
- `skills/rust/rust-no-std` — embedded Rust size patterns
Read more
name: resource-optimization-lowend description: Resource optimization skill for constrained embedded targets. Use when reducing flash/RAM usage, analyzing stack depth, reading linker map files, or tuning size vs speed on MCUs. Activates on queries about firmware size optimization, linker map, stack usage, -Os, flash RAM budget, or bloat analysis.
Resource Optimization (Low-End Systems)
Purpose
Guide agents through flash and RAM optimization on constrained devices: compiler size flags, linker map analysis, stack usage measurement, dead code elimination, and size-vs-speed tradeoffs — for bare-metal and small RTOS images.
When to Use
- Firmware exceeds flash budget
- Stack overflow in production only
- Choosing `-Os` vs `-O2` on MCU
- Finding unexpected `.rodata` or `.bss` growth
Workflow
1. Size measurement toolchain
arm-none-eabi-size -A firmware.elf arm-none-eabi-objdump -h firmware.elf nm --size-sort -S firmware.elf | tail -20
2. Linker map file
/* linker.ld */
OUTPUT_FORMAT("elf32-littlearm")
ENTRY(Reset_Handler)
SECTIONS
{
/* ... */
}
/* Generate map */
/* gcc ... -Wl,-Map=firmware.map */grep -E '\.text|\.rodata|\.data|\.bss' firmware.map | head
Identify largest symbols and unexpected library pull-in.
3. Compiler flags
| Flag | Effect | |------|--------| | `-Os` | Size-first optimization | | `-ffunction-sections -fdata-sections` | Per-symbol sections | | `-Wl,--gc-sections` | Drop unused sections | | `-flto` | Cross-TU dead code elimination | | `-specs=nano.specs` | Smaller newlib (GCC ARM) |
CFLAGS += -Os -ffunction-sections -fdata-sections LDFLAGS += -Wl,--gc-sections -Wl,--print-memory-usage
4. Stack analysis
# Static (if built with -fstack-usage)
find . -name '*.su' -exec cat {} \;
# Linker stack symbol
grep _estack firmware.mapRuntime: fill stack with pattern (`0xDEADBEEF`), run tests, scan high-water mark. FreeRTOS: `uxTaskGetStackHighWaterMark`.
5. RAM categories
| Section | Tactic | |---------|--------| | `.bss` | Shrink buffers; pool allocators | | `.data` | Move const to flash (`const` → `.rodata`) | | Heap | Avoid malloc; fixed pools | | Stack | Reduce nesting; smaller ISR stacks |
6. Size vs speed decision
Hot path in ISR or 1 kHz loop? ├── Yes → -O2 for that file (#pragma GCC optimize) └── No → -Os globally
7. Agent usage
/resource-optimization-lowend Find top 10 flash consumers in firmware.map and suggest -gc-sections fixes
Common Problems
| Symptom | Cause | Fix | |---------|-------|-----| | printf pulls 20+ KB | Full newlib printf | `_write` retarget; tiny printf | | `--gc-sections` broke IRQ | Section collected | `KEEP()` in linker script | | Stack overflow late | Deep call + IRQ nest | Measure HW stack; increase `_estack` | | RAM zero but big ELF | `.data` not loaded | Check VMA/LMA | | LTO link fail | Mixed compiler versions | Same GCC for all objects |
Related Skills
- `skills/embedded/linker-scripts` — MEMORY/Sections layout
- `skills/baremetal/baremetal-startup` — stack symbol
- `skills/baremetal/low-power-embedded` — RAM retention
- `skills/compilers/gcc` — optimization flags
- `skills/rust/rust-no-std` — embedded Rust size patterns
A curated suite of AI agent skills for systems and low-level programming — C/C++, Rust, Zig, GPU, bare-metal firmware, Linux kernel/driver development, computer architecture, compiler internals, HPC, and more.
Repo: mohitmishra786/low-level-dev-skills
Other skills on low-level-dev-skills.
- /custom-allocators
Custom allocator skill for memory allocation strategies. Use when implementing pool/slab/arena allocators, tuning jemalloc/mimalloc, writing Rust GlobalAlloc, or benchmarking allocator performance. Activates on queries about jemalloc, mimalloc, tcmalloc, arena allocator,
Open skill - /numa-programming
NUMA programming skill for multi-socket memory locality. Use when detecting NUMA topology, binding processes with numactl, using libnuma API, building NUMA-aware data structures, or measuring remote access penalties. Activates on queries about numactl, libnuma, NUMA topology,
Open skill - /af-xdp
AF_XDP skill for high-performance XDP sockets. Use when creating AF_XDP sockets, configuring UMEM and XSK rings, XDP_REDIRECT programs, copy vs zero-copy mode, or comparing with DPDK. Activates on queries about AF_XDP, xsk_umem, XDP_REDIRECT, libbpf xsk, or zero-copy XDP.
Open skill - /dpdk
DPDK skill for userspace packet I/O. Use when initializing EAL, configuring PMD drivers, using mbuf pools and rte_ring, setting up huge pages, RSS, or testpmd validation. Activates on queries about DPDK, EAL, rte_eth_rx_burst, hugepages, PMD, or testpmd.
Open skill - /io-uring
io_uring skill for Linux async I/O. Use when building high-performance servers with liburing, multi-shot operations, provided buffers, fixed files, zero-copy send, or tokio-uring. Activates on queries about io_uring, SQE/CQE, liburing, IORING_OP_PROVIDE_BUFFERS, or io_uring vs
Open skill - /adc-dac-baremetal
Bare-metal ADC and DAC skill. Use when configuring analog sampling, DMA-driven ADC, calibration, or DAC output on MCUs. Activates on queries about ADC bare-metal, sampling time, DMA ADC, or DAC channel setup.
Open skill

