Ctxwise
БесплатноПоддерживаетсяCtxWise: The local-first AI Context Firewall, MCP Schema Tree-Shaker, and Token Profiler for Claude Code, OpenAI Codex, and Cursor.
Описание
CtxWise: The local-first AI Context Firewall, MCP Schema Tree-Shaker, and Token Profiler for Claude Code, OpenAI Codex, and Cursor.
README
Stop burning 30,000+ startup tokens on bloated MCP tool schemas, diverging CLAUDE.md / AGENTS.md files, and hidden prompt leaks.
The local-first AI Context Firewall, MCP Schema Tree-Shaker, and Token Profiler for Claude Code, OpenAI Codex, and Cursor.
⚡ 30s Quickstart · 📊 Before vs. After · 🌳 MCP Tree-Shaker · 🛡️ Security Shield · 🤖 GitHub Action · 🤝 5-Min PRs
💡 Using Claude Code, OpenAI Codex, or Cursor? Drop a ⭐ Star on GitHub so you can find CtxWise whenever your MCP servers or
CLAUDE.md/AGENTS.mdfiles start bloating your context window!
⚡ 30-Second Quickstart
Zero config, zero API keys, zero model calls. Run directly with npx in any repository:
# 1. Profile MCP servers & find bloated tool schemas silently eating your context window
npx @framy2/ctxwise mcp-xray --probe-stdio
# 2. Audit startup tokens & parity across Claude Code (CLAUDE.md), Codex (AGENTS.md), and Cursor
npx @framy2/ctxwise agents
# 3. Scan context files & skills for leaked API keys, prompt injection, and hidden Trojan Unicode
npx @framy2/ctxwise shield --fail-on-risk
# 4. Sync CLAUDE.md <-> AGENTS.md <-> Cursor rules and apply lossless Token Diet compression
npx @framy2/ctxwise sync --compress --cursor
📊 Before vs. After CtxWise
Modern coding agents (Claude Code, OpenAI Codex CLI, Cursor) load CLAUDE.md, AGENTS.md, .cursor/rules, skill catalogs, and every connected MCP server's JSON schema on every turn:
| Problem Surface | ❌ Without CtxWise | ✅ With CtxWise v1.0 |
|---|---|---|
| Idle MCP Tool Schemas | 4–5 MCP servers silently burn 15,000–35,000 tokens/turn | ctxwise mcp-xray ranks every tool schema & flags [BLOATED] tools |
| Multi-Agent Rule Drift | CLAUDE.md, AGENTS.md, and .cursor/rules diverge fast |
ctxwise sync --compress keeps all 3 synced + strips 25–40% boilerplate |
| Leaked API Keys in Context | sk-ant-*, sk-proj-*, ghp_* inside .mcp.json or skills |
ctxwise shield blocks secrets before they enter git or model prompts |
| Prompt Injection & Trojan Source | Hidden <!-- curl ... --> comments or zero-width Unicode |
ctxwise shield --fail-on-risk fails CI (exit 2) in <20ms |
| Measured Prompt Overhead | Unbounded context growth across PRs | -73.3% model-visible prompt & -29.1% turn tokens (20/20 pass) |
🏗️ How It Works
flowchart LR
subgraph Sources["Active Agent Context Surface"]
C["Claude Code\nCLAUDE.md · .mcp.json · .claude/skills"]
O["OpenAI Codex\nAGENTS.md · config.toml · .codex/skills"]
U["Cursor\n.cursorrules · .cursor/rules/*.mdc"]
end
subgraph Engine["CtxWise Local Engine (0 API Calls · <50ms)"]
A["ctxwise agents & sync\nCross-Agent Parity + Token Diet"]
M["ctxwise mcp-xray\nMCP Tool Schema Tree-Shaker"]
S["ctxwise shield\nSecret & Prompt-Injection Firewall"]
B["ctxwise budget & drift\nDeterministic Lock & CI Gate"]
end
Sources --> Engine
Engine --> Out1["Lean, Synced Context\n(-29% to -73% Token Overhead)"]
Engine --> Out2["GitHub Action CI Gate\nuses: FramY2/ctxwise@v1"]
🔥 Core Features
1. 🌳 MCP Schema Tree-Shaking (mcp-xray)
Discover all MCP servers declared across .mcp.json, .cursor/mcp.json, .vscode/mcp.json (VS Code's top-level "servers" key), ~/.claude.json, and ~/.codex/config.toml. Measure exact token weights per tool schema (from a saved tools/list JSON file or by probing local stdio servers live) and spot [BLOATED] tools (>= 250 tokens or >= 12 input properties):
npx @framy2/ctxwise mcp-xray --probe-stdio
CtxWise mcp-xray · 3 MCP servers declared · 18 tool schemas analyzed · ~6,420 schema tokens (estimated)
Heaviest MCP tool schemas:
- ~890 tokens · github/create_or_update_pull_request (16 params, 3,560 chars) [BLOATED]
- ~640 tokens · postgres/execute_migration_plan (14 params, 2,560 chars) [BLOATED]
Tree-shaking potential: ~1,530 tokens/turn savable by pruning bloated tools.
Programmatically, generateMcpDietWrapperSnippet(declarations, options?) wraps discovered stdio servers in ready-to-paste .mcp.json / .vscode/mcp.json entries routing traffic through npx -y @framy2/[email protected] --max-desc <N> --max-result-kb <KB> --redact-secrets [--read-only] -- <cmd> <args...>, skipping HTTP/SSE and already-wrapped servers while preserving env and cwd.
2. 🔄 Multi-Agent Context Audit & "Token Diet" Sync (agents & sync)
Keep Claude Code (CLAUDE.md, .claude/rules/, .claude/skills, .claude/commands, .mcp.json), OpenAI Codex (AGENTS.md, .codex/skills), and Cursor (.cursor/rules/*.mdc) 100% aligned while stripping markdown bloat (HTML comments, duplicate bullet rules, blank padding) without touching fenced code blocks. In CI, ctxwise agents --fail-on-divergence exits 1 when CLAUDE.md and AGENTS.md drift apart:
npx @framy2/ctxwise agents
npx @framy2/ctxwise agents --fail-on-divergence
npx @framy2/ctxwise sync --compress --cursor
3. 🛡️ Context Security Shield (shield)
Protect your repository before an agent reads your workspace or before a PR merges:
- Secret Exposure Detection: Catches hardcoded Anthropic (
sk-ant-...), OpenAI (sk-proj-...), GitHub (ghp_...), AWS (AKIA...), and private key blocks insideCLAUDE.md,AGENTS.md,.mcp.json, and skills. - Prompt Injection & Trojan Unicode Guard: Detects override directives (
ignore all previous instructions), covert HTML comment payloads (<!-- curl ... -->), and hidden bidirectional/zero-width Unicode characters. - Claude Settings Hygiene & SARIF 2.1.0 Output: Flags misplaced
"mcpServers"blocks inside.claude/settings.json(anthropics/claude-code#105885) and emits SARIF 2.1.0 (--sarif ctxwise.sarif) for GitHub Code Scanning. - Unpinned MCP Launchers (
unpinned-mcp-exec): Flags MCP servers that run an unpinned or@latestpackage throughnpx/uvxstyle launchers, so a compromised upstream release cannot silently enter your agent's tool surface.
npx @framy2/ctxwise shield --fail-on-risk --sarif ctxwise.sarif
4. 📦 Curated Stack Presets (preset)
Bootstrap a reviewable token budget (ctxwise.budget.yaml) and lean starter AGENTS.md + CLAUDE.md files tailored to your stack in one command:
npx @framy2/ctxwise preset
npx @framy2/ctxwise preset nextjs-typescript --with-guidance
npx @framy2/ctxwise budget --fail-on-exceed # auto-loads ./ctxwise.budget.yaml
ctxwise budget covers Claude Code, Codex, and Cursor startup files. By default (--agent all) the limit applies to the heaviest single agent session, so a synced CLAUDE.md + AGENTS.md pair is never double-counted; use --agent codex|claude|cursor to budget one agent.
Built-in presets include:
nextjs-typescript(Next.js + TypeScript + Tailwind)react-router-v7(React Router v7 + TypeScript + Vite)sveltekit/sveltekit-typescript(SvelteKit 2 + Svelte 5 Runes + TypeScript)angular-standalone(Angular 19 + Standalone Components + Signals)nestjs-prisma(NestJS + Prisma + TypeScript)python-fastapi(Python 3.12 + FastAPI + Pydantic v2)astro-content(Astro 5 + Content Layer + TypeScript)cloudflare-workers-hono(Cloudflare Workers + Hono + Wrangler)dotnet-aspnetcore(.NET 9 + ASP.NET Core + EF Core)kotlin-spring-boot(Kotlin + Spring Boot 3 + Gradle)spring-boot-java(Java 21 + Spring Boot 3 + JPA)elixir-phoenix-liveview(Elixir + Phoenix 1.8 + LiveView)laravel-inertia(Laravel 11 + Inertia.js + PHP 8.3)swift-swiftui(Swift 6 + SwiftUI + SwiftData)rust-cargo(Rust + Cargo Workspace)go-microservice(Go 1.23+ Service)mcp-server-dev(Model Context Protocol Server)monorepo-turbo(Turborepo / pnpm Monorepo)- plus
django-ninja,flutter-riverpod,rails-hotwire,react-native-expo, andterraform-aws(npx @framy2/ctxwise presetlists all 23 built-in presets).
5. 🔒 Multi-Agent Capability Lockfiles & Fail-Closed Drift Policy (lock & drift)
Lock and verify security-critical startup configs across Codex, Claude Code, Cursor, and VS Code MCP without leaking secrets:
npx @framy2/ctxwise lock --all-agents
npx @framy2/ctxwise drift --policy examples/ctxwise.drift.yaml --fail-on-drift
- Multi-Agent Protection (
ctxwise lock --all-agents): Deterministically hashes.claude/settings.json,.claude/settings.local.json,.mcp.json,.cursor/mcp.json,.vscode/mcp.json,CLAUDE.md,.claude/CLAUDE.md,.claude/rules/**/*.md, and.cursorrules. Secret-safe JSON canonicalization redactsenventries, API keys, andBearer/Basictokens before SHA-256 hashing while preservinghooks,disableAllHooks,permissions, and MCP server definitions. - Fail-Closed Drift Policy (
ctxwise drift --policy— fixes #4): Versioned YAML policies (examples/ctxwise.drift.yaml, ADR 0001) evaluate every drift event under deterministicdeny>warn>allow>unmatchedprecedence plus optionalmaxAdded,maxRemoved,maxChanged, andmaxBytesDeltabounds—blocking unreviewed.claude/settings.jsonor.mcp.jsonedits while allowing reviewed.claude/rules/**/*.mdupdates.
🤖 GitHub Action (CI Guard)
Add CtxWise to .github/workflows/ci.yml in 5 lines to automatically block secret leaks, prompt injection, and context token bloat on every Pull Request:
- name: AI Context Firewall & Token Budget Guard
uses: FramY2/ctxwise@v1
with:
max-known-tokens: "4000"
fail-on-secrets: "true"
check-agent-parity: "true"
sarif-file: "ctxwise-shield.sarif"
# Optional fail-closed drift verification:
# drift-lockfile: "ctxwise.lock.json"
# drift-policy: "examples/ctxwise.drift.yaml"
When ./ctxwise.budget.yaml exists (or budget-policy points at a policy file), the Action uses it instead of max-known-tokens. Set drift-lockfile + drift-policy to enforce fail-closed capability drift checks via ctxwise drift --policy. check-agent-parity: "true" runs ctxwise agents --fail-on-divergence, and every run appends a Markdown report (shield status, per-agent token breakdown, budget status) to the job summary.
🧩 Claude Code Plugin
CtxWise ships a native Claude Code plugin manifest (.claude-plugin/plugin.json + .claude-plugin/marketplace.json) that installs the ctxwise skill:
/plugin marketplace add FramY2/ctxwise
/plugin install ctxwise@ctxwise
🧩 Companion Tools / Ecosystem
- FramY2/mcp-diet (
@framy2/mcp-dietv0.2.0): Zero-dependency stdio MCP proxy & runtime firewall — deterministictools/listtree-shaking (--allow,--deny,--read-only,--max-desc), oversizedtools/callcrash guard (--max-result-kbforanthropics/claude-code#105703), and live credential redaction (--redact-secrets). - FramY2/agent-wire-tap (
@framy2/agent-wire-tapv0.3.0): Zero-cost local loopback HTTP interceptor & CI contract tester for coding agents (codex,claude) — captures exact outbound wire payloads and verifies tool sorting, cache-breakpoint coverage, and prefix-stability contracts (--passthrough --assert-tools-sorted --assert-cache-breakpoint-covers-tools --assert-no-prefix-divergence) with $0.00 API cost. - Interactive Context & MCP Token Tax Calculator: 100% client-side web app with Browser Shield (detecting unpinned
npx -ylaunchers and inlineAuthorization/Bearer/x-api-keyheader secrets) plus a 1-click Auto-Fix panel generating wrapped.mcp.json/.vscode/mcp.json(@framy2/[email protected]) configs and[email protected]CI commands. Accepts.mcp.jsonand.vscode/mcp.json. - ctxwise-vscode (editors/vscode): Lightweight VS Code & Cursor status-bar extension displaying live workspace token tax, Context Grade (
A–F), Codex32 KiBcap percentage, and secret alerts.
🎥 20-Second Live Demo & Benchmarks
The public microbenchmark ran 10 paired tasks across requested GPT-5.6 Luna, Terra, and Sol profiles: 20/20 answers passed the same exact validator. Removing irrelevant discovered context reduced the estimated model-visible prompt by 73.3% and exact aggregate turn tokens by 29.1% (with a second maintainer repeat measuring 28.5% across nine comparable pairs).
Read the method and limitations or inspect the machine-readable summary.
🧰 Full CLI Reference
| Command | What it does | Network / Model Call |
|---|---|---|
ctxwise agents |
Audits startup tokens and parity across Claude Code, OpenAI Codex, and Cursor | None |
ctxwise sync |
Synchronizes AGENTS.md ↔ CLAUDE.md ↔ .cursor/rules with optional --compress Token Diet |
None |
ctxwise codex-doctor |
Audits AGENTS.override.md / AGENTS.md hierarchy against Codex's 32 KiB truncation limit |
None |
ctxwise mcp-xray |
Profiles MCP server tool-schema token weights and flags bloated tools for tree-shaking | None (or local stdio probe) |
ctxwise mcp-prune |
Disables bloated or unused MCP servers in .mcp.json / .codex/config.toml with .bak save |
None (or local stdio probe) |
ctxwise shield |
Scans agent context files & skills for leaked API keys, prompt injection, and hidden Unicode | None |
ctxwise preset |
Lists or applies curated stack budgets and AGENTS.md / CLAUDE.md templates |
None |
ctxwise snapshot |
Ranks known Codex context contributors, coverage gaps, and safe next actions | None |
ctxwise budget |
Checks Claude Code / Codex / Cursor startup context against CLI or YAML limits (auto-loads ctxwise.budget.yaml); exits 2 in CI |
None |
ctxwise audit |
Inventories config plus active root-to-CWD guidance, skills, plugins, agents, and MCPs | None |
ctxwise map |
Renders a bounded Mermaid map of context sources and discovery overhead | None |
ctxwise xray |
Summarizes model-visible prompt JSON without echoing its text | None |
ctxwise profile |
Compiles YAML into native ~/.codex/<name>.config.toml, with dry-run and backups |
None |
ctxwise lock |
Hashes a redacted capability surface (ctxwise.lock.json), with --all-agents for .claude/settings.json, .mcp.json, and rules protection |
None |
ctxwise drift |
Compares a capability lock with a file or live setup; supports --all-agents and fail-closed YAML rules (--policy, --fail-on-drift) |
None |
ctxwise quota |
Reads the current plan and quota window through local Codex app-server | Codex account read only |
ctxwise receipt |
Calculates an honest receipt from saved codex exec --json usage |
None |
ctxwise run |
Runs Codex and appends exact usage plus an optional pre-turn prompt X-Ray | Requested Codex turn |
New to profiles? Follow the lean-profile walkthrough: it turns a real audit finding into a reviewable lean profile, end to end.
🤝 Contribute a Stack Preset in 5 Minutes
Want to make your first open-source contribution to an AI developer tool? Adding a new stack preset in presets/ takes less than 5 minutes (just 1 YAML file, validated automatically by npm test):
- 🟢 Issue #61 — Add
nuxt-vuepreset (Nuxt 3 + Vue 3 + TypeScript) - 🟢 Issue #69 — Add
android-composepreset (Kotlin + Jetpack Compose + Hilt) - 🟢 Issue #71 — Add
tauri-rustpreset (Tauri v2 + Rust + TypeScript) - 📋 Browse all open `good first issue` presets or propose your own stack!
See CONTRIBUTING.md for the 3-step guide!
Cost Honesty by Design
| Authentication | Default display | Dollar meaning |
|---|---|---|
| OpenAI API key | Exact runtime tokens + dated API estimate | Estimated billable API charge |
| ChatGPT Plus/Pro/Business | Tokens + credit equivalent + quota snapshot | No dollar amount |
Subscription with --api-equivalent |
Same data + API comparison | Comparison only; not charged |
See Architecture, Cost semantics, and Privacy and security.
License
Apache-2.0. See LICENSE and NOTICE.
If CtxWise saved you tokens or caught a bloated MCP schema, please give the repo a ⭐ Star on GitHub!
⭐ Star FramY2/ctxwise on GitHub
Установить Ctxwise в Claude Desktop, Claude Code, Cursor
unyly install ctxwiseСтавит в Claude Desktop, Claude Code, Cursor и VS Code — сам разбирается с npx, uvx и сборкой из исходников.
Впервые? Поставь CLI: curl -fsSL https://unyly.org/install | sh
Или настроить вручную
Выполни в терминале:
claude mcp add ctxwise -- npx -y @framy2/ctxwiseПошаговые гайды: как установить Ctxwise
FAQ
Ctxwise MCP бесплатный?
Да, Ctxwise MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Ctxwise?
Нет, Ctxwise работает без API-ключей и переменных окружения.
Ctxwise — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Ctxwise в Claude Desktop, Claude Code или Cursor?
Открой Ctxwise на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Изменения
Версии и запрашиваемые доступы со временем.
- Новая версия опубликована
Похожие MCP
GitHub
PRs, issues, code search, CI status
автор: GitHubFilesystem
Secure file operations with configurable access controls.
Memory
Knowledge graph-based persistent memory system.
Unyly Deploy
Deploy sites and MCP servers to Unyly straight from your AI agent
автор: UnylyTemplate MCP Server
A CLI tool to create a new Model Context Protocol server project with TypeScript support, dual transport options, and an extensible structure
автор: mcpdotdirectServer Sequential Thinking
MCP server for sequential thinking and problem solving
автор: GitHub ActionsAmap Maps Mcp Server
MCP server for using the AMap Maps API
автор: duxiaohuiPayMCP
Lightweight payments layer for MCP servers: turn tools into paid endpoints with a two-line decorator. [PyPI](https://pypi.org/project/paymcp/) · [npm](https://w
автор: blustAIdemo
demo — MCP server via Smithery
автор: yoojoohans-jpgServer For Power BI
Enables exploring Microsoft Fabric / Power BI workspaces and semantic models, and executing ad-hoc DAX queries.
автор: Mitsubishi-FusoCompare Ctxwise with
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории development
