Skip to main content

Local code-intelligence layer for AI coding tools (Claude Code, Codex, Gemini, Copilot). Retrieve less, read less, edit safer.

Project description

Code Context Control

The local code-intelligence layer for AI coding tools.
Stop burning tokens on whole-file reads, blind greps, and unbounded log dumps.
Works with Claude Code, Codex, Gemini CLI, Copilot, Cursor, and Antigravity.

PyPI License: Apache-2.0 Python 3.10+ Platforms Status: Beta

C3 per-project dashboard


The problem

LLM-driven coding tools have one expensive failure mode: they read too much. They cat whole files, regex the entire repo, dump 10k-line logs into context, edit-and-pray, and burn through budget before they touch a single line of code. On a half-day session you can spend $20+ on token waste that adds zero value.

What C3 does about it

A thin local layer that sits between your IDE and your repo. Every AI tool call gets routed through narrow, surgical operations instead of broad, wasteful ones:

Without C3 With C3
Read the whole 2,000-line file c3_compress returns a 70%-smaller structural map → c3_read(symbols=...) for the exact function
Grep the whole repo blindly c3_search returns ranked candidates with TF-IDF + symbol awareness
Dump full pytest output into the prompt c3_filter distills 500 lines → 30 actionable ones
Edit, hope it compiled c3_edit writes via a ledger + c3_validate runs pyright/tsc automatically
Bash test runs that hang on Windows c3_shell returns structured {exit_code, stdout, stderr, duration} with auto-filter
Lose all context on /clear c3_session(snapshot) + c3_memory persist decisions across sessions
Re-explain the project every session Auto-synced CLAUDE.md / AGENTS.md / GEMINI.md / copilot-instructions.md from a single source of truth

Everything runs locally. No source code, prompts, or model output ever leaves your machine unless you explicitly opt into a third-party model API.


Install

Requires Python 3.10+.

pip install code-context-control
c3 init /path/to/your/project

The interactive setup walks you through:

  1. IDE selection (Claude Code CLI/App, Codex CLI, Gemini CLI, VS Code, Cursor, Antigravity, or Custom)
  2. Optional local git init
  3. MCP server registration (auto-wired into your IDE)
  4. (Claude Code only) Permission tier selection

Headless / scripted install:

c3 init /path/to/project --force --ide claude --mcp-mode direct --permissions standard

Or install from source:

git clone https://github.com/drknowhow/code-context-control.git
cd code-context-control
pip install .[tui]      # add the optional Textual TUI

A tour of the UI

C3 ships with two web UIs (no electron, no install — pure Flask + vanilla JS):

  • The Hub (c3-hub, port 3330) — manage all your C3 projects from one dashboard.
  • The per-project UI (c3 ui, per-project port) — deep dive into one project's session, memory, edits, instructions, and settings.

1. Project Hub — multi-project mission control

C3 Project Hub - all projects

Every C3-initialized project on your machine appears here automatically — c3 init registers the project with the hub on first run, no extra step. Group them by tag, filter by active/idle, see which IDE each project uses, jump straight into your IDE with one click, and monitor session activity at a glance. Each project card shows live status, version, MCP wiring mode, port, and last activity.

Per-card actions cover the full lifecycle: launch the IDE, open the per-project UI, edit name / tags / notes, transfer the registration to a new path, merge another project's memory + conversation history + edit ledger into this one (with optional source cleanup), or remove it from the registry.

Open in your IDE of choice — C3 auto-detects which CLIs you have installed and gives you one-click launchers:

C3 Hub IDE picker

Hub runs as a background Windows service if you want it to (no terminal, auto-starts on login):

C3 Hub settings

2. Per-project dashboard — at-a-glance health

c3 ui                             # opens http://127.0.0.1:3333

C3 per-project dashboard

Real metrics from a real project: 448K tokens saved (89.9% rate), 208 files indexed, 20 sessions, codebase breakdown by language, current-session live counters (in/out tokens, cache reads, services online), and a stream of recent tool calls and file changes.

3. Edit Ledger — every AI-driven edit tracked

C3 Edit Ledger

A complete audit trail of every file change made via c3_edit (or via Bash git commands intercepted by the C3 shell). Each entry shows timestamp, file, version number, change summary, and +/- line counts. Filter by file path, switch to Stats view for aggregate trends. Backed by a content-addressable store so any prior version is one click away.

4. Memory — durable knowledge across sessions

C3 Memory

A categorized store of facts the AI has learned about your project (architecture decisions, conventions, gotchas, references). Categories, full-text + semantic search, decision tracking, list ↔ graph toggle, and one-click Markdown export. Backed by TF-IDF + optional Ollama embeddings + chromadb (when the [vector] extra is installed).

5. Sessions — history, decisions, costs

C3 Sessions

Every session you've ever run, with duration, decision count, file count, tool calls, token usage, and cost. Captured automatically via the IDE's Stop hook — nothing to remember to click. Click any row to see the full task list, decisions, and file diffs from that session.

6. Instructions — sync your project context across IDEs

C3 Instructions

Manage CLAUDE.md, AGENTS.md (Codex), GEMINI.md, and .github/copilot-instructions.md from one editor. Generate from project state, run a Health Check (drift detection vs the actual codebase), Compact stale sections, or Promote insights captured during sessions. One source of truth instead of four out-of-sync files.

7. Chat — browse prior AI conversations

C3 Chat

C3 syncs and indexes your IDE's chat transcripts (currently Claude Code; others coming). Filter by source, search, click a row to view the full conversation. Useful for "wait, what did we decide about X last week?".

8. Settings — feature flags + integrations

C3 Settings

Per-project knobs for everything: budget thresholds, feature flag mode, edit ledger, background agents, delegate routing, Codex/Gemini integrations, agent workflows, proxy mode, MCP servers, Claude Code permission tier, and more.


The MCP tool suite

C3 exposes 15 tools as a native MCP server. Your IDE calls them directly:

Tool What it does
c3_search TF-IDF / regex / semantic search ranked across the indexed repo
c3_compress AST-based file map (modes: map, dense_map, smart, diff, bug_scan, ast)
c3_read Surgical reads — by symbol name, regex, or line ranges
c3_edit Atomic patch with automatic ledger logging + content-addressable history
c3_validate Type / syntax check (pyright, tsc, ruff, etc. — auto-detected)
c3_filter Distill long terminal/log output via pattern + LLM summarization
c3_shell Run shell commands with structured returns + auto-filtered stdout
c3_status Project health, token budget, notifications, ghost-file detection
c3_memory Persistent fact store with categories, recall, and graph queries
c3_session Snapshot, restore, log decisions, compact session history
c3_impact Blast-radius analysis before edits to shared symbols
c3_delegate Offload heavy work to local Ollama / Codex / Gemini / etc.
c3_agent Multi-step agentic workflows (review, investigate, refactor)
c3_edits Edit-ledger queries + version diffs + restore points
c3_bitbucket Bitbucket Data Center integration — PRs, branches, builds, repo admin (v2.30.0)

Every tool is read-only safe in plan mode (except c3_edit, c3_shell, and write actions on c3_bitbucket).

Bitbucket Data Center / Server (v2.30.0)

c3_bitbucket connects to self-hosted enterprise Bitbucket via REST + Personal Access Token. Tokens live in the OS keyring (Windows Credential Manager, macOS Keychain, Linux Secret Service) — never in .c3/config.json.

# One-time login per server
c3 bitbucket login --url https://bitbucket.example.com
#  → prompts for username + PAT (masked)

# Pin defaults so subsequent calls don't need project/repo
c3 bitbucket set-default --project PROJ --repo my-service

# Inspect status
c3 bitbucket status

The MCP tool dispatches by action. Read-only actions: status, whoami, list_projects, list_repos, get_repo, list_prs, get_pr, get_pr_diff, get_pr_activities, list_branches, list_commits, list_activity, build_status, repo_settings, list_webhooks, list_permissions. Write actions: create_pr, comment_pr, approve_pr, unapprove_pr, decline_pr, merge_pr, create_branch, delete_branch, update_repo_settings, create_webhook, delete_webhook. PR merges and branch deletes are recorded to the C3 edit ledger so the audit trail covers platform-side changes too.

The Hub UI (per-project) gains a "Bitbucket" tab with sub-views for Overview / Pull Requests / Branches / Activity / Admin.


Tiered local AI (optional)

C3 ships with optional Ollama integration so the primary model doesn't have to waste context on grunt work:

Tier Model class Used for Latency target
Nano qwen2:0.5b Intent routing, classification <100 ms
Micro deepseek-r1:1.5b Last-turn Q&A, summarization <1 s
Base llama3.2:3b+ Code analysis, technical reasoning <5 s
c3_delegate(task="summarize this 4k-line stacktrace", backend="ollama")
c3_delegate(task="rate-limit refactor", backend="auto")    # picks the right tier

Ollama is fully optional. C3 works without it.


Permissions (Claude Code)

C3 manages .claude/settings.local.json for you, with three sensible tiers:

Tier What it allows
read-only Exploration only — no file writes, no git writes, no installs
standard Normal dev workflow — edit, build, test, local git (recommended)
permissive Full trust — everything except destructive ops

All tiers always allow C3 MCP tools and include a hard deny list (rm -rf, sudo, git push --force, etc.).

c3 permissions show
c3 permissions standard

Benchmarks

c3 benchmark /path/to/project
c3 bench aider                    # Aider Polyglot suite
c3 bench swe                      # SWE-bench Lite

Real-world A/B tests: same task, with and without C3 mounted. Reports include token deltas, cost deltas, win rates, tool-usage analysis, and per-task breakdowns. See the Benchmark Dashboard under Settings → Background Agents in the Hub.


Security & privacy

  • Hub binds to 127.0.0.1 by default. Setting host to a non-loopback interface in ~/.c3/hub_config.json is opt-in and warned at startup. Do not expose the Hub to a public network without auth/TLS in front of it.
  • No telemetry by default. The OSS package collects nothing. Opt-in Sentry crash reporting requires the [telemetry] extra plus both SENTRY_DSN and C3_TELEMETRY_OPT_IN=1. Even when enabled, request bodies, local variables, and prompts are stripped before sending.
  • API keys for third-party model providers are read from environment variables and never persisted by C3.
  • See SECURITY.md for the full hardening guide and disclosure policy.

License

  • Current OSS license — Apache License 2.0 (LICENSE). Free for any use, including commercial. Modify, fork, redistribute — all permitted under Apache-2.0 terms.
  • Third-party deps — see THIRD_PARTY_LICENSES.md.

The author may introduce a paid offering or relicense future major versions; no commitment either way. Releases already published under Apache-2.0 (including all 2.x versions) keep their Apache-2.0 grant — that grant is irrevocable. Background and FAQ in LICENSING.md. No warranty or support obligation; see LICENSE Sections 7–8.


Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_context_control-2.30.0.tar.gz (813.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

code_context_control-2.30.0-py3-none-any.whl (846.6 kB view details)

Uploaded Python 3

File details

Details for the file code_context_control-2.30.0.tar.gz.

File metadata

  • Download URL: code_context_control-2.30.0.tar.gz
  • Upload date:
  • Size: 813.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code_context_control-2.30.0.tar.gz
Algorithm Hash digest
SHA256 dc5e12f107c08c5d79fe6a5dfefe6c89c24c0551543c0b861361893af237097a
MD5 7209ee8e0cc50a950293d36786ede091
BLAKE2b-256 ca952deb97c460dd558d4382e6972e7cf1425302a89debd7f9e03be757ad45ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_context_control-2.30.0.tar.gz:

Publisher: release.yml on drknowhow/code-context-control

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file code_context_control-2.30.0-py3-none-any.whl.

File metadata

File hashes

Hashes for code_context_control-2.30.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01f3065c0d2a303ca062979d1f2d3f802925d5132cdedfd8eb30e8555448587a
MD5 14275d019857117a1a94b870b3bea097
BLAKE2b-256 d097af3824fabb9b4ae2f17f7ae373ffe841ce1e058ad1dd143af2722f0ceb52

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_context_control-2.30.0-py3-none-any.whl:

Publisher: release.yml on drknowhow/code-context-control

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page