Generic file migration tool for applying ordered transformations to a project directory. Migrations can be written in any language (bash, TypeScript, Python, etc.) using shebangs.
migrate status # Show applied/pending migrations
migrate up # Apply all pending migrations
migrate up --dry-run # Preview without applying
migrate up --baseline # Apply and create baseline at final version
migrate up --baseline --keep # Apply and baseline without deleting files
migrate create <name> # Create new bash migration
migrate create <name> --template ts # Create TypeScript migration
migrate create <name> --list-templates # List available templates
migrate baseline <version> # Create baseline at specific version
migrate baseline <version> --dry-run # Preview baseline changes
migrate baseline <version> --keep # Baseline without deleting filesAll commands accept:
-r, --root <path>- Project root (default:.)-m, --migrations <path>- Migrations directory (default:migrations)
Files: XXXXX-name.{sh,ts,py,js,...} where XXXXX is a 5-character base36 version.
Version format: DDDMM where:
DDD= days since 2020-01-01 in base36 (~127 years of runway)MM= 10-minute slot of the day in base36 (144 slots/day)
Example: 1fb2g-add-config.sh (created on day 1843 at slot 88 = ~14:40)
Migrations are executable files that receive context via environment variables:
MIGRATE_PROJECT_ROOT=/path/to/project # Absolute path to project root
MIGRATE_MIGRATIONS_DIR=/path/to/migrations # Where migration files live
MIGRATE_ID=1fb2g-initial-setup # Current migration ID (includes version)
MIGRATE_DRY_RUN=true|false # Whether this is a dry runBash example:
#!/usr/bin/env bash
set -euo pipefail
# Description: Initialize project structure
cd "$MIGRATE_PROJECT_ROOT"
mkdir -p configTypeScript example:
#!/usr/bin/env -S npx tsx
// Description: Add configuration file
import * as fs from 'fs/promises';
const projectRoot = process.env.MIGRATE_PROJECT_ROOT!;
await fs.writeFile(`${projectRoot}/config.json`, '{}');src/main.rs- CLI entry point (clap)src/lib.rs- Core types and public APIsrc/loader.rs- Migration discoverysrc/executor.rs- Subprocess executionsrc/state.rs- History tracking (.historyfile)src/version.rs- Base36 version generation and parsingsrc/templates.rs- Embedded migration templatessrc/baseline.rs- Baseline management (.baselinefile)src/commands/- CLI command implementationsmod.rs- Command module exportsstatus.rs- Status command (shows version summary)up.rs- Up commandcreate.rs- Create command (generates time-based version)baseline.rs- Baseline command (marks versions as applied)
templates/- Template source files (bash.sh, typescript.ts, python.py, node.js, ruby.rb)
# Setup (enable git hooks, verify toolchain)
./scripts/setup
# Build and test
cargo nextest run # Run tests
cargo build # Build debug binary
cargo build --release # Build release binary
cargo fmt # Format code
cargo clippy # Lint