git.commit.smart
Purpose
This skill automates the creation of high-quality git commits for Carbon ACX by:
- Analyzing staged changes to understand what changed and why
- Drafting commit messages following conventional commit format
- Matching existing repository commit style
- Including standardized Claude Code footer
- Handling pre-commit hook failures gracefully
- Ensuring no secrets or credentials are committed
When to Use
Trigger Patterns:
- "Create a commit"
- "Commit these changes"
- "Make a commit with..."
- User has staged changes and needs to commit
- After completing a task that modified files
Do NOT Use When:
- No changes are staged (
git status shows clean)
- User wants to review changes first (show diff instead)
- Creating a pull request (use
git.pr.create skill instead)
- Amending existing commits (different workflow)
Allowed Tools
bash - Run git commands (status, diff, log, add, commit)
read_file - Read modified files for context
grep - Search for patterns in changes
Access Level: 2 (File Modification - can create commits)
Tool Rationale:
bash: Required for all git operations
read_file: Helps understand changes for better commit messages
grep: Search commit history for style patterns
Explicitly Denied:
- No
--no-verify flag (never skip hooks)
- No force operations
- No git config modifications
- No committing files in
.gitignore patterns
Expected I/O
Input:
- Type: Commit request (implicit or explicit)
- Context: Staged files ready to commit
- Optional: User-provided commit message hint or scope
Example:
"Commit the UX improvements to the dashboard"
"Create a commit for these changes"
"Commit with message: fix typo in README"
Output:
- Type: Git commit successfully created
- Format: Commit hash + message summary
- Includes:
- Files committed (summary)
- Commit message used
- Commit hash
- Next steps suggestion (push, create PR, run tests)
Validation:
- Commit message follows conventional format
- No secrets detected in changes
- Pre-commit hooks passed (or handled)
- Commit footer includes Claude Code attribution
Dependencies
Required:
- Git repository (
.git directory exists)
- Git configured with user.name and user.email
- Changes staged for commit (
git add already run)
Optional:
- Pre-commit hooks installed
gh CLI for GitHub integration (for suggesting PR creation)
Workflow
Step 1: Gather Context
Run in parallel:
git status
git diff --staged
git log --oneline -10
Analysis:
- What files are staged?
- What type of changes (features, fixes, docs, chores)?
- What's the commit message style in recent history?
Step 2: Draft Commit Message
Format:
<type>(<scope>): <subject>
<body>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Conventional Commit Types:
feat - New feature
fix - Bug fix
chore - Maintenance, dependencies, tooling
docs - Documentation only
refactor - Code restructuring without behavior change
test - Adding or updating tests
style - Formatting, whitespace, missing semicolons
perf - Performance improvements
Scope Examples:
web - Modern web app (apps/carbon-acx-web)
site - Static React site
calc - Derivation engine
data - CSV data files
workers - Cloudflare Workers
ci - CI/CD workflows
Subject Line:
- Max 72 characters
- Imperative mood ("add feature" not "added feature")
- No period at end
- Lowercase after colon
Body:
- Explain WHY, not WHAT (what is in the diff)
- Wrap at 100 characters
- Use bullet points for multiple reasons
- Reference issues:
Closes #123, Relates to #456
Step 3: Create Commit
Use HEREDOC for message:
git commit -m "$(cat <<'EOF'
feat(web): add dark mode toggle to dashboard
Users requested ability to switch between light and dark themes
for extended analysis sessions. This adds a theme toggle in the
header that persists preference to localStorage.
Closes #42
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
EOF
)"
Step 4: Handle Pre-commit Hooks
If hook fails:
- Read hook output
- Determine failure type:
- Linter errors: Fix automatically if possible, re-commit
- Formatter changes: Files were modified by hook
- Test failures: Report to user, cannot auto-fix
If hook modified files:
# Check if safe to amend
git log -1 --format='%an %ae' # Verify we're the author
git status # Verify not pushed yet
# If both checks pass:
git add .
git commit --amend --no-edit
If unsafe to amend:
- Create NEW commit with hook fixes (never amend other developers' work)
Step 5: Confirm Success
git log -1 --oneline
git status
Report to user:
- ✅ Commit created:
abc1234 feat(web): add dark mode toggle
- Files committed: 3 files changed, 127 insertions(+), 45 deletions(-)
- Next steps: Run tests, push to remote, or create PR?
Examples
Example 1: Feature Commit
User: "Commit the new emission chart component"
Claude Process:
- Run
git status, git diff --staged, git log -10
- Analyze changes: New React component in
apps/carbon-acx-web/src/components/
- Draft message:
feat(web): add EmissionChart component for layer visualization
Creates reusable chart component using Recharts to display
emission data by layer. Includes responsive design, hover
tooltips, and accessibility labels.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Execute commit
- Report success with hash
Example 2: Fix Commit
User: "Commit the bug fix"
Claude Process:
- Analyze staged changes: Fix in
calc/derive.py line 245
- Read recent commits for style
- Draft message:
fix(calc): correct emission factor calculation for aviation layer
Previous calculation was using wrong unit conversion factor
(kg instead of tCO2e). This fixes the multiplier to match the
emission_factors.csv schema.
Fixes #128
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Execute commit
- Suggest running
pytest tests/ to verify fix
Example 3: Chore Commit with Pre-commit Hook
User: "Commit the dependency updates"
Claude Process:
- Analyze:
package.json and pnpm-lock.yaml modified
- Draft message:
chore(deps): update React and TypeScript dependencies
- React 18.2.0 → 18.3.1 (security patch)
- TypeScript 5.5.3 → 5.5.4 (bug fixes)
All tests pass with updated versions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Execute
git commit
- Pre-commit hook runs and fails: ESLint finds unused imports
- Read hook output, identify issue
- Run
pnpm run lint --fix to auto-fix
- Check authorship: matches current user ✅
- Check pushed: branch is ahead, not pushed ✅
- Amend commit:
git add .
git commit --amend --no-edit
- Report: "Commit created (with pre-commit lint fixes applied)"
Example 4: Documentation Commit
User: "Commit the README updates"
Claude Process:
- Analyze: Only
README.md changed
- Draft message:
docs: update installation instructions for pnpm workspaces
Clarifies the difference between running commands from repo
root vs within app directory. Adds troubleshooting section
for common pnpm workspace issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Execute commit
- Suggest: "Documentation updated. Ready to push or create PR?"
Example 5: Multi-file Refactor
User: "Commit these refactoring changes"
Claude Process:
- Analyze: 8 files changed across
apps/carbon-acx-web/src/
- Identify pattern: Moving components to new directory structure
- Draft message:
refactor(web): reorganize components into feature-based folders
Restructures components from flat directory to feature-based
organization:
- charts/ - All visualization components
- forms/ - Activity and data entry forms
- layout/ - Headers, footers, navigation
No functional changes, only file moves and import updates.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Execute commit
- Suggest: "Run
pnpm test to verify imports still resolve correctly"
Limitations
Scope Limitations:
- Cannot commit unstaged changes (user must
git add first)
- Cannot resolve merge conflicts (different skill)
- Cannot amend commits by other authors (safety constraint)
- Cannot skip pre-commit hooks without user approval
Known Edge Cases:
- Empty commits (no changes staged) → Report error, suggest
git add
- Detached HEAD state → Warn user, suggest checking out branch
- Merge in progress → Warn, suggest completing or aborting merge first
- Untracked files only → Remind to
git add files first
Performance Constraints:
- Very large diffs (1000+ files) may take 10-20 seconds to analyze
- Binary files can't be analyzed for context (rely on filenames)
Security Boundaries:
- Scans for common secret patterns (.env, credentials, API keys)
- Rejects commits with potential secrets (warns user)
- Cannot detect all possible credential formats
- User must manually review sensitive changes
Validation Criteria
Success Metrics:
- ✅ Commit message follows conventional commit format
- ✅ Commit includes Claude Code footer
- ✅ Type and scope appropriate for changes
- ✅ Subject line ≤72 characters
- ✅ Body explains WHY (not just WHAT)
- ✅ No secrets detected in commit
- ✅ Pre-commit hooks passed or handled
- ✅ User informed of success and next steps
Failure Modes:
- ❌ No staged changes → Ask user to
git add files
- ❌ Secret detected → Reject commit, warn user
- ❌ Pre-commit hook failed → Report error, suggest fixes
- ❌ Commit type unclear → Ask user for clarification
- ❌ Git not configured → Report error, suggest
git config
Recovery:
- If uncertain about commit type: Ask user
- If hook fails repeatedly: Show error, ask user to investigate
- If secret detected: Explain pattern matched, ask user to confirm false positive
- If commit message unclear: Draft and ask user to review before committing
Related Skills
Composes With:
git.pr.create - After committing, create pull request
git.branch.manage - Create branch before committing
schema.linter - Validate data files before committing changes
Dependencies:
- None - foundational skill
Alternative Skills:
- For PRs:
git.pr.create
- For releases:
git.release.prep
Maintenance
Owner: Workspace Team (shared skill)
Review Cycle: Monthly
Last Updated: 2025-10-24
Version: 1.0.0
Maintenance Notes:
- Update conventional commit types if Carbon ACX adds new categories
- Adjust secret detection patterns as new credential types emerge
- Review pre-commit hook handling as repo hooks evolve
- Keep commit message examples synchronized with actual repo style
1---2name: git-commit-smart3description: Intelligently create git commits with proper formatting, conventional commit style, and Carbon ACX footer conventions.4---5
6# git.commit.smart
7
8## Purpose
9
10This skill automates the creation of high-quality git commits for Carbon ACX by:
11- Analyzing staged changes to understand what changed and why
12- Drafting commit messages following conventional commit format
13- Matching existing repository commit style
14- Including standardized Claude Code footer
15- Handling pre-commit hook failures gracefully
16- Ensuring no secrets or credentials are committed
17
18## When to Use
19
20**Trigger Patterns:**
21- "Create a commit"
22- "Commit these changes"
23- "Make a commit with..."
24- User has staged changes and needs to commit
25- After completing a task that modified files
26
27**Do NOT Use When:**
28- No changes are staged (`git status` shows clean)
29- User wants to review changes first (show diff instead)
30- Creating a pull request (use `git.pr.create` skill instead)
31- Amending existing commits (different workflow)
32
33## Allowed Tools
34
35- `bash` - Run git commands (status, diff, log, add, commit)
36- `read_file` - Read modified files for context
37- `grep` - Search for patterns in changes
38
39**Access Level:** 2 (File Modification - can create commits)
40
41**Tool Rationale:**
42- `bash`: Required for all git operations
43- `read_file`: Helps understand changes for better commit messages
44- `grep`: Search commit history for style patterns
45
46**Explicitly Denied:**
47- No `--no-verify` flag (never skip hooks)
48- No force operations
49- No git config modifications
50- No committing files in `.gitignore` patterns
51
52## Expected I/O
53
54**Input:**
55- Type: Commit request (implicit or explicit)
56- Context: Staged files ready to commit
57- Optional: User-provided commit message hint or scope
58
59**Example:**
60```
61"Commit the UX improvements to the dashboard"
62"Create a commit for these changes"
63"Commit with message: fix typo in README"
64```
65
66**Output:**
67- Type: Git commit successfully created
68- Format: Commit hash + message summary
69- Includes:
70 - Files committed (summary)
71 - Commit message used
72 - Commit hash
73 - Next steps suggestion (push, create PR, run tests)
74
75**Validation:**
76- Commit message follows conventional format
77- No secrets detected in changes
78- Pre-commit hooks passed (or handled)
79- Commit footer includes Claude Code attribution
80
81## Dependencies
82
83**Required:**
84- Git repository (`.git` directory exists)
85- Git configured with user.name and user.email
86- Changes staged for commit (`git add` already run)
87
88**Optional:**
89- Pre-commit hooks installed
90- `gh` CLI for GitHub integration (for suggesting PR creation)
91
92## Workflow
93
94### Step 1: Gather Context
95
96Run in parallel:
97```bash
98git status
99git diff --staged
100git log --oneline -10
101```
102
103**Analysis:**
104- What files are staged?
105- What type of changes (features, fixes, docs, chores)?
106- What's the commit message style in recent history?
107
108### Step 2: Draft Commit Message
109
110**Format:**
111```
112<type>(<scope>): <subject>
113
114<body>
115
116🤖 Generated with [Claude Code](https://claude.com/claude-code)
117
118Co-Authored-By: Claude <noreply@anthropic.com>
119```
120
121**Conventional Commit Types:**
122- `feat` - New feature
123- `fix` - Bug fix
124- `chore` - Maintenance, dependencies, tooling
125- `docs` - Documentation only
126- `refactor` - Code restructuring without behavior change
127- `test` - Adding or updating tests
128- `style` - Formatting, whitespace, missing semicolons
129- `perf` - Performance improvements
130
131**Scope Examples:**
132- `web` - Modern web app (apps/carbon-acx-web)
133- `site` - Static React site
134- `calc` - Derivation engine
135- `data` - CSV data files
136- `workers` - Cloudflare Workers
137- `ci` - CI/CD workflows
138
139**Subject Line:**
140- Max 72 characters
141- Imperative mood ("add feature" not "added feature")
142- No period at end
143- Lowercase after colon
144
145**Body:**
146- Explain WHY, not WHAT (what is in the diff)
147- Wrap at 100 characters
148- Use bullet points for multiple reasons
149- Reference issues: `Closes #123`, `Relates to #456`
150
151### Step 3: Create Commit
152
153Use HEREDOC for message:
154```bash
155git commit -m "$(cat <<'EOF'
156feat(web): add dark mode toggle to dashboard
157
158Users requested ability to switch between light and dark themes
159for extended analysis sessions. This adds a theme toggle in the
160header that persists preference to localStorage.
161
162Closes #42
163
164🤖 Generated with [Claude Code](https://claude.com/claude-code)
165
166Co-Authored-By: Claude <noreply@anthropic.com>
167EOF
168)"
169```
170
171### Step 4: Handle Pre-commit Hooks
172
173**If hook fails:**
174
1751. Read hook output
1762. Determine failure type:
177 - **Linter errors:** Fix automatically if possible, re-commit
178 - **Formatter changes:** Files were modified by hook
179 - **Test failures:** Report to user, cannot auto-fix
180
181**If hook modified files:**
182
183```bash
184# Check if safe to amend
185git log -1 --format='%an %ae' # Verify we're the author
186git status # Verify not pushed yet
187
188# If both checks pass:
189git add .
190git commit --amend --no-edit
191```
192
193**If unsafe to amend:**
194- Create NEW commit with hook fixes (never amend other developers' work)
195
196### Step 5: Confirm Success
197
198```bash
199git log -1 --oneline
200git status
201```
202
203**Report to user:**
204- ✅ Commit created: `abc1234 feat(web): add dark mode toggle`
205- Files committed: 3 files changed, 127 insertions(+), 45 deletions(-)
206- Next steps: Run tests, push to remote, or create PR?
207
208## Examples
209
210### Example 1: Feature Commit
211
212**User:** "Commit the new emission chart component"
213
214**Claude Process:**
2151. Run `git status`, `git diff --staged`, `git log -10`
2162. Analyze changes: New React component in `apps/carbon-acx-web/src/components/`
2173. Draft message:
218 ```
219 feat(web): add EmissionChart component for layer visualization
220
221 Creates reusable chart component using Recharts to display
222 emission data by layer. Includes responsive design, hover
223 tooltips, and accessibility labels.
224
225 🤖 Generated with [Claude Code](https://claude.com/claude-code)
226
227 Co-Authored-By: Claude <noreply@anthropic.com>
228 ```
2294. Execute commit
2305. Report success with hash
231
232### Example 2: Fix Commit
233
234**User:** "Commit the bug fix"
235
236**Claude Process:**
2371. Analyze staged changes: Fix in `calc/derive.py` line 245
2382. Read recent commits for style
2393. Draft message:
240 ```
241 fix(calc): correct emission factor calculation for aviation layer
242
243 Previous calculation was using wrong unit conversion factor
244 (kg instead of tCO2e). This fixes the multiplier to match the
245 emission_factors.csv schema.
246
247 Fixes #128
248
249 🤖 Generated with [Claude Code](https://claude.com/claude-code)
250
251 Co-Authored-By: Claude <noreply@anthropic.com>
252 ```
2534. Execute commit
2545. Suggest running `pytest tests/` to verify fix
255
256### Example 3: Chore Commit with Pre-commit Hook
257
258**User:** "Commit the dependency updates"
259
260**Claude Process:**
2611. Analyze: `package.json` and `pnpm-lock.yaml` modified
2622. Draft message:
263 ```
264 chore(deps): update React and TypeScript dependencies
265
266 - React 18.2.0 → 18.3.1 (security patch)
267 - TypeScript 5.5.3 → 5.5.4 (bug fixes)
268
269 All tests pass with updated versions.
270
271 🤖 Generated with [Claude Code](https://claude.com/claude-code)
272
273 Co-Authored-By: Claude <noreply@anthropic.com>
274 ```
2753. Execute `git commit`
2764. **Pre-commit hook runs and fails:** ESLint finds unused imports
2775. Read hook output, identify issue
2786. Run `pnpm run lint --fix` to auto-fix
2797. Check authorship: matches current user ✅
2808. Check pushed: branch is ahead, not pushed ✅
2819. Amend commit:
282 ```bash
283 git add .
284 git commit --amend --no-edit
285 ```
28610. Report: "Commit created (with pre-commit lint fixes applied)"
287
288### Example 4: Documentation Commit
289
290**User:** "Commit the README updates"
291
292**Claude Process:**
2931. Analyze: Only `README.md` changed
2942. Draft message:
295 ```
296 docs: update installation instructions for pnpm workspaces
297
298 Clarifies the difference between running commands from repo
299 root vs within app directory. Adds troubleshooting section
300 for common pnpm workspace issues.
301
302 🤖 Generated with [Claude Code](https://claude.com/claude-code)
303
304 Co-Authored-By: Claude <noreply@anthropic.com>
305 ```
3063. Execute commit
3074. Suggest: "Documentation updated. Ready to push or create PR?"
308
309### Example 5: Multi-file Refactor
310
311**User:** "Commit these refactoring changes"
312
313**Claude Process:**
3141. Analyze: 8 files changed across `apps/carbon-acx-web/src/`
3152. Identify pattern: Moving components to new directory structure
3163. Draft message:
317 ```
318 refactor(web): reorganize components into feature-based folders
319
320 Restructures components from flat directory to feature-based
321 organization:
322 - charts/ - All visualization components
323 - forms/ - Activity and data entry forms
324 - layout/ - Headers, footers, navigation
325
326 No functional changes, only file moves and import updates.
327
328 🤖 Generated with [Claude Code](https://claude.com/claude-code)
329
330 Co-Authored-By: Claude <noreply@anthropic.com>
331 ```
3324. Execute commit
3335. Suggest: "Run `pnpm test` to verify imports still resolve correctly"
334
335## Limitations
336
337**Scope Limitations:**
338- Cannot commit unstaged changes (user must `git add` first)
339- Cannot resolve merge conflicts (different skill)
340- Cannot amend commits by other authors (safety constraint)
341- Cannot skip pre-commit hooks without user approval
342
343**Known Edge Cases:**
344- Empty commits (no changes staged) → Report error, suggest `git add`
345- Detached HEAD state → Warn user, suggest checking out branch
346- Merge in progress → Warn, suggest completing or aborting merge first
347- Untracked files only → Remind to `git add` files first
348
349**Performance Constraints:**
350- Very large diffs (1000+ files) may take 10-20 seconds to analyze
351- Binary files can't be analyzed for context (rely on filenames)
352
353**Security Boundaries:**
354- Scans for common secret patterns (.env, credentials, API keys)
355- Rejects commits with potential secrets (warns user)
356- Cannot detect all possible credential formats
357- User must manually review sensitive changes
358
359## Validation Criteria
360
361**Success Metrics:**
362- ✅ Commit message follows conventional commit format
363- ✅ Commit includes Claude Code footer
364- ✅ Type and scope appropriate for changes
365- ✅ Subject line ≤72 characters
366- ✅ Body explains WHY (not just WHAT)
367- ✅ No secrets detected in commit
368- ✅ Pre-commit hooks passed or handled
369- ✅ User informed of success and next steps
370
371**Failure Modes:**
372- ❌ No staged changes → Ask user to `git add` files
373- ❌ Secret detected → Reject commit, warn user
374- ❌ Pre-commit hook failed → Report error, suggest fixes
375- ❌ Commit type unclear → Ask user for clarification
376- ❌ Git not configured → Report error, suggest `git config`
377
378**Recovery:**
379- If uncertain about commit type: Ask user
380- If hook fails repeatedly: Show error, ask user to investigate
381- If secret detected: Explain pattern matched, ask user to confirm false positive
382- If commit message unclear: Draft and ask user to review before committing
383
384## Related Skills
385
386**Composes With:**
387- `git.pr.create` - After committing, create pull request
388- `git.branch.manage` - Create branch before committing
389- `schema.linter` - Validate data files before committing changes
390
391**Dependencies:**
392- None - foundational skill
393
394**Alternative Skills:**
395- For PRs: `git.pr.create`
396- For releases: `git.release.prep`
397
398## Maintenance
399
400**Owner:** Workspace Team (shared skill)
401**Review Cycle:** Monthly
402**Last Updated:** 2025-10-24
403**Version:** 1.0.0
404
405**Maintenance Notes:**
406- Update conventional commit types if Carbon ACX adds new categories
407- Adjust secret detection patterns as new credential types emerge
408- Review pre-commit hook handling as repo hooks evolve
409- Keep commit message examples synchronized with actual repo style