$ show codejunkie99/ztk
ztk is a CLI proxy that reduces LLM token consumption by intercepting and compressing shell command output. It sits between AI agents (Claude Code, Cursor, Gemini CLI) and the shell, executing commands normally but returning filtered output through a six-stage pipeline. The tool removes noise like diff metadata, test runner verbosity, and redundant directory listings while preserving essential information such as error messages and exit codes. Built in Zig with zero dependencies, it features a Thompson NFA regex engine for runtime filters, SIMD-accelerated text processing, and an mmap'd session cache to avoid repeated output for unchanged commands.
The LLM identified 3 files worth highlighting for reuse:
Implements a Thompson NFA regex engine with guaranteed linear time matching, immune to catastrophic backtracking. Self-contained and reusable in any project requiring regex matching.
Uses SIMD instructions to efficiently strip ANSI escape sequences from text. Hardware-accelerated for ARM NEON and x86 SSE2. Self-contained and reusable.
SIMD-accelerated line splitting for text processing. Counts newlines and splits input into lines without per-byte branches. Reusable in any text processing application.