heatshrink-integration
Skill36 starsChanged 5 months agoMITView on GitHub
Use when integrating or debugging heatshrink embedded compression — encoder/decoder sink/poll/finish loops, window/lookahead sz2, HSER/HSDR codes, or static vs dynamic alloc
In this repository75 other files it gives its agents.
- 8051-mcu-debugSkill
- avem-integrationSkill
- battery-charger-fuel-gauge-integrationSkill
- ble-gatt-integrationSkill
- bootloader-debugSkill
- canbus-integrationSkill
- canopen-integrationSkill
- cellular-at-modem-integrationSkill
- cmbacktrace-integrationSkill
- cmsis-dsp-integrationSkill
- cortex-m-debugSkill
- cortex-r5-debugSkill
- crc-checksum-integrationSkill
- easylogger-integrationSkill
- embedded-app-example-libsSkill
- embedded-buffer-queue-libsSkill
- embedded-data-parsing-libsSkill
- embedded-debug-entrySkill
- embedded-fault-debugSkill
- embedded-framework-libsSkill
- embedded-input-libsSkill
- embedded-library-entrySkill
- embedded-linux-login-debugSkill
- embedded-peripheral-bringupSkill
- embedded-serial-log-debugSkill
- embedded-state-machine-libsSkill
- embedded-timing-libsSkill
- epd-integrationSkill
- esp-idf-integrationSkill
- fatfs-integrationSkill
- flashdb-integrationSkill
- freemodbus-integrationSkill
- freertos-kernel-debugSkill
- freertos-plus-tcp-integrationSkill
- gnss-gps-integrationSkill
- hardware-interface-debugSkill
- letter-shell-integrationSkill
- littlefs-integrationSkill
- low-power-debugSkill
- lvgl-integrationSkill
- lwip-integrationSkill
- mbedtls-integrationSkill
- mcuboot-integrationSkill
- mcu-flashing-debugSkill
- micro-ecc-integrationSkill
- miniz-integrationSkill
- mqtt-embedded-integrationSkill
- nanopb-integrationSkill
- nrf-connect-sdk-integrationSkill
- nr-micro-shell-integrationSkill
- openocd-jlink-stlink-debugSkill
- openthread-integrationSkill
- ota-update-integrationSkill
- plooc-integrationSkill
- power-management-integrationSkill
- qspi-xip-flash-debugSkill
- readme-writingSkill
- riscv-mcu-debugSkill
- rtos-debugSkill
- rt-thread-integrationSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use this skill to integrate heatshrink (github.com/atomicobject/heatshrink) by fixing memory budget, window_sz2/lookahead_sz2 sizes, the …
- Distinctive: line 14
Use this skill when:
- Distinctive: line 21
Do not use this skill for general archive formats like gzip/zip unless heatshrink is specifically involved.
- Distinctive: line 27
Use case: logs, UI assets, firmware chunks, telemetry, or storage.
- Very specific: line 46
After the last input, call heatshrink_encoder_finish/heatshrink_decoder_finish.
- Distinctive: line 66
Before claiming heatshrink works:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill 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
heatshrink Integration
Overview
Use this skill to integrate heatshrink (github.com/atomicobject/heatshrink) by fixing memory budget, window_sz2/lookahead_sz2 sizes, the sink/poll/finish streaming loop, and decompression safety. Compression bugs usually come from mismatched encoder/decoder settings, an unfinished poll loop, or output buffers that are too small.
When To Use
Use this skill when:
- The user wants heatshrink compression/decompression on an MCU.
- The task involves compressed logs, resources, firmware chunks, OTA payloads, or serial transfer compression.
- Decompression fails, output is truncated, memory is too high, or compressed data is incompatible.
- The project uses
heatshrink_encoder.h,heatshrink_decoder.h,heatshrink_config.h, or theheatshrinkcommand-line tool.
Do not use this skill for general archive formats like gzip/zip unless heatshrink is specifically involved.
First Questions
Ask for:
- Use case: logs, UI assets, firmware chunks, telemetry, or storage.
- Encoder/decoder settings:
window_sz2(4-15) andlookahead_sz2(3 towindow_sz2 - 1). The CLI's compiled default is-w 11 -l 4; its help text recommends-w 8 -l 4for embedded systems. - Allocation model:
HEATSHRINK_DYNAMIC_ALLOC(heap viaHEATSHRINK_MALLOC/HEATSHRINK_FREE) or static (HEATSHRINK_STATIC_WINDOW_BITS,HEATSHRINK_STATIC_LOOKAHEAD_BITS,HEATSHRINK_STATIC_INPUT_BUFFER_SIZE). - Streaming or one-shot mode, and input/output chunk sizes plus decompressed size bound.
- Whether compressed data comes from host tools or target firmware.
- Current return code or mismatch symptom.
Integration Checklist
- Match settings across the boundary.
Decoder
expansion_buffer_sz2andlookahead_sz2must match the encoder'swindow_sz2/lookahead_sz2. Under static alloc, both sides must share the sameHEATSHRINK_STATIC_WINDOW_BITS/HEATSHRINK_STATIC_LOOKAHEAD_BITS. - Choose the allocation model.
Dynamic:
heatshrink_encoder_alloc(window_sz2, lookahead_sz2)/heatshrink_decoder_alloc(input_buffer_size, expansion_buffer_sz2, lookahead_sz2), freed with*_free. Static: setHEATSHRINK_DYNAMIC_ALLOC 0inheatshrink_config.hand use a stack/BSS instance,*_resetbefore reuse. - Drive the streaming loop correctly.
Feed with
heatshrink_encoder_sink/heatshrink_decoder_sink(check*input_sizefor bytes consumed; re-sink the remainder). Then loop*_polluntil it returnsHSER_POLL_EMPTY/HSDR_POLL_EMPTYbefore sinking more. - Flush at end of stream.
After the last input, call
heatshrink_encoder_finish/heatshrink_decoder_finish; while it returnsHSER_FINISH_MORE/HSDR_FINISH_MORE, keep calling*_pollto drain output. Done isHSER_FINISH_DONE/HSDR_FINISH_DONE. Call*_resetbefore reusing the instance for a new stream. - Validate data integrity. Pair compression with CRC/hash when corruption matters. heatshrink carries no checksum or length header and does not reliably detect corrupt or truncated input, so integrity must be checked externally.
- Test worst case. Some data expands; do not assume size savings. Size the output buffer/store for expansion, not just the compressed happy path.
Common Failures
- Host encoder uses different
window_sz2/lookahead_sz2than the MCU decoder (or mismatchedHEATSHRINK_STATIC_*). - Caller stops after one
*_polland treats partial output as complete, instead of looping untilHSER_POLL_EMPTY/HSDR_POLL_EMPTY. *_finishnever called (or itsHSER_FINISH_MORE/HSDR_FINISH_MOREoutput not drained), so the tail of the stream is lost.- Sinking more data on the encoder after
heatshrink_encoder_finishwithoutheatshrink_encoder_reset(returnsHSER_SINK_ERROR_MISUSE). - Ignoring
*input_sizefrom*_sinkand dropping the unconsumed bytes. - Truncated/corrupt compressed input produces silent garbage rather than an error, because heatshrink has no integrity check;
*_SINK_ERROR_NULL/*_POLL_ERROR_NULLonly guard null handles or buffers, andHSDR_POLL_ERROR_UNKNOWNis an internal-state guard, not a corruption detector. - Compressed firmware lacks CRC before flash write; worst-case expansion exceeds allocated storage.
Verification
Before claiming heatshrink works:
- State
window_sz2/lookahead_sz2, allocation model (HEATSHRINK_DYNAMIC_ALLOC), decoderinput_buffer_size, and buffer sizes. - Confirm the poll loop drains to
*_POLL_EMPTYand the finish loop drains*_FINISH_MOREto*_FINISH_DONE. - Confirm a round-trip test for representative and worst-case (incompressible) data.
- Confirm that corrupt/truncated input is caught by an external integrity check, since heatshrink itself may emit silent garbage without an error code.
- Confirm the integrity check if used for firmware or persistent assets.
Example
User:
用 heatshrink 压缩资源,设备端解压出来缺尾巴。Agent:
- Asks for
window_sz2/lookahead_sz2, decoderinput_buffer_size/expansion_buffer_sz2, chunk sizes, and whetherheatshrink_decoder_finishis called. - Checks that
*_pollloops untilHSDR_POLL_EMPTYand thatfinishis drained untilHSDR_FINISH_DONE(the missing tail is almost always an undrained finish loop). - Verifies round-trip and truncated-input behavior, and that
heatshrink_decoder_resetruns before reusing the instance.
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.

