LightRAG: Instructions file for Codex

AGENTS.md

LightRAG AGENTS.md is an instructions file for Codex, OpenCode from HKUDS/LightRAG. It costs 7,646 tokens per session, scanned A, original, MIT.

A repository guide for LightRAG, a system that helps search documents by building a knowledge graph of entities and their relationships. It explains the Python backend, web interface, project folders, and available search modes.

In plain words
What is it for?
Use it when changing document ingestion, graph construction, retrieval, the web interface, tests, or deployment setup. It is also useful when working with LightRAG’s local, global, hybrid, mixed, or basic search modes.
Why use it?
It gives coding agents a map of the system before they change it. This reduces confusion about where core logic, the React interface, tests, datasets, and deployment files belong.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md.

This is HKUDS/LightRAG's own configuration. It tells Codex and OpenCode how to work on LightRAG itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything LightRAG configures →

About the project

LightRAG is a retrieval-augmented generation system that combines language models with retrieved information and knowledge-graph data to answer questions using relevant sources. It is for building applications that search document or knowledge collections before generating responses.

HKUDS/LightRAG · 40,557 stars · on GitHub · arxiv.org

Reuse

Borrowing it

Nothing to install: this file belongs to HKUDS/LightRAG. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/HKUDS/LightRAG/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/HKUDS/LightRAG

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

README.md
[![agentmods](https://agentmods.dev/badge/instructions/hkuds/lightrag/agents-md/github.svg)](https://agentmods.dev/instructions/hkuds/lightrag/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/hkuds/lightrag/agents-md"><img src="https://agentmods.dev/badge/instructions/hkuds/lightrag/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for LightRAG AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/hkuds/lightrag/agents-md"><img src="https://agentmods.dev/badge/instructions/hkuds/lightrag/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 7,646 This file is loaded in full into every session.
When invoked 7,646 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.07646 $0.07646
Opus 5.5 $0.03058 $0.03058
Sonnet 5.5 $0.01529 $0.01529
Haiku 4.5 $0.00765 $0.00765

Measured 1mo ago against content hash 00ca19f18d78, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

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 1mo 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.

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.

AGENTS.md · 393 lines

How it starts

The opening of the file, as written. The whole thing — 393 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 (use make env-* rather than calling setup.sh directly — 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 in inputs/, rag_storage/, and temp/; deployment collateral lives in docs/, k8s-deploy/, and compose files.

Module Layout (lightrag/)

  • lightrag.py: Main orchestrator class (LightRAG) — assembled from mixins (see LightRAG class composition). Hosts ainsert_custom_kg, _insert_done, _process_extract_entities, _refresh_addon_params_cache, and addon_params accessors. Critical: always call await rag.initialize_storages() after instantiation.
  • pipeline.py: _PipelineMixin — owns the document ingestion pipeline (apipeline_enqueue_documents, apipeline_process_enqueue_documents, apipeline_process_error_documents), the parse_native / parse_mineru / parse_docling parser 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 / ROLES registry 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: ObservableAddonParams plus default_addon_params / normalize_addon_params helpers.
  • 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 in kg/__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.py resolves engine and filename hints for legacy, native, mineru, and docling flows; parser/debug.py provides an offline LightRAG stub for the parser/cli.py debug entry point (python -m lightrag.parser.cli). Native format parsers live as sibling sub-packages under parser/ (currently parser/docx/); external HTTP-based adapters live under parser/external/ (mineru, docling) with shared helpers in parser/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 under routers/, static Swagger assets, packaged WebUI output, and Gunicorn launcher.

Read the full file on GitHub · 393 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. 1mo ago Changed · +5 lines · +462 tokens per session 00ca19f18d78
  2. 1mo ago Changed · +1 lines · +157 tokens per session 65a6ec45ab2e
  3. 1mo ago Changed · +24 lines · +1,100 tokens per session 350ee583b4da
  4. 1mo ago Changed · -14 lines · -101 tokens per session 712c17efb495
  5. 2mo ago Changed · +10 lines · +326 tokens per session f82eb398d861
  6. 2mo ago Changed · -175 lines · -3,898 tokens per session 49cf3b94ef91
  7. 2mo ago Changed · +65 lines · +1,068 tokens per session 986e33f0ad86
  8. 2mo ago Changed · +71 lines · +1,227 tokens per session c0d1845546d6
  9. 2mo ago First seen · 406 lines · 7,305 tokens per session scan A 1f074a3d67f7

Subscribe to this mod's changes

LightRAG AGENTS.md is an instructions file published in the GitHub repository HKUDS/LightRAG (40,557 stars, last pushed yesterday), licensed MIT. It adds 7,646 tokens to every session, about $0.0306 per session on Opus 5.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

LightRAG AGENTS.md compared with instructions from other repositories

LightRAG AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
LightRAG AGENTS.mdHKUDS/LightRAGInstructions file41kyesterdayMITA7,646Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode