Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LightRAG-cli (lg)

A fast, single-binary CLI for LightRAG — query your knowledge graph, manage documents, and explore entities from the terminal.

LightRAG doesn't ship with a native CLI or MCP server, so I built this as a simple way to interact with it from the terminal and from AI agents like Claude Code. Built in Go. Zero runtime dependencies. JSON output by default — friendly to jq, scripts, and AI agents.

Claude Code Skill

This repo includes a Claude Code skill that gives Claude full knowledge of lg commands and usage.

cp -r skills/lg ~/.claude/skills/lg

Once installed, Claude Code will automatically use the skill when you ask about lg commands, LightRAG CLI usage, or managing your knowledge graph from the terminal.

Install

Go install:

go install github.com/AhmedAburady/LightRAG-cli/cmd/lg@latest

From releases:

Download the binary for your platform from Releases, rename to lg, and place on your PATH.

Platform Binary
macOS (Apple Silicon) lg-darwin-arm64
macOS (Intel) lg-darwin-amd64
Linux (x86_64) lg-linux-amd64
Linux (ARM) lg-linux-arm64
Windows lg-windows-amd64.exe

From source:

git clone https://github.com/AhmedAburady/LightRAG-cli.git
cd LightRAG-cli
go install ./cmd/lg/

Setup

lg config set-host https://your-lightrag-server.com
lg config set-key your-api-key    # optional, only if auth is enabled
lg config show

Config is stored at ~/.config/lg/config.json.

Commands

lg query — Query the knowledge graph

lg query "what are the main entities in the knowledge graph?"
lg query "explain the relationship between X and Y" -m local
lg query "summarize everything" --stream
lg query "find connections to X" --context             # retrieved context only, no LLM
lg query "detailed analysis" -m hybrid -e 30 -c 15
Flag Description Default
-m, --mode Search strategy: mix, local, global, hybrid, naive mix
-e, --entities How many entities/relations to pull from the graph 10
-c, --chunks How many text passages to pull from vector search 5
-s, --stream Stream the response as it generates false
--context Return only retrieved context, skip LLM generation false
--data Return full raw retrieval data as JSON false
--max-tokens Hard cap on total context tokens sent to LLM server default
--format Response format: "Single Paragraph", "Bullet Points", etc. -

lg doc — Document management

lg doc upload report.pdf                   # upload a file
lg doc upload *.txt                        # upload multiple files
lg doc insert "some text to index"         # insert text directly
lg doc insert "text" --desc "my notes"     # with description
lg doc insert-batch texts.json             # batch insert from JSON array of strings
lg doc scan                                # scan input directory for new files
lg doc list                                # list documents
lg doc list --status processing            # filter by status
lg doc list --page 2 --limit 10            # paginate
lg doc status                              # status counts
lg doc pipeline                            # pipeline processing status
lg doc track <track_id>                    # track specific document
lg doc delete <doc_id>                     # delete a document
lg doc reprocess-failed                    # retry failed documents
lg doc cancel                              # cancel pipeline
lg doc clear-cache                         # clear LLM cache
lg doc clear-all --confirm                 # delete everything (requires --confirm)

lg graph — Knowledge graph operations

Browse:

lg graph labels                            # list all labels
lg graph popular                           # most connected labels
lg graph search "machine learning"         # search labels
lg graph show                              # show graph data
lg graph show --label Person --limit 50    # filter and limit

Entities:

lg graph entity exists "OpenAI"
lg graph entity create "NewEntity" --desc "description here"
lg graph entity edit "Entity" --desc "updated description"
lg graph entity delete "OldEntity"
lg graph entity merge "Duplicate" "Canonical"

Relations:

lg graph relation create "EntityA" "EntityB" --desc "works with"
lg graph relation edit "EntityA" "EntityB" --desc "updated relation"
lg graph relation delete "EntityA" "EntityB"

lg health — Server status

lg health

Returns server status, version, pipeline state, LLM/embedding config, and storage backends.

lg config — CLI configuration

lg config show                             # show current config
lg config set-host <url>                   # set server URL
lg config set-key <api_key>                # set API key

Output

All commands output pretty-printed JSON by default. Use --json for compact JSON — ideal for piping and scripting:

lg doc status --json | jq '.status_counts.processing'
lg health --json | jq '.configuration.llm_model'
lg graph labels --json | jq '.[0]'

Architecture

cmd/lg/           Entry point
cmd/              Cobra command definitions
internal/client/  HTTP client wrapping LightRAG REST API
internal/config/  Config file management (~/.config/lg/)

Single dependency: cobra for CLI routing.

License

MIT

About

A fast CLI for [LightRAG](https://github.com/HKUDS/LightRAG) — query your knowledge graph, manage documents, and explore entities from the terminal.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages