A CLI tool that generates random LeetCode problems with skeleton code in your preferred programming language.
- Interactive topic selection (Arrays, Linked Lists, Graphs, Trees, Tries, DP, etc.)
- Multiple programming language support (Rust, Python, JavaScript, Java, C++, Go, TypeScript)
- AI-generated problems with proper skeleton code and test cases
- Automatic file creation in
problems/
directory - Customizable AI models for different speed/quality preferences
- Command line interface with help and options
-
Get a Gemini API key from Google AI Studio
-
Build and run:
cargo build --release
cargo run
The tool will ask for your Gemini API key on first run and save it securely in ~/.leetcli_api_key
for future use.
You can also set it as an environment variable to skip the prompt entirely:
export GEMINI_API_KEY="your-api-key-here"
leetcli
On first run, you'll be prompted to select a default difficulty level which will be saved for future use.
leetcli -d
Shows a dropdown menu to select difficulty level and updates your saved preference.
leetcli --difficulty hard
leetcli -d easy
Sets difficulty directly and updates your saved preference.
leetcli --model gemini-1.5-pro-latest --difficulty hard
leetcli -m gemini-2.0-flash-exp -d easy
leetcli --list-models
leetcli --list-difficulties
leetcli --help
-
gemini-2.5-flash-lite
(default) - Fastest model, good for quick problem generation -
gemini-2.0-flash-exp
- Experimental fast model with latest features -
gemini-1.5-flash-latest
- Stable fast model, reliable performance -
gemini-1.5-pro-latest
- More capable but slower, better for complex problems -
gemini-pro
- Older stable model
-
easy
- Simple problems with basic algorithms and data structures -
medium
- Moderate complexity with common algorithms -
hard
- Complex problems with advanced algorithms and optimization
The tool saves your preferences locally:
-
API Key:
~/.leetcli_api_key
-
Difficulty:
~/.leetcli_difficulty
Preferences are automatically updated when you use command line arguments.
The tool checks for your API key in this order:
-
GEMINI_API_KEY
environment variable - Saved key file (
~/.leetcli_api_key
) - Interactive prompt (saves for future use)
$ leetcli
>> LeetCli - Generate LeetCode Problems
[!] No difficulty preference found
? Select default difficulty level: › medium
[+] Difficulty preference saved: medium
Using model: gemini-2.5-flash-lite
Difficulty: medium
[✓] Using saved Gemini API key
? Select a topic: › Arrays
? Select programming language: › Rust
Generating Arrays problem for Rust...
[✓] Problem generated: problems/two_sum.rs
$ leetcli
>> LeetCli - Generate LeetCode Problems
Using model: gemini-2.5-flash-lite
Difficulty: medium
[✓] Using saved Gemini API key
? Select a topic: › Dynamic Programming
? Select programming language: › Python
Generating Dynamic Programming problem for Python...
[✓] Problem generated: problems/coin_change.py
$ leetcli -d
>> LeetCli - Generate LeetCode Problems
? Select difficulty level: › hard
[+] Difficulty preference saved: hard
Using model: gemini-2.5-flash-lite
Difficulty: hard
Generated files include:
- Complete problem description with examples
- Code skeleton with proper function signatures
- Test cases to verify your implementation
- All necessary imports and boilerplate
leetcli [OPTIONS]
Options:
-m, --model <MODEL> Gemini model to use [default: gemini-2.5-flash-lite]
-d, --difficulty [LEVEL] Problem difficulty level (interactive if no value)
--list-models Show available models
--list-difficulties Show available difficulty levels
-h, --help Print help
-V, --version Print version
# Generate problem with saved preferences
leetcli
# First time setup - will ask for difficulty preference
leetcli # Shows difficulty selection dropdown
# Interactive difficulty selection
leetcli -d # Shows dropdown to select and save new difficulty
# Direct difficulty setting
leetcli -d easy # Sets to easy and saves preference
leetcli --difficulty hard # Sets to hard and saves preference
# Generate easy problem with fast model
leetcli -d easy -m gemini-2.5-flash-lite
# Generate hard problem with pro model
leetcli --difficulty hard --model gemini-1.5-pro-latest
# List all available options
leetcli --list-models
leetcli --list-difficulties