LeanKG CLAUDE.md

LeanKG CLAUDE.md is an instructions file for coding agents from FreePeak/LeanKG. It costs 2,396 tokens per session, scanned A, original, Apache-2.0.

A project guide for LeanKG, a tool that indexes source code, maps dependencies, and shows which files may be affected by a change. It also explains how to build, test, and run LeanKG's MCP server, a way for AI tools to use it.

In plain words
What is it for?
Use it to index a codebase, calculate the impact of changing a file, run the service, and follow the documented development workflow.
Why use it?
It gives an agent the project context and commands needed to understand code changes and check their impact.

Instructions file

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/freepeak/leankg/claude-md
Clone the repo
git clone --depth 1 https://github.com/FreePeak/LeanKG

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for LeanKG CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/freepeak/leankg/claude-md.svg)](https://agentmods.dev/instructions/freepeak/leankg/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/freepeak/leankg/claude-md"><img src="https://agentmods.dev/badge/instructions/freepeak/leankg/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 2,396 This file is loaded in full into every session.
When invoked 2,396 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02396 $0.02396
Opus 5 $0.01198 $0.01198
Sonnet 5 $0.00479 $0.00479
Haiku 4.5 $0.00240 $0.00240

Measured today against content hash c28f5eb5ba75, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

LeanKG CLAUDE.md scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

1. `curl http://localhost:9699/health` — Docker MCP up?
CLAUDE.md · 208 lines

How it starts

The opening of the file, as written. The whole thing — 208 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LeanKG - AI Agent Context

Project Overview

LeanKG is a lightweight knowledge graph for codebase understanding. It indexes code, builds dependency graphs, calculates impact radius, and exposes everything via MCP for AI tool integration.

Tech Stack: Rust + PostgreSQL/pgvector + tree-sitter + MCP

Quick Start

# Index a codebase
cargo run -- init
cargo run -- index ./src

# Calculate impact radius
cargo run -- impact src/main.rs 3

# Start MCP server
cargo run -- serve

Development Workflow

When implementing features, follow: docs/workflow-opencode-agent.md

Pattern: Update Docs → Implement → Test → Commit → Push → Bump Version → Tag

  1. Update docs first - Consolidated PRD+HLD (docs/prd.md) → README as needed
  2. Implement - Follow patterns in docs/workflow-opencode-agent.md
  3. Build & test - cargo build && cargo test
  4. Commit - git commit -m "feat: description" (one feature per commit)
  5. Push - git pull --rebase && git push
  6. Bump version - Update version in Cargo.toml
  7. Tag - git tag -a v<version> -m "Release v<version>" && git push origin v<version> (after version bump)

Commit Message Rules

  • NEVER add Co-Authored-By: Claude Opus 4.6 <[email protected]> to commits
  • NEVER add 🤖 Generated with Claude Code or similar AI attribution
  • NEVER add "Generated by" phrases in PR descriptions

Key Commands

IMPORTANT: Always use --release flag for builds. Debug builds are disabled.

cargo build --release  # Build project (release)
cargo test             # Run tests
cargo run --release -- <cmd>  # Run CLI commands

Important Files

File Purpose
src/lib.rs Module exports
src/db/models.rs Data models (CodeElement, Relationship, BusinessLogic)
src/graph/query.rs Graph query engine
src/mcp/tools.rs MCP tool definitions
src/mcp/handler.rs MCP tool handlers
src/indexer/extractor.rs Code parsing with tree-sitter

Read the full file on GitHub · 208 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +4 tokens per session c28f5eb5ba75
  2. 6d ago First seen · 208 lines · 2,392 tokens per session scan A 028cd759fa1b

Subscribe to this mod's changes

LeanKG CLAUDE.md is an instructions file published in the GitHub repository FreePeak/LeanKG (216 stars, last pushed today), licensed Apache-2.0. It adds 2,396 tokens to every session, about $0.0120 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other instructions, from other repositories