rspec
Skill1 starsChanged 7 months agoMITView on GitHub
Use when running RSpec on a Rails project — re-running only failed examples, parallelizing with parallel_tests, generating coverage, or bisecting test-order failures. Multi-project via RSPEC_PROFILE.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- aks-builds/quality-skillstheir own version, first seen Jun 12, 2026
- Mindrally/skillstheir own version, first seen Jan 23, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Mindrally/skills★ 266same name
- aks-builds/quality-skills★ 5same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- azure-devopsSkill
- fastlaneSkill
- firebaseSkill
- herokuSkill
- k6Skill
- linearSkill
- maestroSkill
- postgresSkill
- profiles-and-credentialsSkill
- rails-securitySkill
- react-nativeSkill
- sentrySkill
- shopifySkill
- slackSkill
- trelloSkill
- xlsx-testcasesSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 81
After run, parse /tmp/rspec.json:
- Distinctive: line 175
Test databases get dropped/recreated.
- Very specific: line 179
Use --example "pattern" for focused subset during dev, full parallel only on commit/push.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/rspec — Rails test runner
Wraps bundle exec rspec with structured output parsing and selective retry. No external credentials.
Profile resolution: --profile → RSPEC_PROFILE → ~/.rspec/active_profile → [default].
Overview
Wraps bundle exec rspec with structured JSON output parsing and selective retry. No external credentials. Profiles isolate per-project test settings (parallel workers, seed strategy, rails_env).
When to Use
- Running RSpec test suites with structured failure output
- Re-running only failed examples (after a fix attempt)
- Parallelizing with
parallel_tests(multi-core machines, CI) - Bisecting test-order failures (
--bisect) - Coverage reports via simplecov
When NOT to Use
- Non-Rails Ruby tests → bare
rspecworks fine - Minitest projects → use
rake test, not this skill - E2E / browser tests → not RSpec's job
- Production debugging → tests are not a debugger
Profile config
~/.rspec/credentials (mode 600 — though profiles rarely contain secrets):
[default]
project_path = .
rails_env = test
workers = 1
seed_strategy = random # or "fixed:42" for repro
[ci]
project_path = .
rails_env = test
workers = 4 # parallel via parallel_tests
seed_strategy = fixed:1234Helpers
Shared profile/INI/
ctt_*pattern reference: profiles-and-credentials.
source "$HOME/.claude-team-toolkit/lib/credentials.sh"
ctt_load_creds rspec "$PROFILE"
cd "$CTT_PROJECT_PATH" || { echo "No project at $CTT_PROJECT_PATH" >&2; return 1; }
build_rspec_cmd() {
RSPEC_CMD=(bundle exec rspec)
case "$CTT_SEED_STRATEGY" in
fixed:*) RSPEC_CMD+=(--seed "${CTT_SEED_STRATEGY#fixed:}") ;;
random|"") RSPEC_CMD+=(--order random) ;;
esac
RSPEC_CMD+=(--format documentation --format json --out /tmp/rspec.json)
}Dispatch
run [path] [--example "pattern"] — run specs
build_rspec_cmd
RAILS_ENV="$CTT_RAILS_ENV" "${RSPEC_CMD[@]}" "${1:-spec/}" ${EXAMPLE:+--example "$EXAMPLE"}After run, parse /tmp/rspec.json:
jq -r '
"Examples: \(.summary.example_count) Failed: \(.summary.failure_count) Pending: \(.summary.pending_count) Duration: \(.summary.duration)s\n\n" +
"Failed:\n" + (
if .summary.failure_count == 0 then " none"
else (.examples | map(select(.status=="failed")) | map(" \(.full_description)\n \(.file_path):\(.line_number)") | join("\n"))
end
)
' /tmp/rspec.jsonfailed — re-run only failures from last run
build_rspec_cmd; "${RSPEC_CMD[@]}" --only-failuresnext-failure — run until first failure
build_rspec_cmd; "${RSPEC_CMD[@]}" --next-failureIterate: fix → run → next failure → fix.
parallel [path] — parallel_tests (workers > 1)
[ "$CTT_WORKERS" -gt 1 ] || { echo "Profile workers=$CTT_WORKERS — use 'run'" >&2; return 1; }
grep -q "parallel_tests" Gemfile.lock || {
echo "parallel_tests not in Gemfile.lock — add: gem 'parallel_tests', group: :test" >&2
return 1
}
# Setup parallel test databases (one-time per machine)
[ -f "config/database.yml" ] && bundle exec rake parallel:create parallel:load_schema 2>/dev/null || true
bundle exec parallel_rspec -n "$CTT_WORKERS" "${1:-spec/}"coverage [path] — simplecov coverage
grep -q "simplecov" Gemfile.lock || {
echo "simplecov not in Gemfile — add: gem 'simplecov', require: false, group: :test" >&2
return 1
}
# Verify spec_helper has SimpleCov.start at top
grep -q "SimpleCov.start" spec/spec_helper.rb 2>/dev/null || \
grep -q "SimpleCov.start" spec/rails_helper.rb 2>/dev/null || {
echo "Add 'require \"simplecov\"; SimpleCov.start \"rails\"' at TOP of spec/spec_helper.rb" >&2
return 1
}
build_rspec_cmd
COVERAGE=true RAILS_ENV="$CTT_RAILS_ENV" "${RSPEC_CMD[@]}" "${1:-spec/}"
echo "Coverage: file://$(pwd)/coverage/index.html"
[ -f coverage/.last_run.json ] && jq -r '"Line coverage: \(.result.line)%"' coverage/.last_run.jsonsummary — last run summary (no re-run)
[ -f /tmp/rspec.json ] || { echo "No prior run found" >&2; return 1; }
jq -r '"Examples: \(.summary.example_count) Failed: \(.summary.failure_count) Pending: \(.summary.pending_count) Duration: \(.summary.duration)s"' /tmp/rspec.jsontag <tag-name> [path] — run only tagged
build_rspec_cmd; "${RSPEC_CMD[@]}" --tag "$TAG" "${1:-spec/}"Common tags: :focus, :slow, :integration.
bisect <description> — find order-dependent failure
bundle exec rspec --bisect --example "$DESC"Common Mistakes
- Forgetting
RAILS_ENV=test→ drops dev/prod data. Skill enforces this. --seed randomthen trying to reproduce → impossible. Setfixed:Nfor repro.- Running
parallelwith workers=1 in profile → no speedup, useruninstead simplecov.startAFTERrequire 'rails'→ coverage misses framework load- Re-running full suite when
--only-failureswould work → wastes minutes - "Database is locked" → another test process holding it; kill stale
rspecfirst
Implementation notes
--format jsonrequires RSpec 3+./tmp/rspec.jsonoverwritten each run.parallel_testsusesRAILS_ENV=test+TEST_ENV_NUMBERto isolate DBs (myapp_test1,myapp_test2...).--seed Nreproduces order — important for debugging order-dependent failures.
Safety
- Tests run with full project access — never run untrusted spec files.
RAILS_ENV=testenforced — refuse if profile has non-test rails_env.- Test databases get dropped/recreated. Profile must point to TEST DB, not staging/prod.
Token-saving tip
Use --example "pattern" for focused subset during dev, full parallel only on commit/push.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

