From c5ea6040bf720c12397a0ad3825db7c58558d85e Mon Sep 17 00:00:00 2001 From: goodboy Date: Wed, 4 Mar 2026 14:36:00 -0500 Subject: [PATCH] Improve `/commit-msg` skill fmting + consistency Align `SKILL.md` and `style-guide-reference.md` with the claude-code skills docs and actual usage conventions. Deats, - add missing frontmatter fields: `argument-hint`, `disable-model-invocation`, and scope `Bash` tool to `Bash(git *)` prefix pattern per docs. - add `Grep`/`Glob` to `allowed-tools`. - restructure `!`backtick`` usage for proper dynamic context injection (not mixed with instructional text). - use markdown link for `style-guide-reference.md` ref per docs' supporting-files convention. - switch timestamp format to cross-OS-safe `date -u +%Y%m%dT%H%M%SZ`. Also, - rm errant blank lines between footer attribution and reference-def lines in both files. - fix double space in style guide subject length desc. - reflow long lines for 67 char limit. (this patch was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- .claude/skills/commit-msg/SKILL.md | 47 ++++++++++++------- .../commit-msg/style-guide-reference.md | 8 ++-- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/.claude/skills/commit-msg/SKILL.md b/.claude/skills/commit-msg/SKILL.md index 445eb33a..98741952 100644 --- a/.claude/skills/commit-msg/SKILL.md +++ b/.claude/skills/commit-msg/SKILL.md @@ -1,27 +1,41 @@ --- name: commit-msg -description: Generate git commit messages following project style. - Use when user wants to create a commit or asks for a commit message. +description: > + Generate git commit messages following project style. Use when user + wants to create a commit or asks for a commit message. +argument-hint: "[optional-scope-or-description]" +disable-model-invocation: true allowed-tools: - - Bash + - Bash(git *) + - Bash(date *) + - Bash(cp *) - Read + - Grep + - Glob - Write --- When generating commit messages, always follow this process: -1. **Gather context**: Run, `~/repos/claude_wks/commit_gen.py` - to get staged changes, recent commits, and style guide rules +0. **Check for staged changes**: if `git diff --staged` is + empty, STOP and tell the user "nothing is staged!" with + a reminder to `git add` before invoking this skill. -2. **Analyze the diff**: Understand what files changed and the nature - of the changes (new feature, bug fix, refactor, etc.) +1. **Gather context** from the staged diff and recent + history: + + - Staged changes: !`git diff --staged --stat` + - Recent commits: !`git log --oneline -5` + +2. **Analyze the diff**: understand what files changed and + the nature of the changes (new feature, bug fix, refactor, + etc.) 3. **Write the commit message** following these rules: **Use the accompanying style guide:** -- Use the style guide `./style-guide-reference.md` for more details - on how to write the message based on analysis of past commits in - this repo. +- See [style-guide-reference.md](style-guide-reference.md) + for detailed analysis of past commits in this repo. **Subject Line Format:** - Present tense verbs: Add, Drop, Fix, Use, Move, Adjust, etc. @@ -46,9 +60,10 @@ When generating commit messages, always follow this process: - Minor tweaks: "Adjust `behavior` in `component`" 4. **Write to TWO files**: - - `.claude/__commit_msg.md` (timestamp from `date - --iso-8601=seconds`, hash from `git log -1 --format=%h` first - 7 chars) + - `.claude/__commit_msg.md` + * with `` from `date -u +%Y%m%dT%H%M%SZ` or similar + filesystem-safe format. + * and `` from `git log -1 --format=%h` first 7 chars. - `.claude/git_commit_msg_LATEST.md` (overwrite) 5. **Always include credit footer**: @@ -56,16 +71,14 @@ When generating commit messages, always follow this process: When no part of the patch was written by `claude`, ``` (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) - [claude-code-gh]: https://github.com/anthropics/claude-code ``` -and when some or all of the patch was written by `claude` instead -use, +when some or all of the patch was written by `claude` +instead use, ``` (this patch was generated in some part by [`claude-code`][claude-code-gh]) - [claude-code-gh]: https://github.com/anthropics/claude-code ``` diff --git a/.claude/skills/commit-msg/style-guide-reference.md b/.claude/skills/commit-msg/style-guide-reference.md index 97445d29..3c9fe180 100644 --- a/.claude/skills/commit-msg/style-guide-reference.md +++ b/.claude/skills/commit-msg/style-guide-reference.md @@ -11,7 +11,7 @@ clarity about what changed and why. ## Subject Line Format ### Length and Structure -- Target: ~49 chars (avg: 48.7, max: 50 preferred) +- Target: ~50 chars with a hard-max of 67. - Use backticks around code elements (72.2% of commits) - Rarely use colons (5.2%), except for file prefixes - End with '?' for uncertain changes (rare: 0.8%) @@ -185,16 +185,14 @@ the commit msg content: ``` (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) - [claude-code-gh]: https://github.com/anthropics/claude-code ``` -Further, if the patch was solely or in part written by `claude`, instead -add: +Further, if the patch was solely or in part written +by `claude`, instead add: ``` (this patch was generated in some part by [`claude-code`][claude-code-gh]) - [claude-code-gh]: https://github.com/anthropics/claude-code ```