Skip to main content

Intent-aware code-knowledge index for LLM agents, built on intent-db: index a repo once, query it by intent, cut the token cost of re-reading files.

Project description

intent-code

PyPI CI Python License: MIT

An intent-aware code-knowledge index for LLM agents, built on intent-db.

Index a repository once, then query it by intent so an agent reads only what it needs instead of re-reading the whole repo every session. The same search returns different results for the agent's current phase: debugging, extending, reviewing, or onboarding.

Why

LLM coding agents re-read files every session because they have no durable, queryable understanding of a codebase. intent-code builds that understanding once and keeps it fresh incrementally, so the expensive "read and synthesize" happens once per change and is reused across sessions.

It combines three established ideas:

  • A durable, LLM-maintained knowledge layer of gotcha and flow notes, in the spirit of Karpathy's LLM Wiki.
  • A tree-sitter symbol and dependency map ranked by PageRank, in the spirit of Aider's repo map.
  • Incremental indexing: only changed code is re-embedded, in the spirit of Cursor's Merkle indexing.

The retrieval engine is intent-db: documents are embedded once and a per-intent lens re-ranks results at query time, with a feedback loop that learns per-intent ranking from what the agent actually used.

How an agent uses it

One index, three ways to consume it (the same data, regenerated on every index):

  1. MCP (primary) for Claude Code and any tool-capable agent: code_map, code_search, code_read, code_context, code_flow, code_neighbors, note_put / note_get / note_list_stale, code_feedback, code_index. code_search finds where something is; code_read / code_context / code_flow answer how it works by returning full bodies and the call sequence, so the agent stops re-reading whole files.
  2. Committed markdown under docs/codemap/ (MAP.md, index.md, notes/): readable by any LLM or human, even without MCP, straight from a git clone.
  3. CLI --json for any agent that can run a shell command.

Install

uv tool install intent-code          # or: pipx install intent-code

Quickstart

cd your-repo
intent-code init .                   # builds the index, writes .mcp.json + protocol
# restart Claude Code -> the "code" MCP tools are available

Or use it directly:

intent-code index .
intent-code search "where is the retry handled" --intent debugging
intent-code map
intent-code neighbors your.module.Class.method --direction callers

# understand how code works, not just where it is
intent-code read your.module.handle_request           # full body, untruncated
intent-code context your.module.handle_request        # it + its callees, in call order
intent-code flow your.module.handle_request           # the ordered call sequence

Claude Code plugin

/plugin marketplace add harsharahul/intent-code
/plugin install intent-code

The plugin wires the MCP server, the /code-index and /code-note commands, and an optional PostToolUse freshness hook.

How it works

The index is a single intent-db SQLite file under .intentdb/ (add it to your .gitignore). Documents are tagged by layer:

  • symbol: a signature card per function/class/method (tree-sitter), with line span, content hash, and import/call edges.
  • chunk: AST-aware chunks for text or grammar-less files.
  • note: durable, human-authored gotcha and flow articles.

A dependency graph and PageRank ranking are derived from the symbol edges to produce the repo map and neighbors tracing. Re-indexing hashes each file and re-embeds only the symbols whose content changed.

The default embedder auto-detects: a local Ollama model (nomic-embed-text) if reachable, otherwise the zero-dependency hashing embedder, with BM25 hybrid search always on for exact symbol matches.

Benchmark

A token-spend benchmark ships in intent_code.eval. On the intent-db codebase, answering a five-question set used about 97% fewer input tokens than reading whole files to reach the answer (roughly 7.8k versus 227k), with the zero-dependency hashing embedder. A local embedding model improves which questions land in the top results.

python -m intent_code.eval.run /path/to/repo

Security and supply chain

Minimal runtime dependencies, official tree-sitter grammars, version bounds plus a hash-pinned lockfile, dependency auditing in CI, SHA-pinned GitHub Actions, and PyPI trusted publishing. See SECURITY.md.

License

MIT

Project details


Download files

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

Source Distribution

intent_code-0.2.0.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

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

intent_code-0.2.0-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file intent_code-0.2.0.tar.gz.

File metadata

  • Download URL: intent_code-0.2.0.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for intent_code-0.2.0.tar.gz
Algorithm Hash digest
SHA256 862a1d93d2b41ee13ef26ba05d4741860f9a718b5b9f8c6b21dfb7615de8bb82
MD5 c2d7f9acc91286f181e5825008d283e3
BLAKE2b-256 599298f2d0f5ab0822c5e017dddf96dd715a6078638c3cae4655fd416545a55a

See more details on using hashes here.

Provenance

The following attestation bundles were made for intent_code-0.2.0.tar.gz:

Publisher: release.yml on harsharahul/intent-code

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

File details

Details for the file intent_code-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: intent_code-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for intent_code-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 24d25bc77e74ba1fce140399a07513107bc0ffcf5042e1b5f2ef91003a5fa59d
MD5 9329f4c73880a4fb4e2b207e1ba97e77
BLAKE2b-256 87b208c1e2a747e2addb1ee6a4214c7198b8a095bda999895c6a88f2bb8b5f16

See more details on using hashes here.

Provenance

The following attestation bundles were made for intent_code-0.2.0-py3-none-any.whl:

Publisher: release.yml on harsharahul/intent-code

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

Supported by

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