Skip to main content

Codetrace-ai Banner

PyPI Version Total Downloads Monthly Downloads MIT License GitHub Stars Open Issues Open Pull Requests Build Status Join Slack PRs Welcome

๐Ÿง  CodeTrace AI

Give your AI coding agent X-ray vision into your codebase โ€” call graphs, blast radius, and architecture maps, 100% local.

CodeTrace AI gives your AI coding agent a complete map of your codebase โ€” blast radius, call graphs, architecture boundaries โ€” served 100% locally, zero cloud.
Website ยท PyPI ยท Blog Post


๐ŸŽฅ See it in Action

Watch Demo


๐Ÿ’ก Why CodeTrace AI?

AI coding agents are powerful โ€” but they break things because they don't understand blast radius. They edit a function without knowing it's called by 12 other modules. They suggest refactors without seeing how execution flows through the entire system.

CodeTrace maps your entire codebase locally so your AI agent stops guessing and starts understanding โ€” before it edits.

  • No cloud. All parsing, embedding, and graph mapping runs on your machine.
  • No guessing. The agent sees real call graphs, not just keyword matches.
  • No surprises. Blast radius analysis shows exactly what breaks before you change it.

๐Ÿš€ Installation

Requires Python 3.10โ€“3.12

pip install codetrace-ai
uv pip install codetrace-ai

[!NOTE] Python 3.14 may have compatibility issues with some dependencies. Python 3.10โ€“3.12 is recommended for the best experience. GPU users should ensure CUDA is installed.


โšก Quick Start

cd /path/to/your/project
codetrace init       # configure LLM + download models + index + register MCP
codetrace chat       # start the AI Architect session

codetrace init does everything in one command: configures your LLM provider, downloads embedding models, indexes your codebase, and registers the MCP server for Cursor and Claude Code.


โœจ Features

Feature Description
๐Ÿ” Autonomous Code Research Ask anything in natural language โ€” the agent searches, reads files, and traverses the call graph to answer with citations to exact lines
๐Ÿ—บ๏ธ Interactive Architecture Map codetrace visualize generates a self-contained interactive HTML graph of your entire code architecture
๐Ÿ“Š Structural Call Graph Maps class and function definitions across 15+ languages โ€” see exactly how your application is wired
๐Ÿ’ฅ Blast Radius Analysis Before editing production code, see every file, test, and consumer that will be impacted
โœ๏ธ Human-in-the-Loop Edits Proposes code changes with a rich diff preview โ€” you approve or decline before anything is written to disk
โšก SHA-256 Delta Sync Re-indexes only files that changed. Lightning fast on every subsequent run
๐Ÿ”Œ IDE Integration (MCP) Connects the call graph directly into Cursor, Windsurf, or Claude Code for in-editor AI assistance
๐Ÿ“œ Persistent Chat Sessions All conversations are saved. Resume any past session by ID, or export to Markdown
๐Ÿ”’ 100% Local & Air-Gapped All parsing, embedding, and graph mapping happens on your machine. Zero data leaves without your consent

๐Ÿ”’ Privacy-First Architecture

Codetrace can operate 100% offline with zero external dependencies:

  1. Local LLM: Configure any local provider via Ollama (e.g., llama3.2, deepseek-coder, qwen2.5-coder).
  2. Local Embeddings: Uses HuggingFace bge-small + e5-small models, downloaded once and cached.
  3. True Air-Gap: Transfer the HuggingFace cache (~/.cache/huggingface/hub) via USB. Run codetrace init --offline to block all external calls permanently.

[!WARNING] Ollama Users โ€” Context Window & RAM The effective context window is directly limited by your available RAM. If the model's context exceeds available RAM, Ollama may hang or crash silently.

Recommendations:

  • 8 GB RAM: qwen2.5-coder:7b ยท deepseek-r1:7b ยท phi4-mini
  • 16 GB RAM: qwen2.5-coder:14b ยท deepseek-r1:14b ยท gemma3:12b (recommended sweet spot)
  • 32 GB+ RAM: qwen2.5-coder:32b ยท deepseek-r1:32b ยท devstral:24b (near frontier-level locally)

If Codetrace hangs during chat while using Ollama, the most likely cause is the model running out of RAM. Switch to a smaller model with codetrace config.


๐Ÿ› ๏ธ CLI Command Reference

Command Description
codetrace init [PATH] One-command setup: config โ†’ download models โ†’ index โ†’ register MCP
codetrace chat Launch the interactive AI Architect chat loop
codetrace chat --resume <ID> Resume a specific past chat session
codetrace index <PATH or URL> Re-index a local directory or clone + index a GitHub URL
codetrace config View or update your LLM provider and API key
codetrace visualize Generate an interactive HTML architecture graph
codetrace history List all past chat sessions for the current project
codetrace export <ID> Export a chat session to Markdown

Flags:

  • --offline โ€” Strict air-gapped mode (blocks all external requests)
  • --fast โ€” Use smaller embedding models for lower RAM usage
  • --llm <provider> โ€” Pre-select provider: groq, openai, anthropic, gemini, ollama

In-chat commands:

  • /clear โ€” Start a fresh session without exiting
  • exit / quit โ€” Close the chat

๐Ÿค– Agentic Tool Suite

The AI has access to 7 specialized tools it invokes autonomously:

Tool What it does
search_codebase Hybrid semantic search (BGE + E5 + RRF + FlashRank reranker)
get_symbol_relations Graph traversal โ€” see callers and dependencies of any symbol
analyze_impact Blast radius โ€” find every downstream symbol affected by a change
read_file Read full file content from the indexed DB snapshot
write_file Propose a code change with a diff preview for your approval
inspect_index List all indexed files and DB coverage metadata
git_diff Run a safe, injection-protected git diff

๐Ÿ”Œ IDE Integration (MCP)

codetrace init automatically registers the MCP server in Cursor and Claude Code. No manual configuration needed.

Your IDE instantly gains access to all 7 tools above for in-editor AI assistance.

Using Windsurf? Add it manually to your mcp.json:

"codetrace": {
  "command": "python",
  "args": [
    "/absolute/path/to/your/project/codetrace_mcp/server.py",
    "--project",
    "/absolute/path/to/your/project"
  ]
}

๐Ÿ“‚ File Structure

After codetrace init, your project will have:

your-project/
โ”œโ”€โ”€ .codetrace/
โ”‚   โ”œโ”€โ”€ chroma/                โ† vector embeddings (ChromaDB)
โ”‚   โ”œโ”€โ”€ graph_metadata.db      โ† code call graph (SQLite + NetworkX)
โ”‚   โ”œโ”€โ”€ sync_metadata.db       โ† SHA-256 delta sync state
โ”‚   โ”œโ”€โ”€ chat_history.db        โ† persistent chat sessions
โ”‚   โ””โ”€โ”€ graph_visualization.html  โ† generated by `codetrace visualize`
โ”œโ”€โ”€ src/
โ””โ”€โ”€ your code files

Global config is stored at ~/.codetrace/config.json


๐Ÿ†• Changelog

v1.0.2 โ€” July 2026

  • โœ… FIXED: PyPI packaging bug โ€” 4 missing __init__.py files caused src/cli, src/backend, src/core/agents, and src/core/database to be silently excluded from the wheel, making the installed package non-functional
  • โœ… FIXED: Tree-sitter .scm query files were not included in the PyPI wheel, causing parser failures on a fresh install
  • โœ… NEW: Dynamic model context window resolution via litellm โ€” the token budget manager now auto-detects the correct context window for any model at runtime, eliminating the need for a hardcoded tier registry
  • โœ… NEW: Ollama context window detection โ€” queries the local Ollama API to get the actual loaded context size for your model
  • โœ… IMPROVED: Token counting now uses litellm.token_counter with provider-specific tokenizers for accurate budgeting across all models
  • โœ… IMPROVED: Context compression is now dynamic โ€” automatically reduces keep_turns if a compressed history still exceeds the hard context limit, preventing OOM errors

v1.0.1 โ€” June 2026

  • โœ… NEW: Interactive Architecture Visualizer (codetrace visualize) with collapsible tree, hover panels, search, and cross-folder call edges
  • โœ… NEW: Expanded language support โ€” C#, Swift, Kotlin, Bash, HTML, JSON, CSS, YAML, SQL, TOML, Dockerfile (15+ languages total)
  • โœ… NEW: Token Budget Manager โ€” 3-tier context window management with auto-history compression
  • โœ… NEW: Multi-provider Agent Loop via pure httpx (zero LangChain dependency)
  • โœ… NEW: Live model listing during codetrace config โ€” fetches available models from your provider's API
  • โœ… IMPROVED: Parallel file parsing with ThreadPoolExecutor for significantly faster indexing
  • โœ… IMPROVED: Path traversal protection on read_file and write_file tools

v0.1.2 โ€” Initial Release

  • Initial public release with Hybrid Brain engine (BGE + E5 + ChromaDB + NetworkX)
  • Core agentic tool suite (search_codebase, analyze_impact, write_file, git_diff)
  • MCP auto-registration for Cursor and Claude Code
  • SHA-256 Smart Delta Sync
  • GitHub URL cloning + indexing support
  • Persistent chat sessions with history and export

๐Ÿค Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

๐Ÿ’ฌ Help shape Codetrace: Join the discussion โ†’


๐Ÿ“„ License

MIT License โ€” Copyright (c) 2026 Viraaj Sawant. See LICENSE for details.

Download files

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

Source Distribution

codetrace_ai-1.0.2.tar.gz (94.1 kB view details)

Uploaded Source

Built Distribution

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

codetrace_ai-1.0.2-py3-none-any.whl (106.3 kB view details)

Uploaded Python 3

File details

Details for the file codetrace_ai-1.0.2.tar.gz.

File metadata

  • Download URL: codetrace_ai-1.0.2.tar.gz
  • Upload date:
  • Size: 94.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for codetrace_ai-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c9556ff112b00b6d0929ba84d8e56759a8e738fb374b4539e26de654fea4c12e
MD5 5413669aba0cc7b042c511b0f2c05e4a
BLAKE2b-256 ac1c682a03033fd6723152d39ab83193e8c10058abda0034eeec7047f691c04e

See more details on using hashes here.

File details

Details for the file codetrace_ai-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: codetrace_ai-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 106.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for codetrace_ai-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 465a5c60ea62eff7d0bde535db6203cc2ef8858938a5053c6c3ce0ecc6db2614
MD5 d5a06295bf0ecbcff39f045a62238b23
BLAKE2b-256 04a2ef30d034e4feb56c4b8d42b86a08d443056d96fc649d89940f9c49b6213b

See more details on using hashes here.

Supported by

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