| name | rails-ai:debugging-rails |
| description | Use when debugging Rails issues - provides Rails-specific debugging tools (logs, console, byebug, SQL logging) integrated with systematic debugging process |
Rails Debugging Tools & Techniques
**REQUIRED BACKGROUND:** Use superpowers:systematic-debugging for investigation process
- That skill defines 4-phase framework (Root Cause → Pattern → Hypothesis → Implementation)
- This skill provides Rails-specific debugging tools for each phase
- Rails application behaving unexpectedly
- Tests failing with unclear errors
- Performance issues or N+1 queries
- Production errors need investigation
Before completing debugging work:
- ✅ Root cause identified (not just symptoms)
- ✅ Regression test added (prevents recurrence)
- ✅ Fix verified in development and test environments
- ✅ All tests passing (bin/ci passes)
- ✅ Logs reviewed for related issues
- ✅ Performance impact verified (if applicable)
Check Rails logs for errors and request traces
tail -f log/development.log
kamal app logs --tail
grep ERROR log/production.log
grep "Started GET" log/development.log
Interactive Rails console for testing models/queries
rails console
kamal app exec 'bin/rails console'
user = User.find(1)
user.valid?
user.errors.full_messages
User.where(email: "test@example.com").to_sql
User.includes(:posts).where(posts: { published: true })
Breakpoint debugger for stepping through code
def some_method
byebug
end
Enable verbose SQL logging to see queries
ActiveRecord::Base.logger = Logger.new(STDOUT)
User.all
Check route definitions and paths
rails routes
rails routes | grep users
rails routes -c users
Check migration status and schema
rails db:migrate:status
rails db:version
rails db:abort_if_pending_migrations
Run Ruby code in Rails environment
rails runner "puts User.count"
rails runner scripts/investigate_users.rb
RAILS_ENV=production rails runner "User.pluck(:email)"
Run tests with detailed output
rails test test/models/user_test.rb --verbose
RUBYOPT=-W rails test
rails test --seed 12345
Check logs for many similar queries:
User Load (0.1ms) SELECT * FROM users WHERE id = 1
Post Load (0.1ms) SELECT * FROM posts WHERE user_id = 1
Post Load (0.1ms) SELECT * FROM posts WHERE user_id = 2
Post Load (0.1ms) SELECT * FROM posts WHERE user_id = 3
Use includes/preload:
users.each { |user| user.posts.count }
users.includes(:posts).each { |user| user.posts.count }
Error: "ActiveRecord::StatementInvalid: no such column"
rails db:migrate:status
rails db:migrate
rails db:rollback
rails db:migrate
- superpowers:systematic-debugging (4-phase framework)
- rails-ai:models (Query optimization, N+1 debugging)
- rails-ai:controllers (Request debugging, parameter inspection)
- rails-ai:testing (Test debugging, failure investigation)
Official Documentation:
Gems & Libraries:
Tools: