Skip to content
Back to skills

Derive Test Shape From Name

ASecurity

Given a clear test name, produce given/when/then scaffolding and an assertion structure. Use after derive-test-name-from-behavior to write the actual test body.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
testingtypescriptcode-review

Security analysis

A100/100

Scanned November 7, 2026

npx -y skills add spencerbeggs/vitest-agent --skill derive-test-shape-from-name --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Derive Test Shape From Name?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Derive Test Shape From Name
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/spencerbeggs-derive-test-shape-from-name/badge)](https://www.skillsdirectory.com/skills/spencerbeggs-derive-test-shape-from-name)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: derive-test-shape-from-name
description: Given a clear test name, produce given/when/then scaffolding and an assertion structure. Use after derive-test-name-from-behavior to write the actual test body.
---

# Derive a test shape from a name

Given a test name like `should reject empty username with a ValidationError`, produce a Vitest test body with explicit Given/When/Then sections.

## Template

```typescript
it("should <observable behavior>", () => {
  // Given: <setup, no assertions>
  const input = ...;

  // When: <invoke the SUT>
  const result = ...;

  // Then: <assertions>
  expect(result).toBe(...);
});
```

## Rules

1. **Given** sets up state but never asserts.
2. **When** invokes exactly one method or computes one value.
3. **Then** asserts on the result of When. If you have to compute another value to assert on, the test is doing too much.
4. Prefer concrete inputs over fixtures. `expect(validate(""))` beats `expect(validate(emptyInput))` for readability.

## Reusable outside TDD

Used in red phase to scaffold a failing test. Also used by code-review skills to suggest restructuring overly-complex existing tests.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.