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.
npx agentmods add instructions/freepeak/leankg/gemini-mdgit clone --depth 1 https://github.com/FreePeak/LeanKGWrote 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.
[](https://agentmods.dev/instructions/freepeak/leankg/gemini-md)<a href="https://agentmods.dev/instructions/freepeak/leankg/gemini-md"><img src="https://agentmods.dev/badge/instructions/freepeak/leankg/gemini-md.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.01140 | $0.01140 |
| Opus 5 | $0.00570 | $0.00570 |
| Sonnet 5 | $0.00228 | $0.00228 |
| Haiku 4.5 | $0.00114 | $0.00114 |
Grade A, and why
LeanKG GEMINI.md scanned grade A with 0 findings 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 128 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
- Update docs first - PRD (
docs/requirement/prd-leankg.md) -> HLD (docs/design/hld-leankg.md) -> README - Implement - Follow patterns in
docs/workflow-opencode-agent.md - Build & test -
cargo build && cargo test - Commit -
git commit -m "feat: description"(one feature per commit) - Push -
git pull --rebase && git push - Bump version - Update
versioninCargo.toml - Tag -
git tag -a v<version> -m "Release v<version>" && git push origin v<version>(after version bump)
Key Commands
cargo build # Build project
cargo test # Run tests
cargo run -- <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 |
Data Model
- CodeElement - Files, functions, classes with
qualified_name(e.g.,src/main.rs::main) - Relationship -
imports,calls,tested_by,references,documented_by - BusinessLogic - Annotations linking code to business requirements
MCP Tools
Core tools: query_file, get_dependencies, get_dependents, get_impact_radius, get_review_context, find_function, get_call_graph, search_code, generate_doc, find_large_functions, get_tested_by
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.
- today Changed · +2 tokens per session 32758281edf2
- 5d ago First seen · 128 lines · 1,138 tokens per session scan A 14ffc60daaaf
LeanKG GEMINI.md is an instructions file published in the GitHub repository FreePeak/LeanKG (216 stars, last pushed today), licensed Apache-2.0. It adds 1,140 tokens to every session, about $0.0057 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other instructions, from other repositories
m_flow AGENTS.md
AGENTS.md instructions for FlowElement-xinliuyuansu/m_flow, covering m-flow — developer & agent reference, 1. repository map, extension points, 2. local development and python backend (requires python 3.10 – 3.13).
omnigraph AGENTS.md
AGENTS.md instructions for ModernRelay/omnigraph, covering omnigraph agent guide, required reading, repository snapshot, documentation map and engineering rules.
samyama-graph CLAUDE.md
Claude Code instructions for samyama-ai/samyama-graph, covering claude.md, project overview, build & development commands, build and run tests (1814 unit tests).
kglite CLAUDE.md
Claude Code instructions for kkollsga/kglite, covering kglite — claude code conventions, build & test, architecture, the boundary principle (wrappers vs core) — summary and in-memory is the core product.
vellis AGENTS.md
AGENTS.md instructions for volantlabs/vellis, covering agents.md, repository purpose, startup checks, installing vellis for a user and model-first component workflow.
kivgraph AGENTS.md
AGENTS.md instructions for Luqueee/kivgraph, covering instrucciones de desarrollo de kivgraph, mapa de instrucciones, identidad del proyecto, qué pregunta contesta cada tool de kivgraph and la puerta delante de grep.