Unit Test Improver — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited Unit Test Improver (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 review an existing set of unit tests and improve them. It looks for weak or incomplete tests — tests that pass even when the code is broken, tests that don't assert the right things, tests that are missing critical edge cases, and tests that test implementation details instead of behavior. The output is an improved, rewritten test suite that is harder to fool and more useful as a safety net.
Use this before a major refactor (so you can trust the tests will catch regressions), during a code review, or when a bug slips past your existing tests.
Copy this file to .agents/skills/unit-test-improver/SKILL.md in your project root.
Then ask:
Provide both the test file and the code being tested.
Add the instructions below to your .cursorrules or paste them into the Cursor AI pane. Then share the test file and the source file side by side.
Paste both the test file (labeled "TESTS") and the source file (labeled "SOURCE") and ask Codex to follow the instructions below.
When asked to improve unit tests, follow these steps:
Read the full test file. Then read the source code being tested. Understand what the function is supposed to do before evaluating whether the tests cover it.
Check every test for these problems:
Weak assertions
expect(result).toBeTruthy() instead of expect(result).toBe(true) — passes for any truthy valueexpect(result).toBeDefined() when the actual value should be checkedexpect(fn).not.toThrow() without checking the return valueresult.id but not result.value)Missing coverage
Tests that test implementation, not behavior
Poor test structure
it('works'))beforeEachOver-mocking
Using the source code, enumerate every branch, condition, and edge case that should be tested. Cross-reference with the existing tests and list what's missing.
Rewrite the full test file applying these principles:
it('returns 0 when the cart is empty') not it('cart test').toBe() calls are fine if they're testing the same return value; a single test should not mix unrelated concernsif, else, catch, and switch case should have a testexpect(total).toBe(29.99) not expect(total).toBeGreaterThan(0) // Arrange
const cart = [{ price: 10, qty: 3 }];
// Act
const total = calculateTotal(cart);
// Assert
expect(total).toBe(30);First, provide a review summary:
## Test Review Summary
### Issues found
- [List each issue with the test name or line number]
### Missing coverage
- [List each missing case]Then provide the complete rewritten test file.
Input to Agent:
"Use the Unit Test Improver skill.
>
SOURCE (discount.ts): ``ts export function calculateDiscount(price: number, code: string): number { if (code === 'SAVE10') return price * 0.9; if (code === 'SAVE25') return price * 0.75; if (price > 100) return price * 0.95; return price; }``
>
TESTS (discount.test.ts): ``ts it('applies discount', () => { expect(calculateDiscount(50, 'SAVE10')).toBeTruthy(); }); it('works', () => { const result = calculateDiscount(200, ''); expect(result).toBeDefined(); });``"
Output from Agent:
## Test Review Summary
>
### Issues found -'applies discount': UsestoBeTruthy()— passes for any non-zero number, wouldn't catch a bug returning the wrong discount amount -'works': UsestoBeDefined()— passes as long as the function doesn't throw; doesn't verify the correct value - Both test names are vague and don't describe expected behavior
>
### Missing coverage - SAVE25 code not tested - Price > 100 with no code not tested - Invalid/unknown coupon code with price ≤ 100 not tested - Zero price not tested - Negative price not tested>
---
>
```ts import { calculateDiscount } from './discount';
>
describe('calculateDiscount', () => { describe('with coupon codes', () => { it('applies 10% discount for SAVE10 code', () => { expect(calculateDiscount(100, 'SAVE10')).toBe(90); });
>
it('applies 25% discount for SAVE25 code', () => { expect(calculateDiscount(100, 'SAVE25')).toBe(75); });
>
it('coupon codes take priority over price-based discount', () => { expect(calculateDiscount(200, 'SAVE10')).toBe(180); }); });
>
describe('without coupon codes', () => { it('applies 5% discount when price is above 100', () => { expect(calculateDiscount(200, '')).toBe(190); });
>
it('applies no discount when price is exactly 100', () => { expect(calculateDiscount(100, '')).toBe(100); });
>
it('applies no discount when price is below 100', () => { expect(calculateDiscount(50, '')).toBe(50); }); });
>
describe('edge cases', () => { it('returns 0 for a zero price', () => { expect(calculateDiscount(0, '')).toBe(0); });
>
it('unknown coupon code falls through to price-based logic', () => { expect(calculateDiscount(200, 'INVALID')).toBe(190); }); }); }); ```
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.