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 (C3)

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, and VS Code Copilot.

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

C3 web dashboard


Why C3?

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, and burn through budget before they touch a single line of code.

C3 is a thin, local layer that sits between your IDE and your repo and forces the model to read like a senior engineer:

Without C3 With C3
Read whole 2k-line file c3_compress → 70% smaller map, then 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 context on /clear c3_session(snapshot) + c3_memory persist decisions across sessions

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


Install

Requires Python 3.10+.

# Clone and install
git clone https://github.com/drknowhow/code-context-control.git
cd code-context-control
pip install .

# Initialize a project (interactive)
c3 init /path/to/your/project

This walks you through:

  1. IDE selection (Claude Code / Codex / Gemini / VS Code).
  2. Optional local git init.
  3. MCP server registration.
  4. (Claude Code only) Permission tier selection.

Headless / scripted install:

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

What you get

Surgical reads

c3_compress(file_path="services/router.py", mode="map")    # structural outline (~30% tokens)
c3_read(file_path="services/router.py", symbols=["ModelRouter._classify_features"])

Ranked search

c3_search(query="prompt cache hit rate", action="code", top_k=5)

Safer edits + automatic validation

c3_edit(file_path=..., old_string=..., new_string=..., summary="fix off-by-one")
c3_validate(file_path=...)        # pyright/tsc if installed; syntax check otherwise

Distilled output

c3_filter(text=pytest_output)     # 500 lines → 30 actionable
c3_shell(cmd="pytest -x")          # structured, auto-filtered

Persistent memory

c3_memory(action="recall", query="why did we switch to direct MCP mode")
c3_session(action="snapshot")     # before /clear

A web dashboard for everything you've done

C3 Project Hub

c3-hub                            # http://127.0.0.1:3330

The Hub gives you per-project edit ledgers, session history, memory graphs, benchmark dashboards, and IDE/MCP profile management.

C3 Notifications C3 IDE config


Tiered local AI (optional)

C3 ships with optional Ollama integration for offload work the primary model shouldn't waste context on:

Tier Model class Used for
Nano qwen2:0.5b Sub-100 ms intent routing
Micro deepseek-r1:1.5b Last-turn Q&A, summarization
Base llama3.2:3b+ Code analysis, technical reasoning
c3_delegate(task="summarize this 4k-line stacktrace", backend="ollama")

Ollama is optional. C3 works fine without it.


Permissions (Claude Code only)

C3 can manage Claude Code permission tiers via .claude/settings.local.json:

Tier What it allows
read-only Exploration — 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 deny list that blocks rm -rf, sudo, git push --force, etc.

c3 permissions show
c3 permissions standard

Benchmarks

c3 benchmark /path/to/project

Runs C3 against open task suites (Aider Polyglot, SWE-bench Lite) with local-Ollama delegate measurement included.


Security & Privacy

C3 runs locally. The Hub binds to 127.0.0.1 by default. Do not expose the Hub to a public network without putting auth/TLS in front of it.

No telemetry by default. Opt-in Sentry crash reporting is available via the [telemetry] extra and requires both SENTRY_DSN (your project) and C3_TELEMETRY_OPT_IN=1 to activate. Even when enabled, request bodies, local variables, and prompts are stripped before sending.

See SECURITY.md for vulnerability reports, the full hardening guide, and the telemetry scrubbing details.


License & project posture

  • Current OSS license — Apache License 2.0 (LICENSE). Free for any use, including commercial. Modify, fork, redistribute — all permitted.
  • Pro tier (planned, not yet shipped) — license-key activation will gate new additive features. Existing OSS features stay free. See EULA-PRO.md.
  • Future major versions may relicense to a source-available license (e.g. BSL 1.1 with a 4-year Apache-2.0 conversion) to protect commercialization. Already-published 2.x versions stay Apache-2.0 forever.
  • Trademarks — "C3" and "Code Context Control" are trademarks (™) of Dimitri Tselenchuk. Forks must use a distinct name. See NOTICE.
  • Third-party deps — see THIRD_PARTY_LICENSES.md.

Building on C3 commercially? Please email dtselenc@gmail.com first. Apache-2.0 grants broad rights to the published 2.x code, but as a courtesy we ask the community not to repackage C3 as a commercial competing product. Full FAQ: LICENSING.md.


Links

  • Changelog: CHANGELOG.md
  • Security policy: SECURITY.md
  • Issues / questions: open a GitHub issue or email dtselenc@gmail.com

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.28.1.tar.gz (776.2 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.28.1-py3-none-any.whl (817.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: code_context_control-2.28.1.tar.gz
  • Upload date:
  • Size: 776.2 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.28.1.tar.gz
Algorithm Hash digest
SHA256 e9159fd703f0d40b9af26a66138a2dc89b11fac6b5cdfe899d3596694dc9fa3f
MD5 0561f10fd78c2e9933391db23117b434
BLAKE2b-256 b1a6d03dfe39e1fd8a6e70269cc3cb1268e8b6c62418d39d637a917a6d2a6953

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_context_control-2.28.1.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.28.1-py3-none-any.whl.

File metadata

File hashes

Hashes for code_context_control-2.28.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbe5c1b2c8d82d700de81fb0d384ddbac9f30a6ed1b1ce94489bf56cb5fc3ce1
MD5 ab0ce0a8ba8518c7d8da5c859fc9379a
BLAKE2b-256 e9781fa9fea8c914679fcdf5a08c6c67885a8258b9252b9a880c3ddd61c8f35a

See more details on using hashes here.

Provenance

The following attestation bundles were made for code_context_control-2.28.1-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