AgentSkillsCN

version-analysis

分析 Git 历史记录,依据常规提交规范判断语义版本的更新幅度。在确定下一版本、分析近期变更,或为发布做准备而回顾提交历史时,可使用此技能。

SKILL.md
--- frontmatter
name: version-analysis
description: Analyzes git history to determine semantic version bumps based on conventional commits. Use when determining next version, analyzing recent changes, or reviewing commit history for release preparation.
allowed-tools: Read, Grep, Bash
model: sonnet
user-invocable: true

Version Analysis Skill

Analyze git history and conventional commits to determine appropriate semantic version bumps.

Process

1. Get Current Version

bash
git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0"

2. Analyze Commits (using schangelog for efficiency)

bash
# TOON format is ~8x more token-efficient
schangelog parse-commits --since=$(git describe --tags --abbrev=0 2>/dev/null || echo "")

3. Determine Version Bump

Based on conventional commits:

PrefixBumpExample
feat:MinorNew feature added
fix:PatchBug fix
BREAKING CHANGE:MajorBreaking API change
feat!: or fix!:MajorBreaking change shorthand
docs:, style:, refactor:, test:, chore:PatchNon-functional changes

4. Output Format

Provide analysis in this structure:

code
Current Version: vX.Y.Z
Commits Since Tag: N commits
Breakdown:
  - Features (feat): M
  - Fixes (fix): N
  - Breaking Changes: P
  - Other: Q
Suggested Version: vA.B.C
Reasoning: Specific explanation of why this version bump

Semantic Versioning Rules

Given version vMAJOR.MINOR.PATCH:

  • MAJOR: Incompatible API changes (breaking changes)
  • MINOR: New functionality (backwards-compatible)
  • PATCH: Bug fixes (backwards-compatible)

Pre-release Versions

For pre-release versions:

  • v1.0.0-alpha.1 - Alpha release
  • v1.0.0-beta.1 - Beta release
  • v1.0.0-rc.1 - Release candidate

Example Analysis

code
Current Version: v0.7.0
Commits Since Tag: 12 commits
Breakdown:
  - Features (feat): 3
  - Fixes (fix): 2
  - Breaking Changes: 0
  - Other (docs, chore): 7
Suggested Version: v0.8.0
Reasoning: 3 new features warrant a minor version bump. No breaking changes detected.