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.18.0 ships fully local by default, including optional built-in semantic search (pipx install "loomgraph[embed]" — local CPU model, zero services). pipx install loomgraph and go — no remote services, no API keys, no Docker.


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 serves that class of queries from a local graph.

  • Deterministic graph queriesfind / graph / topology / impact walk SQLite, not an LLM. Same input, same output — and the outputs tell you how much to trust them: every analysis carries a resolved_ratio (share of edges that actually resolved) and orphans are classified as truly-isolated vs unresolved-neighbor, so a resolution blind spot (dynamic dispatch, DI frameworks, path aliases) is visible instead of silently read as dead code.
  • 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.
  • Semantic search, zero or your-way — built-in local CodeRankEmbed (int8 ONNX, MIT, auto-downloaded once) via the [embed] extra, or bring Ollama / any OpenAI-compatible embeddings endpoint. The provider choice is sticky per workspace so embedding spaces never silently mix.
  • 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.

Want zero-config semantic search too? Add the [embed] extra — a 137M code-specialized embedding model (CodeRankEmbed, MIT, int8 ONNX, ~139MB) runs locally on CPU and auto-downloads on first use:

pipx install "loomgraph[embed]"

The embedding provider is sticky per workspace: auto (default) probes a local Ollama first and falls back to the built-in model; whichever wins is recorded in the workspace, and later commands reuse the recorded choice — different models produce incompatible vector spaces, and loomgraph refuses to mix them silently.

Multi-language repos — install the matching grammar extra

Python and PHP grammars ship by default. A pure TypeScript / JavaScript / Swift / Java / Objective-C repo indexes to 0 (or a few stray) entities unless you install the matching tree-sitter grammar — the parser skips files with a warning when the grammar is absent.

pipx install "loomgraph[typescript]"    # TypeScript / TSX
pipx install "loomgraph[javascript]"    # JavaScript / JSX
pipx install "loomgraph[swift]"
pipx install "loomgraph[java]"
pipx install "loomgraph[objc]"          # Objective-C (.h / .m; .mm not supported)

Quotes are required — [extra] is a shell glob in zsh/bash (no matches found without them). Add several at once: pipx install "loomgraph[typescript,javascript]". Then ensure the languages are listed under languages: in .codeindex.yaml (the /loomgraph-setup skill generates this via codeindex's own wizard).

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"

# Semantic search — by meaning, not name ([embed] extra or an embedding provider)
loomgraph search "where is authentication handled"

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

# Topology smells (orphans, hubs, god functions) + resolution trust signal
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

Default provider: auto (v0.18+): a local Ollama is probed first; if absent, the built-in model is used (and downloaded once). The choice is recorded per workspace and reused — flipping providers mid-life would mix incompatible vector spaces, so switching requires loomgraph index --clear ..

Built-in (zero-config, [embed] extra) — no config at all:

embedding:
  enabled: true      # provider: auto → builtin when Ollama is absent

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 check Index freshness vs source files none
loomgraph find "<query>" Fuzzy entity search none
loomgraph search "<query>" Semantic search (by meaning) embedding provider (or built-in)
loomgraph graph "<entity>" Walk callers/callees none
loomgraph topology Orphans / hubs / god functions + resolved_ratio trust signal none
loomgraph debt --with-git Multi-dimensional debt scoring none (reads git log)
loomgraph deps Module dependency graph none
loomgraph impact <ref> Deterministic change-impact none
loomgraph git-metrics Hotspots / bus-factor / churn none (reads git log)
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 / near-duplicates none
loomgraph embed-backfill Vectors for an un-embedded workspace embedding provider
loomgraph hooks Git hooks for auto-update on commit none
loomgraph codeindex <cmd> Run any codeindex command in loomgraph's pinned env local
loomgraph import-export <file> Ingest a codeindex graph-export NDJSON none
loomgraph mcp / install-skills / status Integration & diagnostics none

loomgraph setup-config is deprecated (v0.16+) — zero-config defaults made it redundant.

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)
    └── meta           (workspace facts: embedding_provider, resolved_ratio)
         ↑
Claude Code / Codex / Cursor — read via CLI (JSON) or native MCP server

The full architecture rationale is in ADR-013. Chinese-language user-facing release notes live in customers/CHANGELOG.md.

Status

  • v0.18.0 — Built-in zero-config embedding ([embed] extra); trust-calculus propagation (resolved_ratio, orphan classification); single-author bus-factor suppression; test-pollution warnings
  • v0.17.x — MCP on mcp 2.0; graph-export fail-loud; codeindex 0.35 (Java fixes)
  • v0.11.0 — Local-first rewrite: LightRAG / PostgreSQL removed, SQLite + sqlite-vec

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.18.0.tar.gz (1.3 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.18.0-py3-none-any.whl (172.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: loomgraph-0.18.0.tar.gz
  • Upload date:
  • Size: 1.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for loomgraph-0.18.0.tar.gz
Algorithm Hash digest
SHA256 59f0749e7013e031ac2016ffea75aff8f6b3e6728a729d16c7ac63db730d39c8
MD5 664ea7fe6e511b426de3b8e2a6f8a81a
BLAKE2b-256 8c377bc10d4c2964847612db8b0dd41f75e85d4db45f4012bd7cfb0c37fbc404

See more details on using hashes here.

Provenance

The following attestation bundles were made for loomgraph-0.18.0.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.18.0-py3-none-any.whl.

File metadata

  • Download URL: loomgraph-0.18.0-py3-none-any.whl
  • Upload date:
  • Size: 172.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for loomgraph-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 528de3c7818e0e5d8d679f16c570a19299addbc2cf64834a5303261dfa56e36a
MD5 e50976c7b2e575b2bed3f539cb30e628
BLAKE2b-256 5e735d1ff26b45ccbe1e71e52d87bf75a1691ea11031bee21c55fe4b5a1c0a50

See more details on using hashes here.

Provenance

The following attestation bundles were made for loomgraph-0.18.0-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

This release

0.18.0 This release

2 files

0.17.1

2 files

0.17.0

2 files

0.16.3

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