token-optimizer  by alexgreensh

Prevent AI context decay and token waste

Created 3 months ago
1,095 stars

Top 34.4% on SourcePulse

GitHubView on GitHub
Project Summary

This project addresses AI model degradation caused by "ghost tokens," context compaction, and quality decay in large language models. It provides tools for users of platforms like Claude Code and OpenClaw to track, diagnose, and mitigate these issues, aiming to maintain AI accuracy, efficiency, and reduce token waste.

How It Works

Token Optimizer uses six parallel agents to audit AI setups, identifying token-wasting patterns and offering prioritized fixes. It runs externally, consuming zero context tokens. Key mechanisms include a 7-signal quality scoring system, progressive "Smart Compaction" checkpoints to prevent data loss, and an archive for tool results. The v5 release introduces "Active Compression" features like Delta Mode for efficient file re-reads and Quality Nudges to alert users to degradation.

Quick Start & Requirements

  • Claude Code: Install via plugin marketplace (/plugin marketplace add alexgreensh/token-optimizer, /plugin install token-optimizer@alexgreensh-token-optimizer) or script. Enable auto-update.
  • OpenClaw: Install via openclaw plugins install github:alexgreensh/token-optimizer or from source. Requires Python (Claude Code) or Node.js/npm (OpenClaw). Links to official docs are available within the README.

Highlighted Details

  • Quality Scoring: A 7-signal system provides a letter grade (S-F) reflecting AI session health.
  • Smart Compaction: Progressive checkpoints and restores session state before compaction, preserving critical data.
  • Active Compression (v5): Features like Delta Mode offer significant savings (~97% on file re-reads), while Quality Nudges and Loop Detection proactively manage context.
  • Memory Health Audit: Scans MEMORY.md for inaccessible content and structural issues.
  • Attention Optimizer: Reorders CLAUDE.md rules to align with the model's attention curve.
  • Cost Tracking: Monitors dollar savings and provides per-turn cost analytics across multiple pricing tiers.

Maintenance & Community

Created by Alex Greenshpun. Primary support is via the GitHub repository; no specific community channels or sponsorships are detailed.

Licensing & Compatibility

Licensed under PolyForm Noncommercial 1.0.0. Free for personal, research, educational, and non-commercial use. Commercial use requires a separate license from the creator. Compatible with Claude Code (Python) and OpenClaw (TypeScript), supporting various LLM backends.

Limitations & Caveats

Commercial use requires a separate license. The VS Code extension lacks the CLI-based quality bar status line. Running Claude Code in --bare mode disables essential hooks. The opt-in Bash Compression feature carries moderate risk due to its lossy nature. Delta Mode may occasionally require full file context over just a diff.

Health Check
Last Commit

3 days ago

Responsiveness

Inactive

Pull Requests (30d)
3
Issues (30d)
4
Star History
417 stars in the last 30 days

Explore Similar Projects

Starred by Elie Bursztein Elie Bursztein(Cybersecurity Lead at Google DeepMind), Dan Guido Dan Guido(Cofounder of Trail of Bits), and
5 more.

claude-mem by thedotmack

2.3%
79k
AI coding assistant memory system
Created 8 months ago
Updated 1 day ago
Feedback? Help us improve.