Agent skill

Writing Tests

by spencerpauly in spencerpauly/awesome-cursor-skills

Analyze existing code and write comprehensive unit and integration tests for it.

CC0-1.0Auto-check passedTesting & QA

Install Writing Tests

skills CLI
$ npx skills add spencerpauly/awesome-cursor-skills --skill writing-tests -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install spencerpauly/awesome-cursor-skills writing-tests --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/spencerpauly/awesome-cursor-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/resources/writing-tests .claude/skills/writing-tests && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
writing-tests
GitHub stars
844
Token cost
~1k tokens
SKILL.md length
306 words
Files
1
Skills in repo
60
Repo updated
First seen
Licence
CC0-1.0

At a glance

Analyze existing code and write comprehensive unit and integration tests for it.

  • Works in 8 steps: Detect the test setup — check what's… → If no test runner exists — set one up → Analyze the target code — read the… → …
  • The user asks to add tests
  • SKILL.md covers Steps, What to Test and Notes
  • Calls npm, vitest and playwright

What it does

Writing Tests is an agent skill from spencerpauly/awesome-cursor-skills. Analyze existing code and write comprehensive unit and integration tests for it. Detects the test framework, identifies untested code paths, and generates tests with proper mocking, edge cases, and assertions. Use when the user asks to add tests, improve coverage, or test a specific module.

Its SKILL.md is about 1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Testing & QA, covering Test coverage, Integration testing and Unit testing. The repository describes itself as: A curated list of awesome skills for Cursor. The licence is CC0-1.0.

When your agent uses it

  • The user asks to add tests
  • Improve coverage
  • Test a specific module

Example prompts

  • “/writing-tests”

Requirements

  • Node.js

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  1. Detect the test setup — check what's already configured
  2. If no test runner exists — set one up
  3. Analyze the target code — read the file(s) to test and identify
  4. Create the test file — place it next to the source file or in a tests/ directory, matching the project's convention
  5. Write tests following this structure
  6. Mock external dependencies — don't make real API calls or database queries in unit tests
  7. Test React components with Testing Library
  8. Run the tests and verify they pass

What it can do on your machine

Read from SKILL.md and the folder at commit 99cd265. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npm
    • vitest
    • playwright

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npm, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Writing Tests loads about 1k tokens when it runs. Until then it costs about 76 tokens; SKILL.md has 306 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~76
When it runs · the whole SKILL.md, loaded when a task matches
~1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from spencerpauly/awesome-cursor-skills at commit 99cd265, republished under its CC0-1.0 licence (© spencerpauly). 306 words, ~1,005 tokens.

Download SKILL.mdSave it as .claude/skills/writing-tests/SKILL.md (or your agent's skills folder).
name
writing-tests
description
Analyze existing code and write comprehensive unit and integration tests for it. Detects the test framework, identifies untested code paths, and generates tests with proper mocking, edge cases, and assertions. Use when the user asks to add tests, improve coverage, or test a specific module.

Writing Tests

Use this skill when the user asks to add tests to existing code, improve test coverage, or write tests for a specific file or module.

Steps

  1. Detect the test setup — check what's already configured:

    bash
    # Check package.json for test runner
    cat package.json | grep -E "jest|vitest|mocha|playwright|cypress"

    Look for config files: vitest.config.ts, jest.config.ts, playwright.config.ts, .mocharc.*. Check for existing test files to understand the project's test patterns and conventions.

  2. If no test runner exists — set one up:

    bash
    npm install -D vitest @testing-library/react @testing-library/jest-dom

    Add a test script to package.json:

    json
    { "test": "vitest run", "test:watch": "vitest" }
  3. Analyze the target code — read the file(s) to test and identify:

    • Public API: exported functions, classes, components, hooks
    • Code paths: conditionals, error handling, edge cases
    • Dependencies: external services, databases, APIs that need mocking
    • Side effects: file I/O, network calls, DOM mutations
  4. Create the test file — place it next to the source file or in a __tests__/ directory, matching the project's convention:

    • src/utils/format.ts → src/utils/format.test.ts
    • src/components/Button.tsx → src/components/Button.test.tsx
  5. Write tests following this structure:

    ts
    import { describe, it, expect, vi } from "vitest";
    
    describe("functionName", () => {
      // Happy path
      it("returns formatted output for valid input", () => { ... });
    
      // Edge cases
      it("handles empty string", () => { ... });
      it("handles null/undefined input", () => { ... });
    
      // Error cases
      it("throws on invalid argument", () => { ... });
    
      // Boundary conditions
      it("handles maximum length input", () => { ... });
    });
  6. Mock external dependencies — don't make real API calls or database queries in unit tests:

    ts
    vi.mock("@/lib/db", () => ({
      query: vi.fn().mockResolvedValue([{ id: 1, name: "test" }]),
    }));

    For React components, mock hooks that fetch data:

    ts
    vi.mock("@/hooks/useUser", () => ({
      useUser: () => ({ user: { name: "Test" }, isLoading: false }),
    }));
  7. Test React components with Testing Library:

    tsx
    import { render, screen, fireEvent } from "@testing-library/react";
    
    it("renders the button and handles click", () => {
      const onClick = vi.fn();
      render(<Button onClick={onClick}>Click me</Button>);
      fireEvent.click(screen.getByRole("button", { name: "Click me" }));
      expect(onClick).toHaveBeenCalledOnce();
    });
  8. Run the tests and verify they pass:

    bash
    npm test

    If any fail, fix the test or the code (depending on whether the test expectation or the implementation is wrong).

Show full SKILL.md (102 more words)Show less

What to Test

  • Always test: public API, error handling, edge cases (empty, null, zero, negative), state transitions, async behavior
  • Skip testing: private implementation details, third-party library internals, simple getters/setters, type-only code

Notes

  • Match the project's existing test style — if they use test() instead of it(), follow that.
  • Don't test implementation details — test behavior and outputs, not internal method calls.
  • Use descriptive test names that explain the scenario: "returns 0 when cart is empty" not "test1".
  • One assertion concept per test — multiple expect calls are fine if they verify the same behavior.
  • For async code, always await the result or use resolves/rejects matchers.

© spencerpauly, CC0-1.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in resources/writing-tests of spencerpauly/awesome-cursor-skills.

Open the folder on GitHubat commit 99cd265

Compare with similar skills

Writing Tests next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Writing Tests compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Writing Tests this skillspencerpauly/awesome-cursor-skills844—~1kAutomated safety check: PassCC0-1.0
Memstack Development Test Writercwinvestments/memstack423—~3.7kAutomated safety check: PassProprietary
Test Experteinverne/dotfiles121—~2.3kAutomated safety check: PassGPL-3.0
Scenario Testingaiskillstore/marketplace4331 repos~830Automated safety check: PassNone
Assessing Test Coveragebitwarden/ai-plugins155—~1.1kAutomated safety check: PassCustom licence
Recommending Test Layersbitwarden/ai-plugins155—~2.4kAutomated safety check: PassCustom licence

Similar skills

  • Memstack Development Test Writer

    cwinvestments/memstack

    A skill your agent uses when the user says 'write tests', 'add tests', 'test coverage', 'unit tests', 'integration tests', 'component tests', 'mocking', 'edge cases', or needs to generate tests with…

    423 GitHub stars~3.7k tokensUpdated 13 days ago
    Testing & QAAuto-check passed
  • Test Expert

    einverne/dotfiles

    Testing methodologies, test-driven development (TDD), unit and integration testing, and testing best practices across multiple frameworks.

    121 GitHub stars~2.3k tokensUpdated 1 mo ago
    Testing & QAAuto-check passed
  • Scenario Testing

    aiskillstore/marketplace

    This skill should be used when writing tests, validating features, or needing to verify code works.

    433 GitHub starsUsed in 1 repo~830 tokens
    Testing & QAAuto-check passed
  • Assessing Test Coverage

    bitwarden/ai-plugins

    Official

    A skill your agent uses when determining what test coverage ALREADY exists for a specific change (a PR, Jira key, Tech Breakdown doc, Testmo CSV, changed paths, or named component).

    155 GitHub stars~1.1k tokensUpdated today
    Testing & QAAuto-check passed
  • Recommending Test Layers

    bitwarden/ai-plugins

    Official

    A skill your agent uses when deciding WHICH new tests a change needs and at WHICH layer each belongs, working from a Jira key, a Testmo CSV, an assessing-test-coverage report, a PR, or a feature…

    155 GitHub stars~2.4k tokensUpdated today
    Testing & QAAuto-check passed
  • Test Writing Workflow

    iOfficeAI/AionUi

    Sets the test-writing workflow for the repository: risk-first scenario lists, behavior-focused Vitest tests, a full run before each commit and a coverage target.

    33k GitHub starsUsed in 1 repo~1.2k tokens
    Testing & QAAuto-check passed

More from spencerpauly/awesome-cursor-skills

All 60 skills in this repo
  • Generating Images

    spencerpauly/awesome-cursor-skills

    Generate or edit images using the OpenAI Image API (gpt-image-2).

    844 GitHub stars~3.7k tokensUpdated 2 mo ago
    Auto-check: notes
  • Babysitting PR

    spencerpauly/awesome-cursor-skills

    Monitor a pull request for CI failures, review comments, and merge conflicts — then fix them automatically.

    844 GitHub stars~930 tokensUpdated 2 mo ago
    Auto-check passed
  • Best Of N Solving

    spencerpauly/awesome-cursor-skills

    Solve a hard problem by trying multiple approaches in parallel using isolated git worktrees.

    844 GitHub stars~698 tokensUpdated 2 mo ago
    Auto-check passed
  • Grinding Until Pass

    spencerpauly/awesome-cursor-skills

    Keep iterating on code changes until the tests pass, the build succeeds, or linting is clean.

    844 GitHub stars~796 tokensUpdated 2 mo ago
    Auto-check passed
  • Parallel CI Triage

    spencerpauly/awesome-cursor-skills

    When GitHub Actions fails, fetch failing job logs and assign each failing job to a separate subagent that fixes its slice of the problem in parallel.

    844 GitHub stars~793 tokensUpdated 2 mo ago
    Auto-check passed
  • Parallel Exploring

    spencerpauly/awesome-cursor-skills

    Explore a large codebase in parallel by launching multiple explore subagents that each investigate a different area simultaneously.

    844 GitHub stars~787 tokensUpdated 2 mo ago
    Auto-check: notes

Categories

Questions about Writing Tests

What does Writing Tests do?

Analyze existing code and write comprehensive unit and integration tests for it. Writing Tests is an agent skill from spencerpauly/awesome-cursor-skills. Analyze existing code and write comprehensive unit and integration tests for it.

When should I use Writing Tests?

Writing Tests fits situations like: the user asks to add tests; improve coverage; test a specific module.

How do I install Writing Tests in Claude Code?

Run `npx skills add spencerpauly/awesome-cursor-skills --skill writing-tests -a claude-code`. Or copy the skill folder (resources/writing-tests in spencerpauly/awesome-cursor-skills) into .claude/skills/writing-tests in your project. Claude Code loads it when a task matches its description.

How do I install Writing Tests in Codex?

Run `npx skills add spencerpauly/awesome-cursor-skills --skill writing-tests -a codex`. Or copy the skill folder (resources/writing-tests in spencerpauly/awesome-cursor-skills) into .agents/skills/writing-tests in your project. Codex loads it when a task matches its description.

Can I use Writing Tests in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add spencerpauly/awesome-cursor-skills --skill writing-tests -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/writing-tests, .gemini/skills/writing-tests, .github/skills/writing-tests and .opencode/skills/writing-tests in your project.

What does Writing Tests need to run?

Going by SKILL.md and its folder, Writing Tests needs the command-line tools its instructions call (npm, vitest and playwright). Our summary lists: Node.js.

Does Writing Tests access the network?

SKILL.md contains no URLs. Its commands use npm, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Writing Tests safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Writing Tests use?

Writing Tests is published under the CC0-1.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Writing Tests use?

About 1k tokens (SKILL.md is roughly 4k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Writing Tests?

Skills that share tags, products or a category with Writing Tests: Memstack Development Test Writer (cwinvestments/memstack, 423 stars), Test Expert (einverne/dotfiles, 121 stars), Scenario Testing (aiskillstore/marketplace, 433 stars) and Assessing Test Coverage (bitwarden/ai-plugins, 155 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Writing Tests?

spencerpauly (a GitHub user) maintains it in spencerpauly/awesome-cursor-skills, which has 844 GitHub stars. The repository holds 60 skills in this directory. The repository was last updated on August 2, 2026.

Source: spencerpauly/awesome-cursor-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.