Setup Worktree Database
UTILITY SKILL. INVOKES: bundled Python script, git, local Postgres. FOR SINGLE OPERATIONS: per-worktree DB, env, and VS Code task setup.
Use after creating a Rails worktree, before Rails, specs, Spring, Sidekiq, or VS Code terminals run there.
USE FOR:
- New local Rails worktrees needing isolated
developmentandtestdatabases. - Croft/backburner worktrees seeded from another local worktree.
- Repairing worktrees whose env files still point at shared databases.
DO NOT USE FOR:
- Creating git worktrees, planning branches, or starting app servers.
- Non-Rails repos or remote database setup.
- Copying from staging, demo, production, or non-local databases.
- Dropping, resetting, or overwriting databases.
Workflow
- Pick the source worktree. Default to the one that created the target unless the user names another.
- Resolve
scripts/setup_worktree_database.pyrelative to this skill directory. - Run from the source worktree:
python3 <resolved-skill-dir>/scripts/setup_worktree_database.py \
--source-worktree <source> --worktree <target>
- Read the JSON summary. Stop on warnings about env or VS Code task files not ignored by git.
- Restart stale Rails, Spring, VS Code, or worker processes for the target.
Guardrails
- Use
--dry-runfor preview. - Use
--force-envor--force-vscode-taskonly after explicit approval. - Existing target databases are skipped; temporary dumps are removed.
Examples
- Preview:
python3 <script> --worktree ../new-worktree --dry-run - Explicit source:
python3 <script> --source-worktree /path/to/croft --worktree /path/to/backburner-4 --db-prefix croft
See script behavior for naming defaults, JSON fields, and command options.