npx skills add https://github.com/patricio0312rev/skills --skill conventional-commits编写标准化的语义化提交信息,以实现自动化版本管理和变更日志生成。
<类型>[可选 范围]: <描述>
[可选 正文]
[可选 页脚]
| 类型 | 描述 | Semver | 示例 |
|---|---|---|---|
feat | 新功能 | MINOR | feat: add user authentication |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
fix | 错误修复 | PATCH | fix: resolve login redirect loop |
docs | 仅文档变更 | - | docs: update API reference |
style | 格式化、空白符调整 | - | style: fix indentation in utils |
refactor | 代码重构,非功能/修复 | - | refactor: extract validation logic |
perf | 性能改进 | PATCH | perf: optimize database queries |
test | 添加/修复测试 | - | test: add unit tests for auth |
build | 构建系统、依赖项 | - | build: upgrade to Node 20 |
ci | CI/CD 配置 | - | ci: add GitHub Actions workflow |
chore | 维护任务 | - | chore: update .gitignore |
revert | 回滚之前的提交 | - | revert: undo feature flag change |
范围表示受影响的代码库区域:
# 组件/模块范围
feat(auth): add OAuth2 support
fix(api): handle timeout errors
docs(readme): add installation steps
# 基于文件的范围
style(eslint): update linting rules
build(docker): optimize image size
# 层级范围
refactor(service): extract user service
test(e2e): add checkout flow tests
使用 ! 或 BREAKING CHANGE 页脚标记重大变更:
# 使用 ! 标记
feat(api)!: change response format to JSON:API
# 使用页脚标记
feat(api): change response format
BREAKING CHANGE: Response now follows JSON:API specification.
Clients must update their parsers.
feat: add dark mode toggle
feat(ui): add dark mode toggle to settings page
fix(auth): resolve session expiration race condition
The session refresh was racing with the expiration check,
causing intermittent logouts.
Fixes #234
feat(api)!: migrate to v2 response format
BREAKING CHANGE: All API responses now use camelCase keys
instead of snake_case. Update client parsers accordingly.
Migration guide: https://docs.example.com/v2-migration
fix(payments): correct tax calculation for EU customers
Updated tax calculation to use customer's billing country
instead of shipping country for digital goods.
Fixes #456
Reviewed-by: Alice
Co-authored-by: Bob <bob@example.com>
revert: feat(auth): add OAuth2 support
This reverts commit abc123def456.
Reason: OAuth provider has rate limiting issues in production.
Will re-implement with proper caching.
feat: add email verification flow
fix: prevent duplicate form submissions
refactor: extract payment processing to service
perf: cache user preferences in memory
docs: add API authentication examples
# 过于模糊
fix: fixed it
update: updates
# 时态错误
feat: added new feature
fix: fixes the bug
# 过长
feat: add a new feature that allows users to export their data in multiple formats including CSV, JSON, and XML
何时包含正文:
fix(cache): invalidate user cache on profile update
Previously, profile updates were not reflected until cache expiry.
This caused confusion when users updated their avatar and didn't
see the change immediately.
The fix adds cache invalidation after successful profile updates
and ensures CDN purge for static assets.
| 标记 | 用途 | 示例 |
|---|---|---|
Fixes | 关闭问题 | Fixes #123 |
Closes | 关闭问题 | Closes #456 |
Refs | 引用问题 | Refs #789 |
BREAKING CHANGE | 重大变更 | BREAKING CHANGE: description |
Reviewed-by | 审阅者署名 | Reviewed-by: Name |
Co-authored-by | 合著者署名 | Co-authored-by: Name <email> |
// commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat', 'fix', 'docs', 'style', 'refactor',
'perf', 'test', 'build', 'ci', 'chore', 'revert'
]
],
'scope-case': [2, 'always', 'kebab-case'],
'subject-case': [2, 'always', 'lower-case'],
'subject-max-length': [2, 'always', 72],
'body-max-line-length': [2, 'always', 100]
}
};
# .husky/commit-msg
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit "$1"
{
"devDependencies": {
"@commitlint/cli": "^18.0.0",
"@commitlint/config-conventional": "^18.0.0",
"husky": "^8.0.0"
},
"scripts": {
"prepare": "husky install"
}
}
约定式提交支持自动化版本管理:
# .releaserc.yml
branches:
- main
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- "@semantic-release/npm"
- "@semantic-release/git"
| 提交类型 | 版本提升 | 示例 |
|---|---|---|
feat | Minor (0.X.0) | 1.2.0 → 1.3.0 |
fix | Patch (0.0.X) | 1.2.0 → 1.2.1 |
perf | Patch (0.0.X) | 1.2.0 → 1.2.1 |
BREAKING CHANGE | Major (X.0.0) | 1.2.0 → 2.0.0 |
| 其他 | 不提升 | 1.2.0 → 1.2.0 |
分析变更时,生成提交信息:
# 1. 检查暂存变更
git diff --cached --name-only
# 2. 分析变更类型
# - 新文件 = 可能是 feat
# - 修改的测试文件 = test
# - 修改的文档 = docs
# - 与错误相关的关键词 = fix
# 3. 从路径识别范围
# src/components/Button.tsx → components 或 ui
# src/services/auth.ts → auth 或 services
# 4. 生成信息
feat(ui): add loading state to Button component
git diff --cached 验证变更每条提交信息都应:
! 或页脚标记重大变更每周安装次数
104
代码仓库
GitHub 星标数
20
首次出现
2026年1月24日
安全审计
安装于
codex94
gemini-cli93
opencode92
github-copilot88
amp83
kimi-cli83
Write standardized, semantic commit messages that enable automated versioning and changelog generation.
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
| Type | Description | Semver | Example |
|---|---|---|---|
feat | New feature | MINOR | feat: add user authentication |
fix | Bug fix | PATCH | fix: resolve login redirect loop |
docs | Documentation only | - | docs: update API reference |
style | Formatting, whitespace | - | style: fix indentation in utils |
refactor | Code change, no feature/fix | - | refactor: extract validation logic |
perf | Performance improvement | PATCH | perf: optimize database queries |
test | Adding/fixing tests | - | test: add unit tests for auth |
build | Build system, dependencies | - | build: upgrade to Node 20 |
ci | CI/CD configuration | - | ci: add GitHub Actions workflow |
chore | Maintenance tasks | - | chore: update .gitignore |
revert | Revert previous commit | - | revert: undo feature flag change |
Scopes indicate the area of the codebase affected:
# Component/module scopes
feat(auth): add OAuth2 support
fix(api): handle timeout errors
docs(readme): add installation steps
# File-based scopes
style(eslint): update linting rules
build(docker): optimize image size
# Layer scopes
refactor(service): extract user service
test(e2e): add checkout flow tests
Mark breaking changes with ! or BREAKING CHANGE footer:
# Using ! notation
feat(api)!: change response format to JSON:API
# Using footer
feat(api): change response format
BREAKING CHANGE: Response now follows JSON:API specification.
Clients must update their parsers.
feat: add dark mode toggle
feat(ui): add dark mode toggle to settings page
fix(auth): resolve session expiration race condition
The session refresh was racing with the expiration check,
causing intermittent logouts.
Fixes #234
feat(api)!: migrate to v2 response format
BREAKING CHANGE: All API responses now use camelCase keys
instead of snake_case. Update client parsers accordingly.
Migration guide: https://docs.example.com/v2-migration
fix(payments): correct tax calculation for EU customers
Updated tax calculation to use customer's billing country
instead of shipping country for digital goods.
Fixes #456
Reviewed-by: Alice
Co-authored-by: Bob <bob@example.com>
revert: feat(auth): add OAuth2 support
This reverts commit abc123def456.
Reason: OAuth provider has rate limiting issues in production.
Will re-implement with proper caching.
feat: add email verification flow
fix: prevent duplicate form submissions
refactor: extract payment processing to service
perf: cache user preferences in memory
docs: add API authentication examples
# Too vague
fix: fixed it
update: updates
# Wrong tense
feat: added new feature
fix: fixes the bug
# Too long
feat: add a new feature that allows users to export their data in multiple formats including CSV, JSON, and XML
When to include a body:
Changes need context or explanation
Complex logic that isn't self-evident
Breaking changes require migration info
Multiple related changes in one commit
fix(cache): invalidate user cache on profile update
Previously, profile updates were not reflected until cache expiry. This caused confusion when users updated their avatar and didn't see the change immediately.
The fix adds cache invalidation after successful profile updates and ensures CDN purge for static assets.
| Token | Purpose | Example |
|---|---|---|
Fixes | Closes issue | Fixes #123 |
Closes | Closes issue | Closes #456 |
Refs | References issue | Refs #789 |
BREAKING CHANGE |
// commitlint.config.js
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [
2,
'always',
[
'feat', 'fix', 'docs', 'style', 'refactor',
'perf', 'test', 'build', 'ci', 'chore', 'revert'
]
],
'scope-case': [2, 'always', 'kebab-case'],
'subject-case': [2, 'always', 'lower-case'],
'subject-max-length': [2, 'always', 72],
'body-max-line-length': [2, 'always', 100]
}
};
# .husky/commit-msg
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit "$1"
{
"devDependencies": {
"@commitlint/cli": "^18.0.0",
"@commitlint/config-conventional": "^18.0.0",
"husky": "^8.0.0"
},
"scripts": {
"prepare": "husky install"
}
}
Conventional commits enable automated versioning:
# .releaserc.yml
branches:
- main
plugins:
- "@semantic-release/commit-analyzer"
- "@semantic-release/release-notes-generator"
- "@semantic-release/changelog"
- "@semantic-release/npm"
- "@semantic-release/git"
| Commit Type | Version Bump | Example |
|---|---|---|
feat | Minor (0.X.0) | 1.2.0 → 1.3.0 |
fix | Patch (0.0.X) | 1.2.0 → 1.2.1 |
perf | Patch (0.0.X) | 1.2.0 → 1.2.1 |
BREAKING CHANGE | Major (X.0.0) | 1.2.0 → 2.0.0 |
| Others | No bump | 1.2.0 → 1.2.0 |
When analyzing changes, generate a commit message:
# 1. Check staged changes
git diff --cached --name-only
# 2. Analyze change type
# - New files = likely feat
# - Modified test files = test
# - Modified docs = docs
# - Bug-related keywords = fix
# 3. Identify scope from path
# src/components/Button.tsx → components or ui
# src/services/auth.ts → auth or services
# 4. Generate message
feat(ui): add loading state to Button component
git diff --cached to verify changesEvery commit message should:
! or footerWeekly Installs
104
Repository
GitHub Stars
20
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex94
gemini-cli93
opencode92
github-copilot88
amp83
kimi-cli83
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
96,200 周安装
| Breaking change |
BREAKING CHANGE: description |
Reviewed-by | Reviewer credit | Reviewed-by: Name |
Co-authored-by | Co-author credit | Co-authored-by: Name <email> |