Commit Skill
This skill handles the git commit workflow with a focus on logical grouping and clear documentation.
Workflow
- •
Analyze State
- •Run
git statusto identify all untracked, modified, and deleted files. - •Run
git diff(unstaged) andgit diff --cached(staged) to examine the actual code changes.
- •Run
- •
Group Changes (Crucial Step)
- •Analyze the purpose of changes across all files.
- •Decision:
- •Single Commit: If all changes are small or serve a single purpose (e.g., "fix login bug" involved 3 files), keep them together.
- •Multiple Commits: If changes cover distinct, unrelated tasks (e.g., "update documentation" AND "refactor database code"), split them into separate commits.
- •Plan: If multiple commits are needed, list which files go into which commit.
- •
Draft Commit Messages For each identified commit group:
- •Header:
gitmoji <type>(<scope>): <subject>- •Gitmoji: Use the Gitmoji Guide (e.g., ✨ for features, 🐛 for bugs, ♻️ for refactor, 📝 for docs).
- •Type:
feat,fix,docs,style,refactor,test,chore. - •Subject: Imperative mood, concise.
- •Body (Optional/Context-Dependent):
- •Small/Simple changes: No body or 1-2 sentences explaining why.
- •Large/Complex changes: Use a bulleted list to detail specific changes.
- •Header:
- •
Execute Commits For each group:
- •
git add <specific_files>(Do not lazy usegit add .unless all changes truly belong to one commit). - •
git commit -m "header" -m "body" - •Verify success.
- •
Important Rules
- •NEVER commit secrets, API keys, or
.envfiles. - •Atomic Commits: Prefer smaller, focused commits over giant "dump" commits.
- •Verification: Always run
git statusafter operations to ensure the working directory state is what you expect.
Examples
Scenario 1: Mixed Changes
- •Changes:
auth.py(bug fix),README.md(typo fix). - •Action: Split into two commits.
- •
git add auth.py->git commit -m "🐛 fix(auth): resolve token expiration issue" - •
git add README.md->git commit -m "📝 docs: fix typo in installation guide"
- •
Scenario 2: Large Feature
- •Changes: 5 files related to a new "Dark Mode".
- •Action: Single commit.
- •
Title:
✨ feat(ui): implement dark mode theming - •
Body:
code```text - Add theme context provider - Update color palette in tailwind config - Add toggle switch to settings page - Fix contrast issues on dashboard ```
- •