agentleFS
RoentekRoentek/Claude_Code_Boilerplate_Framework/.claude/skills/lightrag/SKILL.md

lightrag

Skill4 starsChanged 6 months agoMITView on GitHub

Graph-based RAG system for knowledge extraction and Q&A

  • Reads credentials
  • Deletes or force-pushes
  • Sends data out

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Add one of these to .env:

    line 28

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

LightRAG — Fast Graph-Based RAG

LightRAG is a graph-based Retrieval-Augmented Generation system that extracts knowledge graphs from documents for entity-relationship-aware Q&A. Outperforms naive RAG, HyDE, and GraphRAG across multiple domains.

Use when: Building document Q&A systems, knowledge bases, semantic search with graph relationships, or multimodal RAG (PDFs, images, tables).

Source: github.com/HKUDS/LightRAG (EMNLP 2025, 13K+ stars)


Setup Workflow

1. Install Dependencies

cd tools/lightrag-plus
uv sync

Installs lightrag-hku and dependencies in isolated venv.

2. Configure LLM Provider

Add one of these to .env:

# OpenAI
OPENAI_API_KEY=sk-...

# Claude
ANTHROPIC_API_KEY=sk-ant-...

# Gemini
GEMINI_API_KEY=...

# Ollama (local)
OLLAMA_HOST=http://localhost:11434

3. Choose Storage Backend

Default (nano-vectordb) — no setup, good for prototyping:

rag = LightRAG(working_dir="./rag_storage")

Neo4J — advanced graph queries:

# Add to .env
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=...

MongoDB — unified storage:

# Add to .env
MONGODB_URI=mongodb://localhost:27017

PostgreSQL — SQL-based queries:

# Add to .env
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_USER=...
POSTGRES_PASSWORD=...
POSTGRES_DB=lightrag

Usage Patterns

Pattern 1: Core Library (Embedded)

Insert documents:

from lightrag import LightRAG, QueryParam
from lightrag.llm import openai_complete_if_cache, openai_embedding

rag = LightRAG(
    working_dir="./rag_storage",
    llm_model_func=openai_complete_if_cache,
    embedding_func=openai_embedding
)

# Insert
with open("document.txt") as f:
    rag.insert(f.read())

Query:

# Modes: naive, local, global, hybrid, mix
result = rag.query(
    "What is the main topic?",
    param=QueryParam(mode="hybrid")
)
print(result)

Pattern 2: Server Mode (Recommended for Production)

Start server:

cd tools/lightrag-plus
python -m lightrag.server --port 9621 --working-dir ./rag_storage

Query via REST API:

# Insert document
curl -X POST http://localhost:9621/insert \
  -H "Content-Type: application/json" \
  -d '{"text": "Your document text here"}'

# Query
curl -X POST http://localhost:9621/query \
  -H "Content-Type: application/json" \
  -d '{"query": "What is...?", "mode": "hybrid"}'

Web UI: http://localhost:9621 — knowledge graph visualization, node queries, subgraph filtering


Query Modes

ModeWhen to Use
naiveBaseline retrieval without graph context
localLocal entity-based retrieval (fast)
globalCommunity-based global retrieval
hybridCombines local + global (best for broad queries)
mixUses reranker — best performance when reranker is configured

Default: hybrid (no reranker) or mix (with reranker)


LLM/Embedding Configuration

LLM Requirements

  • Minimum: 32B params, 32KB context
  • Recommended: 64KB context
  • Indexing: Non-reasoning models (faster)
  • Query: Stronger models than indexing for best results

Embedding Model

  • Recommended: BAAI/bge-m3, text-embedding-3-large
  • Critical: Same model for indexing AND querying
  • Dimension lock: PostgreSQL requires dimension at table creation — changing models = drop tables and recreate

Reranker (Optional)

  • Boosts performance significantly when enabled with mode="mix"
  • Recommended: BAAI/bge-reranker-v2-m3, Jina reranker API

LLM Provider Examples

OpenAI:

from lightrag.llm import openai_complete_if_cache, openai_embedding

rag = LightRAG(
    working_dir="./rag_storage",
    llm_model_func=openai_complete_if_cache,
    embedding_func=openai_embedding
)

Claude (Anthropic):

from lightrag.llm import anthropic_complete, openai_embedding  # use OpenAI for embeddings

rag = LightRAG(
    working_dir="./rag_storage",
    llm_model_func=anthropic_complete,
    embedding_func=openai_embedding
)

Ollama (Local):

from lightrag.llm import ollama_model_complete, ollama_embedding

rag = LightRAG(
    working_dir="./rag_storage",
    llm_model_func=ollama_model_complete,
    llm_model_name="llama3.2:latest",
    embedding_func=ollama_embedding,
    embedding_model_name="nomic-embed-text"
)

Gemini:

from lightrag.llm import gemini_complete, openai_embedding

rag = LightRAG(
    working_dir="./rag_storage",
    llm_model_func=gemini_complete,
    embedding_func=openai_embedding
)

Advanced Features

  • Token tracking — rag.token_usage()
  • Export KG data — rag.export_knowledge_graph()
  • LLM cache — kv_store_llm_response_cache.json in working_dir
  • Delete documents — rag.delete_document(doc_id) with auto KG regeneration
  • Langfuse tracing — observability integration
  • RAGAS evaluation — measure retrieval quality
  • Multimodal RAG — integrate with RAG-Anything for PDFs, images, tables

Full docs: docs/AdvancedFeatures.md


File Structure

tools/lightrag-plus/
  pyproject.toml        ← Dependencies (lightrag-hku)
  README.md             ← Full documentation
  uv.lock               ← Dependency lock file
  .gitignore            ← Excludes .venv, rag_storage, build artifacts
  .venv/                ← Virtual environment (gitignored, recreated by `uv sync`)
  rag_storage/          ← Working directory (gitignored, auto-created on first use)

Commands

# Install
cd tools/lightrag-plus && uv sync

# Start server
cd tools/lightrag-plus && python -m lightrag.server --port 9621 --working-dir ./rag_storage

# Test insert/query via Python
cd tools/lightrag-plus && uv run python -c "
from lightrag import LightRAG, QueryParam
rag = LightRAG(working_dir='./rag_storage')
rag.insert('The capital of France is Paris.')
print(rag.query('What is the capital of France?', param=QueryParam(mode='naive')))
"

Platform Support

  • Windows: Full support (requires Python 3.10+)
  • macOS: Full support
  • Linux: Full support

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.