tokenjuice CLI
tokenjuice runs noisy commands and returns short, deterministic output to the agent by JSON rules for listings, tests, build logs
- 543 ★ on the repository
- Last commit
Extended access
Why this level
- Sits in front of every command the agent runs and passes its output through a processor, so a bad rule can hide a needed line
- Changes host settings on tokenjuice install and can optionally store raw command output on disk
Install
- Works in
In your terminal, with SkillFoxx CLI
npx skillfoxx add cli/tokenjuiceDetects the agents on your machine, shows the access level and pins the version.
Other ways to install
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- Sits in front of every command the agent runs and passes its output through a processor, so a bad rule can hide a needed line
- Changes host settings on tokenjuice install and can optionally store raw command output on disk
This is third-party code. Review the repository files before installing.
What it does
tokenjuice is a Node.js command-line tool that compacts terminal command output before it reaches the agent's context. tokenjuice wrap runs another command and returns reduced output, and tokenjuice reduce compacts existing text such as a build log. The compaction rules are JSON and cover file listings, test output, build logs and other noise. Built-in rules are extended by layers from ~/.config/tokenjuice/rules and a project's .tokenjuice/rules, and a later rule with the same ID wins. Compaction reaches agents through integrations. For Claude Code, tokenjuice install claude-code adds a pre-tool wrapper and tokenjuice doctor claude-code checks the managed configuration. OpenClaw has an external plugin, and Hermes, Copilot SDK, LangChain, Mastra and FastMCP have native adapters. Host integrations keep exact file reads unchanged. Failed commands stay whole: --keep-failures preserves stdout, stderr and the exit status, and automatic wrappers turn it on themselves. --raw and --full bypass reduction, and --store keeps the original output in an artifact directory.
Who it is for. Developers whose agents often run commands with long output (tests, builds, git, pnpm) and burn context and tokens on noise.
Good fit when
- The agent runs pnpm test and hundreds of lines of passing tests flood the context
- Build logs are too long for the context and should be cut down to the errors
- Your project has its own noisy commands and you want custom JSON rules in .tokenjuice/rules
- You want to see how much output was saved, and tokenjuice stats shows it
Not a fit when
- Command output is short: there is nothing to compact and the wrapper adds another layer
- The agent needs byte-exact output: --raw covers that, but it is simpler to leave the wrapper off
- The machine has no Node.js 22 or newer
Example request
Connect tokenjuice to Claude Code and show how much it shortens the pnpm test output in this projectLimitations
- Needs Node.js 22 or newer.
- A successful doctor check confirms the managed configuration but does not prove the host loaded it and delivered compacted output. Restart the host or start a new session after installing.
- The OpenClaw adapter compacts shell results and leaves Code Mode JavaScript results alone.
- Output capture is limited to 4 MB by default, and the limit changes with --max-capture-bytes. The Pi extension stores the raw bytes of every rewrite.
How to disable. For Claude Code run tokenjuice uninstall claude-code, which removes the managed configuration. The program itself is removed by your package manager, for example npm uninstall -g tokenjuice. Stats telemetry is turned off with TOKENJUICE_STATS=off or the --no-stats flag.
FAQ
How do I connect tokenjuice to Claude Code?
Install the package with npm install -g tokenjuice, then run tokenjuice install claude-code and check with tokenjuice doctor claude-code. Restart Claude Code or start a new session. Remove the connection with tokenjuice uninstall claude-code.
What does tokenjuice compact and what does it leave alone?
It compacts listings, test output and build logs using JSON rules. Exact file reads through host integrations are unchanged, and failed commands keep stdout, stderr and the exit status with --keep-failures on.
How do I get the original output?
Run the command with --raw, which disables compaction but still obeys the 4 MB capture limit. To keep the original output, add --store and set the directory in TOKENJUICE_ARTIFACT_DIR, then read it back with tokenjuice cat.
How do I write my own rule?
Put a JSON rule in ~/.config/tokenjuice/rules or in the project's .tokenjuice/rules. A later rule with the same ID overrides earlier ones, and tokenjuice verify --fixtures checks the fixtures.
Which agents and frameworks does tokenjuice support?
Claude Code through a pre-tool wrapper, OpenClaw through an external plugin, the Pi extension, and adapters for Hermes, Copilot SDK, LangChain, Mastra and FastMCP. The support matrix is in docs/adapter-support-matrix.md.
Discussion
No questions or reviews yet.
Related
CLI toolsToken Optimizer
token-optimizer
A plugin for Claude Code and Codex: trims wasted tokens, keeps work alive across sessions and compactions and shows cost. The license is noncommercial
Tokscale
tokscale
A CLI with an interactive TUI that tracks token usage and cost across AI coding agents: Claude Code, Codex, Copilot, Cursor and more
A local Rust proxy that compresses the model API requests of Claude Code, Codex and Cursor so you pay for fewer tokens
squeez compresses bash output by up to 95 percent in the hooks of seven AI CLIs and preserves exact identifiers
Token Monitor
token-monitor
A desktop widget for tracking tokens, cost and limits across 43 or more tools: Claude Code, Codex, Cursor, OpenRouter and others, for Windows and macOS
Token and cost reports across Claude Code, Gemini CLI, Codex and Cursor in one view, built from local logs with no keys.
Comparison with similar tools
Cards that share the main search query, and how they differ.
| Tool | Official | Repository stars | Main difference |
|---|---|---|---|
| tokenjuice (this card) | no | 543 | |
| RTK | no | 86,384 | another command output compactor, while tokenjuice defines compaction with JSON rules layered by project and user |
| Token Optimizer | no | 2,964 | a different approach to saving tokens, while tokenjuice compacts only terminal command output |
README in short
The README starts with installation through npm, pnpm, yarn and Homebrew, then points to the integration catalog and shows how Claude Code and OpenClaw connect. A command list, a section on output and storage and an index of docs with the rules spec follow.