Smart Commit
Automated, security-aware Git commit workflow. Analyzes changes, groups files logically, and commits with clean Conventional Commit messages.
Activation Triggers
Activate automatically (no confirmation needed) when the user says:
- "commit", "smart commit", "commiter", "drill baby drill", "push"
- "save changes", "push", "send to GitHub"
- "git commit", "commit all", "commit everything"
Workflow
Phase 1 — Security Audit
MANDATORY before any commit. Abort on critical findings.
# 1. Detect secrets and credentials (CRITICAL — block on match)
git diff --cached --name-only | xargs grep -rlE \
'(PRIVATE KEY|password\s*=|api_key\s*=|secret\s*=|token\s*=|AWS_SECRET|sk-[a-zA-Z0-9]{20,})' \
2>/dev/null
# 2. Check for sensitive file extensions
git status --porcelain | grep -iE '\.(env|pem|key|p12|pfx|jks|keystore|secret|credentials|htpasswd)$'
# 3. Detect large files (>10MB)
find . -not -path './.git/*' -not -path './node_modules/*' \
-not -path './.venv/*' -not -path './vendor/*' \
-size +10M -type f 2>/dev/null
# 4. Verify .gitignore covers essentials
# See references/security-checklist.md for full patterns
| Finding |
Action |
| Secrets/credentials detected |
BLOCK — alert user, never commit |
.env, .pem, .key files staged |
BLOCK — alert user, suggest .gitignore |
| Large binaries (>50MB) |
WARN — suggest .gitignore or Git LFS |
| Large files (10-50MB) |
WARN — ask user for confirmation |
Missing .gitignore patterns |
FIX — add essential patterns, include in first commit |
NEVER auto-delete user files. Only warn and suggest actions. File deletion is the user's decision.
Phase 2 — Analyze Changes
git status --porcelain
Classify each file by its git status:
?? → new (untracked)
M → modified
A → added (staged)
D → deleted
R → renamed
Phase 3 — Group by Concern
Group files into logical commits using adaptive detection. The agent MUST inspect the actual project structure — do not assume any framework.
Grouping strategy (priority order):
- Configuration — Package manifests, lockfiles, config files, CI/CD,
.gitignore
- Types/Schemas — Type definitions, interfaces, schemas, models
- Libraries/Utils — Shared code, helpers, utilities
- Core Logic — Components, services, controllers, routes, pages
- Styles — CSS, SCSS, Tailwind, theme files
- Tests — Test files, test configs, fixtures
- Documentation — Markdown, docs, changelogs
- Assets — Images, fonts, static files
- Infrastructure — Docker, Terraform, deployment configs
Adaptive rules:
- Inspect the actual directory tree to determine project type
- Group related files together (e.g., component + its test + its styles)
- If a feature touches <5 files across categories, consider a single feature commit
- For detailed patterns per framework, see references/grouping-patterns.md
Phase 4 — Commit Sequentially
Commit in dependency order (config → types → libs → core → rest).
git add <files>
git commit -m "<type>(<scope>): <description>"
Message format: Conventional Commits
| Type |
When |
feat |
New feature or functionality |
fix |
Bug fix |
docs |
Documentation only |
style |
Formatting, whitespace (no logic change) |
refactor |
Code restructuring (no behavior change) |
test |
Adding or updating tests |
chore |
Build, config, dependencies, tooling |
perf |
Performance improvement |
ci |
CI/CD configuration |
Message rules:
- Imperative mood: "add", "fix", "update" (not "added", "fixes")
- Scope is optional but recommended:
feat(auth): add login endpoint
- Max 72 characters for subject line
- Be specific:
feat(ui): add accordion and badge components not feat: add stuff
- Language: match the project's language convention (default: English)
Phase 5 — Report & Push
After all commits:
✅ Smart Commit complete!
📦 N commits created:
1. chore: update dependencies
→ package.json, pnpm-lock.yaml
2. feat(ui): add button and dialog components
→ src/components/ui/button.tsx
→ src/components/ui/dialog.tsx
🔒 Security: No issues detected
🚀 Push to remote? (Y/n)
If user confirms, push to current tracked branch.
Security Guidelines
See references/security-checklist.md for the full checklist.
Hard blocks (NEVER commit):
- Private keys, API keys, tokens, passwords in code
.env files with real credentials
- Database dumps (
.sql with data)
- Certificate files (
.pem, .p12, .pfx)
Minimum .gitignore patterns:
# Secrets
.env
.env.*
*.pem
*.key
*.p12
# Dependencies
node_modules/
.venv/
vendor/
__pycache__/
# Build outputs
dist/
build/
*.pyc
# OS files
.DS_Store
Thumbs.db
# Large media (adjust per project)
*.mp4
*.mov
*.zip
*.tar.gz
Edge Cases
| Situation |
Action |
| No changes to commit |
Report: "Working directory clean" |
| Already staged files |
Include in analysis, respect existing staging |
| Merge conflicts |
Alert user, abort until resolved |
| Branch behind remote |
Warn, suggest git pull first |
| Detached HEAD |
Warn user, suggest creating a branch |
| Empty repository |
Handle git commit with --allow-empty for initial commit if needed |
| Submodules changed |
Group as separate infrastructure commit |
Customization
The skill adapts automatically to any project. For project-specific behavior:
- Doc tracking: If the project has
CHANGELOG.md, suggest updating it
- Monorepo: Group by package/workspace, prefix scope with package name
- Pre-commit hooks: Respect existing
.pre-commit-config.yaml or husky setup
- Branch naming: Follow existing branch conventions for any new branches
Anti-Patterns
| Don't |
Do Instead |
feat: add everything |
Split into logical atomic commits |
update files |
Describe WHAT changed specifically |
| Mix config + features |
Separate concerns into distinct commits |
| Auto-delete user files |
Warn and suggest, let user decide |
| Commit secrets "temporarily" |
NEVER — secrets in git history persist forever |
| Skip security audit |
ALWAYS run Phase 1, even for "quick" commits |
References
| File |
Contents |
| references/security-checklist.md |
Full pre-commit security audit checklist |
| references/grouping-patterns.md |
Framework-specific grouping patterns |
| references/conventional-commits.md |
Conventional Commits quick reference |
1---2name: smart-commit-43description: Automates intelligent Git commits by analyzing unstaged/staged changes, grouping files by logical development concern, and committing sequentially with descriptive Conventional Commit messages. Includes pre-commit security audit protecting against credential leaks and large binary commits. Use when the user says "commit", "smart commit", "save changes", "push", "git commit", or similar.4---5
6# Smart Commit
7
8Automated, security-aware Git commit workflow. Analyzes changes, groups files logically, and commits with clean Conventional Commit messages.
9
10## Activation Triggers
11
12Activate automatically (no confirmation needed) when the user says:
13
14- "commit", "smart commit", "commiter", "drill baby drill", "push"
15- "save changes", "push", "send to GitHub"
16- "git commit", "commit all", "commit everything"
17
18## Workflow
19
20### Phase 1 — Security Audit
21
22**MANDATORY before any commit.** Abort on critical findings.
23
24```bash
25# 1. Detect secrets and credentials (CRITICAL — block on match)
26git diff --cached --name-only | xargs grep -rlE \
27 '(PRIVATE KEY|password\s*=|api_key\s*=|secret\s*=|token\s*=|AWS_SECRET|sk-[a-zA-Z0-9]{20,})' \
28 2>/dev/null
29
30# 2. Check for sensitive file extensions
31git status --porcelain | grep -iE '\.(env|pem|key|p12|pfx|jks|keystore|secret|credentials|htpasswd)$'
32
33# 3. Detect large files (>10MB)
34find . -not -path './.git/*' -not -path './node_modules/*' \
35 -not -path './.venv/*' -not -path './vendor/*' \
36 -size +10M -type f 2>/dev/null
37
38# 4. Verify .gitignore covers essentials
39# See references/security-checklist.md for full patterns
40```
41
42| Finding | Action |
43| ----------------------------------- | --------------------------------------------------------- |
44| Secrets/credentials detected | **BLOCK** — alert user, never commit |
45| `.env`, `.pem`, `.key` files staged | **BLOCK** — alert user, suggest `.gitignore` |
46| Large binaries (>50MB) | **WARN** — suggest `.gitignore` or Git LFS |
47| Large files (10-50MB) | **WARN** — ask user for confirmation |
48| Missing `.gitignore` patterns | **FIX** — add essential patterns, include in first commit |
49
50> **NEVER auto-delete user files.** Only warn and suggest actions. File deletion is the user's decision.
51
52### Phase 2 — Analyze Changes
53
54```bash
55git status --porcelain
56```
57
58Classify each file by its git status:
59
60- `??` → new (untracked)
61- `M` → modified
62- `A` → added (staged)
63- `D` → deleted
64- `R` → renamed
65
66### Phase 3 — Group by Concern
67
68Group files into logical commits using **adaptive detection**. The agent MUST inspect the actual project structure — do not assume any framework.
69
70**Grouping strategy** (priority order):
71
721. **Configuration** — Package manifests, lockfiles, config files, CI/CD, `.gitignore`
732. **Types/Schemas** — Type definitions, interfaces, schemas, models
743. **Libraries/Utils** — Shared code, helpers, utilities
754. **Core Logic** — Components, services, controllers, routes, pages
765. **Styles** — CSS, SCSS, Tailwind, theme files
776. **Tests** — Test files, test configs, fixtures
787. **Documentation** — Markdown, docs, changelogs
798. **Assets** — Images, fonts, static files
809. **Infrastructure** — Docker, Terraform, deployment configs
81
82**Adaptive rules:**
83
84- Inspect the actual directory tree to determine project type
85- Group related files together (e.g., component + its test + its styles)
86- If a feature touches <5 files across categories, consider a single feature commit
87- For detailed patterns per framework, see [references/grouping-patterns.md](references/grouping-patterns.md)
88
89### Phase 4 — Commit Sequentially
90
91Commit in dependency order (config → types → libs → core → rest).
92
93```bash
94git add <files>
95git commit -m "<type>(<scope>): <description>"
96```
97
98**Message format:** [Conventional Commits](https://www.conventionalcommits.org/)
99
100| Type | When |
101| ---------- | ---------------------------------------- |
102| `feat` | New feature or functionality |
103| `fix` | Bug fix |
104| `docs` | Documentation only |
105| `style` | Formatting, whitespace (no logic change) |
106| `refactor` | Code restructuring (no behavior change) |
107| `test` | Adding or updating tests |
108| `chore` | Build, config, dependencies, tooling |
109| `perf` | Performance improvement |
110| `ci` | CI/CD configuration |
111
112**Message rules:**
113
114- Imperative mood: "add", "fix", "update" (not "added", "fixes")
115- Scope is optional but recommended: `feat(auth): add login endpoint`
116- Max 72 characters for subject line
117- Be specific: `feat(ui): add accordion and badge components` not `feat: add stuff`
118- Language: match the project's language convention (default: English)
119
120### Phase 5 — Report & Push
121
122After all commits:
123
124```
125✅ Smart Commit complete!
126
127📦 N commits created:
128
1291. chore: update dependencies
130 → package.json, pnpm-lock.yaml
131
1322. feat(ui): add button and dialog components
133 → src/components/ui/button.tsx
134 → src/components/ui/dialog.tsx
135
136🔒 Security: No issues detected
137🚀 Push to remote? (Y/n)
138```
139
140If user confirms, push to current tracked branch.
141
142## Security Guidelines
143
144> See [references/security-checklist.md](references/security-checklist.md) for the full checklist.
145
146**Hard blocks (NEVER commit):**
147
148- Private keys, API keys, tokens, passwords in code
149- `.env` files with real credentials
150- Database dumps (`.sql` with data)
151- Certificate files (`.pem`, `.p12`, `.pfx`)
152
153**Minimum `.gitignore` patterns:**
154
155```gitignore
156# Secrets
157.env
158.env.*
159*.pem
160*.key
161*.p12
162
163# Dependencies
164node_modules/
165.venv/
166vendor/
167__pycache__/
168
169# Build outputs
170dist/
171build/
172*.pyc
173
174# OS files
175.DS_Store
176Thumbs.db
177
178# Large media (adjust per project)
179*.mp4
180*.mov
181*.zip
182*.tar.gz
183```
184
185## Edge Cases
186
187| Situation | Action |
188| -------------------- | --------------------------------------------------------------------- |
189| No changes to commit | Report: "Working directory clean" |
190| Already staged files | Include in analysis, respect existing staging |
191| Merge conflicts | Alert user, abort until resolved |
192| Branch behind remote | Warn, suggest `git pull` first |
193| Detached HEAD | Warn user, suggest creating a branch |
194| Empty repository | Handle `git commit` with `--allow-empty` for initial commit if needed |
195| Submodules changed | Group as separate infrastructure commit |
196
197## Customization
198
199The skill adapts automatically to any project. For project-specific behavior:
200
201- **Doc tracking**: If the project has `CHANGELOG.md`, suggest updating it
202- **Monorepo**: Group by package/workspace, prefix scope with package name
203- **Pre-commit hooks**: Respect existing `.pre-commit-config.yaml` or `husky` setup
204- **Branch naming**: Follow existing branch conventions for any new branches
205
206## Anti-Patterns
207
208| Don't | Do Instead |
209| ---------------------------- | -------------------------------------------------- |
210| `feat: add everything` | Split into logical atomic commits |
211| `update files` | Describe WHAT changed specifically |
212| Mix config + features | Separate concerns into distinct commits |
213| Auto-delete user files | Warn and suggest, let user decide |
214| Commit secrets "temporarily" | **NEVER** — secrets in git history persist forever |
215| Skip security audit | **ALWAYS** run Phase 1, even for "quick" commits |
216
217## References
218
219| File | Contents |
220| ------------------------------------------------------------------------ | ---------------------------------------- |
221| [references/security-checklist.md](references/security-checklist.md) | Full pre-commit security audit checklist |
222| [references/grouping-patterns.md](references/grouping-patterns.md) | Framework-specific grouping patterns |
223| [references/conventional-commits.md](references/conventional-commits.md) | Conventional Commits quick reference |