360 Secure SkillHub
360 安全技能中心

ContextSpectre

ContextSpectre 是面向 Claude Code 会话的推理卫生层:以本地代理方式在上游 API 计费前剥离思考块、重复系统提醒与超大内容块,并提供会话诊断摘要、分级清理与跨会话记忆、冲突分析等 CLI 命令。需先安装 contextspectre 二进制,代理可与其他本地代理串联使用。

分类:效率
ppiankov
ppiankov
热度 0.33
最近更新 2026-03-28 13:17:55

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add ppiankov/contextspectre
兼容性
Claude Code 专属
联网要求
需要联网
数据出网
必须出网
Metadata
name
contextspectre
description
Reasoning hygiene layer — API proxy for inline noise prevention, session diagnostics, context cleanup, and cross-session memory. Strips thinking blocks, duplicate system reminders, and oversized content from API traffic before billing.
metadata
{"openclaw":{"requires":{"bins":["contextspectre"]}}}

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.