Skills.MD
# Git Commit Guidelines
This skill enforces git commit best practices for the Packmind project, combining gitmoji for visual commit type identification with Conventional Commits format.
## TRIGGER CHECKLIST - Read This First
**TRIGGER THIS SKILL WHEN:**
- [ ] User asks you to commit changes
- [ ] User asks you to create a commit
- [ ] You are about to run `git commit`
- [ ] User says "commit this" or similar
**TRIGGER IMMEDIATELY** - before running any git commit command.
## Failure Examples - What NOT To Do
### Failure 1: Committing Without User Permission
```
User: "Fix the bug in the login function"
AI: [Fixes the bug]
AI: [Runs git commit directly without asking] ❌
CORRECT BEHAVIOR:
AI: [Fixes the bug]
AI: [Asks user: "Ready to commit. Here's the proposed message: ..."]
AI: [Waits for user approval]
AI: [Then commits]
```
### Failure 2: Using Close/Fix Before Issue References
```
AI: git commit -m "Fix login bug
Closes #123" ❌
CORRECT BEHAVIOR:
AI: git commit -m "Fix login bug
#123" ✓
```
### Failure 3: Skipping Quality Gate
```
AI: [Makes changes]
AI: [Commits immediately without running quality-gate] ❌
CORRECT BEHAVIOR:
AI: [Makes changes]
AI: [Runs npm run quality-gate]
AI: [Fixes any issues]
AI: [Then proposes commit]
```
### Failure 4: Missing Gitmoji
```
AI: git commit -m "feat(auth): add login validation" ❌
CORRECT BEHAVIOR:
AI: git commit -m "✨ feat(auth): add login validation" ✓
```
## Commit Message Format
```
<gitmoji> <type>(<scope>): <subject>
<body>
<issue-reference>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Format Rules
| Element | Rule |
| ------------------- | --------------------------------------------------------------------------------------------------- |
| **Gitmoji** | Required. Must match the commit type |
| **Type** | Required. One of: feat, fix, refactor, docs, test, chore, style, perf, security, remove, move, deps |
| **Scope** | Optional. Component or module affected (e.g., auth, api, ui) |
| **Subject** | Required. Imperative mood, no period, max 72 chars |
| **Body** | Optional. Bullet points with `-` prefix for multiple changes |
| **Issue Reference** | Optional. Use `#123` format. NEVER prefix with "Close", "Fix", or "Resolve" |
| **Co-Author** | Required for AI-assisted commits |
## Gitmoji Reference Table
| Gitmoji | Type | Description | Example |
| ------- | -------- | ----------------------- | -------------------------------------------- |
| ✨ | feat | New feature | `✨ feat(auth): add OAuth2 support` |
| 🐛 | fix | Bug fix | `🐛 fix(api): handle null response` |
| ♻️ | refactor | Code refactoring | `♻️ refactor(core): extract helper function` |
| 📝 | docs | Documentation | `📝 docs: update API reference` |
| ✅ | test | Adding/updating tests | `✅ test(auth): add login tests` |
| 🔧 | chore | Maintenance tasks | `🔧 chore: update dependencies` |
| 🎨 | style | Code formatting | `🎨 style: apply prettier formatting` |
| ⚡️ | perf | Performance improvement | `⚡️ perf(query): optimize database calls` |
| 🔒️ | security | Security fix | `🔒️ security: sanitize user input` |
| 🗑️ | remove | Removing code/files | `🗑️ remove: delete deprecated endpoint` |
| 🚚 | move | Moving/renaming files | `🚚 move: relocate utils to shared` |
| 📦 | deps | Dependencies | `📦 deps: upgrade React to v19` |
## 7-Step Commit Workflow
### Step 1: Complete Work
Ensure all changes are complete and the feature/fix is working.
### Step 2: Run Quality Gate
```bash
npm run quality-gate
```
**MANDATORY**: This must pass before committing. Fix any issues found.
### Step 3: Review Changes
Run these commands to understand what will be committed:
```bash
git status
git diff --staged
```
If changes aren't staged, stage them first:
```bash
git add <files>
```
### Step 4: Prepare Commit Message
Compose the commit message following the format above:
1. Choose the appropriate gitmoji based on the change type
2. Write a clear subject line in imperative mood
3. Add body with bullet points if multiple changes
4. Include issue reference WITHOUT "Close/Fix/Resolve" prefix
5. Add Co-Authored-By footer
### Step 5: Ask User for Permission (MANDATORY)
**NEVER skip this step.** Present the commit to the user:
> Ready to commit. Here's the proposed message:
>
> ```
> <full commit message>
> ```
>
> Do you want me to proceed with this commit?
Wait for explicit user approval.
### Step 6: Create Commit
Use HEREDOC format to preserve formatting:
```bash
git commit -m "$(cat <<'EOF'
✨ feat(scope): subject line here
- First change description
- Second change description
#123
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"
```
**NEVER use `--no-verify`**
### Step 7: Verify Commit
After committing, verify it was successful:
```bash
git log -1 --pretty=format:"%h %s"
git status
```
## Example Scenarios
### Example 1: Simple Bug Fix
```
✨ Staged changes: Fixed null check in user service
✅ Commit message:
🐛 fix(user): handle null user in getProfile
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 2: New Feature with Issue Reference
```
✨ Staged changes: Added export functionality to reports
✅ Commit message:
✨ feat(reports): add CSV export functionality
- Add export button to report toolbar
- Implement CSV generation service
- Add download trigger
#456
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 3: Refactoring with Multiple Changes
```
✨ Staged changes: Refactored authentication module
✅ Commit message:
♻️ refactor(auth): extract token validation logic
- Move validation to dedicated service
- Add unit tests for edge cases
- Update imports across modules
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 4: Documentation Update
```
✨ Staged changes: Updated README with new setup instructions
✅ Commit message:
📝 docs: update installation instructions
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 5: Test Addition
```
✨ Staged changes: Added tests for payment service
✅ Commit message:
✅ test(payment): add unit tests for refund flow
- Test successful refund scenario
- Test partial refund handling
- Test refund validation errors
#789
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 6: Dependency Update
```
✨ Staged changes: Upgraded TypeScript to v5.3
✅ Commit message:
📦 deps: upgrade TypeScript to 5.3
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 7: File Move/Rename
```
✨ Staged changes: Moved utility functions to shared package
✅ Commit message:
🚚 move: relocate date utils to shared package
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
### Example 8: Security Fix
```
✨ Staged changes: Fixed XSS vulnerability in comment input
✅ Commit message:
🔒️ security(comments): sanitize HTML in user input
#security-audit
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
```
## Important Guidelines
### DO
- ✅ Always run `npm run quality-gate` before committing
- ✅ Always ask for user permission before committing
- ✅ Always use gitmoji matching the commit type
- ✅ Always include `Co-Authored-By` for AI-assisted commits
- ✅ Always verify the commit was successful with `git log -1`
- ✅ Use imperative mood in subject line ("add" not "added")
- ✅ Keep subject line under 72 characters
- ✅ Use bullet points with `-` for multi-line bodies
- ✅ Reference issues with just `#123` format
### DO NOT
- ❌ Never commit without user approval
- ❌ Never use `--no-verify` flag
- ❌ Never use "Close", "Fix", or "Resolve" before issue numbers
- ❌ Never skip quality-gate check
- ❌ Never use `git commit --amend` unless explicitly requested
- ❌ Never force push to main/master
- ❌ Never commit files containing secrets (.env, credentials.json)
- ❌ Never forget the gitmoji prefix
- ❌ Never use past tense in subject ("fixed" → "fix")
## Quick Reference Card
```
┌─────────────────────────────────────────────────────────────┐
│ GIT COMMIT QUICK REFERENCE │
├─────────────────────────────────────────────────────────────┤
│ FORMAT: │
│ <gitmoji> <type>(<scope>): <subject> │
│ │
│ GITMOJI: │
│ ✨ feat 🐛 fix ♻️ refactor 📝 docs │
│ ✅ test 🔧 chore 🎨 style ⚡️ perf │
│ 🔒️ security 🗑️ remove 🚚 move 📦 deps │
│ │
│ WORKFLOW: │
│ 1. npm run quality-gate │
│ 2. git status && git diff --staged │
│ 3. Prepare message with gitmoji │
│ 4. ASK USER PERMISSION │
│ 5. git commit (use HEREDOC) │
│ 6. git log -1 (verify) │
│ │
│ RULES: │
│ • Always ask permission before committing │
│ • Never use Close/Fix/Resolve before #issue │
│ • Never use --no-verify │
│ • Always include Co-Authored-By footer │
└─────────────────────────────────────────────────────────────┘
```
---
**REMEMBER:** This skill is MANDATORY when creating commits. Always run quality-gate, always ask for permission, and always use gitmoji. These steps ensure code quality and maintain a clean, informative git history.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「git-commit-guidelines」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次