CodeCortex

مجتمعي أدوات المطورين

Persistent codebase knowledge for coding agents: symbols, dependency graphs, co-change patterns and architectural decisions extracted with tree-sitter.

التثبيت

خطوات التثبيت موجودة في التوثيق أدناه. التوثيق

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. CodeCortex
  2. The Problem
  3. The Solution
  4. Quick Start
  5. What Gets Generated
  6. Six Knowledge Layers
  7. MCP Tools (5)
  8. CLI Commands
  9. How It Works
  10. Supported Languages (27)
  11. Tech Stack
  12. License

CodeCortex

Persistent codebase knowledge layer for AI agents. Pre-builds architecture, dependencies, coupling, and risk knowledge so agents skip the cold start and go straight to the right files.

Website · npm · GitHub

The Problem

Every AI coding session starts with exploration — grepping, reading wrong files, re-discovering architecture. On a 6,000-file codebase, an agent makes 37 tool calls and burns 79K tokens just to understand what's where. And it still can't tell you which files are dangerous to edit or which files secretly depend on each other.

The data backs this up:

The Solution

CodeCortex eliminates the cold start. It pre-builds codebase knowledge — architecture, dependencies, risk areas, hidden coupling — and injects it directly into your agent's context (CLAUDE.md, .cursorrules, etc.) so agents have project knowledge from the first prompt.

Not a middleware. Not a proxy. Just knowledge your agent loads on day one.

Tested on a real 6,400-file codebase (143K symbols, 96 modules):

Without CodeCortexWith CodeCortex
Tool calls3715 (2.5x fewer)
Total tokens79K43K (~50% fewer)
Answer quality23/2523/25 (same)
Hidden dependencies foundNoYes
What makes it unique

Three capabilities no other tool provides:

  1. Temporal coupling — Files that always change together but have zero imports between them. You can read every line and never discover this. Only git co-change analysis reveals it.
  2. Risk scores — File X has been bug-fixed 7 times, has 6 hidden dependencies, and co-changes with 3 other files. Risk score: 35. You can't learn this from reading code.
  3. Inline context injection — Project knowledge is injected directly into CLAUDE.md, .cursorrules, and other agent config files with architecture, risk map, and editing directives. Agents use it without any setup.

Example from a real codebase:

  • schema.help.ts and schema.labels.ts co-changed in 12/14 commits (86%) with zero imports between them
  • Without this knowledge, an AI editing one file would produce a bug 86% of the time

Quick Start

Requires Node 20 or 22. Node 24 is not yet supported (tree-sitter native bindings need an upstream update).

# Install (--legacy-peer-deps needed for tree-sitter peer dep mismatches)
npm install -g codecortex-ai --legacy-peer-deps

# Initialize knowledge for your project
cd /path/to/your-project
codecortex init

# Regenerate inline context in CLAUDE.md and agent config files
codecortex inject
Connect to Claude Code

CLI (recommended):

claude mcp add codecortex -- codecortex serve

Or add to MCP config manually:

{
  "mcpServers": {
    "codecortex": {
      "command": "codecortex",
      "args": ["serve"],
      "cwd": "/path/to/your-project"
    }
  }
}
Connect to Cursor

Add to .cursor/mcp.json:

{
  "mcpServers": {
    "codecortex": {
      "command": "codecortex",
      "args": ["serve"],
      "cwd": "/path/to/your-project"
    }
  }
}

What Gets Generated

All knowledge lives in .codecortex/ as flat files in your repo, plus inline context is injected into agent config files:

.codecortex/
  cortex.yaml          # project manifest
  constitution.md      # project overview for agents
  overview.md          # module map + entry points
  graph.json           # dependency graph (imports, calls, modules)
  symbols.json         # full symbol index (functions, classes, types...)
  temporal.json        # git coupling, hotspots, bug history
  hotspots.md          # risk-ranked files (static, always available)
  AGENT.md             # tool usage guide for AI agents
  modules/*.md         # per-module structural analysis
  decisions/*.md       # architectural decision records
  sessions/*.md        # session change logs
  patterns.md          # coding patterns and conventions

CLAUDE.md              # ← inline context injected here
.cursorrules           # ← and here (if exists)
.windsurfrules         # ← and here (if exists)

Six Knowledge Layers

LayerWhatFile
1. StructuralModules, deps, symbols, entry pointsgraph.json + symbols.json
2. SemanticWhat each module does, data flow, gotchasmodules/*.md
3. TemporalGit behavioral fingerprint — coupling, hotspots, bug historytemporal.json
4. DecisionsWhy things are built this waydecisions/*.md
5. PatternsHow code is written herepatterns.md
6. SessionsWhat changed between sessionssessions/*.md

MCP Tools (5)

Five focused tools that provide capabilities agents can't get from reading code:

ToolDescription
get_project_overviewArchitecture, modules, risk map. Call this first.
get_dependency_graphImport/export graph filtered by module or file.
lookup_symbolPrecise symbol lookup with kind and file path filters.
get_change_couplingFiles that must change together. Hidden dependencies flagged.
get_edit_briefingPre-edit risk: co-change warnings, hidden deps, bug history. Always call before editing.
MCP Resources (3)

Static knowledge available without tool calls:

ResourceDescription
codecortex://project/overviewFull project constitution
codecortex://project/hotspotsRisk-ranked file table
codecortex://module/{name}Per-module documentation
MCP Prompts (2)
PromptDescription
start_sessionReturns constitution + latest session context
before_editingTakes file paths, returns risk/coupling/bug briefing

CLI Commands

CommandDescription
codecortex initDiscover project + extract symbols + analyze git history
codecortex serveStart MCP server (stdio transport)
codecortex updateRe-extract changed files, update affected modules
codecortex injectRegenerate inline context in CLAUDE.md and agent config files
codecortex statusShow knowledge freshness, stale modules, symbol counts
codecortex symbols [query]Browse and filter the symbol index
codecortex search <query>Search across symbols, file paths, and docs
codecortex modules [name]List modules or deep-dive into a specific module
codecortex hotspotsShow files ranked by risk: churn + coupling + bug history
`codecortex hook install\uninstall\status`Manage git hooks for auto-updating knowledge
codecortex upgradeCheck for and install the latest version

How It Works

Hybrid extraction: tree-sitter native N-API for structure (symbols, imports, calls across 27 languages) + host LLM for semantics (what modules do, why they're built that way). Zero extra API keys.

Inline context injection: After analysis, CodeCortex injects a rich knowledge section directly into CLAUDE.md and other agent config files. This includes architecture overview, risk map with coupled file names, and editing directives — so agents have project context from the first prompt without needing MCP.

Git hooks keep knowledge fresh — codecortex update runs automatically on every commit, re-extracting changed files and updating temporal analysis.

Size-adaptive responses — CodeCortex classifies your project (micro → extra-large) and adjusts response caps accordingly. A 23-file project gets full detail. A 6,400-file project gets intelligent summaries. Every MCP tool response stays under 10K chars.

Supported Languages (27)

CategoryLanguages
WebTypeScript, TSX, JavaScript
SystemsC, C++, Objective-C, Rust, Zig, Go
JVMJava, Kotlin, Scala
.NETC#
MobileSwift, Dart
ScriptingPython, Ruby, PHP, Lua, Bash, Elixir
FunctionalOCaml, Elm, Emacs Lisp
OtherSolidity, Vue, CodeQL

Tech Stack

  • TypeScript ESM, Node.js 20+
  • tree-sitter (native N-API) + 27 language grammar packages
  • @modelcontextprotocol/sdk - MCP server
  • commander - CLI
  • simple-git - git integration
  • yaml, zod, glob

License

MIT

الأسئلة الشائعة

ما هو CodeCortex؟

Persistent codebase knowledge for coding agents: symbols, dependency graphs, co-change patterns and architectural decisions extracted with tree-sitter.

كيف أثبّت CodeCortex؟

اتبع خطوات التثبيت في توثيقه المعروض في هذه الصفحة وفي مستودعه.

هل CodeCortex مفتوح المصدر؟

نعم. شيفرته متاحة على GitHub بترخيص MIT.

من يصون CodeCortex؟

ينشره rushikeshmore. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من القوائم المجتمعية awesome-mcp-servers ومستودع المشروع على GitHub. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.