Developers like me, who live in the terminal and use Neovim faced constant context-switching friction when practicing on LeetCode. I had to repeatedly bounce between a web browser (reading problem statements, copying code stubs, checking test outputs) and their local terminal/editor. leetrs was created to bring the entire LeetCode lifecycle—problem searching, problem fetching, editing, local testing, and official judging submission—natively into the terminal
Overview
A Rust-powered CLI and TUI for solving LeetCode problems in the terminal
leetrs is a blazing-fast, Rust-powered CLI and engine designed to make solving LeetCode problems from the terminal a first-class developer experience.
From the maintainer
1. **Authenticate**: Run `leetrs auth` to automatically extract your active LeetCode session cookies from **Chrome** or **Firefox**. 2. **Browse in TUI**: Run `leetrs tui` (or simply `leetrs`) to open the interactive problem browser: - Press `/` to fuzzy-search for a problem (e.g. `two-sum` or `1`). - Press `1`, `2`, or `3` to filter by **Easy**, **Medium**, or **Hard** difficulty. - Press `Enter` on a selected problem. 3. **Solve in Neovim**: `leetrs` generates `two_sum.md` (description) and `two_sum.rs` / `two_sum.py` (code stub) and automatically launches Neovim in vertical split (`vsplit`) view. 4. **Test & Submit**: Save your solution, then run: ```bash leetrs test two_sum.rs # Test sample testcases locally leetrs submit two_sum.rs # Submit to LeetCode judging servers ```
1. **Native Neovim `vsplit` Orchestration**: Rather than building a basic code editor widget into the TUI (which would lack LSP integration, custom keymaps, and personal plugins), `leetrs` executes `nvim <desc>.md -c "vsplit <code>.<ext>"`. This opens a 50/50 vertical split inside your existing terminal editor environment. 2. **Seamless Cookie Extraction**: Uses the Rust `rookie` crate to decrypt active `LEETCODE_SESSION` and `csrftoken` cookies straight from your local Chrome or Firefox SQLite stores, bypassing Cloudflare bot-protection without requiring extra browser extensions. 3. **Sub-10ms Local Caching**: Problem summaries, solved statuses (`ACCEPTANCE`), and topic tags are cached locally in `~/.local/share/leetrs/data.json`, allowing instantaneous TUI startup without waiting for network requests.
1. **Expanding Full Language Support**: Currently, **Python 3** (`python3`) and **Rust** (`rust`) are fully tested and supported. Expanding comprehensive test suites and stub generation for C++, Java, Go, Pandas, MySQL, and PostgreSQL is next. 2. **API & CLI Stabilization**: Transitioning out of Beta status to stabilize subcommands, flags, and configuration schemas. 3. **Enhanced TUI Customization**: Expanding theme customizability, offline reading modes, and tag filtering features.
Latest Release
Install leetrs 1.1.0
Install prebuilt binaries via shell script
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/shadowmkj/leetrs/releases/download/v1.1.0/leetrs-installer.sh | sh
Install prebuilt binaries via Homebrew
brew install shadowmkj/tap/leetrs
Download leetrs 1.1.0
| File | Platform | Checksum |
|---|---|---|
| leetrs-aarch64-apple-darwin.tar.xz | Apple Silicon macOS | checksum |
| leetrs-x86_64-apple-darwin.tar.xz | Intel macOS | checksum |
| leetrs-x86_64-pc-windows-msvc.zip | x64 Windows | checksum |
| leetrs-aarch64-unknown-linux-gnu.tar.xz | ARM64 Linux | checksum |
| leetrs-x86_64-unknown-linux-gnu.tar.xz | x64 Linux | checksum |
Discussions