ContextSpectre — Reasoning Hygiene
Inline noise prevention + post-hoc session cleanup for Claude Code sessions. Proxy mode strips junk tokens before they hit the API. Diagnostic mode shows what fills your context and what it costs.
Install
brew install ppiankov/tap/contextspectre
# Linux
curl -sL https://github.com/ppiankov/contextspectre/releases/latest/download/contextspectre_$(curl -s https://api.github.com/repos/ppiankov/contextspectre/releases/latest | grep tag_name | cut -d'"' -f4 | tr -d v)_linux_amd64.tar.gz | tar xz -C /usr/local/bin
Verify: contextspectre version (expect 0.48.1+)
Proxy Mode — Inline Noise Prevention
Strips from every API request before billing:
- Thinking blocks and signatures (never re-sent, pure waste)
- Duplicate system reminders (keeps last occurrence)
- Oversized content blocks >100KB (truncated with marker)
Metrics: Output Purity Score (OPS) — how clean your traffic is after filtering.
Standalone
contextspectre proxy --port 9997 --upstream https://api.anthropic.com
# Set ANTHROPIC_BASE_URL=http://localhost:9997
Chained with pastewatch (recommended)
# contextspectre strips noise, forwards to pastewatch for secret redaction
contextspectre proxy --port 9997 --upstream http://localhost:9998
pastewatch-cli proxy --port 9998 --upstream https://api.anthropic.com
Full defense-in-depth chain (with chainwatch)
OpenClaw → chainwatch:9999 (policy) → contextspectre:9997 (noise) → pastewatch:9998 (secrets) → Anthropic API
chainwatch intercept --port 9999 --upstream http://localhost:9997 --profile clawbot
contextspectre proxy --port 9997 --upstream http://localhost:9998 --quiet
pastewatch-cli proxy --port 9998 --upstream https://api.anthropic.com --severity high
Diagnostics
contextspectre # TUI — browse all sessions
contextspectre summary --cwd # One-screen summary for current directory
contextspectre active # Active sessions with signal grades + cost
contextspectre stats <session-id> # Detailed context stats
Cleanup (post-hoc)
contextspectre quick-clean # Clean most recent session
contextspectre quick-clean --live # Live cleanup between Claude's turns
contextspectre clean <id> --all # All 9 cleanup operations
contextspectre clean --active --all --watch # Continuous smart sweep
9 operations across 7 safety tiers. Mandatory backup with one-key undo.
Key Concepts
- Vector health score (A-F): signal-to-noise grade. A = >95% signal
- Reasoning contamination: old scaffolding biasing future responses
- Snowball effect: dead tokens re-read every turn — 50K stripped early avoids millions of re-reads
- Context deadlock: too large to continue, too large to compact
Cross-Session
contextspectre graph <project> # Reasoning graph with structural edges
contextspectre conflicts <project> # Decision conflict detection
contextspectre memory <project> # Project memory synthesis
contextspectre sync-claude-md # CLAUDE.md sync from decisions
What This Does NOT Do
- Does not interpret semantics or judge prompts
- Does not modify Claude's behavior or intercept model responses
- Does not work with non-Claude providers (Claude Code session format only)
- Does not auto-trim without explicit confirmation
ContextSpectre Skill v1.0.0 Author: ppiankov Copyright © 2026 Obsta Labs, LLC Canonical source: https://github.com/ppiankov/contextspectre License: MIT
This tool follows the Agent-Native CLI Convention.
