🚀 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
Metadata
Release files for leetcode-sync-cli 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| leetcode_sync_cli-0.1.1.tar.gz | 9.1 kB | Without provenance | Details for leetcode_sync_cli-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| leetcode_sync_cli-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for leetcode_sync_cli-0.1.1-py3-none-any.whl |
Total release size: 19.5 kB
Release files / leetcode_sync_cli-0.1.1.tar.gz
| Download URL | leetcode_sync_cli-0.1.1.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bab0e11fee112c149f9ea564d647916ff6277de562a6e2129d3db92f109a26b6
|
|
BLAKE2b-256 checksum How to use checksums |
b044ca0e85c5ecd8703acd8cc2b2134d76892461292a8ab417308e76c432143b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / leetcode_sync_cli-0.1.1-py3-none-any.whl
| Download URL | leetcode_sync_cli-0.1.1-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
754ceee4c65f6e8e4a41fd2ad8df28508528419ebbbf61386b384e238eb27c4c
|
|
BLAKE2b-256 checksum How to use checksums |
0f725dfa69815de6fc24ddab1733cf9179f89bf44c4650fc60afbd4177f80795
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for leetcode-sync-cli 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.