Token Optimizer

Token Optimizer is an open-source agent plugin and context optimization harness developed by Alex Greenshpun (alexgreensh). Designed to integrate directly with terminal-based coding agents such as Codex CLI and Claude CLI, the project provides lifecycle hooks and modular skills aimed at minimizing token consumption and preventing context window bloat during complex software engineering tasks. In daily use, Token Optimizer operates as an extension inside host agent runtimes. It attaches custom skills and hook scripts to the agent's command loop, allowing developers to filter unnecessary file content, optimize prompt sizes, and automate context-clearing routines without disrupting existing CLI workflows. It interfaces cleanly with agent marketplace manifests and local hook runtimes. What differentiates Token Optimizer from generic token counters or prompt wrappers is its architecture as a multi-runtime plugin harness. It natively supports both Codex CLI and Claude plugin structures, incorporating preflight verification, hook diagnostics (such as codex_doctor.py), and mirror synchronization to ensure consistent skill execution across developer environments. The project is available as open-source software on GitHub with public development and community funding via GitHub Sponsors and Ko-fi.

Tags: AI, cli, developer tools, OpenSource, productivity, prompts

Visit Token Optimizer

Key features

  • Codex CLI Marketplace Integration — Natively registers as a marketplace plugin inside codex-cli with standardized directory manifests. - Claude Plugin Compatibility — Provides structured .claude-plugin hooks and skills ready for terminal-based Claude agent environments. - Lifecycle Hook Runtime — Injects pre- and post-execution hooks into the agent pipeline to optimize context and clean prompt payloads. - Diagnostic and Doctor Tooling — Ships with utility scripts like codex_doctor.py and codex_install.py to verify hook resolution and dependency paths. - Skill Synchronization & Integrity — Includes automated scripts to prevent skill drift between root manifests and platform-specific plugin distributions.

Use cases

Use Case: Context Management in Large Codebases Developers working with large codebases use Token Optimizer to intercept and trim token-heavy context files before sending payloads to LLMs, reducing API costs and context window degradation.

Use Case: Extending Codex CLI Workflows Engineers running codex-cli install the harness via marketplace configurations to attach custom token-trimming skills and automated hooks into their standard terminal coding sessions.

Use Case: Plugin Setup Diagnostics Teams configuring automated coding agents on local developer machines run the bundled doctor scripts to verify hook runtime paths, manifest integrity, and marketplace resolutions.

Who it is for

Token Optimizer is designed for software developers and AI engineers using terminal-based coding agents like Codex CLI or Claude CLI who want granular control over token usage and agent lifecycle hooks. It is not intended for non-technical users or developers looking for a standalone graphical IDE.

Install guide

Installation To install Token Optimizer as a plugin in Codex CLI: bash # Add the marketplace repository codex marketplace add https://github.com/alexgreensh/token-optimizer # Install the plugin codex plugin add token-optimizer Alternatively, clone the repository directly for manual development or custom hook integration: bash git clone https://github.com/alexgreensh/token-optimizer.git cd token-optimizer

First Run Run the built-in diagnostic script to ensure hooks and skills are properly recognized by your agent environment: bash python3 scripts/codex_doctor.py

Example Session Once installed, verify that the plugin skills and hooks are loaded in your agent CLI: bash codex plugin list Run your regular agent commands; Token Optimizer's hooks will automatically monitor and optimize context during multi-turn edits.

Part of CLI Coding Agents

Categories: AI Coding Agents, Developer Tools, Productivity, Prompts

Related CLI agents

  • PicoClaw — PicoClaw is an open-source command-line coding agent developed by Sipeed and community contributors. Written in Go, it is engineered for…
  • Playwright Praman — Playwright Praman is an open-source test harness and agent orchestrator developed by Maheshwar Kanitkar. It is designed to bridge terminal…
  • GreatCTO — GreatCTO is an open-source AI agent orchestration harness and engineering pipeline framework created by Anatoly Velikiy (avelikiy). It coordinates multi-role…
  • Skillreaper — Skillreaper is an open-source skill lifecycle management and auditing tool for AI agent ecosystems, developed by thousandflowers. It analyzes agent…
  • Zosma QA — Zosma QA is an open-source testing-focused agent harness and orchestration framework created by Zosma AI. It provides scaffolding, structured prompt…
  • Stratless — Stratless is an open-source agent harness and execution orchestrator developed by the Stratless AI team. It provides a modular infrastructure…
  • AI Tools
  • Categories
  • Industries
  • CLI Coding Agents
  • MCP Servers
  • MCP Categories