LeanKG GEMINI.md

LeanKG GEMINI.md is an instructions file for Gemini CLI from FreePeak/LeanKG. It costs 1,140 tokens per session, scanned A, original, Apache-2.0.

Project instructions for LeanKG, a Rust-based tool that indexes a codebase, builds a graph of dependencies, calculates which code may be affected by a change, and exposes this information through MCP for AI tools. A monorepo or codebase is a project containing many related files and components.

In plain words
What is it for?
Use it to initialize and index a Rust project, inspect dependency relationships, calculate the impact of a file change, run the MCP server, and follow the project's documented development workflow.
Why use it?
It gives an AI coding agent context about how LeanKG works and how the project expects changes to be made. Impact-radius information helps estimate what else may need review after editing a file.

Instructions file for Gemini CLI

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/gemini-md
Clone the repo
git clone --depth 1 https://github.com/FreePeak/LeanKG

Made for: Gemini CLI.

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 GEMINI.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/freepeak/leankg/gemini-md.svg)](https://agentmods.dev/instructions/freepeak/leankg/gemini-md)
Your own site
<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>
Per session 1,140 This file is loaded in full into every session.
When invoked 1,140 The same file — it is already loaded in full.
Security scan A 0 findings. 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 $0.01140 $0.01140
Opus 5 $0.00570 $0.00570
Sonnet 5 $0.00228 $0.00228
Haiku 4.5 $0.00114 $0.00114

Measured today against content hash 32758281edf2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

GEMINI.md · 128 lines

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

  1. Update docs first - PRD (docs/requirement/prd-leankg.md) -> HLD (docs/design/hld-leankg.md) -> README
  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)

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

Read the full file on GitHub · 128 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 · +2 tokens per session 32758281edf2
  2. 5d ago First seen · 128 lines · 1,138 tokens per session scan A 14ffc60daaaf

Subscribe to this mod's changes

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.

Related

Other instructions, from other repositories