From a56a95769f9ee720e892b520349b39b77bfbe850 Mon Sep 17 00:00:00 2001 From: Yoshihiro OKUMURA Date: Mon, 25 May 2026 21:39:00 +0900 Subject: [PATCH] chore(git-commit): add validation step and checklist to skill --- .agents/skills/git-commit/SKILL.md | 16 ++++++++++++++-- .../references/conventional_commits.md | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.agents/skills/git-commit/SKILL.md b/.agents/skills/git-commit/SKILL.md index c20b2a3..3a6816d 100644 --- a/.agents/skills/git-commit/SKILL.md +++ b/.agents/skills/git-commit/SKILL.md @@ -4,7 +4,7 @@ metadata: github-path: skills/git-commit github-ref: refs/heads/main github-repo: https://github.com/orrisroot/agent-skills - github-tree-sha: 661413ef1afaece6071d57b938ef050d4862e4d4 + github-tree-sha: 332b6fc533ae9085eafbba6827ff7798c85e4b38 name: git-commit --- # Git Commit Operator @@ -29,7 +29,19 @@ You must execute the following sequential workflow whenever a commit task is ini 1. Construct the message draft strictly using the type classifications and syntax limits specified in `references/conventional_commits.md`. 2. Present the drafted structure to the user for validation, highlighting the assigned commit type and scope. -### Step 3: Terminal Command Delivery +### Step 3: Message Validation +1. After drafting the message in Step 2, validate it against **every rule** listed in `references/conventional_commits.md` before proceeding. Check the following: + * **Type:** The commit type must be one of the allowed types (feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert). + * **Language:** The entire message must be in English (unless the user explicitly requested another language). + * **Case & Punctuation:** The description must be lowercase and must NOT end with a period. + * **Imperative Mood:** The description must use imperative mood (e.g., "add", not "added" or "adds"). + * **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. + * **`-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. + * **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). + * **Co-authored-by:** No `Co-authored-by:` trailers unless explicitly requested. +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. + +### Step 4: Terminal Command Delivery 1. Upon user confirmation, output the explicit, single-line terminal command using at most three `-m` flags as specified in the formatting policy. * **CRITICAL:** Use at most one `-m` flag per structural part (Subject, Body, and Footer). * **NEVER** use multiple `-m` flags for individual lines or bullet points within the body. Doing so causes Git to insert unwanted blank lines. diff --git a/.agents/skills/git-commit/references/conventional_commits.md b/.agents/skills/git-commit/references/conventional_commits.md index 1d08004..20277e3 100644 --- a/.agents/skills/git-commit/references/conventional_commits.md +++ b/.agents/skills/git-commit/references/conventional_commits.md @@ -58,3 +58,20 @@ When drafting, validating, or executing Git commits, you must strictly adhere to 6. **Imperative Mood**: * Always use the imperative mood in the description (e.g., use "add", "fix", "change" instead of "added", "fixes", "changed"). + +## Validation Checklist + +When validating a draft commit message, check **every** item below. If any check fails, fix the issue and re-validate until all pass. + +| # | Check | Rule | +|---|-------|------| +| 1 | **Type valid** | The type must be one of: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert. | +| 2 | **Language** | The message must be in English (unless the user explicitly requested another language). | +| 3 | **Lowercase** | The description must be lowercase. | +| 4 | **No period** | The description must NOT end with a period. | +| 5 | **Imperative mood** | Use imperative mood (e.g., "add" not "added", "adds"). | +| 6 | **Subject ≤ 72 chars** | The subject line must not exceed 72 characters. | +| 7 | **Body lines ≤ 72 chars** | **Every line in the body must be wrapped at 72 characters or less.** | +| 8 | **At most 3 `-m` flags** | Use at most one `-m` per structural part; do NOT split body lines across multiple `-m` flags. | +| 9 | **Literal newlines** | Multi-line body/footer must use literal newlines inside double quotes, NOT `\n` escape sequences. | +| 10 | **No Co-authored-by** | Do not include `Co-authored-by:` unless explicitly requested. |