Apply semantic versioning

From pjt222/agent-almanac · View interactive version

Apply semantic versioning is an AI agent skill from the GitHub repository pjt222/agent-almanac. Apply semantic versioning (SemVer 2.0.0) to determine the correct version bump based on change analysis. Covers major/minor/patch classification, pre-release identifiers, build metadata, and breaking change detection. Use when preparing a new release to determine the correct version number, after me

How to use this skill

Skill file

Apply Semantic Versioning

Determine and apply the correct semantic version bump by analyzing changes since the last release. This skill reads version files, classifies changes as breaking (major), feature (minor), or fix (patch), computes the new version number, and updates the appropriate files. Follows SemVer 2.0.0 specification.

When to Use

Inputs

Procedure

Step 1: Read Current Version

Locate and read the version file in the project root.

# R packages
grep "^Version:" DESCRIPTION

# Node.js
grep '"version"' package.json

# Rust
grep '^version' Cargo.toml

# Python
grep 'version' pyproject.toml

# Plain file
cat VERSION

Parse the current version into major.minor.patch components. If the version contains a pre-release suffix (e.g., 1.2.0-beta.1), note it separately.

Got: Current version identified as MAJOR.MINOR.PATCH[-PRERELEASE].

If fail: If no version file is found, check for a VERSION file or git tags (git describe --tags --abbrev=0). If no version exists at all, start at 0.1.0 for initial development or 1.0.0 if the project has a stable public API.

Step 2: Analyze Changes Since Last Release

Retrieve the list of changes since the last tagged release.

# Find the last version tag
git describe --tags --abbrev=0

# List commits since that tag
git log --oneline v1.2.3..HEAD

# If using Conventional Commits, filter by type
git log --oneline v1.2.3..HEAD | grep -E "^[a-f0-9]+ (feat|fix|BREAKING)"

If no tags exist, compare against the initial commit or a known baseline.

Got: A list of commits with messages that can be classified by change type.

If fail: If git history is unavailable or tags are missing, ask the developer to describe the changes manually. Classify based on their description.

Step 3: Classify Changes

Apply the SemVer classification rules:

| Change Type | Version Bump | Examples |

|---|---|---|

| Breaking (incompatible API change) | MAJOR | Renamed/removed public function, changed return type, removed parameter, changed default behavior |

| Feature (new backwards-compatible functionality) | MINOR | New exported function, new parameter with default, new file format support |

| Fix (backwards-compatible bug fix) | PATCH | Bug fix, documentation correction, performance improvement with same API |

Classification rules:

  1. If ANY change is breaking, the bump is MAJOR (resets minor and patch to 0)
  2. If no breaking changes but ANY new features, the bump is MINOR (resets patch to 0)
  3. If only fixes, the bump is PATCH

Special cases:

Got: Each change classified as breaking/feature/fix, and the overall bump level determined.

If fail: If changes are ambiguous, err on the side of a higher bump. A conservative major bump is better than a minor bump that breaks downstream code.

Step 4: Compute New Version

Apply the bump to the current version:

| Current | Bump | New Version |

|---|---|---|

| 1.2.3 | MAJOR | 2.0.0 |

| 1.2.3 | MINOR | 1.3.0 |

| 1.2.3 | PATCH | 1.2.4 |

| 0.9.5 | MINOR | 0.10.0 |

| 2.0.0-rc.1 | (release) | 2.0.0 |

If a pre-release label is requested:

Pre-release precedence: alpha < beta < rc < (release).

Got: New version number computed following SemVer rules.

If fail: If the current version is malformed or non-SemVer, normalize it first. For example, 1.2 becomes 1.2.0.

Step 5: Update Version Files

Write the new version to the appropriate file(s).

# R: Update DESCRIPTION
# Change "Version: 1.2.3" to "Version: 1.3.0"
// Node.js: Update package.json
// Change "version": "1.2.3" to "version": "1.3.0"
// Also update package-lock.json if present
# Rust: Update Cargo.toml
# Change version = "1.2.3" to version = "1.3.0"

If the project has multiple files that reference the version (e.g., _pkgdown.yml, CITATION, codemeta.json), update all of them.

Got: All version files updated consistently to the new version number.

If fail: If a file update fails, revert all changes to maintain consistency. Never leave version files in a partially updated state.

Step 6: Create Version Tag

After committing the version bump, create a git tag.

# Annotated tag (preferred)
git tag -a v1.3.0 -m "Release v1.3.0"

# Lightweight tag (acceptable)
git tag v1.3.0

Use the project's established tag format:

Got: Git tag created matching the new version.

If fail: If the tag already exists, the version was not properly bumped. Check for duplicate tags with git tag -l "v1.3*" and resolve before proceeding.

Validation

Pitfalls

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.