leetkick
Version:
A CLI tool for scaffolding LeetCode exercises with language-specific testing setups
241 lines (179 loc) ⢠9.86 kB
Markdown
# LeetKick
A modern CLI tool for scaffolding LeetCode exercises with language-specific testing setups. Fetch problems, auto-generate boilerplate, and start coding immediately!
> **š§ Heads up!**
> LeetKick is still pretty new and changing fast. Things might break between updates as I add support for more programming languages. Once it hits v1.0, it'll be much more stable!
## Features
- **Fetch problems directly from LeetCode** - no copy/paste needed
- **Auto-scaffolding** - solution + test files generated instantly
- **Clean organization** - problems organized by language and number
- **Zero-config testing** - just run `leetkick test` from anywhere
- **Smart problem matching** - run tests by number, slug, or name
- **Multi-language support** - 8 languages supported, 10+ planned (goal: all LeetCode languages)
## Quick Start
```bash
# Setup once
leetkick init my-practice && cd my-practice
leetkick add python # or typescript, javascript, go, rust, kotlin, java, cpp
# Use daily
leetkick fetch two-sum --language python # Auto-generates solution + test files
leetkick test two-sum --language python # Run tests instantly
```
**What you get:** Ready-to-code files with problem description, starter code, and test setup. No configuration needed!
## Installation
**Prerequisites:** Node.js 18+
```bash
# Install from npm (recommended)
npm install -g leetkick
# Or build from source
git clone https://github.com/charliesbot/leetkick.git
cd leetkick && npm install && npm run compile && npm link
# Verify installation
leetkick --help
```
## Language Support
Our goal is to support all languages that LeetCode offers. Here's our current progress:
| Language | Status | Testing Framework | Formatter | Linter | Notes |
| -------------- | ---------------- | ----------------- | ------------ | ------ | ------------------------------- |
| **TypeScript** | ā
**Supported** | Vitest | Biome | Biome | Full support with type checking |
| **C++** | ā
**Supported** | Catch2 (bundled) | clang-format | ā | C++17 standard |
| **Kotlin** | ā
**Supported** | JUnit 5 + Gradle | ā | ā | Full Gradle integration |
| **Java** | ā
**Supported** | JUnit 5 + Gradle | ā | ā | Full Gradle integration |
| **Go** | ā
**Supported** | Built-in testing | ā | ā | Go 1.21+ with modules |
| **Rust** | ā
**Supported** | cargo test | ā | ā | Rust 2021 edition |
| **Python** | ā
**Supported** | pytest | ruff | ruff | Python 3.8+ with modern tooling |
| **JavaScript** | ā
**Supported** | Vitest | Biome | Biome | ES Modules with modern tooling |
| **C** | š§ **Planned** | ā | ā | ā | Coming soon |
| **C#** | š§ **Planned** | ā | ā | ā | Coming soon |
| **Ruby** | š§ **Planned** | ā | ā | ā | Coming soon |
| **Swift** | š§ **Planned** | ā | ā | ā | Coming soon |
| **Scala** | š§ **Planned** | ā | ā | ā | Coming soon |
| **PHP** | š§ **Planned** | ā | ā | ā | Coming soon |
| **Dart** | š§ **Planned** | ā | ā | ā | Coming soon |
**Legend:**
- ā
**Supported** - Full integration with templates, testing, and tooling
- š§ **Planned** - On our roadmap, contributions welcome!
Each supported language workspace includes setup instructions, prerequisites, and testing guides in its own README.
## Command Reference
| Command | Purpose | Example |
| ----------------------------------- | -------------------- | ---------------------------------------------- |
| `init [dir]` | Create workspace | `leetkick init my-practice` |
| `add <lang>` | Add language support | `leetkick add javascript` |
| `fetch <problem> --language <lang>` | Get LeetCode problem | `leetkick fetch two-sum --language javascript` |
| `test <problem> --language <lang>` | Run tests | `leetkick test 1 --language javascript` |
| `sync [lang]` | Update config files | `leetkick sync --all --dry-run` |
| `help [cmd]` | Show help | `leetkick help fetch` |
### Advanced Features
**Smart Problem Matching**
```bash
leetkick test 1 --language javascript # By number
leetkick test two-sum --language javascript # By slug
leetkick test problem_0001 --language javascript # By exact directory name
```
**Workspace Sync**
```bash
leetkick sync typescript # Sync specific language
leetkick sync --all # Sync all languages
leetkick sync --dry-run # Preview changes only
```
**Works Anywhere:** Run commands from any directory in your workspace
**Safe Overwrites:** CLI warns before overwriting existing solutions. Use `--force` to override
**Shortcuts:** Use `-l` instead of `--language`, `-f` instead of `--force`
## Project Structure
After using the CLI, your project will be organized by language:
```
your-project/
āāā .leetkick.json # Workspace configuration
āāā typescript/ # TypeScript workspace
ā āāā problem_0001/
ā ā āāā TwoSum.ts # Your solution
ā ā āāā TwoSum.test.ts # Test cases
ā āāā problem_0704/
ā āāā BinarySearch.ts
ā āāā BinarySearch.test.ts
āāā cpp/ # C++ workspace
ā āāā problem_0001/
ā ā āāā two_sum.cpp # Your solution
ā ā āāā two_sum.test.cpp # Test cases
ā āāā catch_amalgamated.hpp # Bundled testing framework
āāā kotlin/ # Kotlin workspace
ā āāā src/main/kotlin/ # Solutions
ā ā āāā problem0001/TwoSum.kt
ā āāā src/test/kotlin/ # Tests
ā ā āāā problem0001/TwoSumTest.kt
ā āāā build.gradle.kts # Gradle configuration
āāā go/ # Go workspace
ā āāā go.mod # Module definition
ā āāā problem_0001/ # Each problem is its own package
ā ā āāā solution.go # Solution
ā ā āāā solution_test.go # Tests
ā āāā problem_0704/
ā āāā solution.go
ā āāā solution_test.go
āāā python/ # Python workspace
ā āāā src/ # Source code
ā ā āāā problem_0001/
ā ā ā āāā two_sum.py # Your solution
ā ā āāā problem_0704/
ā ā āāā binary_search.py
ā āāā tests/ # Tests
ā ā āāā problem_0001/
ā ā ā āāā test_two_sum.py
ā ā āāā problem_0704/
ā ā āāā test_binary_search.py
ā āāā requirements.txt # Dependencies
ā āāā pyproject.toml # Configuration
āāā ...
```
Each language workspace includes all necessary configuration files, testing frameworks, and formatting rules.
## What You Get
Each problem generates solution and test files with:
- Problem description and difficulty
- LeetCode starter code
- Test framework setup ready to use
- Language-specific project structure
**Workflow:** Implement solution ā Add test cases ā Run `leetkick test` ā Success!
## Troubleshooting
**Installation Issues:**
- Ensure Node.js 18+ is installed: `node --version`
- Clear npm cache: `npm cache clean --force`
- Use `npm install -g leetkick --force` to reinstall
**Command Issues:**
- Run `leetkick --help` to verify installation
- Check you're in a leetkick workspace (contains `.leetkick.json`)
- Use full problem names if short names don't work
**Language Issues:**
- Check language-specific README for setup instructions and prerequisites
- Ensure required compilers/runtimes are installed
**Update LeetKick:**
```bash
npm update -g leetkick
leetkick --version
```
---
## Contributing
We'd love your contributions! Here's how to help:
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/awesome-feature`
3. Make your changes following the existing code style
4. Run tests: `npm test` and linting: `npm run lint`
5. Submit a pull request
### Development Setup
```bash
git clone https://github.com/charliesbot/leetkick.git
cd leetkick && npm install && npm run compile && npm link
```
**Commands:** `npm run compile` (build) | `npm test` (test) | `npm run lint` (style check)
### Adding New Language Support
Add new language templates easily:
1. Create `templates/<language>/` directory
2. Add `exercise_template.*` and `test_template.*` files with placeholders
3. Include config files (package.json, requirements.txt, etc.)
4. CLI automatically discovers new languages!
**Template placeholders:** `__PROBLEM_ID__`, `__PROBLEM_TITLE__`, `__PROBLEM_DESC__`, `__PROBLEM_DEFAULT_CODE__`, etc.
See existing templates in `templates/` for examples.
## License
MIT
## Acknowledgments
- Built with [Google TypeScript Style (gts)](https://github.com/google/gts)
- Uses LeetCode's GraphQL API for problem fetching
---