Agent skill

Test Writer for Changed Code

by poshan0126 in poshan0126/dotclaude

Writes tests for newly added or changed code by reading the git diff, mapping every code path and writing one-assertion tests that match the project's conventions.

MITAuto-check passedTesting & QA

Install Test Writer for Changed Code

skills CLI
$ npx skills add poshan0126/dotclaude --skill test-writer -a claude-code

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

GitHub CLI
$ gh skill install poshan0126/dotclaude test-writer --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/poshan0126/dotclaude.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/test-writer .claude/skills/test-writer && 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
test-writer
GitHub stars
871
Token cost
~1.2k tokens
SKILL.md length
535 words
Files
1
Skills in repo
14
Repo updated
First seen
Licence
MIT

At a glance

Writes tests for newly added or changed code by reading the git diff, mapping every code path and writing one-assertion tests that match the project's conventions.

  • Works in 4 steps: Discover What Changed → Analyze Every Code Path → Write the Tests → …
  • After adding a function, endpoint or component that has no tests yet
  • SKILL.md covers Step 1: Discover What Changed, Step 2: Analyze Every Code Path, Step 3: Write the Tests and Step 4: Verify, plus 1 more section
  • Calls git

What it does

The change under test is injected from `git diff --stat HEAD` and `git diff HEAD` when the skill loads, with fallbacks such as `git diff --cached` or `git show HEAD` if the diff is empty. The agent reads each changed file, works out the project's test framework and conventions from existing tests, and places new files next to the source or in the established test directory.

It maps each function, method or component across the happy path, edge cases, null values, type boundaries, error paths, concurrency, state transitions and integration points, then writes a test for every scenario with one assertion per test, sentence-style names and arrange-act-assert structure. Extra guidance covers branches and thrown errors in pure functions and, for API endpoints, success responses, per-field validation errors, authentication failures, rate limiting and idempotency. It targets changes without matching test changes, not config, docs or test-only diffs; judging existing tests is left to the `pr-test-analyzer` agent.

When your agent uses it

  • After adding a function, endpoint or component that has no tests yet
  • Changing behavior and needing tests that match the project's conventions
  • Covering error paths and edge cases of a freshly written handler

Example prompts

  • “Write tests for the endpoint I just added.”
  • “I changed how discounts are calculated, so cover the new branches with tests.”
  • “Add edge-case tests for the new date parser, including empty input and invalid formats.”

Requirements

  • A git repository with uncommitted or recent changes
  • An existing test setup to follow
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Bash(git diff *), Bash(git log *)

Workflow steps

4 steps, taken from the step headings in SKILL.md.

  1. Discover What Changed
  2. Analyze Every Code Path
  3. Write the Tests
  4. Verify

What it can do on your machine

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

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Bash(git diff *)
    • Bash(git log *)

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

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

  • Network

    No URLs in SKILL.md. Its commands use git, 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

Test Writer for Changed Code loads about 1.2k tokens when it runs. Until then it costs about 87 tokens; SKILL.md has 535 words of instructions outside code blocks.

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

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 poshan0126/dotclaude at commit 94b84b9, republished under its MIT licence (© poshan0126). 535 words, ~1,163 tokens.

Download SKILL.mdSave it as .claude/skills/test-writer/SKILL.md (or your agent's skills folder).
name
test-writer
description
Write comprehensive tests for new or changed code. Use automatically after adding a function, endpoint, or component, or changing behavior, when the change has no corresponding test changes. Not for config, docs, or test-only diffs. For judging whether existing tests adequately verify a change, use the pr-test-analyzer agent instead.
allowed-tools
Read, Write, Edit, Bash(git diff *), Bash(git log *)

Write comprehensive tests for the code that was just added or changed.

Step 1: Discover What Changed

Change under test (injected at load — already in front of you, no tool call needed):

git diff --stat HEAD 2>/dev/null || echo "(no diff vs HEAD — inspect git status manually)"
git diff HEAD 2>/dev/null || true
  • The diff above is the change under test. If it is empty (already committed or amended elsewhere), run git diff, git diff --cached, or git show HEAD to locate the change
  • Read each changed file to understand the behavior being added
  • Identify the project's existing test framework, patterns, and conventions by finding existing test files
  • Place new test files next to the source files or in the project's established test directory. Match whatever the project already does

Step 2: Analyze Every Code Path

For each new or modified function/method/component, map out:

  • Happy path. Normal input, expected output
  • Edge cases. Empty input, single element, boundary values (0, 1, -1, MAX_INT)
  • Null/undefined/nil. What happens with missing data
  • Type boundaries. Wrong types, type coercion traps
  • Error paths. Invalid input, network failures, timeouts, permission denied
  • Concurrency. Race conditions, parallel calls with shared state
  • State transitions. Initial state, intermediate states, final state
  • Integration points. How this code interacts with its dependencies

Step 3: Write the Tests

For EACH scenario identified above, write a test. No skipping.

Structure
  • One assertion per test. If a test name needs "and", split it into two tests
  • Descriptive names. Test names read as sentences describing the behavior:
    • should return empty array when input is empty
    • should throw ValidationError when email format is invalid
    • should retry 3 times before failing on network timeout
  • Arrange-Act-Assert. Set up, execute, verify. Clear separation.
Show full SKILL.md (274 more words)Show less
What to Test

Pure functions / business logic:

  • Every branch (if/else, switch, ternary)
  • Every thrown error with exact error type and message
  • Return value types and shapes
  • Side effects (mutations, calls to external services)

API endpoints / handlers:

  • Success response (status code, body shape, headers)
  • Validation errors for each field (missing, wrong type, out of range)
  • Authentication/authorization failures
  • Rate limiting behavior if applicable
  • Idempotency for non-GET methods

UI components (if applicable):

  • Renders without crashing with required props
  • Renders correct content for each state (loading, error, empty, populated)
  • User interactions trigger correct callbacks (click, submit, type, select)
  • Accessibility: focusable, keyboard navigable, correct ARIA attributes
  • Conditional rendering. Each branch shows/hides correct elements

Database / data layer:

  • CRUD operations return correct data
  • Unique constraints reject duplicates
  • Cascade deletes work as expected
  • Transactions roll back on failure

Async operations:

  • Successful resolution
  • Rejection / error handling
  • Timeout behavior
  • Cancellation if supported
  • Concurrent calls don't interfere
Mocking Rules
  • Prefer real implementations over mocks
  • Only mock at system boundaries: network, filesystem, clock, random
  • Never mock the code under test
  • If you mock, verify the mock was called with expected arguments
  • Reset mocks between tests. No shared state leaking

Step 4: Verify

  • Run the new tests. Confirm they all pass
  • Temporarily break the code (change a return value or condition). Confirm at least one test fails
  • If no test fails when code is broken, the tests are useless. Rewrite them
  • Check coverage: every new function should have at least one test, every branch should be exercised

Output

  • Complete, runnable test file(s). Not snippets
  • Tests grouped by the function/component they cover
  • A brief summary: how many tests, what scenarios covered, any gaps you couldn't cover and why

© poshan0126, MIT. 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 skills/test-writer of poshan0126/dotclaude.

Open the folder on GitHubat commit 94b84b9

Compare with similar skills

Test Writer for Changed Code 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.

Test Writer for Changed Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Test Writer for Changed Code this skillposhan0126/dotclaude871—~1.2kAutomated safety check: PassMIT
OpenROAD Module Test AdderThe-OpenROAD-Project/OpenROAD3.2k—~1.8kAutomated safety check: PassBSD-3-Clause
Testing iOS Codebitwarden/ios696—~1.8kAutomated safety check: PassGPL-3.0
Caliber Testingcaliber-ai-org/ai-setup1.3k—~3.2kAutomated safety check: PassMIT
Test Coverage Reviewareed1192/finance-news-aggregator149—~2.6kAutomated safety check: PassMIT
Write Testsgrafana/synthetic-monitoring-app171—~1.2kAutomated safety check: PassAGPL-3.0

Similar skills

  • OpenROAD Module Test Adder

    The-OpenROAD-Project/OpenROAD

    Adds integration or unit tests to an OpenROAD module: writes the Tcl test, generates golden files and registers it in both CMake and Bazel.

    3.2k GitHub stars~1.8k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Testing iOS Code

    bitwarden/ios

    Official

    Write tests, add test coverage, unit test, or add missing tests for Bitwarden iOS.

    696 GitHub stars~1.8k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Caliber Testing

    caliber-ai-org/ai-setup

    Writes Vitest tests following project patterns: tests/ directories, vi.mock() for module mocking with vi.hoisted() for test-time factories, global LLM mock from src/test/setup.ts, environment…

    1.3k GitHub stars~3.2k tokensUpdated 15 days ago
    Testing & QAAuto-check passed
  • Test Coverage Review

    areed1192/finance-news-aggregator

    Audit, plan, write, and verify unit tests for Python projects using pytest.

    149 GitHub stars~2.6k tokensUpdated 5 mo ago
    Testing & QAAuto-check passed
  • Write Tests

    grafana/synthetic-monitoring-app

    Official

    Write Jest integration and unit tests for the Grafana Synthetic Monitoring app using React Testing Library, MSW, and src/test helpers.

    171 GitHub stars~1.2k tokensUpdated today
    Testing & QAAuto-check passed
  • Write Tests

    openplayerjs/openplayerjs

    Write or extend Jest tests for OpenPlayerJS to this repo's exact conventions — makeCore factories, typed internals handles instead of as any, media property mocking, fake timers, ads/vast mocks, and…

    649 GitHub stars~1.8k tokensUpdated 4 days ago
    Testing & QAAuto-check passed

More from poshan0126/dotclaude

All 14 skills in this repo
  • Session Catchup and Handoff

    poshan0126/dotclaude

    Rebuilds working context after /clear by reading a handoff note and the branch's git state, or writes that handoff note before a session ends.

    871 GitHub stars~811 tokensUpdated 1 mo ago
    Auto-check passed
  • Context Budget Check

    poshan0126/dotclaude

    Estimates the per-turn token cost of a project's .claude folder and CLAUDE.md, split into always-loaded, path-scoped and invoked-only files, and flags what runs over budget.

    871 GitHub stars~1.4k tokensUpdated 1 mo ago
    Auto-check passed
  • Codebase Onboarding Tour

    poshan0126/dotclaude

    Builds a quick mental model of an unfamiliar codebase by dispatching read-only Explore subagents and merging their findings into one brief.

    871 GitHub stars~858 tokensUpdated 1 mo ago
    Auto-check passed
  • Parallel Specialist PR Review

    poshan0126/dotclaude

    Reviews a pull request, staged changes or a file by sending the diff to specialist reviewer agents in parallel, then merges their findings into one compact report.

    871 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check passed
  • dotclaude Project Setup

    poshan0126/dotclaude

    Scans a codebase, interviews you, and installs only the justified Claude Code rules, hooks, agents and skills, tailored to the project's stack.

    871 GitHub stars~3.6k tokensUpdated 1 mo ago
    Auto-check passed
  • Ship Changes

    poshan0126/dotclaude

    Walks through commit, push and pull request creation for the current changes, asking you to confirm the files, message, push and PR text at each step.

    871 GitHub stars~953 tokensUpdated 1 mo ago
    Auto-check: notes

Works with

Questions about Test Writer for Changed Code

What does Test Writer for Changed Code do?

Writes tests for newly added or changed code by reading the git diff, mapping every code path and writing one-assertion tests that match the project's conventions. The change under test is injected from `git diff --stat HEAD` and `git diff HEAD` when the skill loads, with fallbacks such as `git diff --cached` or `git show HEAD` if the diff is empty. The agent reads each changed file, works out the project's test framework and conventions from existing tests, and places new files next to the source or in the established test directory.

When should I use Test Writer for Changed Code?

Test Writer for Changed Code fits situations like: after adding a function, endpoint or component that has no tests yet; changing behavior and needing tests that match the project's conventions; covering error paths and edge cases of a freshly written handler.

How do I install Test Writer for Changed Code in Claude Code?

Run `npx skills add poshan0126/dotclaude --skill test-writer -a claude-code`. Or copy the skill folder (skills/test-writer in poshan0126/dotclaude) into .claude/skills/test-writer in your project. Claude Code loads it when a task matches its description.

How do I install Test Writer for Changed Code in Codex?

Run `npx skills add poshan0126/dotclaude --skill test-writer -a codex`. Or copy the skill folder (skills/test-writer in poshan0126/dotclaude) into .agents/skills/test-writer in your project. Codex loads it when a task matches its description.

Can I use Test Writer for Changed Code 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 poshan0126/dotclaude --skill test-writer -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/test-writer, .gemini/skills/test-writer, .github/skills/test-writer and .opencode/skills/test-writer in your project.

What does Test Writer for Changed Code need to run?

Going by SKILL.md and its folder, Test Writer for Changed Code needs the command-line tools its instructions call (git). Our summary lists: A git repository with uncommitted or recent changes; An existing test setup to follow. Its frontmatter pre-approves these tools: Read, Write, Edit, Bash(git diff *), Bash(git log *).

Does Test Writer for Changed Code access the network?

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

Is Test Writer for Changed Code 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 Test Writer for Changed Code use?

Test Writer for Changed Code is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Test Writer for Changed Code use?

About 1.2k tokens (SKILL.md is roughly 4.7k 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 Test Writer for Changed Code?

Skills that share tags, products or a category with Test Writer for Changed Code: OpenROAD Module Test Adder (The-OpenROAD-Project/OpenROAD, 3.2k stars), Testing iOS Code (bitwarden/ios, 696 stars), Caliber Testing (caliber-ai-org/ai-setup, 1.3k stars) and Test Coverage Review (areed1192/finance-news-aggregator, 149 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Test Writer for Changed Code?

poshan0126 (a GitHub user) maintains it in poshan0126/dotclaude, which has 871 GitHub stars. The repository holds 14 skills in this directory. The repository was last updated on August 27, 2026.

Source: poshan0126/dotclaude on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.