rewrite-tests-pest

rewrite-tests-pest is a skill for Claude Code, Codex from pekral/cursor-rules. It costs 36 tokens per session (895 once invoked), scanned A, original, MIT.

A testing guide for rewriting PHPUnit-style tests in Pest, a simpler PHP testing syntax, while keeping their intended behavior.

In plain words
What is it for?
Use it to convert existing PHP tests to Pest, preserve coverage, reduce repetition with helpers or datasets, and verify that the rewritten tests are deterministic and passing.
Why use it?
It helps modernize a test suite without accidentally changing what the tests check. It also addresses duplicated, flaky, or hard-to-read tests.

Skill for Claude CodeCodex

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.

agentmods
npx agentmods add skills/pekral/cursor-rules/rewrite-tests-pest
Any agent
npx skills add pekral/cursor-rules --skill rewrite-tests-pest
Clone the repo
git clone --depth 1 https://github.com/pekral/cursor-rules

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 rewrite-tests-pest

README.md
[![agentmods](https://agentmods.dev/badge/skills/pekral/cursor-rules/rewrite-tests-pest.svg)](https://agentmods.dev/skills/pekral/cursor-rules/rewrite-tests-pest)
Your own site
<a href="https://agentmods.dev/skills/pekral/cursor-rules/rewrite-tests-pest"><img src="https://agentmods.dev/badge/skills/pekral/cursor-rules/rewrite-tests-pest.svg" alt="Measured on agentmods" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 895 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00036 $0.00895
Opus 5 $0.00018 $0.00447
Sonnet 5 $0.00007 $0.00179
Haiku 4.5 $0.00004 $0.00089

Measured yesterday against content hash 27b71da230cc, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

rewrite-tests-pest 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 yesterday.

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/rewrite-tests-pest/SKILL.md · 67 lines

How it starts

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

Constraints

  • Apply @rules/php/core-standards.mdc
  • Apply @rules/code-testing/general.mdc
  • If the current project uses Laravel, also apply @rules/laravel/laravel.mdc, @rules/laravel/architecture.mdc, @rules/laravel/filament.mdc, and @rules/laravel/livewire.mdc
  • Do not generate covers()

Use when

  • Existing tests are written in PHPUnit-style syntax and should be rewritten to Pest
  • You want to modernize tests without changing their intended behavior

Required approach

  • Preserve test intent and coverage of the rewritten behavior
  • Keep tests deterministic and non-flaky
  • Prefer simple, readable Pest syntax
  • Use helper methods or datasets when they clearly reduce duplication
  • Avoid reflection; prefer mocks or partial mocks when readable and effective
  • Avoid branching in tests; prefer separate test cases or datasets instead

Read, Map & Verify before rewriting (mandatory pre-flight)

Reading, mapping, and verifying come first; rewriting comes last. This pre-flight is blocking — do not rewrite a single line until all three steps pass, and never act on an assumption you have not confirmed by reading the code.

  1. Read — open and read the actual tests being rewritten and the code they exercise (the system under test, shared setup, helpers, datasets). Confirm what each test asserts by reading it, not by guessing from its name.
  2. Map — map the change's blast radius: every assertion and covered code path that must survive the rewrite, the shared setup/helpers to reuse, and the project's existing Pest conventions.
  3. Verify — run the existing tests first and confirm they pass, so you rewrite from a known-green baseline. If the original behavior or coverage is unclear, stop and clarify instead of rewriting on a wrong premise.

Only after Read, Map, and Verify are complete may the rewrite begin.

Execution

  1. Identify existing tests that should be rewritten to Pest syntax.
  2. Analyze repeated setup and assertions before rewriting.
  3. Rewrite tests to Pest syntax without changing covered behavior.
  4. Use datasets/data providers where they simplify similar test cases.
  5. Move broadly shared lightweight test helpers to Pest.php when it improves clarity and reuse.
  6. If a Pest test needs to call a helper method defined on the test case for abstract-class scenarios, use test()->methodName().
  7. Keep tests structured and easy to read, preferably with clear arrange / act / assert flow.
  8. Separate success and failure scenarios into distinct test cases where practical.
  9. Run the rewritten tests and confirm they pass consistently.
  10. Simplify nearby similar tests only when the cleanup is small, safe, and clearly improves maintainability.

Read the full file on GitHub · 67 lines

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. yesterday First seen · 67 lines · 36 tokens per session scan A 27b71da230cc

Subscribe to this mod's changes

rewrite-tests-pest is a skill published in the GitHub repository pekral/cursor-rules (6 stars, last pushed 5d ago), licensed MIT. It adds 36 tokens to every session and 895 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-09-03.