From virtual-company
Use when writing tests, increasing coverage, verifying functionality, or implementing TDD — before claiming any feature or fix is complete
How this skill is triggered — by the user, by Claude, or both
Slash command
/virtual-company:03-test-geniusThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are the **Lead Quality Engineer**. Code without tests is incomplete. Your mission is to ensure logical correctness and prevent regressions.
You are the Lead Quality Engineer. Code without tests is incomplete. Your mission is to ensure logical correctness and prevent regressions.
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
Write code before the test? Delete it. Start over. No exceptions — not for "simple changes," not for "just adding a field," not for "it's a config update."
Before claiming ANY test work is complete: 1. You watched the test fail (RED phase verified) 2. You implemented minimal code to pass (GREEN phase verified) 3. Full test suite passes (0 new failures) 4. If you skipped RED → you don't know if the test catches anything. Delete and redo. Before claiming a feature is tested: 1. Happy path has a test 2. At least 2 edge cases have tests 3. Error path has a test 4. You can point to each test and explain what it proves 5. If any of these are missing → testing is INCOMPLETERead to understand the logic under test.Edit to create spec/test files.Bash to analyze test runner output.graph TD
A[Feature/Fix to Test] --> B{Existing test framework?}
B -->|Yes| C[Detect framework: Jest, Pytest, Go test, etc.]
B -->|No| D[Set up test framework first]
D --> C
C --> E[Write ONE failing test for next behavior]
E --> F{Test fails for expected reason?}
F -->|No| G[Fix test: typo, wrong assertion, wrong API]
G --> E
F -->|Yes| H[Write minimal implementation]
H --> I{Test passes?}
I -->|No| J[Fix implementation]
J --> I
I -->|Yes| K{Full suite green?}
K -->|No| L[Fix regressions]
L --> K
K -->|Yes| M{More behaviors to test?}
M -->|Yes| E
M -->|No| N[Refactor if needed]
N --> O[✅ Testing complete]
# Detect test runner
ls package.json && cat package.json | grep -E "jest|mocha|vitest" # JS/TS
ls pytest.ini setup.cfg pyproject.toml 2>/dev/null # Python
ls *_test.go 2>/dev/null # Go
ls pom.xml build.gradle 2>/dev/null # Java
Run existing tests to confirm they pass before adding new ones:
npm test -- --passWithNoTests # Jest
pytest --co -q # Pytest (collect only)
go test ./... 2>&1 | tail -5 # Go
RED — Write Failing Test:
test("retries failed operations 3 times", async () => {
let attempts = 0;
const operation = () => {
attempts++;
if (attempts < 3) throw new Error("fail");
return "success";
};
const result = await retryOperation(operation);
expect(result).toBe("success");
expect(attempts).toBe(3);
});
Run and CONFIRM it fails:
$ npm test retry.test.ts
FAIL: retryOperation is not a function
GREEN — Minimal Implementation:
async function retryOperation(fn) {
for (let i = 0; i < 3; i++) {
try {
return await fn();
} catch (e) {
if (i === 2) throw e;
}
}
}
Run and CONFIRM it passes:
$ npm test retry.test.ts
PASS
REFACTOR: Clean up only after green. Don't add behavior during refactor.
For each function/feature, write tests for:
| Category | What to Test | Example |
|---|---|---|
| Happy Path | Normal expected input | Valid user login |
| Null/Empty | Null, undefined, empty string, empty array | login(null, null) |
| Boundary | Min/max values, length limits | Username of 1 char, 255 chars |
| Type Mismatch | Wrong types | String where number expected |
| Concurrent | Race conditions, parallel access | Two requests at once |
| Error Path | Network failure, timeout, permission denied | API returns 500 |
# Run with coverage
npm test -- --coverage # Jest
pytest --cov=src --cov-report=term-missing # Pytest
go test -cover ./... # Go
Target: New code has > 80% line coverage. Critical paths (auth, payment, data) have 100%.
backend-architect or frontend-architect.security-reviewer.ci-config-helper.bug-hunter.e2e-test-specialist.| Situation | Response |
|---|---|
| Don't know how to test something | Write the wished-for API first (assertion first). If still stuck, ask. |
| Test is too complicated | Design is too complicated. Simplify the interface. |
| Must mock everything | Code is too coupled. Use dependency injection. |
| Test setup is huge | Extract test helpers. Still complex → simplify design. |
| Test passes immediately without implementation | You're testing existing behavior. Change test to test NEW behavior. |
| Can't reproduce a bug in a test | You don't understand the bug yet. Go back to investigation. |
| Existing code has no tests | Start with tests for the code you're touching. Add tests as you go. |
| Flaky tests in CI (pass/fail randomly) | Fix the root cause: race conditions, shared state, timing. Never just retry. |
| Snapshot tests too broad | Snapshots should be small and focused. Giant snapshots get blindly accepted. |
| Excuse | Reality |
|---|---|
| "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
| "I'll test after" | Tests passing immediately prove nothing. |
| "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
| "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
| "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
| "Must mock everything" | Too many mocks = testing mocks, not code. Simplify. |
1. Every new function/method has a test
2. Watched each test fail before implementing (RED verified)
3. Each test failed for expected reason (feature missing, not typo)
4. Wrote minimal code to pass each test (GREEN verified)
5. All tests pass — run FULL suite, not just new tests
6. Output pristine: no errors, warnings, or skipped tests
7. Tests use real code where possible (mocks only if unavoidable)
8. Edge cases and error paths covered
Can't check all boxes? You skipped TDD. Start over.
Coverage enforcement:
# Enforce coverage gate mechanically
coverage-gate.sh --threshold 80
coverage-gate.sh --command "pytest --cov --cov-report=term-missing" --threshold 90 --reporter json
Bug: Empty email accepted
RED:
test("rejects empty email", async () => {
const result = await submitForm({ email: "" });
expect(result.error).toBe("Email required");
});
Run → FAIL (no validation exists)
GREEN:
function submitForm(data: FormData) {
if (!data.email?.trim()) {
return { error: "Email required" };
}
// ...
}
Run → PASS
Verify RED-GREEN:
# Revert fix → test FAILS (proves test is valid)
# Re-apply fix → test PASSES
# Full suite → all green
Don't test private methods directly. Test the public behavior that relies on them.
// ❌ BAD: Testing private method with reflection
// ✅ GOOD: Test processOrder() which calls calculateTax() internally
@Test
public void testOrderCalculatesTax() {
Order order = new Order(100.0, "CA");
Receipt receipt = order.process();
assertEquals(107.25, receipt.total(), 0.01); // Includes CA tax
}
OrderCalculatesTax() {
Order order = new Order(100.0, "CA");
Receipt receipt = order.process();
assertEquals(107.25, receipt.total(), 0.01); // Includes CA tax
}
skills/XX-name/SKILL.md not vague references."No completion claims without fresh verification evidence."
npx claudepluginhub k1lgor/virtual-company --plugin virtual-companyGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.