CLI tool to sync LeetCode submissions into structured Git repository
Project description
๐ leetcode-sync-cli
A powerful CLI tool to automatically sync your LeetCode submissions into a clean, structured GitHub repository โ with versioning, difficulty grouping, dashboard generation, and optional auto-sync via GitHub Actions.
โจ Features
- ๐ Secure credential handling (persistent session storage)
- โ Credential validation before syncing
- ๐ Automatic re-authentication if session expires
- ๐ Organizes problems by difficulty (Easy / Medium / Hard)
- ๐ง Keeps only latest submission per language
- โก Caches problem difficulty for performance
- ๐ Auto-generates README per problem
- ๐ Auto-updates progress dashboard in root README
- ๐ Optional Git auto-commit & push
- ๐ค Optional GitHub Actions daily auto-sync
- ๐ฆ Installable via pip
๐ฆ Installation
Install from PyPI:
pip install leetcode-sync-cli
๐ First-Time Setup
On first run, the CLI will prompt for:
- LEETCODE_SESSION
- CSRFTOKEN
You can find these in:
LeetCode โ DevTools โ Application โ Cookies
They are stored securely in:
~/.leetcode_sync/.env
๐ Basic Usage
Sync your submissions:
leetcode-sync --sync
Sync and push changes to GitHub:
leetcode-sync --sync --push
๐ Generated Repository Structure
problems/
โโโ easy/
โ โโโ two_sum/
โ โโโ solution.py
โ โโโ README.md
โ
โโโ medium/
โ โโโ group_anagrams/
โ
โโโ hard/
Root README automatically contains:
| Difficulty | Count |
|---|---|
| Easy | 24 |
| Medium | 38 |
| Hard | 8 |
| Total | 70 |
๐ค Enable Daily Auto-Sync (Optional)
Generate GitHub Actions workflow:
leetcode-sync --setup-autosync
This creates:
.github/workflows/leetcode-sync.yml
Then:
- Commit & push the workflow
- Go to GitHub โ Settings โ Secrets
- Add:
- LEETCODE_SESSION
- CSRFTOKEN Your repo will now auto-sync daily.
๐ Session Expiration Handling
If your LeetCode session expires:
- The CLI detects invalid credentials
- Prompts for new session
- Updates stored credentials automatically
- Continues execution No manual cleanup needed.
โ๏ธ Advanced Features
- Automatic difficulty caching
- Graceful Git error handling
- Safe commit (no changes โ no crash)
- Clean package architecture
- Compatible with GitHub Actions
- Ready for pipx installation
๐ง How It Works
- Uses LeetCode's internal GraphQL API
- Fetches accepted submissions
- Deduplicates by latest per language
- Retrieves difficulty (cached)
- Generates structured folders
- Updates progress dashboard
- Optionally commits and pushes
๐ก Security Note
This tool uses your LeetCode session cookie.
- Credentials are never committed
- Stored locally in user config directory
- Not shared externally
- Can be reset anytime by deleting:
~/.leetcode_sync/
๐ Development
Clone Repo:
git clone https://github.com/WixBe/leetcode-sync-cli
cd leetcode-sync-cli
pip install -e .
Run locally:
leetcode-sync --sync
๐ Roadmap
- Runtime & memory stats in problem README
- Exponential retry/backoff
- Multi-profile support
- Progress badges
- Semantic version automation
โญ Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
Built with โค๏ธ by Narendran
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file leetcode_sync_cli-0.1.1.tar.gz.
File metadata
- Download URL: leetcode_sync_cli-0.1.1.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bab0e11fee112c149f9ea564d647916ff6277de562a6e2129d3db92f109a26b6
|
|
| MD5 |
db1bc2765935d3614b0eefc7434d39e7
|
|
| BLAKE2b-256 |
b044ca0e85c5ecd8703acd8cc2b2134d76892461292a8ab417308e76c432143b
|
File details
Details for the file leetcode_sync_cli-0.1.1-py3-none-any.whl.
File metadata
- Download URL: leetcode_sync_cli-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
754ceee4c65f6e8e4a41fd2ad8df28508528419ebbbf61386b384e238eb27c4c
|
|
| MD5 |
6dc53f911b073e79ea8b192a7bab8d32
|
|
| BLAKE2b-256 |
0f725dfa69815de6fc24ddab1733cf9179f89bf44c4650fc60afbd4177f80795
|