From 448080e80cae5a577b95270a43fcefcc06906539 Mon Sep 17 00:00:00 2001 From: Siu Jam Oh Date: Mon, 15 Jun 2026 11:39:12 +0800 Subject: [PATCH] feat: add skill `commit-message` --- commit-message/SKILL.md | 233 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 commit-message/SKILL.md diff --git a/commit-message/SKILL.md b/commit-message/SKILL.md new file mode 100644 index 0000000..a39fbe2 --- /dev/null +++ b/commit-message/SKILL.md @@ -0,0 +1,233 @@ +--- +name: commit-message +description: Create git commit messages based on current staged changes. Has support for git emoji messages. +--- + +# Git Commit Message + +## Instructions + +When this skill is invoked, follow these steps: + +1. **Check if there are staged changes**: Run `git status` +2. If the output of `git status` contains `Changes not staged for commit`, then: + - Generate an interactive yes/no prompt artifact asking "You have unstaged changes. Would you like me to stage your changes?" + - Upon confirmation, proceed by adding the staged changes +3. If the output of `git status` contains `nothing to commit, working tree clean`, then: + - Display response to the user: "No changes found. Please make changes to your files before trying to commit." + - Stop and exit the skill. +4. Only proceed if all changes have been staged, and there are no unstaged changes. +5. Get details of staged changes: Run `git diff --cached` to get the details of the staged changes. Review the diff output to understand: + - What files were modified + - What functionality changed + - The purpose and impact of the changes +6. **Check current branch**: Run `git branch --show-current` to determine the current branch. + - If the current branch is `main` or `master` or `dev` or `development`: + - Using the staged changes already retrieved in step 5, determine the appropriate branch type and a short task description + - Generate a branch name in the format `/` (see **Branch Naming Format** section below). Be specific rather than generic in branch name, ie `feature/switch-to-branch` instead of `feature/update-commit-skill` + - Inform the user they are committing directly to the mainline branch + - Generate an interactive yes/no prompt artifact asking "You're on the `` branch. Would you like me to create the branch `` for this commit?" with the suggested branch name filled in + - Upon confirmation, create and switch to the new branch using `git switch -c ` + - If the user declines, continue committing on the current branch +7. Determine emoji usage: + - Search the user's original request for keywords like "emoji", "gitmoji", "with emoji", or "use emoji" + - By default (if no emoji keywords found): Generate the commit message in standard format WITHOUT any emojis + - If the user explicitly asks for emojis: Add emojis using the mapping table below, placing the emoji before the type +8. Generate commit message: Create a commit message following the semantic commit format below, ensuring: + - Appropriate commit type (feat, fix, docs, etc.) + - Only put a gitmoji in first line if user specified gitmoji or emoji + - Relevant scope based on affected codebase area + - Clear, imperative subject line under 50 characters + - Body and footer if needed for complex changes + - Add line breaks in the body if there are multiple sentences. +9. Present to user for commit approval: + - Display the formatted commit message for review (without showing the git command) + - Generate an interactive yes/no prompt artifact asking "Would you like me to create this commit?" + - Upon confirmation, proceed to step 10 +10. **Final branch check before committing**: Run `git branch --show-current` one final time before executing the commit. + - If the current branch is still `main` or `master` or `dev` or `development`: + - Warn the user: "You are about to commit directly to ``. Are you sure?" + - Generate an interactive yes/no prompt artifact asking "Commit directly to ``?" + - Upon confirmation, proceed to create the commit + - If the user declines, stop and ask them to create a new branch before committing + - If the current branch is not a mainline branch, proceed to create the commit +11. Present to user for push confirmation: + - Once the commit is created, generate an interactive yes/no prompt asking "Would you like me to push this to the remote?" + - Upon confirmation, proceed with the push operation + +## Commands to get details of staged changes + +**Note**: `git diff --cached` and `git diff --staged` are equivalent commands - both show staged changes. + +### Show which files are staged, modified, or untracked + +git status + +### Show detailed line-by-line changes in staged files + +git diff --staged + +### Show summary of staged changes with file names and line counts + +git diff --staged --stat + +### Show detailed changes for a specific staged file + +git diff --staged path/to/file + +## Commit Message Format + +The basic semantic message format is: + +```text +(): + + + +