reliant-labs/forge/unit
Claude Code and agent skill by reliant-labs/forge
- community
Checking that the SKILL.md file is still in the repository.
Unit tests — hermetic, fast, handler-level tests using generated mocks.
Install
npx vskill@latest install reliant-labs/forge/unitSKILL.md
Unit Tests
Principles
Unit tests are hermetic: no network, no database, no filesystem. They test a single handler or function in complete isolation using generated mocks for all contract dependencies.
Running
Iterate on task test:short, scoped to what you touched: it is -short, cached, and race-free, so an unchanged package costs nothing. Don't add -count=1 or -race to it — those belong to task test and CI.
Test Naming Convention
Follow the pattern: TestHandlerName_Scenario_ExpectedOutcome
Table-Driven Tests
Use table-driven tests for edge cases — this is idiomatic Go:
Using Generated Mocks
Dependencies are defined as interfaces in your handler contracts. Mock implementations are generated in mock_gen.go files — don't hand-write stubs when the contract mock already exists. Inject them during test setup, never construct real clients.
Mock collaborators, never the subject. Mock the handler's dependencies; the handler itself stays real. A unit test that stubs the thing it claims to test asserts only that your mock returned what you told it to.
For the table-driven scaffolding around these mocks (terse construction, RPC case tables, authed contexts), use the pkg/tdd + pkg/testkit helpers rather than wiring it by hand — see testing/patterns.
Testing Error Paths
Always verify the correct Connect error code is returned, not just that an error occurred:
Read the code with svcerr.Code, not connect.CodeOf. A test calls the handler directly, so the svcerr interceptor never runs: a handler returning a bare kind (return nil, svcerr.PermissionDenied("admin only")) hands the test no *connect.Error, and connect.CodeOf reads it as Unknown. svcerr.Code is the code the client is sent — it reads a *connect.Error exactly as connect.CodeOf does, and a bare kind as the interceptor will wrap it.
Rules
- Don't test generated code in
gen/— it's regenerated and not your logic - Don't `t.Skip()` failing tests without linking an issue reference in the skip message
- Don't over-mock — if you're mocking 5+ dependencies, the unit is too big
Common Pitfalls
- Testing mocks instead of code — asserting that your mock returned what you told it to
- Over-mocking — mocking things that are fast and deterministic; just use the real thing
- Assertions that always pass — e.g., checking
err != nilwhen the mock can't fail
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 repositoryCheckinginternal/templates/project/skills/forge/testing/unit/SKILL.md
Popularity
- 7-day trend score
- 5
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/reliant-labs/forge/unit)