Skip to content

Commit 6400bf5

Browse files
committed
chore: update git-commit skill configuration
Add message validation step and clarify -m flag usage rules for the git-commit skill.
1 parent 3e7072b commit 6400bf5

2 files changed

Lines changed: 45 additions & 7 deletions

File tree

.agents/skills/git-commit/SKILL.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
github-path: skills/git-commit
55
github-ref: refs/heads/main
66
github-repo: https://github.com/orrisroot/agent-skills
7-
github-tree-sha: e578a03c4a4295e65d0b0ef737d9ee979fbf08a0
7+
github-tree-sha: 332b6fc533ae9085eafbba6827ff7798c85e4b38
88
name: git-commit
99
---
1010
# Git Commit Operator
@@ -29,7 +29,22 @@ You must execute the following sequential workflow whenever a commit task is ini
2929
1. Construct the message draft strictly using the type classifications and syntax limits specified in `references/conventional_commits.md`.
3030
2. Present the drafted structure to the user for validation, highlighting the assigned commit type and scope.
3131

32-
### Step 3: Terminal Command Delivery
33-
1. Upon user confirmation, output the explicit, single-line terminal command using multiple `-m` flags as specified in the formatting policy.
32+
### Step 3: Message Validation
33+
1. After drafting the message in Step 2, validate it against **every rule** listed in `references/conventional_commits.md` before proceeding. Check the following:
34+
* **Type:** The commit type must be one of the allowed types (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert).
35+
* **Language:** The entire message must be in English (unless the user explicitly requested another language).
36+
* **Case & Punctuation:** The description must be lowercase and must NOT end with a period.
37+
* **Imperative Mood:** The description must use imperative mood (e.g., "add", not "added" or "adds").
38+
* **Line Length:** The subject line must not exceed 72 characters. **Every line in the body must also be wrapped at 72 characters or less.** If any line exceeds this limit, insert line breaks to fix it.
39+
* **`-m` Flags:** The command must use at most three `-m` flags (one per structural part). Body lines must NOT be split across multiple `-m` flags.
40+
* **Literal Newlines:** Multi-line body/footer content must use **literal newlines** inside double-quoted strings, NOT `\n` escape sequences (which shells commit as literal backslash-n).
41+
* **Co-authored-by:** No `Co-authored-by:` trailers unless explicitly requested.
42+
2. If **any** rule is violated, fix the draft and re-validate from step 1. Repeat this loop until all checks pass. Only proceed to Step 4 once the message passes every validation check.
43+
44+
### Step 4: Terminal Command Delivery
45+
1. Upon user confirmation, output the explicit, single-line terminal command using at most three `-m` flags as specified in the formatting policy.
46+
* **CRITICAL:** Use at most one `-m` flag per structural part (Subject, Body, and Footer).
47+
* **NEVER** use multiple `-m` flags for individual lines or bullet points within the body. Doing so causes Git to insert unwanted blank lines.
48+
* **CRITICAL:** For multi-line body or footer content, you must use a single double-quoted string containing **literal newlines (actual line breaks)** within the command. Do NOT use escape sequences like `\n` (which shell command execution will commit literally) or additional `-m` flags.
3449

3550
Process each step in order and complete the current step before moving to the next.

.agents/skills/git-commit/references/conventional_commits.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,21 @@ When drafting, validating, or executing Git commits, you must strictly adhere to
3535
* The subject line (first line) must not exceed 72 characters, ideally 50 characters or less.
3636
* **Every single line within the commit message body must also be wrapped at 72 characters or less.** If an explanation runs longer, you must manually insert line breaks to keep each line under the 72-character threshold.
3737

38-
3. **Part Separation via Multiple `-m` Flags**:
39-
* Use one `-m` flag per structural part: the subject line, the body, and the footer. Use at most three `-m` flags in total.
40-
* All body content — including bullet lists and multi-sentence explanations — must be placed in a single `-m` value. Do not split body content across multiple `-m` flags; doing so inserts unwanted blank lines between items.
38+
3. **Part Separation via Multiple `-m` Flags (At Most Three)**:
39+
* Use at most one `-m` flag per structural part: the subject line, the body, and the footer. Use at most three `-m` flags in total.
40+
* **NEVER split body lines or bullet lists across multiple `-m` flags.** Doing so inserts unwanted blank lines because Git automatically treats each `-m` flag as a separate paragraph.
41+
* **DO NOT use escape sequences like `\n` in double quotes.** Shells like bash will treat `\n` as literal backslash-n characters and commit them as-is.
42+
* **Use literal newlines (actual line breaks)** inside double quotes to write multi-line bodies or footers.
4143
* *Example:*
4244

4345
```bash
44-
git commit -m "feat(auth): add jwt authentication" -m $'Validate tokens on every incoming request.\nSecure endpoints by rejecting expired credentials.\n- Added middleware for token validation\n- Removed legacy session handling' -m "BREAKING CHANGE: The old session-based cookie auth is deprecated."
46+
git commit -m "feat(auth): add jwt authentication" -m "Validate tokens on every incoming request.
47+
Secure endpoints by rejecting expired credentials.
48+
- Added middleware for token validation
49+
- Removed legacy session handling" -m "BREAKING CHANGE: The old session-based cookie auth is deprecated."
4550
```
4651

52+
4753
4. **Co-authored-by Restriction**:
4854
* **Do not include any `Co-authored-by:` trailers** in the commit message or footer unless the user explicitly requests you to add credit for a co-author.
4955

@@ -52,3 +58,20 @@ When drafting, validating, or executing Git commits, you must strictly adhere to
5258

5359
6. **Imperative Mood**:
5460
* Always use the imperative mood in the description (e.g., use "add", "fix", "change" instead of "added", "fixes", "changed").
61+
62+
## Validation Checklist
63+
64+
When validating a draft commit message, check **every** item below. If any check fails, fix the issue and re-validate until all pass.
65+
66+
| # | Check | Rule |
67+
|---|-------|------|
68+
| 1 | **Type valid** | The type must be one of: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert. |
69+
| 2 | **Language** | The message must be in English (unless the user explicitly requested another language). |
70+
| 3 | **Lowercase** | The description must be lowercase. |
71+
| 4 | **No period** | The description must NOT end with a period. |
72+
| 5 | **Imperative mood** | Use imperative mood (e.g., "add" not "added", "adds"). |
73+
| 6 | **Subject ≤ 72 chars** | The subject line must not exceed 72 characters. |
74+
| 7 | **Body lines ≤ 72 chars** | **Every line in the body must be wrapped at 72 characters or less.** |
75+
| 8 | **At most 3 `-m` flags** | Use at most one `-m` per structural part; do NOT split body lines across multiple `-m` flags. |
76+
| 9 | **Literal newlines** | Multi-line body/footer must use literal newlines inside double quotes, NOT `\n` escape sequences. |
77+
| 10 | **No Co-authored-by** | Do not include `Co-authored-by:` unless explicitly requested. |

0 commit comments

Comments
 (0)