Skip to main content

The cgh CLI landing screen: banner, command list, and examples

PyPI version Python versions npx CI License: Apache-2.0

cgh, the context graph hub: the project memory of your coding agents.

cgh is not a coding agent. It is an MCP server and a CLI that the agent you already use plugs into: Claude Code, Codex, Cursor, Gemini or IBM Bob. It keeps what those agents learn about a project, and it answers their questions about the code from a graph, so they find the code in fewer turns and pick up where the last session stopped.

  • Shared project memory. Knowledge, decisions, gotchas and session digests are stored per repo, with where each one came from (session, branch, commit, PR, files). Every connected agent reads the same store, it survives a /clear or a compaction, and it can be exported to another repo.
  • A code and document graph. Files, functions, classes, calls, imports, Terraform resources and Markdown sections are indexed locally. Lookups return an exact file:line, so the agent reads those lines instead of whole files. Sibling repos can be federated into one view.
  • Faster navigation and continuity. Fewer turns and fewer tokens per code question, measured below, and a resume bundle that hands the next session the standing instructions, recent digests and open plans.
  • Gates on what leaves the machine. Scanner findings (PII, secrets, confidentiality labels) are recorded in the graph, and plugins check them before a file goes to a cloud model.

Result: code questions answered in fewer turns and fewer tokens, learnings that survive context clears, and nothing leaving the machine without a gate. On a whole ticket the bill stays the same: both figures are below.

pip install cgh && cgh init && cgh serve

Why cgh: the measured gains

cgh answers code questions from the graph, returning exact file:line, instead of the agent reading whole files or grepping. Two benchmarks measure what that buys, at two scales. Both compare cost only across runs that every arm got right, so a cheap wrong answer never reads as a saving.

Per code question: fewer turns, fewer tokens. A two-arm benchmark asks the same navigation questions (where is X defined, who calls Y, what breaks if Z changes) twice against the same repo, once with cgh and once with Read/Grep only, over five runs of 5 to 8 tasks:

with cgh, against Read/Grep only
turns 18 to 40% fewer
wall time 19 to 36% faster
billed tokens, cache included 12 to 31% fewer in four runs, 5% more in one
non-cached tokens (input and output, under 1% of the bill) 33 to 61% fewer
correct answers unchanged (all correct in both arms)

The gap is widest on multi-file questions, where a graph beats text search. For "what breaks if I change _backend?", the agent has to follow call edges across a module:

turns non-cached tokens
Read / Grep 13 2607
cgh 6 886

That question is one command:

cgh callers: the call graph of resolve_import rendered as a tree with exact file and line

Per ticket: the same bill, a faster agent. A second benchmark replays already-merged tickets (API, front end, a Python service) from their parent commit: 78 runs, up to three per ticket and setup, judged blind against the merged pull request, with CI required. There, navigation is a small part of the work, and the per-question saving does not show in dollars:

Claude Code alone, cgh as installed, cgh with a full ticket setup
cost per ticket, every token type priced the same: all three within x0.96 to x1.04 of each other
quality (blind judge, CI, the merged PR's own tests) the same, within the run-to-run noise
wall time about 2x faster with the full ticket setup, which hands the agent the file locations at the start and routes its searches to cgh. That setup is not yet part of cgh init

So cgh makes finding code cheaper and quicker, and with the full ticket setup a ticket quicker, but not cheaper. Large token savings claimed for code graphs measure a single question against reading raw files, not a full piece of work.

Delegating writes. The cgh-codegen plugin does the same for writes: predictable, pattern-following code (tests, stubs, config, boilerplate) is handed to a cheap or local model that mirrors an existing file, and the reference never enters the primary model's context. cgh picks the file to mirror from the graph, so selecting it costs zero model tokens.

task reference size primary-model tokens (without -> with)
generate an auth-stripping test suite 108KB test file ~27,980 -> ~100 (99.6%)
generate a models.pyi type stub 41KB module ~14,000 -> ~100 (99.3%)

Per task, what the agent does instead of reading files:

Task Without cgh With cgh
Find where process_data is defined Read 3-5 files (~2,000 tokens) symbol_lookup (< 50 tokens)
Find all callers of save_record Read every candidate file find_callers (< 50 tokens)
Understand blast radius of utils.py Read imports manually subgraph (< 100 tokens)
Find docs about reconciliation Read all .md files search_docs (< 50 tokens)
Build context for a task 5-10 file reads (~5,000 tokens) context_for_task (< 200 tokens)

What this is not. The billed cost, once the model's prompt cache is counted, is roughly a wash on the read side: the cache dominates the invoice, so fewer turns do not cut it much. cgh's gain there is a smaller working context and fewer turns, not a smaller bill. On a trivial one-file edit cgh adds nothing. Run-to-run variance is real (around 20%), so read these as ratios over a task set rather than a single guaranteed number.


Install

pip install cgh                 # or: pipx install cgh / uv tool install cgh
pip install "cgh[full]"         # plugins, extra language parsers, precise Python calls

cgh[plugins] and cgh[full] bring cgh-codegen and cgh-bugreport. PDF, Word, Excel, PowerPoint and CSV parsing is built in (it used to be the cgh-docs plugin, which cgh now ignores if it is still installed). cgh-pii (on-demand secret scanning, PII redaction) and cgh-vision (image understanding) install by name; see docs/PLUGINS.md.

Upgrading from 0.14 or older? Read docs/UPGRADING-0.15.md first: cgh no longer blocks agent file access, the default plugin set is smaller, and the upgrade command needs -U.

No Python? Run the standalone binary through npm, or download it from the latest release:

npx @altikva/cgh serve          # fetches the binary for your OS, verifies it, runs it
npx @altikva/cgh --egress serve # the egress build, with the model-calling plugins

The binary uses the SQLite backend; uvx cgh bundles DuckDB and every plugin. One-line installers for macOS, Linux, WSL, Git Bash and Windows PowerShell, corporate mirror settings, optional extras and the cgh: command not found fix are in docs/INSTALL.md. Python 3.11 through 3.14.

Quick start

# 1. Initialize (interactive wizard)
cgh init

# 2. Build the graph
cgh index

# 3. Check what was indexed
cgh stats

# 4. Start the MCP server for your AI tool
cgh serve --watch --reindex

cgh status tells you what the graph holds and whether it still matches the working tree:

cgh status: backend, owner, scan freshness, import coverage and file count

How it works

AI Assistant (Claude / Cursor / Codex / Gemini / IBM Bob)
    |  symbol_lookup("process_data")
    |  search_docs("reconciliation")
    |  context_for_task("fix auth bug")
    v
MCP server (cgh)                <-- stdio, no network
    |  SQL graph query + BM25 FTS
    v
DuckDB graph DB (.codegraph/graph.duckdb)   <-- embedded, file-based
SQLite FTS5 (.codegraph/fts.db)       <-- BM25 full-text search
    |  indexed from
    v
Your source files (.py / .ts / .java / .go / .rs / .vue / .tf / .md)
    ^
File watcher (watchdog)         <-- live incremental updates on save

Instead of reading services.py (800 tokens) to find where verify_token is defined, your AI calls symbol_lookup("verify_token") and gets back the file, the line range, the kind and the docstring, then reads only those lines.

Languages

Six languages get a full symbol graph, functions and classes and the calls between them, with their imports resolved into File -> File edges:

imports resolved
Python .py .pyw yes
TypeScript, JavaScript .ts .tsx .js .jsx .mjs .cjs yes
Java .java yes
Go .go yes
Rust .rs yes
Vue SFC .vue yes

C# and Ruby parse too, behind pip install "cgh[langs]".

Alongside them, Markdown becomes a heading tree with its links and code references, Terraform yields resources, variables and outputs, and JSON, TOML, YAML and SQL expose their structure as sections. Every one of them is searchable and reachable from the graph.

Documents are read out of the box, no plugin needed: PDF pages, Word headings and tables, Excel sheets, PowerPoint slides with their speaker notes, and CSV / TSV summaries (header, size, first rows) all land in the index as sections, so search_docs and cgh search --text find what is inside them. Big files stay cheap: the size cap applies first and each format bounds its own work (see docs/PARSERS.md).


Documentation

Guide What it covers
Install one-line installers, extras, corporate mirrors, PATH
Upgrading to 0.15 what changed for your agent, the upgrade command, old findings, rollback
Upgrading to 0.16 the one-time re-parse, what refuses until then, federation and seeds, removed plugins, rollback
CLI reference every verb and flag
Configuration config.toml, environment variables, .cghignore
MCP tools the tools your agent calls, by category
Integrations Claude Code, Cursor, Codex, Gemini, IBM Bob
Federation one parent repo querying its sub-repos read-only
Session memory knowledge and plans that survive a context clear
Security what can leave the machine, findings, the egress gate, the MCP auth key
Plugins installing them, disabling them, writing one
Parsers the parser interface and how to add a language
Graph schema the nodes and edges the index holds
Embedding (SDK) using cgh as a library

Limitations

  • CALLS resolution is name-based by default, guided by imports. For Python and TS/JS a call follows its shape: a same-file definition wins, then the file an import names (from lib import f, import * as m), self.f() the class and its bases, obj.f() on a local or attribute whose class is known (built, annotated or returned by an annotated factory) that class, and obj.f() on an object of unknown type only the few methods of that name (or one in a file the caller imports). Calls into third-party modules and from production code into test files get no edge. Other languages link to a same-file function of that name, else to every function with that name outside test files. Cross-file edges stay best-effort: without types, obj.f() can miss its target or pick a look-alike. For Python you can opt into precise resolution with pip install cgh[lsp] and precise_calls = true (jedi-backed).
  • Terraform is read file by file, not evaluated. Blocks, references, module inputs and moved/import/removed are parsed with a real HCL grammar, but nothing is planned: count/for_each instances, dynamic blocks and computed addresses stay unexpanded, and a remote module is only read when [terraform] module_sources maps it to a local checkout.
  • Imports resolve to files in your repo, never to dependencies. Python, JS/TS, Vue, Java, Go and Rust each map an import onto the file it names, following that language's own layout rules. Anything outside the repo stays unresolved on purpose: the standard library, a Go module you do not own, an external crate or npm package gets no node and no edge, because inventing one would be a lie about your code. Cross-repo edges are not inferred either, each federated scope is canonical for its own files.
  • Markdown code refs are heuristic. PascalCase and snake_case patterns are matched, so a ref can be a false positive.
  • Large repos take minutes to index. Incremental updates stay fast (well under a second per changed file), and a pull or merge reindexes only the changed files via the git hooks.

License

Licensed under the Apache License, Version 2.0, from version 0.19 on. That covers cgh itself, the first-party plugins under plugins/, the SDK and the npx wrapper. Copyright 2026 ALTIKVA; see NOTICE.

Versions 0.18.x and earlier were published under MIT and CC BY-NC-SA 4.0 and keep that license.

Metadata

Release files for cgh 0.19.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cgh 0.19.0
File Size Uploaded Provenance Actions
cgh-0.19.0.tar.gz 697.1 kB With provenance Details for cgh-0.19.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cgh 0.19.0
File Interpreter ABI Platform Actions
cgh-0.19.0-py3-none-any.whl Python 3 none any Details for cgh-0.19.0-py3-none-any.whl

Total release size: 1.5 MB

Release files / cgh-0.19.0.tar.gz

Download URL cgh-0.19.0.tar.gz
Size 697.1 kB
Tags Source
SHA-256 checksum
How to use checksums
712819a16f9f7fb8d52414d643fc054c8da1cf68b330b8c5ad8b03990f7486bc
BLAKE2b-256 checksum
How to use checksums
01014e5424d1ea2dff86265780e747aacd6684ee9ab36bf22ecd7998bc8e8ff7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Release files / cgh-0.19.0-py3-none-any.whl

Download URL cgh-0.19.0-py3-none-any.whl
Size 798.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d793f0ced5932c893ca2a1a8d3b0a301d87b5689d45a91e13b2adaeaa5ef0820
BLAKE2b-256 checksum
How to use checksums
cdf6edc0795df021d080af3cfbb476e31b732e44a2aae0a02e61d7dba0b030a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

Security for cgh 0.19.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cgh-0.19.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page