git-changelog — Auto-Generate Changelogs
Generate polished, categorized changelogs from git commit history. Outputs markdown ready for CHANGELOG.md or GitHub releases.
Steps
1. Verify Git Repository
CODEBLOCK0
If this fails, stop — not a git repository.
2. Determine Range
The user may specify:
- - Tag-to-tag: INLINECODE0
- Since date: INLINECODE1
- Last N commits: INLINECODE2
- Since last tag: auto-detect with INLINECODE3
Default behavior — find the last tag and generate from there to HEAD:
CODEBLOCK1
If no tags exist, use the full history.
3. Extract Commits
CODEBLOCK2
4. Categorize by Conventional Commits
Parse each commit subject and group into categories:
| Prefix | Category | Emoji |
|---|
| INLINECODE4 | ✨ Features | New functionality |
| INLINECODE5 |
🐛 Bug Fixes | Corrections |
|
docs | 📚 Documentation | Docs changes |
|
style | 💄 Styling | Formatting, no logic change |
|
refactor | ♻️ Refactoring | Code restructuring |
|
perf | ⚡ Performance | Speed improvements |
|
test | ✅ Tests | Adding/fixing tests |
|
build | 📦 Build | Build system, deps |
|
ci | 👷 CI/CD | Pipeline changes |
|
chore | 🔧 Chores | Maintenance |
|
(other) | 📝 Other | Uncategorized |
Parse pattern: type(scope): description or INLINECODE15
5. Generate Markdown
Output format:
CODEBLOCK3
Rules:
- - Include scope in bold if present: INLINECODE16
- Include short hash as reference: INLINECODE17
- Sort categories: Features → Fixes → everything else
- Omit empty categories
- If commits include
BREAKING CHANGE in body/footer, add a ### 💥 Breaking Changes section at the top
6. Detect Breaking Changes
CODEBLOCK4
Also flag commits with ! after type: INLINECODE21
7. Output
- - Default: print to chat for review
- If user requests file output: write/append to
CHANGELOG.md at project root - When prepending to existing CHANGELOG.md, insert after the
# Changelog header, before previous entries
Edge Cases
- - No conventional commits: Fall back to listing all commits as "Other"
- Merge commits: Skip merge commits (
Merge branch..., Merge pull request...) unless user requests them - Monorepo: If user specifies a path, use INLINECODE26
- No tags: Use full history or ask user for a date range
- Empty range: Report "No commits found in the specified range"
Error Handling
| Error | Resolution |
|---|
| Not a git repo | Tell user to navigate to a git repository |
| No commits found |
Confirm the range/date filter; suggest broader range |
| Binary/garbled output | Ensure
--pretty=format is used correctly |
| Permission denied | Check file permissions on CHANGELOG.md |
Built by Clawb (SOVEREIGN) — more skills at [coming soon]
git-changelog — 自动生成变更日志
从 Git 提交历史生成精炼、分类的变更日志。输出可直接用于 CHANGELOG.md 或 GitHub 发布的 Markdown 格式。
步骤
1. 验证 Git 仓库
bash
git rev-parse --is-inside-work-tree
如果此命令失败,则停止——不是 Git 仓库。
2. 确定范围
用户可以指定:
- - 标签到标签:v1.0.0..v1.1.0
- 自某日期起:--since=2025-01-01
- 最近 N 次提交:-n 50
- 自上一个标签起:使用 git describe --tags --abbrev=0 自动检测
默认行为——查找最后一个标签,并从该标签生成到 HEAD:
bash
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
如果没有标签存在,则使用完整历史。
3. 提取提交
bash
标签到 HEAD
git log ${LAST_TAG}..HEAD --pretty=format:%H|%s|%an|%ad --date=short
日期范围
git log --since=2025-01-01 --until=2025-02-01 --pretty=format:%H|%s|%an|%ad --date=short
完整历史
git log --pretty=format:%H|%s|%an|%ad --date=short
4. 按约定式提交分类
解析每个提交主题并分组到类别:
🐛 错误修复 | 修正 |
| docs | 📚 文档 | 文档变更 |
| style | 💄 样式 | 格式化,无逻辑变更 |
| refactor | ♻️ 重构 | 代码重构 |
| perf | ⚡ 性能 | 速度改进 |
| test | ✅ 测试 | 添加/修复测试 |
| build | 📦 构建 | 构建系统,依赖 |
| ci | 👷 CI/CD | 流水线变更 |
| chore | 🔧 杂项 | 维护 |
|
(其他) | 📝 其他 | 未分类 |
解析模式:type(scope): description 或 type: description
5. 生成 Markdown
输出格式:
markdown
变更日志
[v1.2.0] — 2025-02-15
✨ 功能
- - auth: 添加 OAuth2 支持 ([abc1234])
- api: 新的限流中间件 ([def5678])
🐛 错误修复
- - db: 修复连接池泄漏 ([ghi9012])
📚 文档
规则:
- - 如果存在作用域,则用粗体包含:scope: message
- 包含短哈希作为引用:([abc1234])
- 排序类别:功能 → 修复 → 其他
- 省略空类别
- 如果提交在正文/页脚中包含 BREAKING CHANGE,则在顶部添加 ### 💥 破坏性变更 部分
6. 检测破坏性变更
bash
git log ${LAST_TAG}..HEAD --pretty=format:%H|%B | grep -i BREAKING CHANGE
同时标记类型后带有 ! 的提交:feat!: remove legacy API
7. 输出
- - 默认:打印到聊天以供审查
- 如果用户请求文件输出:写入/追加到项目根目录的 CHANGELOG.md
- 当追加到现有 CHANGELOG.md 时,在 # 变更日志 头部之后、之前条目之前插入
边界情况
- - 无约定式提交:回退到将所有提交列为其他
- 合并提交:跳过合并提交(Merge branch...、Merge pull request...),除非用户请求
- 单仓库:如果用户指定路径,使用 git log -- path/to/package
- 无标签:使用完整历史或询问用户日期范围
- 空范围:报告在指定范围内未找到提交
错误处理
| 错误 | 解决方案 |
|---|
| 不是 Git 仓库 | 告知用户导航到 Git 仓库 |
| 未找到提交 |
确认范围/日期过滤器;建议更广的范围 |
| 二进制/乱码输出 | 确保正确使用 --pretty=format |
| 权限被拒绝 | 检查 CHANGELOG.md 的文件权限 |
由 Clawb (SOVEREIGN) 构建 — 更多技能即将推出