claude-token-optimizer

Cut the tokens Claude Code loads at session start. CLI that sets up a small CLAUDE.md with on-demand docs, measures startup tokens, and keeps them small.

What is claude-token-optimizer?

Cut the tokens Claude Code loads at session start. CLI that sets up a small CLAUDE.md with on-demand docs, measures startup tokens, and keeps them small.

Overview of claude-token-optimizer

What it is

Claude Token Optimizer is a CLI tool that reduces the number of tokens Claude Code loads at the start of each session. It sets up a small CLAUDE.md file and moves detailed documentation into separate files that are read on demand. The tool measures startup tokens and provides commands to keep them small. It is available as an npm package and requires Node 20 or newer.

Key features

  • Measures the token count of files loaded at session start using cto measure
  • Prunes CLAUDE.md by moving completed tasks and old session notes into side files with cto prune
  • Initializes a project structure with a minimal CLAUDE.md and on-demand documentation files via cto init
  • Audits the project structure with 19 structural checks using cto audit
  • Compresses markdown files by removing blank lines, verbose fences, long lists, HTML comments, and inline SVGs with cto compress
  • Provides a live token dashboard that refreshes when watched files change with cto watch
  • Includes hooks for Claude Code to enforce token limits automatically

Use cases

  • Reducing token consumption in Claude Code sessions to save costs and stay within usage limits - Setting up a new project with an optimized CLAUDE.md structure from the start - Auditing existing projects for token-heavy startup files and fixing them - Integrating token optimization into CI pipelines using non-interactive commands like cto audit --json
  • Using with AI coding agents by providing the repository link and AGENTS.md

Getting started

Ensure Node 20 or newer is installed. Run the following commands in your project folder: bash npx -y claude-token-optimizer measure npx -y claude-token-optimizer prune --yes For a global install: bash npm install -g claude-token-optimizer # or curl -fsSL https://raw.githubusercontent.com/nadimtuhin/claude-token-optimizer/main/install.sh | bash

License and pricing

This project is licensed under the MIT License and is open source. No pricing information is stated beyond being open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/nadimtuhinclaude-token-optimizer.svg)](https://yunodb.com/tools/nadimtuhinclaude-token-optimizer?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/nadimtuhinclaude-token-optimizer?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/nadimtuhinclaude-token-optimizer.svg" alt="Featured on YunoDB" height="20"></a>