LeanKG

作者 FreePeak已验证

LeanKG: Stop Burning Tokens. Start Coding Lean.

212
Stars
26
Forks
Rust
语言
2026/8/23
添加时间

⚠️ 第三方软件声明

本 Skill 为第三方开源软件,独立托管于 GitHub。SkillTip 仅为信息目录,不控制或维护底层仓库。所显示的安全检查为自动化且范围有限,安装前请自行审查源码。

阅读服务条款

安装

添加到你的 Claude Code skills 目录:

# Add to your Claude Code skills
git clone https://github.com/FreePeak/LeanKG

快速入门

使用 LeanKG 等 Skills 的指南。

安全报告

已验证

上次扫描:—

{
  "status": "PASSED",
  "issues": []
}

README.md

LeanKG

LeanKG

Enterprise-ready code knowledge graph for AI coding agents
Multi-repo · env governance · incidents & services · req↔code · −65% tokens / −85% tool calls

Live Demo · Docs · Docker Hub

License: Apache 2.0 crates.io Docker Hub CI

LeanKG


Installation

Prerequisites

Postgres + pgvector is required (only storage engine). From a LeanKG checkout:

docker compose up -d postgres   # host :5433

Default URL: postgresql://postgres:postgres@localhost:5433/leankg (override with LEANKG_PG_URL).
One-liners below do not start Postgres — they fail if :5433 is down.

One-liners

# Docker — index + embed + MCP HTTP (Postgres must already be up)
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/docker-up.sh | bash

# Agent — binary + MCP wiring (cursor | claude | opencode | gemini | kilo | antigravity | docker | update)
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- cursor

Skip cold embed: LEANKG_SKIP_EMBED=1 curl -fsSL …/docker-up.sh | bash

Docker (manual)

docker compose up -d          # Postgres :5433 + MCP :9699
# or MCP only (bring your own PG via LEANKG_PG_URL):
docker run -d --name leankg -p 9699:9699 \
  -e LEANKG_PG_URL=postgresql://postgres:postgres@host.docker.internal:5433/leankg \
  -v "$(pwd):/workspace" freepeak/leankg:latest
curl http://localhost:9699/health

MCP URL: http://localhost:9699/mcp

From source

cargo install leankg
# or: git clone https://github.com/FreePeak/LeanKG.git && cd LeanKG && cargo build --release

Get Started

# 0. Postgres once — point at your instance (or: docker compose up -d postgres)
export LEANKG_PG_URL="postgres://user:pass@host:5432/db"

# 1. Per project: init -> migrate -> index
cd your-project
leankg init && leankg migrate && leankg index ./src

# 2a. Wire up an AI client — one command (also: cursor | codex | gemini)
leankg connect claude-code           # add --remote http://host:9699 to reuse a shared server

# 2b. ...or serve MCP over HTTP yourself
leankg mcp-http --port 9699          # GET /health returns 200 when ready

Self-check any deployment: leankg doctor --deep — PG latency, migrations, index freshness, embedding coverage, pool env, orphan edges, duplicate names (exit 0 pass / 1 warn / 2 fail).

Measured timings (scripts/quickstart_smoke.sh, run weekly in CI): full e2e smoke 88 s vs a 300 s budget; indexing a small repo takes well under 2 minutes.

Docker MCP users: pass container paths as project= (e.g. /workspace), never host paths.

Server-side setup pipeline (clone -> index -> embed)

leankg setup with no flags keeps the legacy client-side behavior (register MCP + hooks). Pass pipeline flags to instead clone a list of repos and index each one server-side:

# Status: print the resolved repo list without running anything
LEANKG_REPOS="github.com/org/repo-a,github.com/org/repo-b" leankg setup --status

# Clone + index + embed each repo under LEANKG_CLONE_ROOT (default: cwd)
LEANKG_REPOS="github.com/org/repo-a,github.com/org/repo-b" \
  LEANKG_GIT_REF=main \
  LEANKG_CLONE_ROOT=/srv/repos \
  leankg setup --clone --index --embed

Repo sources:

  • LEANKG_REPOS — comma-separated host/namespace paths to clone.
  • LEANKG_PROJECT_DIRS — comma-separated dirs already mounted on disk (skips clone; falls back to indexing what exists when no git token is set).

Env knobs: LEANKG_GIT_HOST (default github.com), LEANKG_GIT_REF (default main), LEANKG_CLONE_ROOT / CLONE_ROOT, LEANKG_ENV (default local), git token via GITLAB_TOKEN / GIT_TOKEN / GITHUB_TOKEN. Each cloned repo gets a minimal .leankg/leankg.yaml, then leankg index and leankg embed --wait run inside it. A setup.done marker prevents re-runs.

Set LEANKG_SETUP=1 on leankg mcp-http to run the same pipeline once after the server binds (spawned as a background task; the server stays healthy).

Web UI

UI talks REST (:8080), not MCP (:9699). Start the API, then the Vite app in ui-v2/:

# Terminal A — REST API (+ embedded UI if assets are in src/embed/)
leankg serve --port 8080
# open http://127.0.0.1:8080/

# Terminal B — hot-reload explorer (recommended for local UI work)
cd ui-v2
npm install
npm run dev
# open http://127.0.0.1:5173/?path=src

Vite proxies /api127.0.0.1:8080. Status should show connected.
Details: ui-v2/README.md · docs/web-ui.md


Enterprise Ready

Peers in this space are mostly personal / single-repo. LeanKG is the company platform: shared index, ops graph, and measured agent economics.

PillarShips as
Multi-repo serverDocker MCP :9699 + Postgres/pgvector; LEANKG_PROJECT_DIRS
Env governanceenv=, promote_environment, find_env_conflicts
Ops & ownershipget_service_graph, query_incidents, get_team_map
Req ↔ codeindex_prd, get_traceability, get_traceability_matrix
Mega-graphFrontier-local queries; 100k–700k+ elements
Agent surface85+ MCP tools (peers typically ~1–17)
CostA/B −65% tokens, −85% tool calls, 2.5× vs grep/cat
CapabilityLeanKGGitNexusGraphifyCodannaContext7
Multi-repo team deployYesPartialLimitedLimitedn/a
Env / incidents / team mapYesNoNoNoNo
PRD traceabilityYesNoPartialNoNo
Mega-graph (100k+)YesPartialViz cappedVariesn/a
MCP depth85+~17~10~5docs only

Deep dives: ROI vs Graphify · Competitive one-pager · Research matrix


Why LeanKG?

Agents normally rebuild structure with grep → open files → huge context. LeanKG returns a targeted subgraph (callers, dependents, blast radius, tests, docs) plus the team layer (env, services, incidents, requirements) over MCP.

WithoutWith LeanKG
Many tool calls, large contextSurgical subgraph + TOON (~40% smaller payloads)
No blast radiusSeverity-graded impact
Keyword onlyKeyword + HNSW semantic + ontology
Single-repo guessworkMulti-repo index + ops tools

Key Features

  • MCP-native — search, impact, call graphs, ontology, architecture, team knowledge
  • Postgres + pgvector — only storage engine; HNSW semantic search (--features embeddings / Docker)
  • Procedural ontology — hot-reload ontology/workflows.yamlkg_trace_workflow
  • Impact & depsimports, calls, tested_by, http_calls, service_calls
  • Web UI v2 — Force / Tree / Circles explorer (leankg serve + cd ui-v2 && npm run dev)
  • Languages — Rust, Go, C/C++, Java, Kotlin, TS/JS, Python, Ruby*, PHP*, Dart, Swift*, ObjC*, Terraform, CI YAML (*depth varies)

MCP prefer-order

Discover first — do not open with query_graph:

get_overview_contextmcp_statusconcept_searchsemantic_searchsearch_code / find_function → impact / deps / get_context

QuestionFirst tools
Fuzzy / domain NLconcept_searchsemantic_searchsearch_code
Exact symbol / filefind_function / search_code / query_file
How A↔B?shortest_path
Expand after seedsquery_graph

Catalog: docs/mcp-tools.md · Setup: docs/agentic-instructions.md


CLI

leankg init | index ./src | status | update
leankg impact <file> --depth 3
leankg path <from> <to> | explain <symbol> | graph-query "<q>"
leankg embed --init && leankg embed   # --features embeddings
leankg mcp-stdio --watch | mcp-http --port 9699 | serve --port 8080
leankg ontology sync | ontology trace <workflow>

UI hot-reload: cd ui-v2 && npm install && npm run devhttp://127.0.0.1:5173

Full reference: docs/cli-reference.md


Docs

Doc
ArchitectureDesign & data model
MCP toolsTool catalog
CLIAll commands
BenchmarksMethodology
EmbeddingsHNSW / ops
Postgres migrationEngine notes
AGENTS.mdAgent / Docker notes

Troubleshooting

IssueFix
High RAM (macOS)LEANKG_MMAP_SIZE=134217728 — see INSTRUCTION.md
MCP “not initialized” in DockerUse container project=/workspace, not the host path
Embeddings / cold embedsrc/embeddings/EMBEDDINGS.md

Requirements: macOS or Linux · Docker recommended for teams · Rust 1.75+ only when building from source.


Contributing

  1. Fork + feature branch (prefer a worktree)
  2. Update docs when behavior changes
  3. cargo build --release && cargo test
  4. Open a PR with summary + test plan

License

Apache License 2.0

常见问题

What is LeanKG?

LeanKG 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 212 GitHub stars.

Is LeanKG safe to use?

Yes. LeanKG passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.

How do I install LeanKG?

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).

What programming language is LeanKG written in?

LeanKG is primarily written in Rust. It is open-source under FreePeak on GitHub, so you can review or fork the full source.

Are there alternatives to LeanKG?

Yes. SkillsLLM 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.

评论 (0)

暂无评论,成为第一个分享想法的人!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI 智能体
查看详情

开发者还喜欢

基于喜欢此 Skill 的开发者投票和收藏

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI 智能体ai-agentsbrainstorming
查看详情

hermes-agent

by NousResearch

10

The agent that grows with you

234,43747,175Python
AI 智能体ai-agentsagent-orchestration
查看详情

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP 服务器apisai-tools
查看详情

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI 智能体ai-agentsanthropicclaude-code
查看详情

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI 智能体claude-codeai-tools
查看详情
LeanKG — Claude Code AI Skill | SkillTip