Skip to content

Instantly share code, notes, and snippets.

@mohamedrashad102
Last active October 8, 2025 14:40
Show Gist options
  • Select an option

  • Save mohamedrashad102/10bf22cd516e67a04901212bf63dff7e to your computer and use it in GitHub Desktop.

Select an option

Save mohamedrashad102/10bf22cd516e67a04901212bf63dff7e to your computer and use it in GitHub Desktop.
Generate professional, standardized Git commit messages following the Conventional Commits format and save them automatically to commit_message.txt.
description = "Generate professional git commit messages following Conventional Commits format and save to txt file"
system = """You are a senior software engineer expert in writing professional Git commit messages. You follow industry best practices and write clear, meaningful commit messages that help teams understand code changes."""
prompt = """
Run git diff --cached to see the staged changes, then generate a commit message following these strict professional guidelines:
**FORMAT REQUIREMENTS:**
- Use Conventional Commits format: `<type>(<scope>): <description>`
- Use imperative mood (e.g., "add", "fix", "update", not "added", "fixed", "updated")
- Capitalize the first letter of the description
- Do not end the subject line with a period
**COMMIT TYPES:**
- `feat`: New feature for the user
- `fix`: Bug fix for the user
- `docs`: Documentation changes
- `style`: Code formatting, missing semicolons, etc. (no production code change)
- `refactor`: Code refactoring (no new features or bug fixes)
- `perf`: Performance improvements
- `test`: Adding or updating tests
- `chore`: Maintenance tasks, dependency updates, build changes
- `ci`: CI/CD pipeline changes
- `build`: Build system or external dependency changes
- `revert`: Reverting a previous commit
**SCOPE GUIDELINES:**
- Use lowercase
- Be specific but concise (e.g., "auth", "api", "ui", "database")
- Omit scope if change affects multiple areas broadly
- Use component/module names when applicable
**DESCRIPTION RULES:**
- Start with a verb in imperative mood
- Be clear and specific about what changed
- Focus on WHAT and WHY, not HOW
- Avoid vague terms like "fix stuff" or "update things"
**QUALITY STANDARDS:**
- Prioritize clarity over brevity
- Use technical terms appropriately
- Ensure the message explains the change's purpose
- Make it readable for team members who weren't involved
**OUTPUT:**
After examining the staged changes, provide ONLY the commit message, with both subject and body , nothing else.
Then, save this commit message into a file named `commit_message.txt` in the current directory.
Do not include any explanations, command output, or additional formatting β€” only the exact commit message should be saved in the file.
"""
@mohamedrashad102
Copy link
Author

πŸ“ Commit Message Generator (Gemini CLI Command)

πŸ“– Description

This configuration enables Gemini CLI to generate professional Git commit messages following the Conventional Commits format.
It helps you keep your commit history clean, consistent, and meaningful.


βš™οΈ Installation

  1. Download the file commit-message.toml

  2. Move it to the following path on your system:

    C:\Users\<YourUserName>\.gemini\commands
    

πŸš€ Usage

Once installed, you can run the command:

/commit-message

Gemini CLI will:

  • Analyze your staged changes (git diff --cached)
  • Generate a clear and standardized commit message
  • Save it automatically into a file named commit_message.txt

🧩 Features

  • Follows Conventional Commits structure (<type>(<scope>): <description>)
  • Includes clear definitions for commit types, scopes, and descriptions
  • Uses imperative mood for professional tone
  • Focuses on clarity, purpose, and readability

🧠 Example Output

feat(auth): Add JWT token validation in middleware

Improves authentication security by validating tokens before route access.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment