Skip to main content

Command Palette

Search for a command to run...

I Built a LeetCode CLI That Tracks Your Solve Time and Saves Solution Versions

Updated
•3 min read•View as Markdown

The Problem

If you've ever grinded LeetCode, you know the pain:

  • Constantly switching between browser and editor

  • No way to track how long problems actually take you

  • Losing your brute-force solution after optimizing

  • No timer to simulate real interview pressure

I solved all of this by building leetcode-cli — a full LeetCode workflow that runs entirely in your terminal.

Demo


What It Does

📋 List and Solve Problems

leetcode list -d medium        # Filter by difficulty
leetcode show 1                # View problem
leetcode pick 1                # Generate solution file
leetcode test 1                # Test locally
leetcode submit 1              # Submit to LeetCode

Files are auto-organized by difficulty and category:

leetcode/
├── Easy/
│   └── Array/
│       └── 1.two-sum.java
└── Medium/
    └── String/
        └── 3.longest-substring.java

⏱️ Interview Timer

Practice under real pressure with difficulty-based defaults:

leetcode timer 1               # Easy: 20min, Medium: 40min, Hard: 60min
leetcode timer 1 -m 30         # Custom: 30 minutes
leetcode timer --stats         # See your solve time history

The timer tracks your times so you can measure improvement over weeks.

📸 Solution Snapshots

Save different approaches and compare them:

leetcode snapshot save 1 "brute-force"
# ... optimize your solution ...
leetcode snapshot save 1 "optimized"
leetcode snapshot diff 1 1 2   # Compare the two
leetcode snapshot restore 1 brute-force  # Go back if needed

Never lose a working solution again.

👥 Collaborative Coding

Practice with a partner using room codes:

# Person 1
leetcode collab host 1         # Creates room: ABC123

# Person 2
leetcode collab join ABC123

# Both solve, then compare
leetcode collab compare

Great for mock interviews with friends.

📁 Workspaces

Keep different contexts separate:

leetcode workspace create interview -w ~/lc-interview
leetcode workspace create daily -w ~/lc-daily
leetcode workspace use interview

Each workspace has its own config, timer history, and snapshots.

🔄 Git Sync

Auto-backup solutions to GitHub:

leetcode config --repo https://github.com/you/leetcode-solutions.git
leetcode sync

Installation

npm install -g @night-slayer18/leetcode-cli

Or with Docker:

docker pull nightslayer/leetcode-cli:latest

Quick Start

leetcode login     # Paste your LeetCode cookies
leetcode daily     # Get today's challenge
leetcode pick 1    # Start solving

Why I Built This

I was tired of:

  1. Opening Chrome just to see the problem

  2. Not knowing if I was getting faster

  3. Losing my first approach after refactoring

Now my entire LeetCode workflow lives in the terminal, and I have data on my improvement.



If this helps your LeetCode grind, give it a ⭐ on GitHub!

What features would you want to see next? Let me know in the comments 👇