/rails-ai:debugging-railsfrom rails-ai
Provides Rails-specific debugging tools (logs, console, byebug, SQL logging, routes, migrations) integrated with a systematic 4-phase debugging process for investigating unexpected behavior, failing tests, and performance issues.
Ships in rails-ai. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
# Development logs
tail -f log/development.log
# Production logs (Kamal)
kamal app logs --tail
# Filter by severity
grep ERROR log/production.log
# Filter by request
grep "Started GET" log/development.log
Interactive Rails console for testing models/queries
# Start console
rails console
# Or production console (Kamal)
kamal app exec 'bin/rails console'
# Test models
user = User.find(1)
user.valid? # Check validations
user.errors.full_messages # See errors
# Test queries
User.where(email: "[email protected]").to_sql # See SQL
User.includes(:posts).where(posts: { published: true }) # Avoid N+1
Breakpoint debugger for stepping through code
# Add to any Rails file
def some_method
byebug # Execution stops here
# ... rest of method
end
# Byebug commands:
# n - next line
# s - step into method
# c - continue execution
# pp variable - pretty print
# var local - show local variables
# exit - quit debugger
Enable verbose SQL logging to see queries
# In rails console or code
ActiveRecord::Base.logger = Logger.new(STDOUT)
# Now all SQL queries print to console
User.all
# => SELECT "users".* FROM "users"
Check route definitions and paths
# List all routes
rails routes
# Filter routes
rails routes | grep users
# Show routes for controller
rails routes -c users
Check migration status and schema
# Migration status
rails db:migrate:status
# Show schema version
rails db:version
# Check pending migrations
rails db:abort_if_pending_migrations
Run Ruby code in Rails environment
# Run one-liner
rails runner "puts User.count"
# Run script
rails runner scripts/investigate_users.rb
# Production environment
RAILS_ENV=production rails runner "User.pluck(:email)"
Run tests with detailed output
# Run single test with backtrace
rails test test/models/user_test.rb --verbose
# Run with warnings enabled
RUBYOPT=-W rails test
# Run with seed for reproducibility
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:
# Bad
users.each { |user| user.posts.count }
# Good
users.includes(:posts).each { |user| user.posts.count }
Error: "ActiveRecord::StatementInvalid: no such column"
# Check migration status
rails db:migrate:status
# Run pending migrations
rails db:migrate
# Or rollback and retry
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:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
rails-debugging, byebug, sql-logging, n-plus-one, systematic-debugging
npx claudepluginhub zerobearing2/rails-ai --plugin rails-ai12 skills in this plugin
/controllersrails-ai:controllersUse when building Rails controllers - RESTful actions, nested resources, skinny controllers, concerns, strong parameters/hotwirerails-ai:hotwireUse when adding interactivity to Rails views - Hotwire Turbo (Drive, Frames, Streams, Morph) and Stimulus controllers/jobsrails-ai:jobsUse when setting up background jobs, caching, or WebSockets - SolidQueue, SolidCache, SolidCable (TEAM RULE/mailersrails-ai:mailersUse when sending emails - ActionMailer with async delivery via SolidQueue, templates, previews, and testing/modelsrails-ai:modelsUse when designing Rails models - ActiveRecord patterns, validations, callbacks, scopes, associations, concerns, query objects, form objects/project-setuprails-ai:project-setupSetting up and configuring Rails 8+ projects - Gemfile dependencies, environment config, credentials, initializers, Docker, RuboCop, project validationOther plugins' skills for the same job