LeetCode's search bar is useless.
Stop worrying about what to practice, just open LeetRAG in your terminal like Claude Code, except it has all of the LeetCode problems and learns from your history.
leetrag_demo.mp4
Watch it on YouTube.
1. Install Go
brew install go # mac
sudo apt install go # ubuntu/debianor go.dev/dl.
2. Clone and build
git clone https://github.com/rickytang666/leetrag
cd leetrag
go build -o leetrag .3. API key
Sign up at openrouter.ai and create a key for LLM, embeddings, and hints.
4. Config
./leetrag configFollow the prompts to set your OpenRouter API key (required) and LeetCode session token (optional, enables personal history).
To get your LeetCode session token: log into leetcode.com, DevTools > Application > Cookies, copy LEETCODE_SESSION.
5. Ingest
./leetrag ingestScrapes problems, (optionally) generates retrieval hints, and embeds them.
First run takes time; subsequent runs are incremental.
To reset from scratch:
./leetrag ingest --resetNote
By default, ingest asks if you want to generate "approach hints"—short algorithmic cues for every problem to improve semantic retrieval. These take a very long time:
- Free tier model: ~15-20s hours to finish
- Paid tier model: ~2-3 hours to finish
Hints are optional and not perfect (they only bridge keyword gaps in retrieval). Skip if you just want to start; generate later with ./leetrag hint.
Advanced: Run individual pipeline steps
./leetrag scrape # scrape problems
./leetrag hint # generate hints
./leetrag embed # embed into vector storeEach step is resumable. Use --reset to wipe and restart a step.
./leetrag chatChat naturally:
> i keep failing sliding window, what should i practice?
> what's the difference between #3 and #76?
> give me a hard graph problem i haven't solved
> just solved #207
Keyboard Shortcuts:
Ctrl+C: ExitESC(while thinking): Cancel requestESCtwice: Clear input
Slash Commands:
Type / to see available:
/clear: Clear conversation/history: Show solve/attempt counts/refresh: Refetch LeetCode history/debug: Show retrieved context + rewritten query/exit: Exit
Warning
If you see "session expired" when running /refresh command in the chat, re-copy the LEETCODE_SESSION cookie and update your config.
- Premium problems are labeled
[premium]: need premium LeetCode account - History is cached 6 hours; use
/refreshto force update
Go, Cobra, Bubbletea, Lipgloss, Glamour, SQLite, chromem-go, OpenRouter.