From rails-agent-skills
Plans tests for a Rails change using a Test Design Review checkpoint, selects the smallest strong slice, and writes one minimal failing example as the initial TDD gate.
How this skill is triggered — by the user, by Claude, or both
Slash command
/rails-agent-skills:plan-testsThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
| Change type | First spec | Path | Why |
| Change type | First spec | Path | Why |
|---|---|---|---|
| API contract, params, status code, JSON shape | Request spec | spec/requests/ | Proves the real HTTP contract |
| Domain rule on a cohesive record or value object | Model spec | spec/models/ | Fast feedback on domain behavior |
| Multi-step orchestration across collaborators | Service spec | spec/services/ | Focuses on the workflow boundary |
| Enqueue/run/retry/discard behavior | Job spec | spec/jobs/ | Captures async semantics directly |
| Critical Turbo/Stimulus or browser-visible flow | System spec | spec/system/ | Use only when browser interaction is the real risk |
| Engine routing, generators, host integration | Engine spec | spec/requests/ or engine path | Normal app specs miss engine wiring — see test-engine |
| Bug fix | Reproduction spec | Where the bug is observed | Proves the fix and prevents regression |
CHECKPOINT: Test Design Review
1. Present: Show the failing spec(s) written
2. Ask:
- Does this test cover the right behavior?
- Is the boundary correct (request vs service vs model)?
- Are the most important edge cases represented?
- Is the failure reason correct (feature missing, not setup error)?
3. Confirm: Only proceed to implementation once test design is approved.
Start at the highest-value boundary that proves the behavior with the least unnecessary setup.
spec/requests/..., spec/services/..., spec/jobs/..., spec/models/...).write-tests for general spec writing, test-service for service-layer coverage, or test-engine for engine integration.# Behavior: POST /orders validates params and returns 201 with JSON payload
# First slice: request spec
# Suggested path: spec/requests/orders/create_spec.rb
RSpec.describe "POST /orders", type: :request do
let(:user) { create(:user) }
let(:valid_params) { { order: { product_id: create(:product).id, quantity: 1 } } }
before { sign_in user }
it "creates an order and returns 201" do
post orders_path, params: valid_params, as: :json
expect(response).to have_http_status(:created)
expect(response.parsed_body["id"]).to be_present
end
end
# Behavior: Orders::CreateOrder validates inventory, persists, and enqueues follow-up work
# First slice: service spec
# Suggested path: spec/services/orders/create_order_spec.rb
RSpec.describe Orders::CreateOrder do
subject(:result) { described_class.call(user: user, product: product, quantity: 1) }
let(:user) { create(:user) }
let(:product) { create(:product, stock: 5) }
it "returns a successful result with the new order" do
expect(result).to be_success
expect(result.order).to be_persisted
end
end
| Pitfall | What to do |
|---|---|
| Starting with a PORO spec because it is easy | Easy ≠ high-signal — choose the boundary that proves the real behavior |
| Writing three spec types before running any | Pick one slice, run it, prove the failure, then proceed |
| Defaulting to one spec type for everything | Match the spec type to the layer where the real risk lives (HTTP, domain, async, browser) |
| Jumping to system specs too early | Reserve for critical browser flows that lower layers cannot prove |
Load these files only when their specific content is needed:
When completing test planning, produce a brief structured summary and populate the full plan using assets/first_slice_template.md. The summary must cover:
npx claudepluginhub igmarin/rails-agent-skills2plugins reuse this skill
First indexed Jun 21, 2026
Writes, reviews, and configures RSpec tests in Ruby on Rails following TDD workflow. Executes specs via bundle exec rspec and captures actual test output.
Strict 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 for features, bug fixes, and refactoring. Requires failing tests before any production code, with guidance on test types and spec-to-test mapping.