Skip to content

Instantly share code, notes, and snippets.

@alexey-max-fedorov
Last active May 18, 2026 18:12
Show Gist options
  • Select an option

  • Save alexey-max-fedorov/afd71efa9cd19915c3ea2c1eba883f95 to your computer and use it in GitHub Desktop.

Select an option

Save alexey-max-fedorov/afd71efa9cd19915c3ea2c1eba883f95 to your computer and use it in GitHub Desktop.
Claude prompt: add a bump-version.sh script to any project
Add the version bump script to this repo by following the spec/instructions from
https://gist.githubusercontent.com/alexey-max-fedorov/afd71efa9cd19915c3ea2c1eba883f95/raw/e518ce1560a559333e39a75e3727b7944989537f/add-bump-version.md

Add Bump Version Script

Scan this project for every file that contains a version number, then:

  1. Write bump-version.sh in the project root that atomically updates all of them.
  2. chmod +x bump-version.sh
  3. Update CLAUDE.md — append a ## Version Bump section (two lines: the header + a one-line quick ref). If no CLAUDE.md exists, create one with just those two lines.

Step 1 — Discover version files

Look for version numbers in:

  • package.json"version" field
  • manifest.json / manifest.v3.json"version" field
  • Any *.ts / *.js file with export const VERSION = "..." or export const version = "..."
  • Cargo.tomlversion = "..." under [package]
  • pyproject.tomlversion = "..." under [tool.poetry] or [project]
  • Any file literally named VERSION

Read each candidate file to confirm the version field actually exists. Skip build output directories (build/, dist/, .next/, target/).

Report what you found before writing anything.

Step 2 — Write bump-version.sh

Use this structure, adapting the body to only include the files you actually found:

#!/usr/bin/env bash
set -euo pipefail

NEW_VERSION="${1:-}"
if [ -z "$NEW_VERSION" ]; then
  echo "Usage: ./bump-version.sh <new-version>"
  echo "Example: ./bump-version.sh 1.2.0"
  exit 1
fi

ROOT="$(cd "$(dirname "$0")" && pwd)"

# JSON files — use node so formatting stays intact
# node -e "
#   const fs = require('fs');
#   const p = '\$ROOT/package.json';
#   const pkg = JSON.parse(fs.readFileSync(p, 'utf8'));
#   pkg.version = '\$NEW_VERSION';
#   fs.writeFileSync(p, JSON.stringify(pkg, null, 2) + '\n');
# "

# TypeScript/JS VERSION constants — use sed
# sed -i '' "s/^export const VERSION = \".*\";/export const VERSION = \"\$NEW_VERSION\";/" \
#   "\$ROOT/path/to/version.ts"

# Cargo.toml — use sed (replace only the first occurrence under [package])
# sed -i '' "0,/^version = \".*\"/{s/^version = \".*\"/version = \"\$NEW_VERSION\"/}" \
#   "\$ROOT/Cargo.toml"

echo "✓ Bumped to v\$NEW_VERSION"
# echo "  → package.json"
# echo "  → ..."

Uncomment and fill in only the blocks that match the files you found. Do not include stubs for files that don't exist.

Step 3 — Update CLAUDE.md

Append (or create) exactly:

## Version Bump
`./bump-version.sh <version>` — syncs version across <comma-separated list of files you found>

If CLAUDE.md already has a ## Version Bump section, replace it instead of duplicating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment