v2.x
Documentation

Claude Code Companion

C3 is a local intelligence layer for Claude Code โ€” adding token-efficient code search, structural file reading, persistent memory, session management, and multi-model delegation directly into your AI coding workflow.

๐Ÿ’ก What is C3?

C3 wraps Claude Code with a local MCP server that provides code intelligence tools unavailable in the base product. Every tool call is optimized to minimize token usage โ€” the primary cost driver in long coding sessions.

C3 provides

TF-IDF + semantic code search, structural file compression (40โ€“70% token savings), persistent cross-session memory, session snapshots, multi-model delegation, edit ledger, and agent workflows.

Without C3

Claude reads full files, loses context on /clear, has no persistent memory, and burns tokens on repetitive re-reads of large files.

โ„น๏ธ
How it works C3 runs as an MCP (Model Context Protocol) server. Claude Code connects to it via stdio. All C3 tools are available inside Claude Code sessions as c3_* tool calls. The server stores data in a hidden .c3/ directory at the project root.

๐Ÿ—๏ธ Architecture
Component Location Purpose
mcp_server.py cli/ FastMCP server โ€” exposes all c3_* tools to Claude
c3.py cli/ CLI entry point โ€” c3 init, c3 install-mcp, benchmarks
services/ project root All business logic: memory, compressor, indexer, session, agentsโ€ฆ
hub_server.py cli/ Flask REST server for the web UI (Hub)
.c3/ project root Data directory: index, sessions, memory facts, edit ledger
Hooks cli/hook_*.py PreToolUse / PostToolUse hooks enforcing c3 discipline
๐Ÿ”—
MCP vs REST The MCP server and Flask REST server run as separate processes. They share state only through the .c3/ directory on disk.

๐Ÿ—‚๏ธ Tools at a Glance
Tool Category One-liner
c3_search Search TF-IDF / semantic / file discovery across the codebase
c3_read Read Targeted symbol or line-range reads (not whole files)
c3_compress Read Structural file map โ€” 40โ€“70% token savings
c3_edit Write Read + patch + write + log in one atomic step
c3_validate Write Syntax-check files after edits
c3_filter Utility Extract signal from noisy terminal output / log files
c3_session Session Snapshot, restore, log decisions, compact context
c3_memory Memory Persistent facts across sessions (add / recall / queryโ€ฆ)
c3_status Status Budget, health, notifications, session overview
c3_delegate AI Offload tasks to Ollama / Codex / Gemini
c3_agent AI Multi-step compound workflows (review, investigateโ€ฆ)
c3_edits Ledger Edit ledger: history, versions, audit trail

โ†’ Full tools reference with parameters and examples


โšก Quick Reference

Common CLI Commands

c3 init Initialize C3 for a project (.c3/, index, CLAUDE.md)
c3 install-mcp claude Wire C3 MCP server into Claude Code
c3 install-mcp vscode Wire C3 MCP server into VS Code Copilot
c3 install-mcp codex Wire C3 MCP server into Codex
c3 benchmark Run local token efficiency benchmark
c3 hub Launch the Project Hub web dashboard
c3 ui Launch the session web UI
c3 permissions readonly Apply read-only permission tier
c3 terse [dismiss|later|reset|status] Manage the terse-advisor auto-nudge (silence, snooze 24h, or reset)

Mandatory Workflow (7 Steps)

1. c3_memory(action='recall') Recall relevant facts before any multi-step task
2. c3_search(action='code|files|semantic') Discover files / content โ€” never start with Grep/Glob
3. c3_compress(mode='map') + c3_read(symbols=โ€ฆ) Map then surgically read โ€” never start with native Read
4. c3_edit(file, old, new, summary) Atomic read-patch-write-log โ€” never use native Edit
5. c3_filter(text=โ€ฆ) Filter terminal output >10 lines or log files
6. c3_validate(file_path) Syntax-check after every edit
7. c3_session(action='log') Log decisions; snapshot before /clear

โ†’ Full workflow guide with examples and anti-patterns