360 Secure SkillHub
360 安全技能中心

ContextSpectre

这是专为Claude Code会话打造的推理卫生工具,核心功能包括:代理模式实时拦截清理思维块、重复系统提示、大体积内容等无效噪声,减少API计费浪费;诊断模式查看会话纯度、成本与健康度;事后会话清理(支持一键撤销备份);跨会话的项目记忆合成、决策冲突检测等。以CLI命令操作,典型场景为Claude API使用时过滤请求、诊断或整理会话。

ppiankov
ppiankov
热度 20.18
最近更新 2026-03-28 13:17:55
分类:开发依赖:代码执行 / 第三方 API应用场景:API 集成 / DevOps / 调试排错

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add contextspectre
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.