name: writing-git-tags
description: Generates git tag annotations from commit history following Semantic Versioning and Conventional Commits. Use when creating git tags, writing release notes, tagging versions, or generating changelog entries.
compatibility: Requires git and git-format CLI tools (invoked as git formatted-tag)
license: GPL-3.0-or-later
metadata:
author: Amolith amolith@secluded.site
Generate well-structured git tag annotations by analyzing commits since the last tag. Follows Semantic Versioning 2.0.0 and organizes changes by impact.
Tag generation workflow
-
Determine base reference
- Get latest tag:
git describe --tags --abbrev=0 - If no tags exist, use first commit or last 10 commits
- User may specify a different base tag
- Get latest tag:
-
Collect commit data
- Git status:
git status - Commits since base:
git log --format="# %s%n%n%b" BASE..HEAD - If no base tag:
git log -10 --format="# %s%n%n%b"
- Git status:
-
Analyze commits
- Parse conventional commit format:
type(scope): description - Identify breaking changes (
!suffix orBREAKING CHANGEfooter) - Categorize by type: feat, fix, perf, docs, style, refactor, test, build, chore
- Parse conventional commit format:
-
Determine version bump
- Breaking changes present โ MAJOR
- Features without breaking โ MINOR
- Only fixes โ PATCH
- Reset lower components per SemVer (1.9.0 โ 2.0.0, not 2.9.0)
-
Generate annotation
- Subject:
Brief description(โค50 characters total, version comes from tag name) - Body sections in priority order:
- โ ๏ธ BREAKING CHANGES (always first if present)
- โจ Features
- ๐ Bug Fixes
- โก Performance Improvements
- ๐ Documentation
- โป๏ธ Code Refactoring
- ๐งช Tests
- ๐ง Build System
- ๐จ Styling
- Format:
- [scope]: descriptionor- description - Wrap all body lines at 72 characters maximum
- For breaking changes, include what changed and migration path
- Subject:
-
Create tag
- Lightweight tag (no body):
git tag TAG_NAME - Annotated tag with body:
git formatted-tag TAG_NAME -m "SUBJECT" -b "BODY" - Or show to user for review:
echo "Proposed annotation:" && echo "..."
- Lightweight tag (no body):
git formatted-tag requires a tag NAME as the first argument and supports:
๐ Bug Fixes
- [login]: correct password validation error EOF )"
Commit type mapping
| Type | Section |
|---|---|
| feat | โจ Features |
| fix | ๐ Bug Fixes |
| perf | โก Performance Improvements |
| docs | ๐ Documentation |
| style | ๐จ Styling |
| refactor | โป๏ธ Code Refactoring |
| test | ๐งช Tests |
| build, ci | ๐ง Build System |
| chore | ๐ง Build System (or omit if trivial) |
| revert | Include in relevant section with "(revert)" |
Subject line constraints
- Maximum 50 characters
- Use past tense for completed work
- Capitalize first letter
- No period at end
- Focus on primary user value
Example output
Tag: v1.2.0
Annotation:
Add user authentication and session management
โจ Features
- [auth]: implement JWT-based authentication
- [api]: add login and logout endpoints
- [session]: add session middleware
๐ Bug Fixes
- [login]: correct password validation error