feat: add Ruby on Rails CLI support (rspec, rubocop, bundle, rails)#1
Closed
feat: add Ruby on Rails CLI support (rspec, rubocop, bundle, rails)#1
Conversation
navidemad
added a commit
that referenced
this pull request
Mar 1, 2026
- Remove fragile byte_offset tracking in filter_bundle_install, use string search instead (issue #1) - Add signal-killed process diagnostics (eprintln when code() is None) across all 7 occurrences in 4 Ruby modules (issue rtk-ai#2) - Remove diagnostic note from stdout in rspec JSON fallback path — the eprintln on the line above already logs to stderr (issue rtk-ai#3) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
326fa9e to
29566d1
Compare
Add 4 new command modules for the Ruby on Rails ecosystem with shared infrastructure, discover registry integration, and hook rewrites. 96+ unit tests, 527 total passing. New commands: - rtk rspec: JSON parsing with text fallback (60%+ / 30%+ savings) - rtk rubocop: JSON parsing, group by cop/severity (60%+ savings) - rtk bundle list/outdated/install/update: text parsing (10-30%) - rtk rails test/routes/db:migrate/status/rollback/generate (40-50%+) Shared infrastructure: - ruby_exec() auto-detects bundle exec when Gemfile declares gem - fallback_tail() last-resort filter with diagnostic logging - count_tokens() shared test helper (deduplicated from 4 modules) - exit_code_from_output() returns 128+signal on Unix Hook rewrites cover rspec, rubocop, bundle, rails, rake, and bin/bundle exec variants via .claude/hooks/rtk-rewrite.sh.
29566d1 to
4c22082
Compare
Owner
Author
|
Moved to rtk-ai#292 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds comprehensive Ruby on Rails ecosystem support to RTK with 4 new command modules covering the full Rails development workflow, plus shared infrastructure and discover registry integration.
New Commands
rtk rspec--format jsoninjection) with text fallbackrtk rubocop--format jsoninjection) with text fallbackrtk bundle list/outdated/install/updatertk rails test/routes/db:migrate/db:migrate:status/db:rollback/generateShared Infrastructure
ruby_exec()inutils.rs— Auto-detectsbundle execwhen Gemfile declares the tool gem. Prevents forcing globally-installed tools through bundler.gemfile_mentions_gem()avoids false positives (e.g.,guardrails≠rails)fallback_tail()inutils.rs— Last-resort filter fallback showing final N lines with diagnostic loggingcount_tokens()inutils.rs— Shared test helper for token savings assertions (deduplicated from 4 modules)exit_code_from_output()— Signal-aware exit code extraction: returns128 + signalon Unix per convention, logs signal numberHook Integration
.claude/hooks/rtk-rewrite.shrewrites:rspec,bundle exec rspec,bin/rspec→rtk rspecrubocop,bundle exec rubocop→rtk rubocopbundle list/outdated/install/update→rtk bundle ...rails test/routes/db:migrate/db:migrate:status/db:rollback/generate→rtk rails ...rake routes/db:migrate/db:migrate:status/db:rollback→rtk rails ...bin/rails,bundle exec railsvariantsDiscover Registry
(?:bundle\s+exec\s+)?so the subcommand lands in capture group 1db:migrate:statusordered beforedb:migrateto avoid prefix matchtest50%,routes50%,db:migrate:status40%,db:migrate40%,db:rollback40%,generate/g20%Key Design Decisions
--format jsonunless user specified-f/--format. Detects autocorrect mode (-a,-A) in rubocop to skip JSONfallback_tail(). Logs serde error on final fallback for debuggingfallback_tail()instead of feeding JSON through the text parsersaturating_subthroughout,extract_countreturnsOption<usize>to distinguish 0 from parse errorstrip_ansi()at filter entry point to handle colored terminal outputChanges by File
src/rspec_cmd.rssrc/rails_cmd.rssrc/rubocop_cmd.rssrc/bundle_cmd.rsscripts/test-rails.shsrc/discover/registry.rssrc/utils.rsruby_exec(),fallback_tail(),count_tokens(), signal handlingsrc/main.rs.claude/hooks/rtk-rewrite.shscripts/test-all.shREADME.mdCLAUDE.mdARCHITECTURE.mdPR Review Fixes (2 rounds, 27 issues addressed)
Round 1 (issues 1-14)
saturating_subinbuild_rspec_summary(prevents underflow panic)fallback_tail()instead of text parseroutput.status.success()check in signal handlerbundle_cmd::run_passthroughusesexit_code_from_outputextract_countreturnsOption<usize>(0 vs parse error)db:rollback/generate/gruby_execskip, migrate direction docs)Round 2 (issues 1-13, skipping 9)
db:migrate:statusto discover PATTERNS and subcmd_savings + teststarts_with(") ")in rspec text parser128 + signalon Unix (was hardcoded1)strip_ansi()infilter_bundle_list()+ improved ANSI test assertionsexit_code_from_outputdoc comment reflects128 + signalbehaviorcount_tokensto sharedutils.rs(removed from 4 modules)compact_ruby_pathdoc comment accurately describes behaviorHeader → FailedExamplestransition test for rspec text parserTesting
Test Plan
cargo fmt --all --check && cargo clippy --all-targets && cargo test --allpassesrspec→rtk rspec)scripts/test-rails.shon a machine with Ruby/Railsrtk gain --historyrecords Ruby/Rails usagertk rspec -fdocumentationuses text fallbackrtk rspecin empty dir shows "FAILED" messagertk rails db:migrate:status,db:rollback,generatework correctlyrtk discoverdetectsrails db:migrate:statusas supported🤖 Generated with Claude Code