More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    CompactSim: Claude Code & Codex Compaction Audit

    1

    Replays local Claude Code and Codex session transcripts to tune autoCompactWindow and surface Context Rent.

    $5

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    CompactSim: Claude Code & Codex Compaction Audit

    CompactSim: Claude Code & Codex Compaction Audit

    Example session with this skill installed

    Run an audit on my current Claude Code transcripts and suggest a new autoCompactWindow setting.

    • Read your context and instructions
    • Compiled the compactsim

    $ node scripts/compactsim.mjs

    CompactSim v0.1.0 - Context Compaction & Token Waste Simulator
    Corpus: 147 sessions (123 Claude Code, 24 Codex) | 2,284 API turns (3,197 raw JSONL usage records, 1.40x raw overcount)

    Baseline Token Profile

    • Total input tokens: 255.79M (143.49M uncached @ 1.0x, 112.30M cache-read @ 0.1x, 43.9% cache hit rate)
    • Weighted input token-equivalents: 160.79M tok-eq
    • Peak session context: 467,835 tokens (session 78fd79c6)
    • Turns > 200K context: 307 turns (13.4% of turns driving 47.8% of weighted token cost)
    • Turns > 400K context: 59 turns (2.6% of turns driving 15.7% of weighted token cost)
    • Mid-session cache-bust spikes (>25K uncached jump): 760 spikes across 147 sessions

    Counterfactual Policy Replay

    1. Baseline (recorded transcripts): 160.79M tok-eq | 0.0% saved | 9 compactions | 8.7m wait
    2. autoCompactWindow = 400,000 tokens: 138.92M tok-eq | -13.6% saved | 10 compactions | 9.8m wait
    3. autoCompactWindow = 250,000 tokens: 114.93M tok-eq | -28.5% saved | 11 compactions | 11.9m wait
    4. autoCompactWindow = 150,000 tokens: 89.49M tok-eq | -44.3% saved | 17 compactions | 18.2m wait
    5. Sliding tool-output eviction (15t): 136.67M tok-eq | -15.0% saved | 9 compactions | 8.7m wait

    Recommendation
    Set autoCompactWindow to 250000 in ~/.claude/settings.json (or model_auto_compact_token_limit = 250000 in ~/.codex/config.toml) to cut weighted token usage by 28.5% while adding only 2 extra compactions across 147 sessions.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Long Claude Code and Codex sessions burn roughly half their weighted token cost after context passes 200K tokens, and compacting too late or too early forces expensive file re-reads.

    Most token counters sum raw JSONL usage rows without deduplicating multi-chunk streaming assistant records or simulating what an earlier compaction threshold would have done to your actual sessions. CompactSim parses local transcripts, deduplicates streaming records by message.id, attributes Context Rent per tool output, and replays every turn under candidate compaction policies.

    What it runs:

    • Scans ~/.claude/projects//*.jsonl and ~/.codex/sessions//*.jsonl locally (or any custom directory).
    • Deduplicates multi-chunk streaming assistant records by message.id so 3-part tool turns are counted once instead of 3x.
    • Computes Context Rent (payload_tokens multiplied by turns_carried) for Read, Bash, Grep, Edit, and MCP outputs.
    • Detects redundant same-file reads and post-compaction amnesia re-reads where the agent re-opens files right after a compaction boundary.
    • Replays sessions against autoCompactWindow thresholds (400K, 250K, 150K) and sliding tool-output eviction (15 turns) to compare weighted token savings against extra compaction latency.

    What it refuses to do:

    • It never uploads transcripts, prompts, file paths, or code over the network.
    • It does not guess exact dollar invoices because Anthropic and OpenAI billing tiers vary by plan, batching, and enterprise discounts; instead it reports exact token-equivalents with 0.1x cache-read weighting.
    • It does not mutate your live Claude Code or Codex config files automatically; it prints the recommended setting so you decide whether to apply it.

    Package contents:

    • SKILL.md workflow instructions for any SKILL.md-compatible coding agent
    • scripts/compactsim.mjs zero-dependency CLI analyzer and counterfactual simulator
    • tests/compactsim.test.mjs unit test suite (6 tests covering deduplication, amnesia re-reads, and policy replay)
    • reference/compaction-mechanics.md technical reference on Claude Code and Codex JSONL schemas and Context Rent math

    Requirements:

    • Node.js 18+ (zero npm dependencies, standard library only, no API keys required).

    1. Requires local Claude Code (/.claude/projects/**/*.jsonl) or Codex CLI (/.codex/sessions/**/*.jsonl) transcript files on disk (or synthetic demo mode for offline evaluation).
    2. Reports weighted token-equivalents (1.0x uncached input, 0.1x cache_read_input_tokens, 1.25x cache_creation_input_tokens) rather than plan-specific USD billing totals.
    3. Counterfactual replay models deterministic compaction summaries and observed post-compaction file re-read penalties, which can vary slightly if an agent takes a different branching path after compaction.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 11 days ago

    Requires

    Node.js

    Permissions

    Terminal / Shell
    Read Files

    Terminal / Shell is used to run the local Node.js analyzer script (scripts/compactsim.mjs). Read Files is used to parse local session transcripts in ~/.claude/projects and ~/.codex/sessions.

    Listed11 days ago

    What's inside

    Frequently Asked Questions

    CompactSim is a diagnostic tool that audits your Claude Code and Codex session logs to identify "token waste," such as redundant file reads or oversized tool outputs that remain in your context window for too long. It helps you lower your API bills by simulating different auto-compaction settings to find the most cost-effective configuration for your workflow.

    This utility is built for Node.js 18+ and is compatible with session logs generated by Anthropic's Claude Code and the Codex environment. It specifically parses JSONL files found in the local project directories of these agents to provide deterministic data.

    While a standard LLM can guess why a session is expensive, CompactSim performs a deterministic audit using "weighted context rent" math (payload size multiplied by turns carried). It accesses your local raw session files to provide exact integers and cache hit rates that a chat-based LLM simply cannot see or calculate accurately.

    You will receive the standalone Node.js CLI utility, the core analyzer script, and documentation on how to interpret the simulation reports. It also includes a configuration generator that outputs ready-to-use settings for your global Claude Code environment.

    No, CompactSim operates entirely on your local machine by scanning your local filesystem for existing session logs. It does not require an active API connection or send your proprietary code/transcripts to any external servers during the audit.

    New in LLM Ops