rewrite-tests-pest
Skill10 starsChanged 3 months agoMITView on GitHub
Use when rewriting existing tests to Pest syntax. Preserve behavior, follow project testing conventions, reduce duplication where helpful, and verify rewritten tests are deterministic and passing.
We split this skill into the rules it gives an agent
18 rules. About 0 are common, 13 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
If the current project uses Laravel, also apply @rules/laravel/laravel.mdc, @rules/laravel/architecture.mdc, @rules/laravel/filament.mdc, …
- Very specific: line 13
Do not generate covers()
- Distinctive: line 21
Keep tests deterministic and non-flaky
- Distinctive: line 22
Prefer simple, readable Pest syntax
- Distinctive: line 23
Use helper methods or datasets when they clearly reduce duplication
- Distinctive: line 24
Avoid reflection; prefer mocks or partial mocks when readable and effective
- Distinctive: line 25
Avoid branching in tests; prefer separate test cases or datasets instead
- Distinctive: line 35
Only after Read, Map, and Verify are complete may the rewrite begin.
- Distinctive: line 41
Use datasets/data providers where they simplify similar test cases.
- Very specific: line 43
If a Pest test needs to call a helper method defined on the test case for abstract-class scenarios, use test()->methodName().
- Distinctive: line 44
Keep tests structured and easy to read, preferably with clear arrange / act / assert flow.
- Distinctive: line 46
Run the rewritten tests and confirm they pass consistently.
- Distinctive: line 50
Run all rewritten tests and confirm they pass.
- Distinctive: line 51
Verify 100% code coverage for all rewritten test paths — if coverage tooling exists, run it.
- Distinctive: line 53
Run available fixers on changed test files and fix any violations.
- Very specific: line 54
Run available checkers/analyzers on changed test files and resolve all reported errors by rewriting the flagged code, never by adding a …
- Very specific: line 55
Run a quick code review of rewritten tests against @rules/code-testing/general.mdc and fix any findings.
- Distinctive: line 63
Test review passed with no findings
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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
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.
- 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.
- 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.
- 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
- Identify existing tests that should be rewritten to Pest syntax.
- Analyze repeated setup and assertions before rewriting.
- Rewrite tests to Pest syntax without changing covered behavior.
- Use datasets/data providers where they simplify similar test cases.
- Move broadly shared lightweight test helpers to
Pest.phpwhen it improves clarity and reuse. - If a Pest test needs to call a helper method defined on the test case for abstract-class scenarios, use
test()->methodName(). - Keep tests structured and easy to read, preferably with clear arrange / act / assert flow.
- Separate success and failure scenarios into distinct test cases where practical.
- Run the rewritten tests and confirm they pass consistently.
- Simplify nearby similar tests only when the cleanup is small, safe, and clearly improves maintainability.
Post-rewrite validation
- Run all rewritten tests and confirm they pass.
- Verify 100% code coverage for all rewritten test paths — if coverage tooling exists, run it.
- Discover available fixers and checkers (prefer Phing targets from
build.xml/phing.xml; fall back to Composer scripts incomposer.json). - Run available fixers on changed test files and fix any violations.
- Run available checkers/analyzers on changed test files and resolve all reported errors by rewriting the flagged code, never by adding a suppression annotation (
@rules/php/core-standards.mdcPHP Practices). - Run a quick code review of rewritten tests against
@rules/code-testing/general.mdcand fix any findings.
Done when
- Target tests are rewritten to Pest syntax
- Rewritten tests preserve original intent and behavior
- Tests are deterministic and pass reliably
- 100% code coverage is verified for rewritten code paths
- Code style and quality checks pass (fixers and checkers ran clean)
- Test review passed with no findings
- Duplication is reduced where it meaningfully improves readability
- Shared lightweight helpers are extracted appropriately
- The rewritten tests follow project testing conventions
In this repository62 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analyze-problemSkill
- api-reviewSkill
- article-writingSkill
- assignment-compliance-checkSkill
- automation-audit-opsSkill
- autonomous-loopsSkill
- benchmark-optimization-loopSkill
- benchmarkSkill
- blueprintSkill
- class-refactoringSkill
- cleanup-local-branchesSkill
- codebase-simplification-auditSkill
- code-review-bugsnagSkill
- code-review-githubSkill
- code-review-jiraSkill
- code-reviewSkill
- composer-updateSkill
- create-issues-from-textSkill
- create-issueSkill
- create-missing-tests-in-prSkill
- create-testSkill
- design-systemSkill
- docker-patternsSkill
- e2e-testingSkill
- frontend-a11ySkill
- frontend-design-directionSkill
- frontend-patternsSkill
- frontend-slidesSkill
- git-workflowSkill
- laravel-authorization-reviewSkill
- laravel-securitySkill
- laravel-telescopeSkill
- latency-critical-systemsSkill
- merge-github-prSkill
- mysql-patternsSkill
- mysql-problem-solverSkill
- penetration-testerSkill
- postgres-patternsSkill
- prepare-issue-contextSkill
- process-code-reviewSkill
- product-capabilitySkill
- production-auditSkill
- pr-staged-merge-planSkill
- pr-summarySkill
- record-project-memorySkill
- redis-patternsSkill
- refactor-entry-point-to-actionSkill
- refresh-claude-mdSkill
- resolve-issueSkill
- security-bounty-hunterSkill
- security-reviewSkill
- security-threat-analysisSkill
- seoSkill
- skill-creatorSkill
- slack-messagingSkill
- smartest-project-additionSkill
- test-driven-developmentSkill
- tester-cookbookSkill
- test-like-humanSkill
- The first 60 shown.
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.

