
smart-commit
by johnmog
dotfiles for my dotfiles
SKILL.md
name: smart-commit description: Commits changes with concise, clear commit messages (under 52 characters). Automatically creates feature branches when committing from main/master branches, using simple names like 'johnmog-area-change'. Use when you want to commit changes with a meaningful message or need to safely work off main.
Smart Commit
Overview
This skill automates the git commit workflow by generating concise, clear commit messages based on changes and automatically creating feature branches when working on main/master. It ensures safe development practices by preventing direct commits to main branches.
Quick Start
Use this skill when you need to:
- Commit staged changes, or all changes if none are staged, with a concise, clear commit message (under 52 characters)
- Safely branch off main/master before committing
- Generate simple, descriptive branch names based on your changes
- Follow git best practices for commit messages
Workflow
1. Check Current Branch and Status
First, determine the current git state:
git status
git branch --show-current
2. Branch Decision Logic
If on main or master:
- If no changes are staged, stage current changes:
git add . - Analyze staged changes to generate a simple branch name
- Create branch with format:
johnmog-<area>-<change>- Example:
johnmog-auth-validation - Example:
johnmog-cache-fix - Example:
johnmog-api-client - Example:
johnmog-sentry-rollup
- Example:
- Switch to the new branch
- Proceed with commit
If on any other branch:
- Proceed directly with commit on current branch
3. Generate Commit Message
Analyze the staged changes using git diff --cached to generate a simple, clear commit message.
Guidelines:
- Maximum 52 characters (git standard)
- Clear and direct - describe what changed
- Imperative mood - "add" not "added" or "adds"
- No prefixes - avoid "fix:", "feat:", "refactor:" etc.
- Lowercase first letter unless it's a proper noun
- No period at the end
Good Examples:
add user authentication validation
fix cache undefined access bug
simplify exception rollup logic
update API client with retry logic
remove unused rollup check registry
improve error logging with kvp fields
Bad Examples:
feat(auth): add user authentication validation ❌ (too long, uses prefix)
Fix bug ❌ (too vague, capitalized)
refactor(observability): simplify exceptions ❌ (uses prefix)
Added new feature for user authentication ❌ (past tense, too long)
4. Execute Commit
Commit with the generated message:
git commit -m "<generated-message>"
Examples
Example 1: Feature Addition on Main
User Request: "Commit these changes"
Current State:
$ git branch --show-current
main
$ git diff --cached
+++ b/src/auth/login.js
+export function validateLogin(username, password) {
+ // validation logic
+}
Actions:
- Create branch:
git checkout -b johnmog-auth-validation - Generate message:
add user authentication validation - Commit:
git commit -m "add user authentication validation"
Output:
Created branch: johnmog-auth-validation
Committed with message: add user authentication validation
Example 2: Bug Fix on Feature Branch
User Request: "Commit my fix"
Current State:
$ git branch --show-current
johnmog-performance
$ git diff --cached
--- a/src/utils/cache.js
+++ b/src/utils/cache.js
- return cache[key];
+ return cache.has(key) ? cache.get(key) : null;
Actions:
- Stay on current branch (not main)
- Generate message:
fix cache undefined access - Commit:
git commit -m "fix cache undefined access"
Output:
Committed with message: fix cache undefined access
Example 3: Refactoring on Main
User Request: "Smart commit"
Current State:
$ git branch --show-current
main
$ git diff --cached
--- a/internal/pkg/observability/exceptions/exceptions.go
+++ b/internal/pkg/observability/exceptions/exceptions.go
-var (
- rollupChecks []func(exception error) (info string, ok bool)
- rollupChecksMutex sync.Mutex
-)
+rollupFunc := func(exception error) (string, bool) {
+ fingerprint := generateRollupFingerprint(exception.Error())
+ return hashString(fingerprint), true
+}
Actions:
- Create branch:
git checkout -b johnmog-sentry-rollup - Generate message:
simplify exception rollup logic - Commit:
git commit -m "simplify exception rollup logic"
Output:
Created branch: johnmog-sentry-rollup
Committed with message: simplify exception rollup logic
Branch Naming Conventions
When creating branches from main, generate names that are:
- Simple: 2-3 words, area + action/topic
- Concise: Short but clear
- Lowercase: All lowercase letters with hyphens
- Prefixed: Always start with
johnmog-
Format: johnmog-<area>-<change>
Good Examples:
johnmog-auth-validationjohnmog-cache-fixjohnmog-api-clientjohnmog-sentry-rollupjohnmog-obs-loggingjohnmog-deps-update
Avoid:
- Too vague:
johnmog-changes,johnmog-fix - Too long:
johnmog-add-new-user-authentication-with-oauth - Too detailed:
johnmog-refactor-exception-rollup-fingerprint-generation - Action verbs in name:
johnmog-add-auth,johnmog-fix-cache
Error Handling
No staged changes:
Error: No changes staged for commit.
Please stage changes with: git add <files>
Not in a git repository:
Error: Not in a git repository.
Please initialize with: git init
Branch creation fails:
Error: Branch 'johnmog-<name>' already exists.
Options:
1. Switch to existing branch: git checkout johnmog-<name>
2. Choose a different branch name
3. Delete existing branch: git branch -d johnmog-<name>
Best Practices
- Stage intentionally: Only stage related changes for each commit
- Review before committing: Always review
git diff --cachedbefore proceeding - Keep commits atomic: One logical change per commit
- Keep messages under 52 chars: Follow git's standard commit message length
- Be clear and direct: Avoid jargon, prefixes, or overly technical terms
- Pull before branching: When on main, ensure you're up to date with
git pull
Message Style Guide
Good commit messages:
add login validation logic
fix null pointer in cache lookup
update API retry behavior
remove unused rollup checks
improve error logging detail
refactor database connection pool
Messages to avoid:
feat(auth): add login validation ❌ uses conventional commit prefix
Fixed bug in the cache system ❌ capitalized, past tense
refactoring the database connection logic ❌ gerund form, too wordy
WIP ❌ not descriptive
small fix ❌ too vague
Score
Total Score
Based on repository quality metrics
SKILL.mdファイルが含まれている
ライセンスが設定されている
100文字以上の説明がある
GitHub Stars 100以上
3ヶ月以内に更新がある
10回以上フォークされている
オープンIssueが50未満
プログラミング言語が設定されている
1つ以上のタグが設定されている
Reviews
Reviews coming soon