acedergren/agentic-tools/write-tests
Claude Code and agent skill by acedergren/agentic-tools
- community
Checking that the SKILL.md file is still in the repository.
Use when adding or improving test coverage for existing source code without changing production behavior. Selects mock strategy by module type (route handler, repository, plugin, utility, service), handles mockReset:true environments, and prevents common vitest/jest mock wiring failures. Triggers on: write tests, add tests, test coverage, regression coverage, untested module, *.test.ts. Triggers on "write tests" or "add test coverage".
Install
npx vskill@latest install acedergren/agentic-tools/write-testsSKILL.md
Write Tests for Existing Code
When to Use
Load this skill when the user request matches the frontmatter description for Write Tests for Existing Code.
NEVER
- NEVER chain `mockResolvedValueOnce` when
mockReset: true— the chain clears between tests. Use counter-basedmockImplementationinstead. - NEVER define mock variables at module scope then reference them inside `vi.mock()` factories — hoisting creates a temporal dead zone. Use
vi.hoisted()or globalThis registry. - NEVER `vi.importActual()` for modules with side effects — use selective re-exports instead.
- NEVER test implementation details (private state, internal call order) — test observable behavior through the public API.
- NEVER copy mock patterns from other projects — check YOUR test runner config first (
mockReset,mockClear,restoreMocks). - NEVER modify source code — this skill writes tests only; production behavior is fixed.
Before Writing, Ask Yourself
- Module type? Each has a different mock strategy (see table below).
- Blast radius? Does this module have side effects (DB writes, API calls, filesystem) that need isolation?
- Nearest test file? Find the closest
*.test.tsand match its exact mock structure — don't invent a new pattern.
Mock Strategy by Module Type
| Module Type | Strategy | |
|---|---|---|
| Route handler | Test app builder + session simulation + app.inject() | |
| Repository | Mock DB connection + counter-based execute | |
| Framework plugin | Real framework instance + selective dependency mocks | |
| Pure utility | No mocks — test inputs/outputs directly | |
| Service w/ DI | Mock injected deps via forwarding pattern |
Mock Setup (mockReset: true)
If your test runner uses mockReset: true, most examples from the internet will silently fail — return values clear between tests.
For complex TDZ cases (multiple interdependent mocks), use the globalThis registry pattern:
Metacognitive Rule
If >3 tests fail on first run: STOP. Root cause is almost certainly a mock wiring issue affecting all tests — not individual test logic. Re-examine the mock setup holistically before fixing tests one by one.
Run
Arguments
$ARGUMENTS: Path to the source file or module to cover- Example:
/write-tests src/routes/admin/settings.ts - If empty: ask the user which file needs test coverage
Security
- Security scanPassed, 100 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/write-tests/SKILL.md
Popularity
- Repository stars
- 8
- Repository forks
- 1
- 7-day trend score
- 11
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 3 Apr 2026, 7 months ago.
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/acedergren/agentic-tools/write-tests)