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/hkuds/lightrag/agents-mdgit clone --depth 1 https://github.com/HKUDS/LightRAGWhat 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.08532 | $0.08532 |
| Opus 5 | $0.04266 | $0.04266 |
| Sonnet 5 | $0.01706 | $0.01706 |
| Haiku 4.5 | $0.00853 | $0.00853 |
Grade A, and why
LightRAG AGENTS.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 — 477 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Repository Guidelines
Project Overview
LightRAG is a Retrieval-Augmented Generation (RAG) framework that uses graph-based knowledge representation for enhanced information retrieval. The system extracts entities and relationships from documents, builds a knowledge graph, and uses multiple retrieval modes (local, global, hybrid, mix, naive) for queries.
Project Structure
Top-level directories:
- lightrag/: Core Python package — see Module Layout below.
- lightrag_webui/: React 19 + TypeScript client (Bun + Vite + Tailwind). UI components in
src/. - scripts/:
test.sh(preferred test runner),setup/interactive environment wizard (usemake env-*rather than callingsetup.shdirectly — see Configuration > Setup Wizard Outputs), and release tooling. - tests/: Pytest coverage, organized into subdirectories that mirror
lightrag/(see Testing below for layout). Working datasets stay ininputs/,rag_storage/, andtemp/; deployment collateral lives indocs/,k8s-deploy/, and compose files.
Module Layout (lightrag/)
- lightrag.py: Main orchestrator class (
LightRAG) — assembled from mixins (see LightRAG class composition). Hostsainsert_custom_kg,_insert_done,_process_extract_entities,_refresh_addon_params_cache, andaddon_paramsaccessors. Critical: always callawait rag.initialize_storages()after instantiation. - pipeline.py:
_PipelineMixin— owns the document ingestion pipeline (apipeline_enqueue_documents,apipeline_process_enqueue_documents,apipeline_process_error_documents), theparse_native/parse_mineru/parse_doclingparser dispatchers, multimodal analysis, validation, and the worker scaffolding. - utils_pipeline.py: Pure helpers shared by the pipeline mixin and other entry points: doc-status field access, document identity (source key, content hash), parsed-artifact path resolution, parser payload normalization, multimodal entity augmentation, and
make_lightrag_doc_content. - llm_roles.py:
RoleSpec/RoleLLMConfig/_RoleLLMState/ROLESregistry plus_RoleLLMMixin— role normalization, builder registration, wrapper rebuild, runtime config update, queue cleanup, sanitized config export, queue status reporting. Route role-specific behavior here rather than into provider modules. - storage_migrations.py:
_StorageMigrationMixin—check_and_migrate_data,_migrate_entity_relation_data,_migrate_chunk_tracking_storage. - addon_params.py:
ObservableAddonParamsplusdefault_addon_params/normalize_addon_paramshelpers. - operate.py: Core extraction and query operations including entity/relation extraction, chunking, and multi-mode retrieval logic.
- base.py: Abstract base classes for storage backends (
BaseKVStorage,BaseVectorStorage,BaseGraphStorage,BaseDocStatusStorage). - kg/: Storage implementations (JSON, NetworkX, Neo4j, PostgreSQL, MongoDB, Redis, Milvus, Qdrant, Faiss, Memgraph, OpenSearch, NanoVectorDB). The backend registry (
STORAGE_IMPLEMENTATIONS/STORAGES) lives inkg/__init__.py;kg/factory.py::get_storage_class()resolves backend classes from configuration. - llm/: LLM and embedding provider bindings (OpenAI, Ollama, Azure, Gemini, Bedrock, Anthropic, etc.). All async with caching support.
- parser/: Unified parsing layer.
parser/routing.pyresolves engine and filename hints forlegacy,native,mineru, anddoclingflows;parser/debug.pyprovides an offline LightRAG stub for theparser/cli.pydebug entry point (python -m lightrag.parser.cli). Native format parsers live as sibling sub-packages underparser/(currentlyparser/docx/); external HTTP-based adapters live underparser/external/(mineru,docling) with shared helpers inparser/external/_common.py,_manifest.py,_zip.py. - chunker/: Chunking strategies (token-size, recursive character, semantic vector, paragraph semantic).
- api/: FastAPI service (
lightrag_server.py) with REST endpoints and Ollama-compatible API; routers underrouters/, static Swagger assets, packaged WebUI output, and Gunicorn launcher.
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 · +71 lines · +1,227 tokens per session c0d1845546d6
- yesterday First seen · 406 lines · 7,305 tokens per session scan A 1f074a3d67f7
LightRAG AGENTS.md is an instructions file published in the GitHub repository HKUDS/LightRAG (39,305 stars, last pushed today), licensed MIT. It adds 8,532 tokens to every session, about $0.0427 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
helicone CLAUDE.md
Instructions for Helicone/helicone, covering claude.md, project overview, core architecture, services and data flow.
helicone AGENTS.md
Instructions for Helicone/helicone, covering repository guidelines, project structure & module organization, build, test, and development commands, coding style & naming conventions and testing guidelines.
edgequake AGENTS.md
Instructions for raphaelmansuy/edgequake, covering repository guidelines, project structure & module organization, build, test, and development commands, quick start with make and start with ollama (default).
jurisd AGENTS.md
Instructions for russellbrenner/jurisd, covering agent instructions for jurisd, purpose, current foundation architecture, command contract rule and mcp surface rule.
einbiogpt copilot-instructions.md
Instructions for ehsanghaffar/einbiogpt, covering biogpt copilot instructions, project architecture, rate limiting & error handling, key patterns & conventions and environment variables.
einbiogpt AGENTS.md
Instructions for ehsanghaffar/einbiogpt, covering agents.md - coding guidelines for ai agents, project overview, build/development commands, development server and production build.