Simplifies worktree based agentic Rails development with Herdr.
- Runs
rails db:preparefor new worktrees - Runs
rails css:installfor new worktrees if cssbundling-rails is present - Runs
rails javascript:installfor new worktrees if jsbundling-rails is present
To install run:
herdr plugin install codergeek121/herdr-rails
By default all worktrees share the same database. If you want each worktree to
use its own database (so parallel agents don't step on each other's data), you
don't need any changes to this plugin — Herdr already exposes a per-worktree
identity via the HERDR_WORKSPACE_ID environment variable, which is available
throughout the worktree.
Opt in from your app by referencing that variable in config/database.yml:
development:
<<: *default
database: myapp_development<%= "_#{ENV['HERDR_WORKSPACE_ID']}" if ENV['HERDR_WORKSPACE_ID'] %>
test:
<<: *default
database: myapp_test<%= "_#{ENV['HERDR_WORKSPACE_ID']}" if ENV['HERDR_WORKSPACE_ID'] %>- Outside of Herdr (local machine, CI) the variable is unset, so your regular database names are used and nothing changes.
- Inside a worktree the name becomes e.g.
myapp_development_<id>, giving each worktree its own database. - The existing
rails db:preparestep creates the namespaced database automatically — it just readsdatabase.yml, so no extra setup is required.
Herdr doesn't auto-bind plugin actions, so add this to ~/.config/herdr/config.toml and run herdr server reload-config:
[[keys.command]]
key = "prefix+alt+d" # example keybind
type = "plugin_action"
command = "codergeek121.herdr-rails.dev-layout"
description = "Dev-Layout: Editor + Rails + Terminal"- TODO: Handle multiple test DBs without app configuration change
- TODO: Failure should mark the pane as "blocked"
- TODO: Copy Bootsnap Cache for worktrees