Skip to content

About

Automatically fetches accepted LeetCode submissions and commits them to GitHub every 10 minutes. Built with Python, Git, and LeetCode GraphQL API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CommitCode

Automatically sync your accepted LeetCode submissions to GitHub.
Solve problems on LeetCode, and CommitCode saves and pushes your solutions automatically — no manual uploads needed.


Features

  • Fetches accepted LeetCode submissions automatically
  • Pushes solutions directly to GitHub
  • Runs every 10 minutes in the background
  • Prevents manual copy-paste workflow
  • Organizes solutions neatly by platform
  • Lightweight and easy to configure

How It Works

CommitCode periodically checks your LeetCode account for newly accepted submissions using the LeetCode GraphQL API.

When a new solution is detected:

  1. The solution code is fetched
  2. A file is generated automatically
  3. Git commits and pushes the update to your repository

Installation

1. Clone the Repository

git clone https://github.com/your-username/commitcode.git
cd commitcode

2. Install Dependencies

pip install requests

3. Configure Credentials

Create a config.json file:

{
  "leetcode": {
    "username": "your_username",
    "session_cookie": "your_LEETCODE_SESSION_cookie"
  }
}

4. Add Sensitive Files to .gitignore

echo "config.json" >> .gitignore
echo "logs/" >> .gitignore
echo "__pycache__/" >> .gitignore

Getting LeetCode Session Cookie

  1. Log into LeetCode
  2. Open Developer Tools (F12)
  3. Go to:
    • Application → Cookies → leetcode.com
  4. Copy the value of:
LEETCODE_SESSION

Usage

Run Normally

python main.py

Run Without Pushing to GitHub

python main.py --no-push

Automatic Scheduling (Windows)

You can use Windows Task Scheduler to run CommitCode every 10 minutes.

Example Configuration

Program

C:\path\to\venv\Scripts\python.exe

Arguments

main.py

Start In

C:\path\to\commitcode

Tech Stack

  • Python
  • Git
  • LeetCode GraphQL API
  • Windows Task Scheduler

Python Libraries Used

  • requests
  • subprocess
  • argparse
  • logging
  • json
  • os

Project Structure

commitcode/
├── main.py
├── leetcode_fetcher.py
├── git_committer.py
├── config.json
└── solutions/
    └── leetcode/

Future Improvements

  • GitHub Actions support
  • Multi-platform coding support
  • Docker support
  • Daily statistics dashboard
  • Auto README progress updates

License

This project is open-source and available under the MIT License.

About

Automatically fetches accepted LeetCode submissions and commits them to GitHub every 10 minutes. Built with Python, Git, and LeetCode GraphQL API.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages