From rails-agent-skills
Orchestrates the full Rails TDD cycle: write failing test, get approval, implement minimal code, verify passes, run Rubocop/Brakeman/RSpec, document with YARD, and open PR.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rails-agent-skills:tddThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
1. **context/load-context**: Load schema, routes, and patterns.
HARD GATE — tdd-process (from ruby-core-skills)
undefined method 'full_name').write-tests.bundle exec rspec spec/path/to/spec.rb.If test does not pass, fix minimal changes and re-verify.
Return to Phase 1 for next behavior or proceed to Phase 4.
bundle exec rubocop && bundle exec brakeman && bundle exec rspec.Abbreviated walkthrough for adding a full_name method to a User model. For the full end-to-end example, see assets/example.md.
Step 1 — Write the failing spec (spec/models/user_spec.rb):
RSpec.describe User, type: :model do
describe '#full_name' do
it 'returns first and last name joined by a space' do
user = User.new(first_name: 'Jane', last_name: 'Doe')
expect(user.full_name).to eq('Jane Doe')
end
end
end
Run: bundle exec rspec spec/models/user_spec.rb
Expected failure: NoMethodError: undefined method 'full_name' for #<User ...> ✅
Step 2 — Propose & confirm
Proposal: Add
def full_name = "#{first_name} #{last_name}"toapp/models/user.rb. Proceed?
Step 3 — Minimal implementation (app/models/user.rb):
def full_name
"#{first_name} #{last_name}"
end
Run: bundle exec rspec spec/models/user_spec.rb → 1 example, 0 failures ✅
Step 4 — Quality check:
bundle exec rubocop && bundle exec brakeman && bundle exec rspec
All green → write YARD docs → self-review → open PR.
When completing a TDD cycle, produce a report following the template in assets/tdd-report-template.md. At minimum the report must include:
| Predecessor | This Persona | Successor |
|---|---|---|
| load-context | tdd | code-review |
| define-domain-language | tdd | quality |
| None (standalone) | tdd | PR submission |
Use plan-tests alone if you only need to decide which test to write next.
Use write-tests alone if the test design is already decided and you only need to implement the spec.
Test fails for the wrong reason (syntax/config error):
SyntaxError, NameError, LoadError indicate test problems, not missing features.NoMethodError).Implementation makes test pass but breaks other tests:
bundle exec rspec to identify regressions.Quality gate fails (RuboCop/Brakeman):
bundle exec rubocop -a for auto-correctable offenses; fix remaining ones manually.npx claudepluginhub igmarin/rails-agent-skillsStrict red-green-refactor TDD workflow for Rails: write a failing test, then minimal production code. Drop down layers as failures demand, one change per run.
Enforces test-driven development: write failing tests before production code for any behavior change. Triggers on TDD, implementation tasks, bug fixes needing regression tests.
Enforces test-driven development for features, bug fixes, and refactoring. Requires failing tests before any production code, with guidance on test types and spec-to-test mapping.