rahulsub/code-practices-plugin/test-first
Claude Code and agent skill by rahulsub/code-practices-plugin
- community
Checking that the SKILL.md file is still in the repository.
Write failing tests before implementation. Enables LLM self-correction through feedback loops. Use for new features and bug fixes.
Install
npx vskill@latest install rahulsub/code-practices-plugin/test-firstSKILL.md
The same SKILL.md was published earlier as rahulsub/code-practices-plugin/test-first.
Test-First Development Skill
Trigger
Use when implementing new features or fixing bugs. Especially valuable for complex logic.
Why Test-First with LLMs
Karpathy insight: "Get it to write tests first and then pass them." Tests create a feedback loop that lets LLMs self-correct. Tests are success criteria that enable autonomous iteration.
Process
Step 1: Understand the Requirement
Before writing any code:
- What is the input?
- What is the expected output?
- What are the edge cases?
- What should happen on errors?
Step 2: Write Failing Tests First
Step 3: Run Tests (They Should Fail)
Verify tests fail for the right reasons. This confirms tests are actually testing something.
Step 4: Implement Minimal Code to Pass
Don't over-engineer. Write the simplest code that makes tests green.
Step 5: Refactor if Needed
Now that tests pass, clean up the code while keeping tests green.
Test Quality Checklist
- [ ] Tests verify behavior, not implementation
- [ ] Each test tests one thing
- [ ] Tests are independent (can run in any order)
- [ ] Test names describe expected behavior
- [ ] Edge cases are covered
- [ ] Error cases are covered
- [ ] Tests run fast
Anti-Patterns to Avoid
- Tests that just check code runs without asserting behavior
- Tests that duplicate implementation logic
- Tests with many assertions (split them)
- Tests that depend on other tests
- Mocking everything (test real behavior when possible)
The Loop
Verify with Independent Subagents
From Anthropic's Claude Code best practices: Use independent subagents to verify implementations aren't overfitting to tests.
After implementation passes tests, spawn a separate verification:
Why This Matters
LLMs can "overfit" to test cases - writing code that passes the specific tests but fails on real-world inputs. An independent reviewer catches:
- Magic numbers that match test values
- Conditional logic that only handles test scenarios
- Missing validation that tests don't exercise
Example of Overfitting
The subagent review catches these patterns before they reach production.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/test-first/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/rahulsub/code-practices-plugin/test-first)