write-compressor
Installation
SKILL.md
Write Compressor
Overview
This skill provides strategies for implementing encoders that produce output compatible with existing decoders. It applies to tasks involving compression algorithms, arithmetic coding, entropy encoding, or any scenario requiring the construction of an encoder as the mathematical inverse of a decoder.
Core Principle: Encoder as Decoder Inverse
When implementing an encoder for an existing decoder, the encoder must be the exact mathematical inverse of the decoder operations. Every decoder operation has a corresponding encoder operation that must produce the exact values the decoder expects to read.
Mathematical Derivation First
Before writing any code:
- Document the decoder's state machine - Identify all state variables (e.g.,
low,high,range,fraction) and how they evolve - Derive encoder operations algebraically - For each decoder read operation, derive what the encoder must write
- Verify the inverse relationship on paper - Prove mathematically that encoder output → decoder input produces the original data