Skip to main content

Generate a well-structured commit message based on staged changes

Project description

pour lire la documentation en français, cliquez ici

🧠 The Problem: The Empty Commit Syndrome

Empty illustration

You've just wrapped up an intense coding session. You proudly type:

git add .
git commit ""

And then… nothing.

The cursor blinks, the quotes are empty, and no idea comes to mind. How do you summarize what you just did? How do you stick to your commit conventions? Should you mention the ticket? Where? How?

That’s where Commitly comes in.


🚀 What is Commitly?

Commitly is a Python library that leverages artificial intelligence to automatically generate a well-structured commit message based on your staged changes (git diff --cached).

No more empty commit syndrome. Commitly gives you a clear, contextual message — with or without a ticket — in French or English, and tailored to your team’s standards.


⚙️ Features

__init__(model=gpt_4o_mini, file_temp="commit.txt", lang="fr")

Creates a Commitly instance.

  • model: AI model to use (default is gpt_4o_mini via g4f).
  • file_temp: temporary file to store the generated message before committing.
  • lang: language for commit generation (fr or en).

add(file: str) -> bool

Adds a specific file to the Git staging area.

commitly.add("app/models/user.py")

Equivalent to:

git add app/models/user.py

generate_commit_message(style_commit=None, format_commit=None, recommandation_commit=None, ticket=None) -> str

Automatically generates a commit message based on the current staged diff (git diff --cached).

  • style_commit: customize commit style (type, scope, etc.).
  • format_commit: overall message format.
  • recommandation_commit: writing guidelines or hints.
  • ticket: optional ticket identifier to include in the footer.

⚠️ Note: If there are no staged changes, this method raises a DiffEmptyException.


save_message_to_file(message: str) -> bool

Saves a generated commit message to the specified temporary file (default: commit.txt).

commitly.save_message_to_file(message)

Useful if you want to reuse this file in a git commit command.


commit() -> bool

Commits changes using the message stored in the temporary file. Deletes the file after committing.

commitly.commit()

push()

Runs a git push to send your commit to the remote repository.

commitly.push()

unstage(file: str)

Removes a file from staging (same as git reset <file>).

commitly.unstage("README.md")

_run_cmd(cmd: str, return_code: bool = False)

Internal method to run shell commands. Returns either:

  • the command output (stdout)
  • or the exit code (0 or 1) if return_code=True

🧪 Full Example

from commitly import Commitly

commitly = Commitly()
commitly.add("main.py")
message = commitly.generate_commit_message(ticket="#42")
commitly.save_message_to_file(message)
commitly.commit()
commitly.push()

📸 Visual Demo

Full example


🧩 About the Commit Format

The generated message follows this structure:

<type>[optional scope]: <description>

[optional body]

[optional footer]  ← ticket here (#1234)

Common types:

  • feat: new feature
  • fix: bug fix
  • docs: documentation
  • refactor: code improvement without behavior change
  • chore: miscellaneous tasks (maintenance, updates, etc.)

📋 License

MIT © 2025 Kouya Chance Boman Tosten


Say goodbye to the empty commit syndrome. Let Commitly tell your code’s story.


Dis-moi si tu veux un badge PyPI (une fois publié), ou une version anglaise des images (si nécessaire) !

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

commitly-1.0.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

commitly-1.0.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file commitly-1.0.0.tar.gz.

File metadata

  • Download URL: commitly-1.0.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for commitly-1.0.0.tar.gz
Algorithm Hash digest
SHA256 35ea9bfdc691198de7c353a55fafc51fa11d70987f482a14383cd889a608472e
MD5 a29efaba7a252b7ead6645e66d6f4df5
BLAKE2b-256 7a46d2807943fa70f2c31fac898685c71326701b2d14fb88417da5928e53b3ef

See more details on using hashes here.

File details

Details for the file commitly-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: commitly-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for commitly-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9605a74d6b2783066f70010cdfe13069b7bbde9e5783ef1393978f7bc0d071d
MD5 0632c044047296d8dd7dbd6aff4f1508
BLAKE2b-256 a3a441ee35f5e0c80aaae4ae4312f8502beb3b2705e134e6fa7a99e2530fb31d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page