jupes/agent-forge-harness / .agents/skills/add-unit-tests
add-unit-tests
VerifiedAdd focused regression tests for critical behavior and edge cases. Use when strengthening unit coverage with the target repository's test runner.
add-unit-tests
Adds high-signal unit tests using the Bun test runner (bun test). Optimize for correctness on critical paths, invariants, and failure modes — not chasing 100% line coverage.
When Not to Use
- Purely cosmetic or copy-only changes with no executable behavior
- Integration/E2E suites — use the repo’s existing patterns instead
- Generated code — test the generator or hand-written seams, not every generated line
Principles
- Mission-critical first — pure functions, validation, state machines, error mapping, JSON envelopes (
ok/error), idempotency, security-sensitive branches. - Edge cases that matter — empty input, boundary values, malformed data,
null/undefined, duplicate keys, unicode, very large strings when the code promises behavior there. - Deterministic tests — no real network, clock, or filesystem unless the repo already provides fakes; use
mock/ injected dependencies. - Colocate —
foo.ts→foo.test.tsbeside it, or__tests__/foo.test.tsif the repo already does that. Match existing layout in the target package. - Strict typing — no
anywithout a// justification:comment (harness rules). - No noise — avoid trivial “it imports” tests; each test should fail for a concrete, plausible mistake.
Before Writing
- Read
AGENTS.mdand the sub-repo’sAGENTS.mdif working underrepos/<name>/. - Find how tests are run:
package.jsonscripts and anybunfig.toml/ Vitest config — default harness expectation isbun test. - Skim the module under test; list public API, invariants, and documented edge behavior to cover.
Steps
1. Pick targets
List the behaviors worth locking in (happy path + failures + one boundary each). Skip low-value branches.
2. Add test file(s)
Use Bun’s built-in describe / test / expect API (Jest-compatible).
import { describe, expect, test } from "bun:test";
import { parseEnvelope } from "./envelope.ts";
describe("parseEnvelope", () => {
test("accepts valid ok envelope", () => {
const input = JSON.stringify({ ok: true, data: { id: 1 }, error: null });
expect(parseEnvelope(input)).toEqual({ ok: true, data: { id: 1 }, error: null });
});
test("rejects malformed JSON", () => {
expect(() => parseEnvelope("{")).toThrow();
});
});
3. Run the narrow suite, then full suite
bun test path/to/module.test.ts
bun test
Fix failures before claiming the task is done.
4. Gate with typecheck
bun run typecheck
If the repo defines bun run lint, run it too.
5. Evidence for Beads / PR
- Note which behaviors are covered (bullet list in PR or
worklog:comment). - Do not claim “100% coverage”; say critical paths + listed edge cases.
Checklist (self-review)
- Every new test would catch a real regression or documents an explicit contract
- No flaky timing or network
- No
console.logleft in committed tests -
bun testpasses; TypeScript strict clean for new code
Sub-repos (repos/<name>/)
Follow that repo’s test runner and conventions if they differ from Bun. Still apply the same critical-path-first prioritization.
Optional references
Put long fixtures or golden files in references/ only when it keeps tests readable — prefer small inline data for unit tests.
Completion
Selected behaviors have regression-sensitive assertions, focused tests and repository checks have recorded outcomes, and remaining coverage gaps are stated.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |