# Add to your Claude Code skills
git clone https://github.com/FreePeak/LeanKGLeanKG is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by FreePeak. LeanKG: Stop Burning Tokens. Start Coding Lean. It has 222 GitHub stars.
LeanKG's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/FreePeak/LeanKG" and add it to your Claude Code skills directory (see the Installation section above).
LeanKG is primarily written in Go. It is open-source under FreePeak on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh LeanKG against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
An AI coding agent starts every session with no structural knowledge of the repository it is working in. It compensates the only way it can: search, open files, read, search again. That loop is expensive in tokens and time, and it is unreliable — the answer depends on which grep happened to match.
Three failures follow from it:
LeanKG indexes a repository into a graph of code elements and relationships, then answers agent questions from that graph. It is one CGO-free binary with an embedded store, and it can serve one developer or a team behind HTTP.
| What it gives an agent | How |
|---|---|
| A targeted answer instead of a file scan | Callers, callees, impact, paths, context and compressed reads from one graph |
| A traceable answer | Every response reports the retrieval rung, the reason, and index freshness |
| Team knowledge in the same place | Memory, incidents, ownership, environments and requirements share the store |
| One server for many clients | MCP over stdio and HTTP, REST, ConnectRPC, CLI and a web UI over one engine |
| Access rules at the door | Viewer, Contributor and Admin roles per route, bearer tokens, project grants |
query answer names the retrieval rung it came from (retrieval.rung, retrieval.reason) and how fresh the index is: freshness (cold, fresh or possibly_stale), indexed_at, and head_sync on a git-indexed store. A consumer can tell an exact match from a fallback and a current index from a stale one. The ontology, session, prd, incidents, env_conflicts, service_context, compress and languages actions carry no retrieval, and a portfolio fan-out has none at the top level (each child answer has its own); see the tool contract.project:<name> scopes, and the grant is checked on MCP, REST, auto-config, the dashboard API and project switcher, and portfolio reads. RPC has no grant check of its own: a token that does not cover the default project is refused there. A restricted token lists and revokes only its own token, and cannot create orgs or claim resources. Every query answer's access block states the role and project the caller was served as. Viewer, Contributor and Admin roles are declared per HTTP route, and a non-loopback bind is refused without a token.LEANKG_PROJECT_DIRS registers several repositories in one process. Each request selects its project, and a portfolio query skips the projects the caller cannot see.A real query answer, trimmed to the provenance keys (hits, query and limit omitted). It is the output of leankg query -action exact Greet on a three-function Go fixture indexed in a git repository, run through the CLI, which calls the same engine as the MCP tool. indexed_at is a unix time and differs on each index run.
{
"access": {
"project": "fixture-repo",
"restricted": false,
"role": "admin",
"via": "local"
},
"freshness": "fresh",
"head_sync": "match",
"indexed_at": 1795510603,
"retrieval": {
"reason": "exact identifier match",
"rung": "L1",
"scope": "all"
}
}
flowchart LR
Repo["Repository<br/>HEAD commit or working tree"] --> Indexer["Indexer<br/>regex · tree-sitter · ast-grep"]
Indexer --> Graph[("Element graph<br/>files · symbols · edges")]
Indexer --> FTS[("Keyword index<br/>FTS5 / full-text")]
Graph --> Embed["Embedding pipeline<br/>local · OpenAI-compatible"]
Embed --> Vectors[("Vectors<br/>model-stamped")]
Graph --> Engine["Query engine<br/>retrieval ladder · graph traversal"]
FTS --> Engine
Vectors --> Engine
Engine --> Doors["MCP · REST · ConnectRPC · CLI · Web UI"]
Doors --> Agent["AI coding agent"]
Indexing extracts elements (files, functions, types, modules) and their
relationships (contains, calls, imports, references). In a git
repository the HEAD commit is the source of truth, so uncommitted and ignored
files do not leak into the graph. Embeddings are incremental, and every vector
writer is model-stamp guarded: changing the model fails loudly instead of
mixing vector spaces.
flowchart TD
Q["Question or symbol"] --> L1{"L1 exact identifier"}
L1 -->|hit| A["Answer with retrieval.rung + freshness"]
L1 -->|miss| L2{"L2 keyword / fuzzy"}
L2 -->|hit| A
L2 -->|miss| L3{"L3 semantic"}
L3 -->|hit| A
L3 -->|"unavailable or miss"| D["Best available rung<br/>reason states why"]
D --> A
A query stops at the first rung that can answer. Exact and keyword matches
need no embedding round trip; semantic search is used when they miss. When a
rung is unavailable — no vectors yet, for example — the answer comes from the
next rung down and says so in retrieval. The consumer can therefore tell an
exact match from a fallback without trusting the prose.
flowchart LR
A1["stdio harness"] -->|MCP| MCP["MCP server<br/>import · query · status · authenticate"]
A2["HTTP agent or IDE"] -->|"MCP over HTTP"| MCP
A3["CI and scripts"] -->|REST| REST["REST API"]
A4["Browser"] -->|"web API"| WEB["Web UI server"]
MCP --> CORE["One query engine"]
REST --> CORE
WEB --> CORE
CORE --> STORE[("Project store<br/>SQLite · PostgreSQL + pgvector")]
The same question returns the same answer whichever door it came through.
A process can serve several repositories; on a multi-project server the
project argument is required, because guessing the graph produces confident
wrong answers.
Read the detailed component map, indexer tiers and trust boundaries in Architecture, and the request and data flows in Flow diagrams.
Source: the public README of context-mode, read as of 2026-11-24. This is not a code audit of context-mode. "Not documented" means that README is silent on the point.
| Capability | LeanKG | context-mode |
|---|---|---|
| Provenance per answer | Every answer carries access. Index-backed answers carry retrieval{rung,reason}, naming the rung (L0-L3, ast-grep, lsp, graph, memory, git) |
Search hits show the source file and heading |
| Per-answer freshness | freshness (cold, fresh, possibly_stale), indexed_at and head_sync (match, stale) on index-backed answers; the key is omitted from an answer when the head state is unknown, and status reports unknown |
Not documented for indexed content |
| Role/ACL on reads | Viewer, Contributor and Admin roles per route; project:<name> grants enforced on the routed surfaces; RPC has no grant check of its own and refuses a token that lacks the default project |
Not documented. The README mentions a PreToolUse deny list, not read roles |
| Multi-project from one server | LEANKG_PROJECT_DIRS serves several repositories from one process; each request selects one |
One context.db per project under ~/.context-mode; serving several projects from one server is not documented |
| M |