{"id":47685715,"url":"https://github.com/freepeak/leankg","last_synced_at":"2026-04-20T10:00:44.701Z","repository":{"id":352203550,"uuid":"1209659708","full_name":"FreePeak/LeanKG","owner":"FreePeak","description":"LeanKG: Stop Burning Tokens. Start Coding Lean.","archived":false,"fork":false,"pushed_at":"2026-04-19T07:39:40.000Z","size":2422,"stargazers_count":55,"open_issues_count":2,"forks_count":9,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-19T09:37:10.256Z","etag":null,"topics":["antigravity","claude-code","concise-context","cursor","gemini","graph-database","kilo-code","kn","knowledge-graph","lean-code","lean-context","lean-token","llm","mcp","mcp-server","opencode","saving-token","token"],"latest_commit_sha":null,"homepage":"https://www.leankg.com","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FreePeak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":"docs/roadmap.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-04-13T16:46:35.000Z","updated_at":"2026-04-19T07:39:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"563e1b9d-f63b-4f4a-9f05-8fd78884f847","html_url":"https://github.com/FreePeak/LeanKG","commit_stats":null,"previous_names":["freepeak/leankg"],"tags_count":94,"template":false,"template_full_name":null,"purl":"pkg:github/FreePeak/LeanKG","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreePeak%2FLeanKG","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreePeak%2FLeanKG/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreePeak%2FLeanKG/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreePeak%2FLeanKG/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FreePeak","download_url":"https://codeload.github.com/FreePeak/LeanKG/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FreePeak%2FLeanKG/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32042293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["antigravity","claude-code","concise-context","cursor","gemini","graph-database","kilo-code","kn","knowledge-graph","lean-code","lean-context","lean-token","llm","mcp","mcp-server","opencode","saving-token","token"],"created_at":"2026-04-02T14:49:18.283Z","updated_at":"2026-04-20T10:00:44.589Z","avatar_url":"https://github.com/FreePeak.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://www.leankg.com/icon.svg\" alt=\"LeanKG\" width=\"80\" height=\"80\"\u003e\n\u003c/p\u003e\n\n# LeanKG\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n[![Rust](https://img.shields.io/badge/rust-1.70%2B-orange?logo=rust\u0026logoColor=white)](https://www.rust-lang.org/)\n[![crates.io](https://img.shields.io/badge/crates.io-latest-orange)](https://crates.io/crates/leankg)\n[![SafeSkill 77/100](https://img.shields.io/badge/SafeSkill-77%2F100_Passes%20with%20Notes-yellow)](https://safeskill.dev/scan/freepeak-leankg)\n\n**Lightweight Knowledge Graph for AI-Assisted Development**\n\nLeanKG is a local-first knowledge graph that gives AI coding tools accurate codebase context. It indexes your code, builds dependency graphs, and exposes an MCP server so tools like Cursor, OpenCode, and Claude Code can query the knowledge graph directly. No cloud services, no external databases.\n\n\nVisualize your knowledge graph with force-directed layout, WebGL rendering, and community clustering.\n\n![LeanKG Graph Visualization](docs/screenshots/graph.jpeg)\n![LeanKG Obsidian](docs/screenshots/obsidian.jpeg)\n\nSee [docs/web-ui.md](docs/web-ui.md) for more features.\n\n---\n\n## Live Demo\n\nTry LeanKG without installing: **https://leankg.onrender.com**\n\n```bash\nleankg web --port 9000\n```\n\n---\n\n## Installation\n\n### One-Line Install (Recommended)\n\n```bash\ncurl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- \u003ctarget\u003e\n```\n\n**Supported targets:**\n\n| Target | AI Tool | Auto-Installed |\n|--------|---------|-----------------|\n| `opencode` | OpenCode AI | Binary + MCP + Plugin + Skill + AGENTS.md |\n| `cursor` | Cursor AI | Binary + MCP + Skill + AGENTS.md + Session Hook |\n| `claude` | Claude Code | Binary + MCP + Plugin + Skill + CLAUDE.md + Session Hook |\n| `gemini` | Gemini CLI | Binary + MCP + Skill + GEMINI.md |\n| `kilo` | Kilo Code | Binary + MCP + Skill + AGENTS.md |\n| `antigravity` | Google Antigravity | Binary + MCP + Skill + GEMINI.md |\n\n**Examples:**\n```bash\ncurl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- cursor\ncurl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- claude\n```\n\n### Install via Cargo or Build from Source\n\n```bash\ncargo install leankg \u0026\u0026 leankg --version\n```\n\n```bash\ngit clone https://github.com/FreePeak/LeanKG.git \u0026\u0026 cd LeanKG \u0026\u0026 cargo build --release\n```\n\n---\n\n## Quick Start\n\n```bash\nleankg init                              # Initialize LeanKG in your project\nleankg index ./src                        # Index your codebase\nleankg watch ./src                        # Auto-index on file changes\nleankg impact src/main.rs --depth 3       # Calculate blast radius\nleankg status                             # Check index status\nleankg metrics                            # View token savings\nleankg web                                # Start Web UI at http://localhost:8080\n\n# Obsidian vault sync\nleankg obsidian init                      # Initialize Obsidian vault structure\nleankg obsidian push                      # Push LeanKG data to Obsidian notes\nleankg obsidian pull                      # Pull annotation edits from Obsidian\nleankg obsidian watch                     # Watch vault for changes and auto-pull\nleankg obsidian status                    # Show vault status\n\n# Microservice call graph (via Web UI)\nleankg web                                # Start Web UI at http://localhost:8080\n                                          # Then visit http://localhost:8080/services\n```\n\nSee [docs/cli-reference.md](docs/cli-reference.md) for all commands.\n\n---\n\n## How LeanKG Helps\n\n```mermaid\ngraph LR\n    subgraph \"Without LeanKG\"\n        A1[AI Tool] --\u003e|Scans entire codebase| B1[10,000+ tokens]\n        B1 --\u003e A1\n    end\n\n    subgraph \"With LeanKG\"\n        A2[AI Tool] --\u003e|13-42 tokens| C[LeanKG Graph]\n        C --\u003e|Targeted subgraph| A2\n    end\n```\n\n**Without LeanKG**: AI scans entire codebase (~10,000+ tokens).\n**With LeanKG**: AI queries knowledge graph for targeted context (13-42 tokens). **98% token saving** for impact analysis.\n\n---\n\n\n## Highlights\n\n- **Auto-Init** -- Install script configures MCP, rules, skills, and hooks automatically\n- **Auto-Trigger** -- Session hooks inject LeanKG context into every AI tool session\n- **Token Concise** -- 13-42 tokens per query vs 10,000+ for full codebase scan\n- **Token Saving** -- Up to 98% token reduction for impact analysis\n- **Impact Radius** -- Compute blast radius before making changes\n- **Dependency Graph** -- Build call graphs with `IMPORTS`, `CALLS`, `TESTED_BY` edges\n- **MCP Server** -- Expose graph via MCP protocol for AI tool integration\n- **Multi-Language** -- Index Go, TypeScript, Python, Rust, Java, Kotlin with tree-sitter\n- **Android** -- Extract XML layouts, resources, and manifest relationships\n\nSee [docs/architecture.md](docs/architecture.md) for system design and data model details.\n\n---\n\n## Supported AI Tools\n\n| Tool | Auto-Setup | Session Hook | Plugin |\n|------|------------|--------------|--------|\n| Cursor | Yes | session-start | - |\n| Claude Code | Yes | session-start | Yes |\n| OpenCode | Yes | - | Yes |\n| Kilo Code | Yes | - | - |\n| Gemini CLI | Yes | - | - |\n| Google Antigravity | Yes | - | - |\n| Codex | Yes | - | - |\n\n\u003e **Note:** Cursor requires per-project installation. The AI features work on a per-workspace basis, so LeanKG should be installed in each project directory where you want AI context injection.\n\nSee [docs/agentic-instructions.md](docs/agentic-instructions.md) for detailed setup and auto-trigger behavior.\n\n---\n\n## Context Metrics\n\nTrack token savings to understand LeanKG's efficiency.\n\n```bash\nleankg metrics --json              # View with JSON output\nleankg metrics --since 7d           # Filter by time\nleankg metrics --tool search_code   # Filter by tool\n```\n\nSee [docs/metrics.md](docs/metrics.md) for schema and examples.\n\n---\n\n## Update\n\n```bash\n# Check current version\nleankg version\n\n# Update LeanKG binary via install script\ncurl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- update\n\n# Obsidian vault sync\nleankg obsidian init                      # Initialize Obsidian vault\nleankg obsidian push                      # Push LeanKG data to Obsidian notes\nleankg obsidian pull                      # Pull annotation edits from Obsidian\n```\n\n\n---\n\n## Documentation\n\n| Doc | Description |\n|-----|-------------|\n| [docs/cli-reference.md](docs/cli-reference.md) | All CLI commands |\n| [docs/mcp-tools.md](docs/mcp-tools.md) | MCP tools reference |\n| [docs/agentic-instructions.md](docs/agentic-instructions.md) | AI tool setup \u0026 auto-trigger |\n| [docs/architecture.md](docs/architecture.md) | System design, data model |\n| [docs/web-ui.md](docs/web-ui.md) | Web UI features |\n| [docs/metrics.md](docs/metrics.md) | Metrics schema \u0026 examples |\n| [docs/benchmark.md](docs/benchmark.md) | Performance benchmarks |\n| [docs/roadmap.md](docs/roadmap.md) | Feature planning |\n| [docs/tech-stack.md](docs/tech-stack.md) | Tech stack \u0026 structure |\n| [docs/android-extraction.md](docs/android-extraction.md) | Android XML \u0026 resource extraction |\n\n---\n\n## Troubleshooting\n\n### Database Lock Error\n\nIf you see `database is locked (code 5)`, another LeanKG process is holding the database:\n\n```bash\n# Kill all leankg and vite processes\nleankg-kill\n\n# Or manually\npkill -9 -f \"leankg\"\npkill -9 -f \"vite\"\n```\n\n### Process Management\n\n```bash\nleankg-kill              # Kill all leankg and vite processes (after adding to ~/.zshrc)\nleankg-status            # Show running leankg/vite processes\n```\n\n**Important:** Always kill the web server before indexing to avoid database lock conflicts.\n\n---\n\n## Performance Benchmarks\n\n### Load Test Results (100K nodes)\n\n| Test | Throughput |\n|------|------------|\n| Insert elements | ~173,000 elements/sec |\n| Insert relationships | ~179,000 relationships/sec |\n| Retrieve all elements | ~662,000 elements/sec |\n\nRun load tests:\n```bash\ncargo test --release load_test -- --nocapture\n```\n\nSee [docs/analysis/load-testing-1m-nodes-2026-04-17.md](docs/analysis/load-testing-1m-nodes-2026-04-17.md) for detailed performance analysis.\n\n---\n\n## Requirements\n\n- Rust 1.70+\n- macOS or Linux\n\n---\n\n## License\n\nMIT\n\n---\n\n## Star History\n\n\u003ca href=\"https://www.star-history.com/?repos=FreePeak%2FLeanKG\u0026type=date\u0026legend=top-left\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/chart?repos=FreePeak/LeanKG\u0026type=date\u0026theme=dark\u0026legend=top-left\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/chart?repos=FreePeak/LeanKG\u0026type=date\u0026legend=top-left\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/chart?repos=FreePeak/LeanKG\u0026type=date\u0026legend=top-left\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreepeak%2Fleankg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreepeak%2Fleankg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreepeak%2Fleankg/lists"}