# leetcode-cli: a terminal client for LeetCode by skygragon

> skygragon/leetcode-cli drives LeetCode from the shell: browse cached questions, generate a source file, run the sample tests, submit, and pull old submissions back down. It is a Node.js tool aimed at people who would rather stay in the terminal than in a browser tab.

**skygragon/leetcode-cli** — A cli tool to enjoy leetcode!

- Repository: https://github.com/skygragon/leetcode-cli
- Stars: 3,873 · Forks: 459
- Language: JavaScript
- License: MIT
- Published: 2026-09-23 · Updated: 2026-09-23 · Language: en
- Canonical page: https://hysenlabs.com/projects/skygragon-leetcode-cli

## What skygragon/leetcode-cli replaces

The browser workflow for LeetCode has a fixed shape. You find a problem, read it, copy a starter snippet into an editor, paste the solution back, run the sample cases, submit, and wait. Every one of those steps crosses a window boundary, and the editor you actually like is usually on the other side of it.

skygragon/leetcode-cli moves that loop into the shell. The README lists what it does: cache questions for offline thinking, generate source code before coding, test and submit live against leetcode.com, download previous submissions, and track status. The audience is narrow and obvious. It is for people who keep a terminal open, who want their solutions sitting in a local directory under version control, and who find the site's editor incidental to the actual work.

It is not a practice tracker, a spaced-repetition system, or an interview-prep curriculum. It is a client. Everything it shows you comes from leetcode.com, and everything it sends goes back there.

## How the client talks to leetcode.com

Two mechanisms show up in the repository layout. The first is caching. The README points at an advanced page for cache behaviour, and the quick start separates browsing from solving: leetcode list browses all questions, and the cache is what lets you keep reading a problem after the network is gone. That is a deliberate design choice. Problem statements change rarely, so fetching them once and keeping them locally is cheaper than hitting the site on every command.

The second is code generation from templates. The repository has a templates/ directory, and package.json lists templates alongside colors and icons as pkg assets, which means the shipped binary carries them. leetcode show 1 -g -l cpp generates a file for problem 1 in C++, so the template decides the skeleton you start from.

Underneath, the dependency list tells you how the HTTP layer works. The package depends on request 2.88.0 for HTTP and cheerio 0.20.0 for parsing, which is the classic combination for scraping HTML rather than consuming a documented JSON API. That is the structural weakness of the whole design, and it is worth naming plainly: when the site's markup changes, a scraper breaks in ways a typed API client would not. The repository also ships a .lc-completion.bash file for shell completion, and a Dockerfile that builds the tool into an image with /root as a volume, which is how the auto-login-across-agents story in the README is meant to work in practice.

## Installing leetcode-cli and solving one problem

The npm page is the primary distribution channel, and package.json declares the binary as leetcode through bin/leetcode, so a global install puts that command on your PATH. Node 4 or newer is the stated engine requirement, which is low enough that almost any current Node installation satisfies it.

```bash
npm install -g leetcode-cli
leetcode help
```

The README's own advice is to read help first, and that is the right first move here: the command surface is large enough that guessing wastes more time than reading. Next, log in with your LeetCode account. The quick start uses the user command with -l.

```bash
leetcode user -l
```

After that, browse the question list, then pick one and generate a file. The README's example generates a C++ file for problem 1.

```bash
leetcode list
leetcode show 1 -g -l cpp
```

You should end up with a source file in your working directory, pre-filled from the template for that language. Write your solution in it, then run the sample tests. The README passes the test input as a literal string with escaped newlines.

```bash
leetcode test ./two-sum.cpp -t '[3,2,4]\n7'
```

When the tests pass, submit the same file.

```bash
leetcode submit ./two-sum.cpp
```

If you would rather not install Node globally, the Dockerfile builds an image from node:alpine, copies the repository in, runs npm install, and sets /root as a volume with an entrypoint script. The README does not document the image's exact run command, so check the entrypoint before wiring it into anything.

## Where leetcode-cli breaks or stops fitting

The honest limitation is maintenance. The newest release listed is 2.6.2, published on 2019-09-29, and the release before it was 2.6.1 on 2018-12-03. The repository is not archived and the last push was on 2026-03-04, so there is activity, but it has not been cut into a release in years. The version in package.json is still 2.6.2. If you need a tool with a release cadence you can plan around, this is not it.

The second limitation follows from the architecture. A client built on request plus cheerio depends on the site's current HTML. LeetCode can change its login flow or submission endpoint at any time, and the failure mode is not a clean error message; it is a command that returns nothing useful or a session that quietly expires. The related searches around session expiry and login suggest this is the pain people hit. The README does not document rollback or a compatibility policy, so there is no stated contract about how quickly a break gets fixed.

The third is scope. Everything runs through leetcode.com. If you want to practise without an account, or you want a problem set the site does not host, this tool has nothing to offer. It is a client, not a content source.

## How it differs from the VS Code extension route

The obvious alternative for the same job is the LeetCode extension for Visual Studio Code, which the related searches reference directly. The difference is not cosmetic. An editor extension lives inside the editor's process: it gets the editor's language server, its debugger, its test runner integration, and its settings UI for free. You click a problem in a sidebar and a file appears in a workspace.

leetcode-cli takes the opposite position. It assumes the terminal is the interface and the editor is a separate program you launch yourself. That buys portability: the same command works over SSH, inside tmux, in a container built from the project's Dockerfile, or on a machine where you never install an IDE. It also means you get no editor integration at all. There is no debugger hook, no inline test results, no language server. You run leetcode test in one pane and read the output.

There is also a separate Rust implementation that appears in the related searches under the name Clearloop leetcode-cli. That is a different codebase with a different language and dependency set, not a fork of this one. If you find it while searching, do not assume the commands and flags match. The npm package name leetcode-cli belongs to skygragon's JavaScript project.

## Licence position and what upgrading costs

The project is MIT licensed, and the LICENSE file sits at the repository root. For practical purposes that means you can read the source, modify it, and ship it inside your own tooling as long as you keep the copyright notice and the licence text. It does not give you any rights over LeetCode's content, and the tool's whole function is to move that content between the site and your machine, so the interesting question is not the software licence but the site's terms. The README does not discuss that, and this is not legal advice.

Upgrade cost is close to zero in the normal case and high in the abnormal one. Because the published version has been 2.6.2 since 2019, there is no upgrade treadmill. You install it and it stays. The cost arrives when the site changes and the client stops working: at that point your options are to wait for a push, to patch the scraping code yourself, or to switch tools. The dependency list makes patching less pleasant than it sounds. cheerio 0.20.0 and request 2.88.0 are both old, and request in particular has been a known maintenance concern in the wider Node ecosystem for years. A fix may mean more than changing one selector.

## Conclusion

Adopt skygragon/leetcode-cli if you already solve problems in a local editor and want the browser out of the loop; the npm package and the Dockerfile give you two install paths. Skip it if you need a maintained, versioned tool, since the newest release listed is 2.6.2 from 2019-09-29. Before relying on it, run leetcode user -l against your account and check whether login and submission still work, because that is the part that breaks when the site changes.

## FAQ

### How do I use skygragon/leetcode-cli?

Install it globally with npm, run leetcode help, log in with leetcode user -l, then browse with leetcode list and generate a file with leetcode show, for example leetcode show 1 -g -l cpp. Test with leetcode test on the generated file and submit with leetcode submit.

### Is there a leetcode cli?

Yes. skygragon/leetcode-cli is published on npm as leetcode-cli and installs a leetcode command, and the repository also has a Dockerfile that builds the tool into an image. A separate Rust implementation also appears in search results, but it is a different codebase.

### How do I install skygragon/leetcode-cli on Ubuntu?

The npm package is the primary distribution path, so npm install -g leetcode-cli works on any system with Node 4 or newer, and the Dockerfile builds an image from node:alpine if you prefer a container. The README does not list distro-specific packages.

### What happens when the skygragon/leetcode-cli session expires?

The README documents auto login across multiple agents with a single account, but it does not document what happens when a session expires or how to recover from it. Since the client talks to leetcode.com, a stale session shows up as a command that fails rather than a documented error path.

### Is skygragon/leetcode-cli still maintained?

The repository is not archived and the last push was on 2026-03-04, but the newest release listed is 2.6.2 from 2019-09-29 and package.json still declares 2.6.2. There is activity in the repository without a corresponding release.

## Sources

- [Issues](https://github.com/skygragon/leetcode-cli/issues)
- [License: MIT](https://github.com/skygragon/leetcode-cli/blob/master/LICENSE)
- [README](https://github.com/skygragon/leetcode-cli/blob/master/README.md)
- [Releases](https://github.com/skygragon/leetcode-cli/releases)
- [skygragon/leetcode-cli on GitHub](https://github.com/skygragon/leetcode-cli)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/skygragon-leetcode-cli
