LeanKG AGENTS.md

LeanKG AGENTS.md is an instructions file for Codex, OpenCode from FreePeak/LeanKG. It costs 1,827 tokens per session, scanned A, original, Apache-2.0.

A project guide for LeanKG, a Rust tool that indexes code, builds dependency graphs, and provides code information to AI tools through MCP. It lists release builds, tests, linting, formatting, and command-line operations.

In plain words
What is it for?
Use it to initialize and index projects, calculate code impact, run local or remote MCP services, build embeddings, test, lint, and format the code.
Why use it?
It gives agents the correct commands and tool-discovery order for working safely in the repository.

Instructions file for CodexOpenCode

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

Made for: Codex, OpenCode.

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

README.md
[![agentmods](https://agentmods.dev/badge/instructions/freepeak/leankg/agents-md.svg)](https://agentmods.dev/instructions/freepeak/leankg/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/freepeak/leankg/agents-md"><img src="https://agentmods.dev/badge/instructions/freepeak/leankg/agents-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,827 This file is loaded in full into every session.
When invoked 1,827 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 $0.01827 $0.01827
Opus 5 $0.00914 $0.00914
Sonnet 5 $0.00365 $0.00365
Haiku 4.5 $0.00183 $0.00183

Measured 4d ago against content hash bf133219a4e5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

LeanKG AGENTS.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 4d ago.

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.

Health check: `curl http://localhost:9699/health`. If healthy → use Docker MCP. Else → fall back to stdio + host-path `mcp_init`.
AGENTS.md · 120 lines

How it starts

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

LeanKG — Agent Context

Tech stack: Rust + CozoDB + tree-sitter + MCP

Build & Test

cargo build --release          # always --release; debug profile has debug=false
cargo test --lib                # quick unit tests only (CI does this)
cargo test                      # full suite including integration/e2e
make lint                       # = cargo clippy --all-targets --all-features -- -D warnings
cargo fmt --all -- --check      # formatting check

.opencode.json auto-loads instructions/leankg-tools.md — detailed MCP tool reference.

CLI Quick Reference

Command Purpose
cargo run --release -- init Init project
cargo run --release -- index ./src Index codebase
cargo run --release -- mcp-stdio --watch MCP stdio (local AI tools)
cargo run --release -- mcp-http --port 9699 MCP HTTP (remote clients)
cargo run --release -- embed Build embedding vectors (after index)
cargo run --release -- embed --dry-run Export embed queries to .leankg/embed_export.jsonl (offsite/GPU batch — pair with scripts/embed_batch.py + embed --import)
cargo run --release -- embed --import <file> Import vectors produced from a --dry-run export (resumable; --no-verify skips drift check)
cargo run --release -- serve REST API + embedded UI v2 on :8080
cargo run --release -- impact <file> <depth> Blast radius calc
cargo run --release -- doctor Stale-process / mmap diagnostics
cargo run --release -- doctor --deep [--format json] [--project PATH] Deployment self-diagnosis (H9): PG latency, migrations, index freshness, embeddings coverage, pool env, orphan edges, duplicate names. Exit 0 pass / 1 warn / 2 fail

Embeddings require --features embeddings build flag (off by default). Without them, semantic_search / kg_semantic_context return "no vectors".

MANDATORY: Docker MCP project paths

When MCP talks to Docker HTTP on :9699, always pass container mount paths as project=. Host paths return "not initialized".

Read the full file on GitHub · 120 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. 4d ago First seen · 120 lines · 1,827 tokens per session scan A bf133219a4e5

Subscribe to this mod's changes

LeanKG AGENTS.md is an instructions file published in the GitHub repository FreePeak/LeanKG (215 stars, last pushed 11d ago), licensed Apache-2.0. It adds 1,827 tokens to every session, about $0.0091 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