princejain756

Compactsim — Security skill for Claude Code

Security community

Audit local Claude Code and Codex session transcripts, measure Context Rent per tool output, and replay counterfactual autoCompactWindow policies offline.

How to install Compactsim

This entry records only its repository, not the path inside it, so there is no exact command to give. Open princejain756/compactsim and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

What Compactsim does

Audit local Claude Code and Codex session transcripts, measure Context Rent per tool output, and replay counterfactual autoCompactWindow policies offline.

Alternatives in Security

  • Loongsuite Pilot — Local-first telemetry collector for AI coding agents — unified OpenTelemetry events for Claude Code, Codex, Cu 150 ★
  • Validation Gate — Audit replay, regression, and rollback gates before promoting an evolution candidate 58 ★
  • Codeinspectus — Local-first MCP security scanner for AI-generated apps 47 ★

README

compactsim

compactsim logo

Zero-dependency profiler and counterfactual `autoCompactWindow` replay simulator for local Claude Code (`~/.claude/projects`) and Codex (`~/.codex/sessions`) JSONL transcripts.

![compactsim real run across 147 local sessions](demo.png)

Install & Run

npx compactsim

No API keys, no network calls, and no dependencies. By default it scans `~/.claude/projects/**/*.jsonl` and `~/.codex/sessions/**/*.jsonl`.

# Run against a specific directory or JSONL transcript
npx compactsim --dir ~/.claude/projects

# Run against the bundled 24-turn sample transcript
npx compactsim --demo

# Emit machine-readable JSON or a standalone dark-mode HTML report
npx compactsim --json > report.json
npx compactsim --html report.html

Why this exists

On 1M-context models, Claude Code waits until roughly 967K tokens before compacting the conversation. Every turn between 200K and 967K resends the full transcript history. Across 147 real local sessions (2,284 deduplicated API turns, 255.79M total input tokens) on my machine, 47.8% of weighted token spend happened on the 307 turns where the window had already crossed 200K tokens.

Setting `"autoCompactWindow"` lower cuts that tail cost, but compacting too aggressively triggers 65-second summary pauses, invalidates the prompt cache prefix on the turn after compaction, and causes post-compaction amnesia where the agent immediately re-reads files it had read 10 turns earlier because the summary dropped implementation details.

`compactsim` parses your actual local session history and replays every turn under candidate compaction windows (`400K`, `250K`, `150K`) and sliding tool-output eviction (`slide-tools@15t`) so you can pick a threshold backed by your own workload instead of a guess.

What it measures

  1. Streaming-aware turn deduplication (1.4x to 3.0x overcount correction): My first parser summed `mess