Skip to content

Commit e60ac49

Browse files
authored
Feature: Implement Expert Git Commit Agent Skill (#22)
# Summary This PR introduces a specialized Agent Skill named `git-commit` to provide a streamlined,standardized, and safe way to generate high-quality commit messages within the Gemini CLI. Previously, users had to manually prompt for commit suggestions, which often resulted in output containing Markdown backticks. Since the Gemini CLI interprets backticks as bash commands, this posed a significant security risk and led to unintended command executions or shell errors. This change implements a robust "No Backticks" policy across both the new Agent Skill and the existing `/git:commit` command, ensuring all output is strictly raw text or uses single quotes for references. ### Changes Made - **New Git Commit Skill:** Created `skills/gitcommit/SKILL.md` to define the expert commit agent, including a structured workflow for analyzing staged changes. - **Commit Standards Documentation:** Added `skills/gitcommit/references/commit-standards.md` which provides detailed rules for Conventional Commits (types, scope detection, and formatting). - **Security Hardening:** Updated `commands/git/commit.toml` with critical instructions to strictly forbid the use of backticks in generated subjects and bodies, mandating single quotes instead. - **Feature Documentation:** Updated `README.md` to highlight Conventional Commits support, the "Safety First" backtick prevention, and context awareness. - **Version Bump:** Incremented the extension version to `0.2.0` in `gemini-extension.json` to reflect the new functionality. ## Related Issues Closes #21 ## Type of Change Please select the type of change that applies to this PR: - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Refactor (code change that neither fixes a bug nor adds a feature) - [x] Documentation (changes to documentation) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] Chore (maintenance tasks, build process, etc.) ## Checklist - [x] I have performed a self-review of my own code. - [x] I have updated the documentation accordingly. - [x] My changes generate no new warnings. ## Screenshots/Video N/A
2 parents acdafba + bf2b10b commit e60ac49

5 files changed

Lines changed: 85 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ descriptive body to keep your project history clear and concise.
66

77
## Features
88

9-
- **Automated Analysis:** Inspects your Git staging area to understand code changes.
10-
- **Smart Generation:** Produces an AI-generated title and description based on the context of your work.
11-
- **Seamless Integration:** Adds a custom command directly into your Gemini CLI workflow.
9+
- **Conventional Commits:** Automatically generates messages following the industry-standard [Conventional Commits](https://www.conventionalcommits.org/) specification.
10+
- **Safety First (No Backticks):** Guarantees output without backticks (`), preventing the Gemini CLI from incorrectly identifying messages as bash commands.
11+
- **Context Awareness:** Automatically activates when you ask to "commit this," "write a commit message," or similar requests.
12+
- **Automated Analysis:** Inspects your Git staging area to understand code changes and provide meaningful context.
13+
- **Seamless Integration:** Adds both an Agent Skill and a custom command directly into your Gemini CLI workflow.
1214

1315
## Installation
1416

commands/git/commit.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# In: .gemini/commands/git/commit.toml
1+
# In: commands/git/commit.toml
22
# Invoked via: /git:commit
33

44
description = "Generates a Git commit message (title and body) based on staged changes."
@@ -49,13 +49,15 @@ Analyze the provided code changes (`git diff`) and generate a complete commit me
4949
* Write in the **imperative mood** (e.g., "add", "fix", "change" not "added", "fixed").
5050
* Begin with a lowercase letter.
5151
* Do not end with a period.
52+
* **CRITICAL: Never include backticks (`) in the output.**
5253
</subject>
5354
5455
<body_formatting>
5556
* Separate from the subject with a blank line.
5657
* Explain the **intent** and **reasoning**. Answer "why" you are making the change, not just "what" you changed.
5758
* **Lists:** If the commit includes multiple distinct logical changes, use a bulleted list (using `-`) to detail them for better readability.
5859
* Wrap the body at 72 characters per line.
60+
* **CRITICAL: Never include backticks (`) in the output. Use single quotes (') instead if needed.**
5961
</body_formatting>
6062
6163
<breaking_changes>

gemini-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "geminicli-gitcommit",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"excludeTools": [],
55
"tools": ["list_directory", "search_file_content", "read_file", "glob", "replace", "run_shell_command", "save_memory"],
66
"model": "flash",

skills/gitcommit/SKILL.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: git-commit
3+
description: Expert Git commit message generation following Conventional Commits. Use when the user wants to commit changes, needs help writing a commit message, or asks to "commit this".
4+
---
5+
6+
# Git Commit Generator
7+
8+
This skill transforms staged changes into professional, meaningful commit messages.
9+
10+
## Workflow
11+
12+
1. **Analyze Staged Changes**: Use `git diff --staged` to understand the code changes.
13+
2. **Apply Standards**: Follow the detailed rules in [references/commit-standards.md](references/commit-standards.md).
14+
3. **Generate Output**: Produce a commit command that the user can run.
15+
16+
## Guidelines
17+
18+
- **Context First**: Always read the diff before proposing a message.
19+
- **No Backticks**: **CRITICAL**: Never include backticks (`) in the commit message or any part of the output. Gemini CLI interprets backticks as shell commands.
20+
- **Why over What**: Prioritize the reasoning behind the change in the message body.
21+
- **Breaking Changes**: Be extremely vigilant about breaking changes and document them in the footer as per the standards.
22+
23+
## Example Usage
24+
25+
When a user says "Commit these changes", you should:
26+
1. Run `git diff --staged`.
27+
2. Review the output.
28+
3. Construct the message following the standards.
29+
4. Output the final `git commit` command for the user.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Conventional Commit Standards
2+
3+
## Structure
4+
```
5+
<type>(<scope>): <concise subject>
6+
7+
<body explaining the "why" of the change>
8+
9+
<footer for BREAKING CHANGES or issue references>
10+
```
11+
12+
## Mandatory Types
13+
* **feat**: A new feature.
14+
* **fix**: A bug fix.
15+
* **docs**: Documentation only changes.
16+
* **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
17+
* **refactor**: A code change that neither fixes a bug nor adds a feature.
18+
* **perf**: A code change that improves performance.
19+
* **test**: Adding missing tests or correcting existing tests.
20+
* **build**: Changes that affect the build system or external dependencies (e.g., npm, make).
21+
* **ci**: Changes to our CI configuration files and scripts (e.g., GitHub Actions).
22+
* **chore**: Other changes that don't modify source or test files (e.g., updating `.gitignore`).
23+
24+
## Scope Detection
25+
* **Infer Scope:** Look at file paths.
26+
* If changes are isolated (e.g., `src/auth/`, `lib/utils.ts`), use that as scope (e.g., `auth`, `utils`).
27+
* If changes are global or spread across many modules, omit the scope.
28+
29+
## Subject Rules
30+
* Max 50 characters.
31+
* Use **imperative mood** (e.g., "add", "fix", "change").
32+
* Lowercase start, no trailing period.
33+
* **NO BACKTICKS**: Never use backticks (`) in the subject.
34+
35+
## Body Formatting
36+
* Blank line after subject.
37+
* Explain **intent** and **reasoning** ("why", not just "what").
38+
* Use bulleted lists (`-`) for multiple distinct changes.
39+
* Wrap at 72 characters.
40+
* **NO BACKTICKS**: Never use backticks (`) in the body. Use single quotes (') instead if needed.
41+
42+
## Breaking Changes
43+
* **Detection:** Look for removal of public API, signature changes, or incompatible config changes.
44+
* **Format:** Footer MUST start with `BREAKING CHANGE:` followed by description and migration instructions.
45+
46+
## Footer
47+
* Reference issues using `Closes: #`.

0 commit comments

Comments
 (0)