Unit Test Writer — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Unit Test Writer (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
This skill directs the agent to write a thorough unit test suite for a given function, class, or module. It systematically identifies happy paths, edge cases, error paths, and boundary conditions — then writes tests in your chosen framework (Jest, Vitest, Mocha, etc.) with proper mocking where needed.
Use this when you have a function that needs test coverage or when you want to verify your implementation handles edge cases you might not have thought of.
Copy this file to .agents/skills/unit-test-writer/SKILL.md in your project root.
Then ask the agent:
Paste the function code into the chat, or reference the file path.
Add the instructions from the "Prompt / Instructions" section below to your .cursorrules, or paste them into the Cursor AI pane before asking for tests.
Paste your function and the instructions below into the Codex chat. Specify your test framework explicitly (Jest, Vitest, etc.) since Codex does not infer it from the project.
When asked to write unit tests, follow these steps:
null, undefined, 0, "", falsedescribe block per function or classdescribe blocks for logical groups (e.g., describe('when user is not logged in', ...))it('returns null when input is an empty array')jest.mock() / vi.mock() for module-level mocksjest.spyOn() / vi.spyOn() for spying on methods without replacing the moduleafterEach or use clearMocks: true in configimport { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; // or jest equivalents
import { functionUnderTest } from '../path/to/module';
// Mock external dependencies
vi.mock('../path/to/dependency', () => ({
someFunction: vi.fn(),
}));
describe('functionUnderTest', () => {
beforeEach(() => {
vi.clearAllMocks();
});
describe('happy path', () => {
it('returns the expected result for valid input', () => {
// arrange
// act
// assert
});
});
describe('edge cases', () => {
it('returns null when input is an empty array', () => { ... });
it('handles zero correctly', () => { ... });
});
describe('error handling', () => {
it('throws TypeError when input is not a string', () => { ... });
});
});Input to Agent:
"Use the Unit Test Writer skill to write Vitest tests for this function:
>
``typescript export function parsePriceString(price: string): number { if (!price || typeof price !== 'string') throw new TypeError('price must be a string'); const cleaned = price.replace(/[$,\s]/g, ''); const num = parseFloat(cleaned); if (isNaN(num)) throw new RangeError(Cannot parse price from "${price}"); return num; }``"
Output from Agent:
import { describe, it, expect } from 'vitest';
import { parsePriceString } from '../utils/parsePriceString';
describe('parsePriceString', () => {
describe('happy path', () => {
it('parses a plain number string', () => {
expect(parsePriceString('9.99')).toBe(9.99);
});
it('strips dollar signs', () => {
expect(parsePriceString('$19.99')).toBe(19.99);
});
it('strips commas from large numbers', () => {
expect(parsePriceString('$1,299.00')).toBe(1299);
});
it('strips leading and trailing whitespace', () => {
expect(parsePriceString(' $5.00 ')).toBe(5);
});
});
describe('edge cases', () => {
it('handles zero', () => {
expect(parsePriceString('$0.00')).toBe(0);
});
it('handles a string with only a dollar sign as invalid', () => {
expect(() => parsePriceString('$')).toThrow(RangeError);
});
});
describe('error handling', () => {
it('throws TypeError when price is not a string', () => {
expect(() => parsePriceString(null as any)).toThrow(TypeError);
});
it('throws TypeError when price is undefined', () => {
expect(() => parsePriceString(undefined as any)).toThrow(TypeError);
});
it('throws TypeError when price is an empty string', () => {
expect(() => parsePriceString('')).toThrow(TypeError);
});
it('throws RangeError when string contains no numeric characters', () => {
expect(() => parsePriceString('abc')).toThrow(RangeError);
});
});
});~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.