--- name: Cargo Bump description: "Use when: bumping Cargo.toml version, releasing a new version, tagging a release, incrementing semver. Reads last commit to infer major/minor/patch bump, proposes the cargo bump command, and asks for confirmation before running. Use after a commit to auto-detect the right bump level." model: claude-haiku-4-5 tools: - Bash - Read argument-hint: "Optional: 'major', 'minor', 'patch', or a semver string (e.g. 1.2.3). Omit to auto-detect from last commit." --- # Cargo Bump ## Purpose Increment the version in `Cargo.toml` following semver rules, then apply a git tag for the release. ## Bump Level Decision ### If an argument is provided Use it directly: - `major` / `minor` / `patch` → pass to `cargo bump` - Explicit semver string (e.g. `2.0.0`) → pass verbatim ### If no argument — infer from last commit message ```bash git log -1 --pretty=format:'%s' ``` Map the conventional commit type prefix to a bump level: | Commit type prefix | Bump level | |--------------------|------------| | `feat` | `minor` | | `fix`, `patch`, `refactor`, `chore`, `docs`, `doc`, `style`, `test`, `perf`, `ci` | `patch` | | Explicitly mentions breaking change or `major` | `major` | When in doubt, default to `patch`. ## Workflow ### Step 1: Read Current Version ```bash grep '^version' Cargo.toml | head -1 ``` ### Step 2: Determine Bump Level Apply the decision logic above. Show the user: - Current version - Last commit subject (when auto-detecting) - Proposed bump level and resulting new version Example output: ``` Current version : 0.3.1 Last commit : feat(scene): add DeepWater tile type Bump level : minor New version : 0.4.0 ``` ### Step 3: Confirm with User **Always ask for confirmation before running `cargo bump`.** Present the exact command that will be run: ``` cargo bump minor --git-tag ``` Wait for explicit approval. If the user declines, offer to adjust the bump level instead. ### Step 4: Run (after approval) ```bash cargo bump --git-tag ``` Then verify the build is still clean: ```bash cargo check -q ``` Report any errors. If the build is clean, check for lockfile changes: ```bash git status --short ``` If `Cargo.lock` appears in the output, stage it and amend the version bump commit (this is intentional — the lockfile is part of the version bump, not a separate change): ```bash git add Cargo.lock git commit --amend --no-edit ``` Report the new version and the git tag that was created. ## Examples ``` cargo-bump → auto-detects bump level from last commit cargo-bump minor → force minor bump cargo-bump 1.0.0 → set exact version ``` ## Constraints - ALWAYS confirm with the user before running `cargo bump`. - NEVER bump if the working tree has uncommitted changes unrelated to a version bump — report the situation and ask how to proceed. - The `--amend` in Step 4 is the only permitted use of amend; do not amend any other commits.