# heroku-debug > Debug Rails API backend on Heroku using CLI. Use when investigating errors, checking logs, querying database via rails runner, inspecting Redis, or viewing dyno status. Supports -r staging and -r production remotes. - Author: Eric Kreutzer - Repository: erickreutz/dotfiles - Version: 20260124140251 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/erickreutz/dotfiles - Web: https://mule.run/skillshub/@@erickreutz/dotfiles~heroku-debug:20260124140251 --- --- name: heroku-debug description: Debug Rails API backend on Heroku using CLI. Use when investigating errors, checking logs, querying database via rails runner, inspecting Redis, or viewing dyno status. Supports -r staging and -r production remotes. --- # Heroku Debug ## Safety Rules **Read-only by default.** Do not perform write operations unless the operator explicitly authorizes them. **Never use `heroku logs`** - logs stream too fast for historical debugging. Use rails runner queries instead. Write operations requiring explicit permission: - `update!`, `save!`, `destroy!`, `delete` in rails runner - `heroku ps:restart` - `heroku pg:reset` - Any data modification Before running any command, confirm which remote (staging or production). ## Remote Selection Always use `-r` flag to specify environment: - `-r staging` for staging - `-r production` for production If unclear which environment, ask before running. ## Rails Runner Use heredoc pattern for complex scripts: ```bash heroku run 'bundle exec rails runner "$(cat <<'RUBY' user = User.first puts "#{user.id}: #{user.first_name} #{user.last_name}" puts "Created: #{user.created_at}" RUBY )"' -r staging ``` For write operations (ONLY with explicit permission): ```bash heroku run 'bundle exec rails runner "$(cat <<'RUBY' user = User.find("uuid") user.update!(field: "value") puts "Updated: #{user.id}" RUBY )"' -r staging ``` ## Command Reference See [references/commands.md](references/commands.md) for full command reference including: - Database (Postgres) - Redis - Dyno management