---
name: interactive
description: Interactively run Ruby commands against a live Rails process using bin/interact. Supports two modes: a standalone server (bin/interactive) for general exploration, and binding.interactive breakpoints inside tests or app code to pause execution and inspect local state. Use when the user wants to explore live Rails objects, debug a test, or poke at a running process.
---
Interactively run Ruby commands against a live Rails process.
$ARGUMENTS
Start a persistent Rails process with a fresh binding:
bin/interactive > /tmp/drb_server.log 2>&1 &Rails takes ~12 seconds to boot. bin/interact waits automatically — no need to sleep first.
Add binding.interactive at any point in a test to pause execution there and expose the local binding (local variables, subject, page, etc.):
RSpec.describe MyThing do
it "does something" do
client = create(:client, first_name: "Valentina")
binding.interactive # execution pauses here
expect(client.first_name).to eq("Valentina")
end
endRun the test in the background:
bin/rspec spec/path/to/spec.rb > /tmp/rspec.log 2>&1 &Then send commands immediately — bin/interact polls until the breakpoint is hit:
bin/interact 'client.first_name'Use bin/interact '<ruby expression>' to evaluate expressions. State persists across calls — variables set in one call are available in the next:
bin/interact 'Client.count'
bin/interact 'client = Client.first'
bin/interact 'puts client.inspect'
bin/interact 'client.snap_apps.map(&:status)'Both the return value and any stdout output are printed.
When finished, shut down the server and resume execution (if in breakpoint mode):
bin/interact shutdownbin/interactwaits up to 5 minutes for the server to become available — no need to coordinate timingbin/interactitself is fast (~250ms) since it does not reload Rails- The server runs on port 8787 — only one instance at a time
- Use
bin/interact shutdownrather thanpkillso breakpoint mode resumes cleanly - If something goes wrong, check
/tmp/rspec.logor/tmp/drb_server.logfor errors