Skip to main content

LoomGraph

PyPI Python License: MIT Tests

Local code knowledge graph for AI agents. SQLite + sqlite-vec, AST-driven, no RAG framework needed. Designed as a Claude Code plugin and a CLI for any agent that needs precise structural code queries.

v0.11.0 ships fully local by default. pipx install loomgraph and go — no remote services, no API keys, no Docker. Semantic vector search is opt-in.


Why LoomGraph

LLM agents are good at fuzzy natural-language code Q&A. They are bad at deterministic structural queries — "every caller of authenticate() across this 200k-LoC codebase, including indirect callers two hops deep." LoomGraph fills exactly that gap.

  • Deterministic graph queriesfind / graph / topology / impact walk SQLite, not an LLM. Same input, same output, every time.
  • AST is the source of truth — call/inherit/import edges come from tree-sitter via codeindex, not LLM inference.
  • Single-file storage~/.loomgraph/<workspace>.db. No Postgres, no Docker, no fork of someone else's RAG framework.
  • Vector KNN where it matters — sqlite-vec virtual tables, caller-provided embeddings, OpenAI-compatible provider config (Ollama default).
  • AI-Agent-shaped CLI — every command emits JSON; designed to be called by Claude Code or any agent harness.

Install

pipx install loomgraph

That's it. codeindex is pulled in automatically as the parser engine — no separate install, no direct operation. No additional services required for the structural commands.

LLM code interpretation — codeindex --ai, not loomgraph

LoomGraph's index is pure AST (entities, relations, call graph) — no LLM, fully reproducible. If you want LLM-generated natural-language descriptions of modules/functions (richer README_AI.md, AI-completed docstrings), that's codeindex's own --ai mode, which is orthogonal to loomgraph:

# Requires ai_command in .codeindex.yaml (e.g. claude -p, deepseek, etc.)
codeindex scan . --ai          # enrich README_AI.md via LLM
codeindex scan-all --ai        # whole tree
  • When you need it: unfamiliar large codebase where you want an LLM to narrate what each module does, or to fill in missing docstrings.
  • When you don't: structural queries via loomgraph (find/graph/topology/deps). The AST is ground truth there; LLM would only add latency and hallucination risk.
  • Relationship: loomgraph consumes codeindex's graph-export (the structural AST output), never the --ai enrichment. The two are independent — --ai makes codeindex's human-facing docs richer; loomgraph's graph stays structural either way.

Quick start

# Index a repo (uses codeindex under the hood for parsing)
loomgraph index .

# Structural search — fuzzy match on entity names
loomgraph find "UserService"

# Walk the call graph
loomgraph graph "UserService.login" --depth 2

# Topology smells (orphans, hubs, god functions)
loomgraph topology

# Change-impact analysis from a git diff
loomgraph impact HEAD --depth 2

# Cross-module dependency map
loomgraph deps

Every command outputs JSON to stdout (logs go to stderr) — pipe-friendly for agents.

Workspaces

A workspace is one indexed snapshot of a codebase, stored as a single SQLite file at ~/.loomgraph/<workspace>.db. The name auto-derives from your current directory and git branch:

<repo-dir>:<branch>    # git repo, e.g.  loomgraph:main
<repo-dir>             # non-git fallback (lowercase)

So indexing the same repo on two branches gives two independent graphs — querying feature-x won't see main's entities, and vice versa. You rarely type a workspace name: loomgraph index . auto-detects it, and every query command auto-targets the current branch's workspace. Override with --workspace.

loomgraph workspace list          # what's indexed
loomgraph workspace info          # current workspace details (auto-detected)
loomgraph workspace delete NAME --yes   # remove a workspace (unlinks the .db)

If the current branch's workspace is empty (e.g. you're on a fresh branch that was never indexed), query commands auto-fall-back to maindevelopmaster so you still get results — index the current branch explicitly with loomgraph index . when you want branch-specific data.

Configuration

LoomGraph reads .loomgraph.yaml from the current dir, then ~/.config/loomgraph/config.yaml. Env vars (LOOMGRAPH_<SECTION>__<KEY>) override file values.

Minimal (fully local, no remote services)

storage:
  backend: sqlite
  db_path: "~/.loomgraph/{workspace}.db"
embedding:
  enabled: false   # turn on later for vec0 semantic search

Semantic search with local Ollama

# Install once: https://ollama.com
ollama pull nomic-embed-text
embedding:
  enabled: true
  provider: ollama
  api_url: http://localhost:11434/v1
  model: nomic-embed-text
  dimension: 768

With OpenAI / Voyage / GLM (any OpenAI-compatible /v1/embeddings)

embedding:
  enabled: true
  provider: openai
  api_url: https://api.openai.com/v1
  api_key: sk-...
  model: text-embedding-3-small
  dimension: 1536

LLM provider (for overview summaries)

llm:
  provider: glm        # glm | openrouter | vllm
  api_url: http://localhost:8000/v1
  model: glm-4-flash

Most commands work without an LLM. Only loomgraph overview (module summary mode) calls the LLM; --no-summary skips it entirely.

What's in the box

Command Purpose Network calls
loomgraph index <path> Index a repo codeindex (local) + optional embedding
loomgraph update Incremental from git diff same
loomgraph find "<query>" Fuzzy entity search none
loomgraph graph "<entity>" Walk callers/callees none
loomgraph topology Orphans / hubs / god functions none
loomgraph debt --with-git Tech debt scoring none (reads git log)
loomgraph deps Module dependency graph none
loomgraph impact <ref> Deterministic change-impact none
loomgraph trends --entity X Code-rot trend prediction none
loomgraph overview Module summaries LLM (or --no-summary)
loomgraph workspace ... Multi-workspace management none
loomgraph compare / similar Cross-workspace diff none

Claude Code integration

LoomGraph speaks MCP (Model Context Protocol) natively as of v0.12.0. After pipx install loomgraph and one-time indexing (loomgraph index .):

loomgraph mcp install-config --path ~/.claude/mcp.json

Restart Claude Code. loomgraph_find / loomgraph_graph / loomgraph_topology / loomgraph_impact / loomgraph_deps / loomgraph_overview / loomgraph_workspace_* appear as native tools — no subprocess overhead, no /skill-name invocation. Full reference: docs/api/MCP_DESIGN.md.

Legacy skill commands (debt audit, sync advisor, evolution) still ship via loomgraph install-skills for users who prefer the explicit-invoke model.

Architecture (v0.11.0+)

codeindex (AST parse)
    ↓
loomgraph (map + persist)
    ↓
~/.loomgraph/<workspace>.db (SQLite + sqlite-vec, single file)
    ├── entities       (functions / classes / modules)
    ├── relations      (CALLS / INHERITS / IMPORTS / ...)
    ├── vec_node_descriptions  (vec0, optional)
    └── vec_code_snippets      (vec0, optional)
         ↑
Claude Code / Codex / Cursor — read via CLI (JSON) or upcoming MCP

The full architecture rationale is in ADR-013.

Status

  • v0.10.0 — LightRAG and PostgreSQL removed; local SQLite backend
  • v0.11.0 — Embedding provider decoupled; OpenAI-compatible by default, off by default

600+ unit tests passing, ruff clean. Dogfood-benchmarked on loomgraph (10.9k LoC, indexed in 0.88s) and codeindex (22.0k LoC, indexed in 0.93s) with sub-0.4s wall on every query — see docs/benchmarks/dogfood.md for the full numbers, including round-trip preservation of codeindex graph-export artifacts (81-85% relation coverage vs direct index). Larger fixture benchmarks (Django/FastAPI-scale) are still pending and are an honest gap in the README's earlier claims. See CHANGELOG.md.

License

MIT

Download files

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

Source Distribution

loomgraph-0.16.3.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

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

loomgraph-0.16.3-py3-none-any.whl (158.5 kB view details)

Uploaded Python 3

File details

Details for the file loomgraph-0.16.3.tar.gz.

File metadata

  • Download URL: loomgraph-0.16.3.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loomgraph-0.16.3.tar.gz
Algorithm Hash digest
SHA256 f546fe0db580dd29c259aadee2ba96dde17aded3b31bae766c8cd896c2574e63
MD5 8a02071a23aa4d2cf29848a06e9d0a21
BLAKE2b-256 57f3176366be11ba3174367e944dc39a74630f53eee36838849caec8a41acd64

See more details on using hashes here.

Provenance

The following attestation bundles were made for loomgraph-0.16.3.tar.gz:

Publisher: release.yml on dreamlx/LoomGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file loomgraph-0.16.3-py3-none-any.whl.

File metadata

  • Download URL: loomgraph-0.16.3-py3-none-any.whl
  • Upload date:
  • Size: 158.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for loomgraph-0.16.3-py3-none-any.whl
Algorithm Hash digest
SHA256 70088a6eac85a9d8d9479baf1481b936f2f64bf7d55c63bacb6efc4ca3348853
MD5 581cb6d0436f348d92c8215de94df7e1
BLAKE2b-256 7c22e01f08a7cd844bbd09b56fb76db6cf2057bac29383fb37277e0fdaa855f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for loomgraph-0.16.3-py3-none-any.whl:

Publisher: release.yml on dreamlx/LoomGraph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.21.1

2 files

0.21.0

2 files

0.20.0

2 files

0.19.2

2 files

0.19.1

2 files

0.19.0

2 files

0.18.1

2 files

0.18.0

2 files

0.17.1

2 files

0.17.0

2 files

This release

0.16.3 This release

2 files

0.16.2

2 files

0.16.1

2 files

0.16.0

2 files

0.15.5

2 files

0.15.4

2 files

0.15.3

2 files

0.15.2

2 files

0.15.1

2 files

0.15.0

2 files

0.14.2

2 files

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

0.12.2

2 files

0.12.1

2 files

0.12.0

2 files

0.11.3

2 files

0.11.2

2 files

0.11.1

2 files

Supported by

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