mcpField
R
rails-debugger

rails-debugger

github.com/majesticlabs-devDevelopment5048 installsUpdated 7w ago
Repository

About rails-debugger

rails-debugger is a Rails debugging skill for developers investigating application errors. It guides log and stack-trace analysis, issue isolation, bug classification, and reporting a minimal fix with verification steps.

Key features

  1. 01Log and stack-trace analysis
  2. 02Database and dependency checks
  3. 03Console reproduction and binary search
  4. 04Recent-change inspection
  5. 05Structured bug report with verification

Use cases

  1. 01Trace an exception to its application origin
  2. 02Investigate migration or dependency problems
  3. 03Reproduce and classify a reported bug

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/majesticlabs-dev/majestic-marketplace --skill rails-debugger

After installing, type/rails-debuggerin Claude Code to confirm it loaded.

Details

From the project README

Rails Debugger

Debugging Process

1. Gather Information
tail -100 log/development.log
bundle exec rspec --format documentation
bin/rails db:migrate:status
2. Analyze Stack Traces

Identify the origin:

  • Find the first line in app/ directory
  • Note the file, line number, and method

Common patterns:

ErrorLikely Cause
NoMethodError: undefined method for nil:NilClassMissing association, nil return
ActiveRecord::RecordNotFoundID doesn't exist, scoping issue
ActiveRecord::RecordInvalidValidation failed
ActionController::ParameterMissingRequired param not sent
NameError: uninitialized constantMissing require, typo
LoadErrorFile not found, autoload path issue
3. Check Common Issues

Database:

bin/rails db:migrate:status
bin/rails db:schema:dump

Dependencies:

bundle check
bundle install
4. Isolate the Problem

Reproduce in console:

user = User.find(123)
user.some_method  # Does it fail here?

Binary search:

  • Comment out half the code
  • Does error persist?
  • Narrow down
5. Check Recent Changes
git log --oneline -20
git log -p --follow app/models/user.rb
git diff HEAD~5 app/models/user.rb

Debugging Techniques

Hypothesis Testing
  1. Form specific, testable theories
  2. Design minimal tests to prove/disprove
  3. Document what you've ruled out
State Inspection
Rails.logger.debug { "DEBUG: user=#{user.inspect}" }
binding.irb  # Pause here (Rails 7+)

Common Rails Issues

N+1 Queries
grep "SELECT" log/development.log | sort | uniq -c | sort -rn

Fix: User.includes(:posts)

Routing Issues
bin/rails routes | grep users
bin/rails routes -c users
Callback Issues
User._create_callbacks.map(&:filter)
User._save_callbacks.map(&:filter)

Bug Report Validation

Classification
StatusMeaning
Confirmed BugReproduced with clear deviation
Cannot ReproduceUnable to reproduce
Not a BugBehavior is correct per spec
Data IssueProblem with specific data

Output Format

  1. Reproduction Status - Confirmed / Cannot Reproduce / Not a Bug
  2. Root Cause - What's actually wrong (explain why)
  3. Evidence - Specific logs, traces, or code
  4. Fix - Minimal code changes
  5. Prevention - How to avoid similar issues
  6. Verification - Commands/tests to confirm fix

Comments

Markdown supported