asalsali/codeknow

Turn any codebase into a queryable knowledge graph. Simulate changes, discover features, analyze architecture.

3

stars

7

commits

Python

primary language

Sep 3, 2026

updated

README

Codeknow

Turn any codebase into a queryable knowledge graph. Health scores, drift detection, impact analysis, onboarding guides -- all from your AST.

Why Codeknow?

Most code intelligence tools need embeddings, vector stores, or LLM API keys before they do anything useful. Codeknow builds a real graph from your source code using tree-sitter AST parsing -- 25+ languages, zero configuration, no API keys required. The graph is a NetworkX DiGraph: nodes are symbols (functions, classes, modules), edges are relationships (imports, calls, inheritance). Every analysis command operates on this graph directly.

It works standalone or as a force multiplier for AI coding assistants (Claude Code, Cursor, Gemini CLI, Codex, and more).

Quick Start

pip install codeknow

cd your-project/
codeknow .

That's it. Open codegraph-out/graph.html for the interactive visualization, or codegraph-out/GRAPH_REPORT.md for the architectural report.

Core Commands

CommandWhat it does
codeknow <path>Build knowledge graph from source code
codeknow debtComposite health score (0-100) with letter grade
codeknow drift snapshotSave current architecture as a named baseline
codeknow drift compareDetect what changed since the last baseline
codeknow onboardGenerate a guided codebase tour from graph topology
codeknow impact "<file>"Blast radius -- what breaks if you change this?
codeknow test-impactWhich tests to run for your changed files
codeknow securityAttack surface analysis: source-to-sink path tracing
codeknow ownersGit-blame overlay: knowledge silos, bus factor, orphaned code
codeknow refactor-plan "<target>"Safe refactoring order with dependency-aware risk assessment

Example: codeknow debt

  ARCHITECTURAL DEBT SCORE
  ========================================

    72.4 / 100   [B]

  Graph: 1,247 nodes, 3,891 edges, 18 communities

  BREAKDOWN
  ----------------------------------------
  [========      ]  God Node Concentration (25%)
                    Top nodes: Router(47), Database(38), Config(31)
  [===========   ]  Cross-Community Coupling (25%)
                    412/3891 edges cross boundaries
  [=============]   Import Cycles (20%)
                    0 cycle(s) detected
  [=========     ]  Community Cohesion (20%)
                    Avg density: 34% across 18 communities
  [============  ]  Dead Code (10%)
                    89/1247 nodes unreferenced (7%)

  RECOMMENDATIONS
  ----------------------------------------
  1. Split Router (degree 47) -- extract route groups into sub-modules
  2. Reduce coupling between Community 3 <-> Community 7 (28 edges)

All Commands

CommandDescription
codeknow <path>Build knowledge graph from source code
codeknow updateIncrementally rebuild only changed files
codeknow debtArchitectural debt score (0-100) with CI gating (--threshold)
codeknow drift snapshotSave current graph as a named baseline
codeknow drift compareCompare current graph against a baseline
codeknow drift historyList saved baselines
codeknow changelogGit-aware architectural changelog (--since 2w, --ref HEAD~10)
codeknow onboardGuided codebase tour from graph topology
codeknow impact "<file>"Blast radius analysis with risk assessment
codeknow test-impactMap changed files to affected tests (pipe to xargs pytest)
codeknow securityAttack surface: source-to-sink path tracing
codeknow ownersOwnership analysis: knowledge silos, bus factor, --codeowners generation
codeknow refactor-plan "<target>"Dependency-aware refactoring plan with safe ordering
codeknow tuiInteractive terminal navigator (keyboard-driven, no dependencies)
codeknow dashboardLive architecture dashboard at localhost:8787
codeknow affected "<node>"Reverse traversal: all nodes impacted by a change
codeknow simulate remove "<node>"Simulate removing a node -- cascade analysis
codeknow simulate merge "<A>" "<B>"Simulate merging two modules
codeknow simulate refactor "<a>" "<b>" --into <name>Simulate extracting nodes into a new module
codeknow discoverDetect latent connections, bridges, capability clusters
codeknow featuresIdentify product features from code structure
codeknow patternsMatch against 10 software architecture patterns
codeknow diagnoseDiagnose architectural issues
codeknow reflectGenerate architectural reflection from saved Q&A
codeknow explain "<node>"Explain a node and its connections
codeknow path "<A>" "<B>"Shortest path between two concepts
codeknow query "<question>"Natural language query (requires LLM)
codeknow treeInteractive collapsible dependency tree (HTML)
codeknow god-nodesList the most connected nodes
codeknow prsPR dashboard: CI state, review status
codeknow export html|neo4j|obsidian|svg|graphml|callflow-html|wikiExport to various formats
codeknow global add <path>Add a repo to the cross-repo global graph
codeknow benchmarkMeasure token reduction vs naive full-corpus approach

All commands support --json for machine-readable output.

Supported Languages (25+)

Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, C#, Ruby, Kotlin, Scala, PHP, Swift, Lua, Zig, PowerShell, Elixir, Objective-C, Julia, Verilog, Fortran, Bash, Groovy, Apex, Dart, Pascal, OCaml, Common Lisp, Terraform (HCL), Robot Framework, DM (BYOND), Razor, Blade, SQL, JSON/config, Markdown

Language detection is automatic. Each language has a dedicated tree-sitter extractor.

How It Works

Source Code
    |
    v
[tree-sitter AST parsing] -- per-language extractors for 25+ languages
    |
    v
[Symbol extraction] -- functions, classes, modules, imports, calls
    |
    v
[Cross-file resolution] -- resolve imports, inheritance, call chains
    |
    v
[NetworkX DiGraph] -- nodes = symbols, edges = relationships
    |
    v
[Analysis / Simulation / Visualization]
    |--- Debt scoring (health grade 0-100)
    |--- Drift detection (baseline snapshots)
    |--- Impact & test-impact analysis
    |--- Security (source-to-sink tracing)
    |--- Simulation engine (remove, merge, refactor)
    |--- Discovery engine (latent connections, features, patterns)
    |--- Interactive HTML + TUI + dashboard
    |--- Export (Neo4j, Obsidian, SVG, GraphML)

Zero-LLM default mode: The core pipeline (parse, build, analyze, simulate, discover, debt, drift, onboard, security, test-impact, owners, refactor-plan) works without any API key. LLM integration is optional for natural language queries, enriched reports, and community labeling.

AI Agent Integration

codeknow install claude              # Claude Code
codeknow install cursor              # Cursor
codeknow install gemini              # Gemini CLI
codeknow install codex               # OpenAI Codex
codeknow install kilo                # Kilo Code
codeknow install vscode              # VS Code Copilot Chat
codeknow install antigravity         # Google Antigravity
codeknow install kiro                # Kiro IDE/CLI

An MCP server is also available:

pip install "codeknow[mcp]"
codeknow-mcp                        # exposes suggest_refactoring + impact_analysis tools

CI Integration

Use codeknow debt --threshold as a CI quality gate:

# .github/workflows/codeknow.yml
- name: Architecture health check
  run: |
    pip install codeknow
    codeknow . --code-only
    codeknow debt --threshold 60

Use codeknow test-impact --changed to run only affected tests:

- name: Smart test selection
  run: |
    codeknow test-impact --changed | xargs pytest

Optional Extras

pip install "codeknow[mcp]"          # MCP server for AI coding assistants
pip install "codeknow[openai]"       # OpenAI LLM integration
pip install "codeknow[anthropic]"    # Anthropic LLM integration
pip install "codeknow[ollama]"       # Ollama (local LLM) integration
pip install "codeknow[neo4j]"        # Neo4j graph database export
pip install "codeknow[falkordb]"     # FalkorDB graph database export
pip install "codeknow[pdf]"          # PDF document ingestion
pip install "codeknow[watch]"        # File watcher for live rebuilds
pip install "codeknow[svg]"          # Static SVG diagram export
pip install "codeknow[office]"       # Word/Excel document ingestion
pip install "codeknow[video]"        # Video transcription ingestion
pip install "codeknow[postgres]"     # PostgreSQL schema introspection
pip install "codeknow[all]"          # Everything

Requirements

  • Python 3.10+
  • No API keys required for core functionality

License

MIT License. See LICENSE for details.

Contributors

asalsali

7 commits

asalsali/codeknow

Turn any codebase into a queryable knowledge graph. Simulate changes, discover features, analyze architecture.

3

stars

7

commits

Python

primary language

Sep 3, 2026

updated

README

Codeknow

Turn any codebase into a queryable knowledge graph. Health scores, drift detection, impact analysis, onboarding guides -- all from your AST.

Why Codeknow?

Most code intelligence tools need embeddings, vector stores, or LLM API keys before they do anything useful. Codeknow builds a real graph from your source code using tree-sitter AST parsing -- 25+ languages, zero configuration, no API keys required. The graph is a NetworkX DiGraph: nodes are symbols (functions, classes, modules), edges are relationships (imports, calls, inheritance). Every analysis command operates on this graph directly.

It works standalone or as a force multiplier for AI coding assistants (Claude Code, Cursor, Gemini CLI, Codex, and more).

Quick Start

pip install codeknow

cd your-project/
codeknow .

That's it. Open codegraph-out/graph.html for the interactive visualization, or codegraph-out/GRAPH_REPORT.md for the architectural report.

Core Commands

CommandWhat it does
codeknow <path>Build knowledge graph from source code
codeknow debtComposite health score (0-100) with letter grade
codeknow drift snapshotSave current architecture as a named baseline
codeknow drift compareDetect what changed since the last baseline
codeknow onboardGenerate a guided codebase tour from graph topology
codeknow impact "<file>"Blast radius -- what breaks if you change this?
codeknow test-impactWhich tests to run for your changed files
codeknow securityAttack surface analysis: source-to-sink path tracing
codeknow ownersGit-blame overlay: knowledge silos, bus factor, orphaned code
codeknow refactor-plan "<target>"Safe refactoring order with dependency-aware risk assessment

Example: codeknow debt

  ARCHITECTURAL DEBT SCORE
  ========================================

    72.4 / 100   [B]

  Graph: 1,247 nodes, 3,891 edges, 18 communities

  BREAKDOWN
  ----------------------------------------
  [========      ]  God Node Concentration (25%)
                    Top nodes: Router(47), Database(38), Config(31)
  [===========   ]  Cross-Community Coupling (25%)
                    412/3891 edges cross boundaries
  [=============]   Import Cycles (20%)
                    0 cycle(s) detected
  [=========     ]  Community Cohesion (20%)
                    Avg density: 34% across 18 communities
  [============  ]  Dead Code (10%)
                    89/1247 nodes unreferenced (7%)

  RECOMMENDATIONS
  ----------------------------------------
  1. Split Router (degree 47) -- extract route groups into sub-modules
  2. Reduce coupling between Community 3 <-> Community 7 (28 edges)

All Commands

CommandDescription
codeknow <path>Build knowledge graph from source code
codeknow updateIncrementally rebuild only changed files
codeknow debtArchitectural debt score (0-100) with CI gating (--threshold)
codeknow drift snapshotSave current graph as a named baseline
codeknow drift compareCompare current graph against a baseline
codeknow drift historyList saved baselines
codeknow changelogGit-aware architectural changelog (--since 2w, --ref HEAD~10)
codeknow onboardGuided codebase tour from graph topology
codeknow impact "<file>"Blast radius analysis with risk assessment
codeknow test-impactMap changed files to affected tests (pipe to xargs pytest)
codeknow securityAttack surface: source-to-sink path tracing
codeknow ownersOwnership analysis: knowledge silos, bus factor, --codeowners generation
codeknow refactor-plan "<target>"Dependency-aware refactoring plan with safe ordering
codeknow tuiInteractive terminal navigator (keyboard-driven, no dependencies)
codeknow dashboardLive architecture dashboard at localhost:8787
codeknow affected "<node>"Reverse traversal: all nodes impacted by a change
codeknow simulate remove "<node>"Simulate removing a node -- cascade analysis
codeknow simulate merge "<A>" "<B>"Simulate merging two modules
codeknow simulate refactor "<a>" "<b>" --into <name>Simulate extracting nodes into a new module
codeknow discoverDetect latent connections, bridges, capability clusters
codeknow featuresIdentify product features from code structure
codeknow patternsMatch against 10 software architecture patterns
codeknow diagnoseDiagnose architectural issues
codeknow reflectGenerate architectural reflection from saved Q&A
codeknow explain "<node>"Explain a node and its connections
codeknow path "<A>" "<B>"Shortest path between two concepts
codeknow query "<question>"Natural language query (requires LLM)
codeknow treeInteractive collapsible dependency tree (HTML)
codeknow god-nodesList the most connected nodes
codeknow prsPR dashboard: CI state, review status
codeknow export html|neo4j|obsidian|svg|graphml|callflow-html|wikiExport to various formats
codeknow global add <path>Add a repo to the cross-repo global graph
codeknow benchmarkMeasure token reduction vs naive full-corpus approach

All commands support --json for machine-readable output.

Supported Languages (25+)

Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, C#, Ruby, Kotlin, Scala, PHP, Swift, Lua, Zig, PowerShell, Elixir, Objective-C, Julia, Verilog, Fortran, Bash, Groovy, Apex, Dart, Pascal, OCaml, Common Lisp, Terraform (HCL), Robot Framework, DM (BYOND), Razor, Blade, SQL, JSON/config, Markdown

Language detection is automatic. Each language has a dedicated tree-sitter extractor.

How It Works

Source Code
    |
    v
[tree-sitter AST parsing] -- per-language extractors for 25+ languages
    |
    v
[Symbol extraction] -- functions, classes, modules, imports, calls
    |
    v
[Cross-file resolution] -- resolve imports, inheritance, call chains
    |
    v
[NetworkX DiGraph] -- nodes = symbols, edges = relationships
    |
    v
[Analysis / Simulation / Visualization]
    |--- Debt scoring (health grade 0-100)
    |--- Drift detection (baseline snapshots)
    |--- Impact & test-impact analysis
    |--- Security (source-to-sink tracing)
    |--- Simulation engine (remove, merge, refactor)
    |--- Discovery engine (latent connections, features, patterns)
    |--- Interactive HTML + TUI + dashboard
    |--- Export (Neo4j, Obsidian, SVG, GraphML)

Zero-LLM default mode: The core pipeline (parse, build, analyze, simulate, discover, debt, drift, onboard, security, test-impact, owners, refactor-plan) works without any API key. LLM integration is optional for natural language queries, enriched reports, and community labeling.

AI Agent Integration

codeknow install claude              # Claude Code
codeknow install cursor              # Cursor
codeknow install gemini              # Gemini CLI
codeknow install codex               # OpenAI Codex
codeknow install kilo                # Kilo Code
codeknow install vscode              # VS Code Copilot Chat
codeknow install antigravity         # Google Antigravity
codeknow install kiro                # Kiro IDE/CLI

An MCP server is also available:

pip install "codeknow[mcp]"
codeknow-mcp                        # exposes suggest_refactoring + impact_analysis tools

CI Integration

Use codeknow debt --threshold as a CI quality gate:

# .github/workflows/codeknow.yml
- name: Architecture health check
  run: |
    pip install codeknow
    codeknow . --code-only
    codeknow debt --threshold 60

Use codeknow test-impact --changed to run only affected tests:

- name: Smart test selection
  run: |
    codeknow test-impact --changed | xargs pytest

Optional Extras

pip install "codeknow[mcp]"          # MCP server for AI coding assistants
pip install "codeknow[openai]"       # OpenAI LLM integration
pip install "codeknow[anthropic]"    # Anthropic LLM integration
pip install "codeknow[ollama]"       # Ollama (local LLM) integration
pip install "codeknow[neo4j]"        # Neo4j graph database export
pip install "codeknow[falkordb]"     # FalkorDB graph database export
pip install "codeknow[pdf]"          # PDF document ingestion
pip install "codeknow[watch]"        # File watcher for live rebuilds
pip install "codeknow[svg]"          # Static SVG diagram export
pip install "codeknow[office]"       # Word/Excel document ingestion
pip install "codeknow[video]"        # Video transcription ingestion
pip install "codeknow[postgres]"     # PostgreSQL schema introspection
pip install "codeknow[all]"          # Everything

Requirements

  • Python 3.10+
  • No API keys required for core functionality

License

MIT License. See LICENSE for details.

Contributors

asalsali

7 commits

Languages

Python

99.3%