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

---

## 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](https://github.com/night-slayer18/leetcode-cli/raw/main/docs/demo.gif align="left")

---

## What It Does

### 📋 List and Solve Problems

```bash
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:

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

### ⏱️ Interview Timer

Practice under real pressure with difficulty-based defaults:

```bash
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:

```bash
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:

```bash
# 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:

```bash
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:

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

---

## Installation

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

Or with Docker:

```bash
docker pull nightslayer/leetcode-cli:latest
```

## Quick Start

```bash
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.

---

## Links

* **GitHub:** [night-slayer18/leetcode-cli](https://github.com/night-slayer18/leetcode-cli)
    
* **npm:** [@night-slayer18/leetcode-cli](https://www.npmjs.com/package/@night-slayer18/leetcode-cli)
    
* **Docs:** [night-slayer18.github.io/leetcode-cli](http://night-slayer18.github.io/leetcode-cli)
    

---

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 👇
