fuyu12345/terminalgen-skills/dictionary-compression-lzw-hard
Claude Code and agent skill by fuyu12345/terminalgen-skills
- community
Checking that the SKILL.md file is still in the repository.
Implement a robust LZW-style compress/decompress CLI with compact integer-code serialization and corruption handling. Use when fixing or building dictionary-based archival tools that must pass round-trip tests and compression-ratio thresholds.
Install
npx vskill@latest install fuyu12345/terminalgen-skills/dictionary-compression-lzw-hardSKILL.md
The same SKILL.md was published earlier as fuyu12345/terminalgen-skills/dictionary-compression-lzw-hard.
Implementing LZW CLI Compression
When to Use
Use this skill when a task requires:
- A single script with
compress,decompress, andtestcommands - Dictionary-based compression (LZW-like) over text/byte data
- Explicit edge-case handling (empty input, single char, repeated patterns, printable ASCII)
- A hard compression-ratio gate (for example
<= 0.70) - Graceful handling of corrupted compressed archives
Minimal Reliable Workflow
- Inspect evaluation inputs before coding.
Parse test-case format exactly (including cases like |0 for empty input and inputs with leading/trailing spaces).
- Implement LZW on bytes with bounded dictionary growth.
- Initialize compressor/decompressor dictionaries with single-byte symbols (
0..255). - Cap dictionary size (commonly
4096for 12-bit codes). - Implement the LZW decompression special case
k == next_code(entry = w + w[:1]).
- Serialize integer codes compactly.
Avoid naive storage (e.g., text integers or always-16-bit codes) when ratio matters. Use bit-packed codes (fixed 12-bit or dynamic 9→12-bit) with a small binary header.
- Harden decompression against corruption.
Validate:
- magic/header
- code count vs payload length
- code range validity
- truncation / malformed padding
Raise clear errors instead of crashing or silently emitting bad bytes.
- Implement CLI contract exactly.
Support:
python solution.py compress <input_file> <output_file>python solution.py decompress <input_file> <output_file>python solution.py test(writes/workspace/results.jsonwith required schema)
- Compute ratio from on-disk compressed bytes, not internal code list length.
Compare actual archive size to original file size.
- Write results JSON with exact required fields and types.
Include: tests_passed, tests_failed, compression_ratio, all_tests_passed.
Common Pitfalls
- Using a storage format that ruins ratio despite correct LZW logic.
Evidence: one run passed round-trip but failed ratio at 0.7394 with fixed 16-bit code storage; switching to bit-packed coding passed (0.4785 / 0.5551).
- Ignoring whitespace-sensitive test inputs.
Stripping lines can break inputs like " spaces test ".
- Forgetting explicit empty-input handling.
Test files may encode empty input via a leading delimiter (|0).
- Omitting decompressor special-case logic (`k == next_code`).
Causes failures on valid LZW streams with self-referential dictionary growth patterns.
- Not validating archive structure before decode.
Missing checks for header/payload mismatch leads to fragile corruption handling.
- Letting compressor/decompressor dictionary policies diverge.
Any mismatch in growth/cap behavior breaks round-trip.
Verification Strategy
Run verification in layers:
- Static/CLI sanity
- Ensure script is executable.
- Run
python solution.py testwith zero crashes.
- Results contract
- Confirm
/workspace/results.jsonexists and is valid JSON. - Confirm required keys and types are exact.
- Functional correctness
- Ensure
tests_failed == 0. - Ensure
all_tests_passed == true.
- Compression gate
- Explicitly check
compression_ratio <= required_threshold(e.g.,0.70). - If ratio fails but round-trip passes, optimize serialization first (not necessarily core LZW logic).
- Edge/corruption checks
- Round-trip: empty, single-char, repeated sequences, printable ASCII range.
- Corruption: malformed header/truncated payload/invalid codes must fail gracefully.
References to Load On Demand
- Canonical LZW compressor/decompressor state transitions
- Bit-packing patterns for fixed-width and variable-width code streams
- Robust binary container validation checklist (magic/version/count/padding)
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinggenerated_skills_10tasks/dictionary_compression_lzw_hard/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/fuyu12345/terminalgen-skills/dictionary-compression-lzw-hard)