write-tests

write-tests is a skill for Claude Code, Codex from igmarin/rails-agent-skills. It costs 37 tokens per session (1,248 once invoked), scanned A, original, MIT.

A guide for writing and cleaning up RSpec tests in Ruby on Rails projects. RSpec is a framework for describing expected software behavior, and the guide emphasizes writing a failing test before implementation.

In plain words
What is it for?
Use it to write model, request, job, service, or system specs, choose suitable test doubles and factories, and run the relevant RSpec command.
Why use it?
It keeps tests focused on user-visible behavior and makes new behavior test-driven instead of relying on tests that merely mirror the code.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to write model, request, job, service, or system specs, choose suitable test doubles and factories, and run the relevant RSpec command.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/igmarin/rails-agent-skills/write-tests
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add igmarin/rails-agent-skills --skill write-tests
Clone the repo
git clone --depth 1 https://github.com/igmarin/rails-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for write-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/igmarin/rails-agent-skills/write-tests.svg)](https://agentmods.dev/skills/igmarin/rails-agent-skills/write-tests)
Your own site
<a href="https://agentmods.dev/skills/igmarin/rails-agent-skills/write-tests"><img src="https://agentmods.dev/badge/skills/igmarin/rails-agent-skills/write-tests.svg" alt="Measured on agentmods" height="20"></a>
Per session 37 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,248 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00037 $0.01248
Opus 5 $0.00018 $0.00624
Sonnet 5 $0.00007 $0.00250
Haiku 4.5 $0.00004 $0.00125

Measured 8d ago against content hash 8367e47287ed, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

write-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/write-tests/SKILL.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Write Tests

Use this skill when the task is to write, review, or clean up RSpec tests.

Quick Reference

Aspect Rule
Spec types Model: domain logic / pure domain → start here; Request: HTTP endpoints; Job: background processing; Service/PORO: clean Ruby; System: E2E cross-layer journey (sparingly)
Assertions Test behavior, not implementation
Factories Minimal attributes; traits for options; prefer build/build_stubbed over create
Mocking Stub external boundaries at class level (e.g. allow(Client).to receive); no Active Record mocking
Service specs Required: describe '.call' and subject(:result) (see assets/output_checklist.md)
let vs let! Default to let; use let! only when object must exist before action
Example names Present tense; no should; no and (see assets/output_checklist.md)

HARD-GATE

DO NOT write implementation code before a failing test exists.
Run bundle exec rspec and keep the real failure class and message.

Core Process

When driving new behaviour with RSpec, follow this sequence:

  1. Write the failing spec — pick the smallest spec type that exercises the intended behaviour (model > service > request > system), as shown in the Spec types row above.
  2. Run it and confirm the failure message — show the concrete RED failure class/message. Do not leave this as a placeholder template; do not use illustrative e.g. failure examples in the final artifact.
  3. Implement the minimum code to make the spec pass.
  4. Refactor — clean up duplication and naming while keeping the suite green.
  5. Verify — run the full relevant spec file, then the suite, before committing.

For output format and RED/GREEN proof requirements, see assets/tdd_proof_checklist.md.

Service Spec (anchor pattern)

RSpec.describe Invoices::MarkOverdue do
  describe '.call' do
    subject(:result) { described_class.call(invoice: invoice) }

    context 'when the invoice is overdue and unpaid' do
      let(:invoice) { create(:invoice, due_date: 2.days.ago, paid_at: nil) }
      it 'marks the invoice overdue' do
        expect { result }.to change { invoice.reload.overdue? }.from(false).to(true)
      end
    end
  end
end

Read the full file on GitHub · 110 lines

Files

What ships with it

5 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 110 lines · 37 tokens per session scan A 8367e47287ed

Subscribe to this mod's changes

write-tests is a skill published in the GitHub repository igmarin/rails-agent-skills (24 stars, last pushed 17d ago), licensed MIT. It adds 37 tokens to every session and 1,248 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

rspec-conventions

Rootstrap RSpec conventions. Use when writing, reviewing, or editing RSpec test files (spec//spec.rb, spec/railshelper.rb, spec/spechelper.rb, spec/support//.rb) or factories. Covers describe/context structure, let/subject, matchers, factories, mocking/stubbing, shared examples, and spec types (model, request…

rootstrap/rails_api_base · 82 tokens

ruby

Ruby development guidelines covering idiomatic code style, Ruby 3.x features, testing with RSpec, and best practices for building maintainable Ruby applications.

Mindrally/skills · 32 tokens

rspec

RSpec testing best practices for Ruby and Rails applications, covering test organization, data management, and isolation patterns.

Mindrally/skills · 24 tokens

testunit-skill

Generates Test::Unit tests in Ruby. Classic xUnit-style testing with assert methods and test case classes. Use when user mentions "Test::Unit", "assertequal Ruby", "Ruby test-unit". Triggers on: "Test::Unit", "Ruby test-unit", "assertequal Ruby" (not RSpec).

LambdaTest/agent-skills · 70 tokens

rspec

This skill should be used when the user asks to "write specs", "create spec", "add RSpec tests", "fix failing spec", or mentions RSpec, describe blocks, it blocks, expect syntax, test doubles, or matchers. Should also be used when editing spec.rb files, working in spec/ directory, planning implementation phases that…

hoblin/claude-ruby-marketplace · 125 tokens

rails-testing

Ruby on Rails testing best practices for writing effective, maintainable test suites with RSpec. This skill should be used when writing, reviewing, or refactoring Rails tests to ensure proper test design, data management, and coverage patterns. Triggers on tasks involving RSpec specs, model tests, request specs…

pproenca/dot-skills · 103 tokens