npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@night-slayer18/leetcode-cli

v1.5.0

Published

A modern LeetCode CLI built with TypeScript

Readme

leetcode-cli

A modern, feature-rich LeetCode CLI built with TypeScript.

CI npm version License

Features

  • 🔐 Cookie-based authentication - Secure login using browser cookies
  • 📋 List problems - Filter by difficulty, status, tags, and search
  • 📖 Beautiful problem display - Formatted output with examples and constraints
  • 📝 Generate solution files - Auto-organized by difficulty and category
  • 🧪 Test solutions - Run against sample test cases
  • 📤 Submit solutions - Submit directly to LeetCode
  • 📊 View statistics - Track your progress
  • 🎯 Daily challenge - Get today's problem
  • ⚙️ Configurable - Set language, editor, and working directory
  • 📂 Smart file discovery - Use problem ID, filename, or full path
  • 🔄 Git Sync - Auto-sync solutions to GitHub/GitLab

📚 Documentation

View Full Documentation →

Installation

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

Quick Start

# Login with your LeetCode cookies
leetcode login

# Get today's daily challenge
leetcode daily

# Pick a problem and generate solution file
leetcode pick 1

# Test your solution (any format works!)
leetcode test 1                              # Problem ID
leetcode test 1.two-sum.java                 # Filename
leetcode test ./Easy/Array/1.two-sum.java   # Full path

# Submit your solution
leetcode submit 1

Commands

| Command | Description | |---------|-------------| | login | Login with LeetCode browser cookies | | logout | Clear stored credentials | | whoami | Check login status | | today | Show daily progress & challenge | | list | List problems with filters | | show <id> | Display problem description | | pick <id> | Generate solution file | | pick-batch <ids> | Pick multiple problems | | bookmark <action> | Manage problem bookmarks | | note <id> | Manage problem notes | | daily | Show today's challenge | | random | Get a random problem | | test <id\|file> | Test solution against sample cases | | submit <id\|file> | Submit solution to LeetCode | | submissions <id> | View past submissions | | stat [username] | Show user statistics | | timer <id> | Interview mode with timer | | config | View or set configuration | | sync | Sync solutions to Git repository |

Usage Examples

List Problems

# List all problems
leetcode list

# Filter by difficulty
leetcode list -d easy
leetcode list -d medium
leetcode list -d hard

# Pagination
leetcode list --page 2 -n 10

# Search by keyword
leetcode list -s "binary tree"

Show Problem

leetcode show 1
leetcode show two-sum

Pick Problem

# Generate solution file (uses default language)
leetcode pick 1

# Specify language
leetcode pick 1 --lang python3

# Skip opening in editor
leetcode pick 1 --no-open

Test & Submit

All formats work for both test and submit:

# Using problem ID (auto-finds the file)
leetcode test 20
leetcode submit 20

# Using filename
leetcode test 20.valid-parentheses.java
leetcode submit 20.valid-parentheses.java

# Using full path
leetcode test ./Easy/String/20.valid-parentheses.java

# With custom test case
leetcode test 20 -c "[1,2,3]\n4"

Random Problem

Fetch and solve a random problem.

# Get random problem
leetcode random

# Filter by difficulty
leetcode random -d hard

# Filter by topic tag
leetcode random -t dp

# Pick immediately
leetcode random -d medium --pick

View & Download Submissions

View past submissions and download code.

# List last 20 submissions
leetcode submissions 1

# View details of last accepted submission
leetcode submissions 1 --last

# Download last accepted solution
leetcode submissions 1 --download

Productivity Features

# Show today's progress & challenge
leetcode today

# Pick multiple problems at once
leetcode pick-batch 1 2 3 -l python3

# Bookmark problems
leetcode bookmark add 1
leetcode bookmark list

# Keep personal notes
leetcode note 1 edit

User Statistics

# Basic stats (solved count, rank, streak)
leetcode stat

# Weekly activity table (last 12 weeks)
leetcode stat -c

# Skill breakdown by topic tags
leetcode stat -s

# 7-day trend chart
leetcode stat -t

Git Integration

# Sync all solutions to your configured git repo
leetcode sync

Interview Timer

# Start timer for a problem (default: Easy=20m, Medium=40m, Hard=60m)
leetcode timer 1

# Custom time limit
leetcode timer 1 -m 30

# View your solve time stats
leetcode timer --stats

# Stop active timer
leetcode timer --stop

Configuration

# View current config
leetcode config

# Interactive setup
leetcode config -i

# Set specific options
leetcode config --lang python3
leetcode config --editor code
leetcode config --workdir ~/leetcode
leetcode config --repo https://github.com/username/leetcode-solutions.git

Folder Structure

Solution files are automatically organized by difficulty and category:

leetcode/
├── Easy/
│   ├── Array/
│   │   └── 1.two-sum.java
│   └── String/
│       └── 20.valid-parentheses.java
├── Medium/
│   └── Array/
│       └── 15.3sum.java
└── Hard/
    └── Array/
        └── 4.median-of-two-sorted-arrays.java

Supported Languages

| Language | Extension | |----------|-----------| | TypeScript | .ts | | JavaScript | .js | | Python3 | .py | | Java | .java | | C++ | .cpp | | C | .c | | C# | .cs | | Go | .go | | Rust | .rs | | Kotlin | .kt | | Swift | .swift |

Authentication

This CLI uses cookie-based authentication. To login:

  1. Open leetcode.com in your browser
  2. Login to your account
  3. Open DevTools (F12) → Application → Cookies → leetcode.com
  4. Run leetcode login and paste your LEETCODE_SESSION and csrftoken values

Configuration File

Config is stored at ~/.leetcode/config.json:

{
  "credentials": {
    "session": "...",
    "csrfToken": "..."
  },
  "config": {
    "language": "java",
    "editor": "code",
    "workDir": "/path/to/leetcode",
    "repo": "https://github.com/username/leetcode-solutions.git"
  }
}

Requirements

  • Node.js >= 20.0.0

Docker Usage

You can run the CLI using Docker without installing Node.js.

Method 1: Pre-built Image (Recommended)

  1. Pull the image:

    docker pull nightslayer/leetcode-cli:latest
  2. Setup Shell Function (Add to your shell config):

    Bash/Zsh (~/.bashrc or ~/.zshrc):

    leetcode() {
      docker run -it --rm \
        -w /root/leetcode \
        -v "$(pwd)/leetcode:/root/leetcode" \
        -v "$HOME/.leetcode:/root/.leetcode" \
        nightslayer/leetcode-cli:latest "$@"
    }

    Fish (~/.config/fish/config.fish):

    function leetcode
        docker run -it --rm \
            -w /root/leetcode \
            -v (pwd)/leetcode:/root/leetcode \
            -v $HOME/.leetcode:/root/.leetcode \
            nightslayer/leetcode-cli:latest $argv
    end

    PowerShell ($PROFILE):

    function leetcode {
      docker run -it --rm `
        -w /root/leetcode `
        -v "${PWD}/leetcode:/root/leetcode" `
        -v "$env:USERPROFILE/.leetcode:/root/.leetcode" `
        nightslayer/leetcode-cli:latest $args
    }
  3. Usage:

    leetcode list
    leetcode pick 1

Method 2: Build Locally

  1. Build the image:

    docker build -t leetcode-cli .
  2. Run commands:

    docker run -it --rm \
      -w /root/leetcode \
      -v "$(pwd)/leetcode:/root/leetcode" \
      -v "$HOME/.leetcode:/root/.leetcode" \
      leetcode-cli list

    Note: We mount ~/.leetcode to persist login credentials and leetcode folder to save solution files.

License

Apache-2.0 © night-slayer18