Checkpoint: File edits

Automatic checkpoint created by Claude Code
- Branch: rebrand/ruvflow-umbrella
- Timestamp: 2026-02-10T20:20:48Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rUvandClaude Opus 4.5 committed 2026-02-10 20:20:48 +00:00
1 parent 6a0dd01453
commit 237fb8d6d0
1 file changed
+36
@@ -0,0 +1,36 @@
#!/usr/bin/env node
/**
* Aggressive Micro-Compaction Preload
*
* Claude Code's micro-compaction (Vd function) only prunes old tool results
* when context is above the warning threshold (~80%) and only if it can save
* at least 20K tokens. These hardcoded thresholds mean context can grow large
* before any pruning happens.
*
* This script patches the environment to make micro-compaction more aggressive
* by lowering the threshold at which it activates. It works by setting
* CLAUDE_AUTOCOMPACT_PCT_OVERRIDE to trigger compaction earlier if micro-compaction
* isn't enough, but the real win is keeping context lean through early pruning.
*
* The micro-compact function Vd() works like this:
* 1. Collects all tool results from: Read, Bash, Grep, Glob, WebSearch, WebFetch, Edit, Write
* 2. Keeps the last 3 tool results intact (Ly5=3)
* 3. If total tool result tokens > 40K (Ny5) AND context is above warning threshold:
* - Replaces old results with "[Old tool result content cleared]"
* - Only if savings >= 20K tokens (qy5)
* 4. This runs on EVERY query — it IS automatic pruning
*
* The problem: Ny5=40000 and qy5=20000 are hardcoded. We can't change them.
* The solution: Set CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 so the warning/error
* thresholds drop, which makes micro-compaction activate much earlier.
*/
// This file is sourced by settings.json hooks to document the strategy.
// The actual configuration is in settings.json env vars:
// CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50 → lowers all thresholds
// autoCompactEnabled=true → enables the auto-compact fallback
console.log('[AggressiveMicrocompact] Strategy: CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50');
console.log('[AggressiveMicrocompact] Micro-compact activates when tokens > warning threshold');
console.log('[AggressiveMicrocompact] Warning threshold = maxTokens - 20K (relative to override)');
console.log('[AggressiveMicrocompact] Effect: pruning starts at ~45% instead of ~80%');