PRECC Tool Cuts Claude Code API Costs with Pre-Tool-Call Compression

PRECC is an open source tool that reduces Claude Code API costs by compressing redundant context before it reaches the model. It uses a pre-tool-call hook that intercepts Bash, Read, and Grep calls to apply compression algorithms.
How It Works
The tool addresses cost issues where API bills were climbing due to redundant context being sent multiple times. Common sources of waste include:
- Same file contents sent repeatedly
- Verbose shell output
- Overlapping grep results that the model doesn't need in full
The pre-tool-call hook runs RTK (Redundancy-aware Token Kompression) on tool output before it reaches Claude. The compression process:
- Deduplicates repeated spans
- Strips noise
- Summarises large reads
- Returns compressed version to the model
Performance Results
The hook runs in approximately 2.93ms, adding no perceptible latency to operations. In practice, users see 40-66% fewer input tokens across typical coding sessions. Model output quality remains unchanged because the compression preserves signal while stripping redundancy.
This type of optimization is particularly useful for developers using Claude Code extensively, where repeated file reads and tool outputs can significantly increase token usage and costs.
📖 Read the full source: r/ClaudeAI
👀 See Also

Claude Desktop App Cowork Function Enables AI-to-AI Communication via Shared Google Docs
Users successfully implemented Claude-to-Claude communication using the new cowork function in the desktop app, with two AI agents reading and writing to a shared Google Doc in a structured five-exchange dialogue.

Rift: A Better Alternative to Git Worktrees with Instant Copy-on-Write Snapshots
Rift uses btrfs or APFS snapshots to create instant, space-efficient copies of Git repositories. Initialization, creation, and listing via CLI or JavaScript FFI.

MCP Server Enables AI Agents to Make Real Purchases with Ephemeral Virtual Cards
A developer has built an MCP server that allows AI agents to complete real purchases using ephemeral virtual Visa cards issued just-in-time. The system requires user approval via MFA and issues cards locked to specific merchants with 15-minute TTLs.

Free macOS Menu Bar Monitor for Claude AI Usage Limits
A free, open-source macOS tool that displays Claude AI's session usage percentage, weekly limits, and reset countdowns directly in your menu bar. Installs with a single Homebrew command and piggybacks on existing Chrome sessions without storing data.