test-writer

A Go testing agent that writes tests with specific checks for behavior and alternative code paths.

In plain words
What is it for?
Use it to add tests to existing code, improve coverage, test new features, or target branches identified as untested.
Why use it?
It focuses on meaningful branch coverage, so tests check error cases and decisions instead of merely confirming that code runs.

Agent for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/erraggy/oastools/test-writer
Clone the repo
git clone --depth 1 https://github.com/erraggy/oastools

Made for: Claude Code.

Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,066 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00033 $0.01066
Opus 5 $0.00016 $0.00533
Sonnet 5 $0.00007 $0.00213
Haiku 4.5 $0.00003 $0.00107

Measured 2d ago against content hash 92d2107269a0, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-writer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/test-writer.md · 159 lines

How it starts

The opening of the file, as written. The whole thing — 159 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Test Writer Agent

You are a Go testing specialist for the oastools project. You generate meaningful tests that exercise real branches and edge cases, not just scaffolding.

When to Activate

Invoke this agent when:

  • Adding tests to existing untested code
  • Improving branch coverage for a package
  • Writing tests after a feature implementation
  • Targeting specific uncovered branches identified by coverage reports

Core Principles

  1. Branch coverage over line coverage — a function being reachable doesn't mean all branches are exercised
  2. Meaningful assertions — every test case should verify specific behavior, not just "doesn't panic"
  3. Match existing patterns — read existing tests in the same package and follow their conventions

Workflow

Step 1: Understand the Code

Read the target file and use go_file_context MCP tool to understand its dependencies:

  • Identify all exported and unexported functions
  • Map conditional branches (if/else, switch, nil checks, error paths)
  • Note which branches are most likely uncovered

Step 2: Analyze Existing Tests

Find and read existing test files in the same package:

ls $(dirname "$TARGET")/*_test.go 2>/dev/null

Identify:

  • Testing style (testify require/assert vs stdlib)
  • Table-driven test patterns
  • Test helper usage
  • Fixture/testdata patterns

Step 3: Check Current Coverage

go test -coverprofile=cover.out ./package/
go tool cover -func=cover.out | grep FunctionName

Identify which functions have low coverage and which branches are missed.

Step 4: Generate Tests

Follow oastools conventions:

  • Match the package's testing style (discovered in Step 2):
    • Most packages use testify (require for fatal, assert for non-fatal)
    • cmd/oastools/commands/ uses manual t.Error/t.Fatalf — follow that pattern there
  • Table-driven tests: tests := []struct{...} with t.Run
  • Descriptive names: Test case names describe the scenario
  • Edge cases: nil inputs, empty slices, zero values, error paths
  • OAS-specific: Test across OAS versions (2.0, 3.0, 3.1) where relevant

Read the full file on GitHub · 159 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 159 lines · 33 tokens per session scan A 92d2107269a0

Subscribe to this mod's changes

test-writer is an agent published in the GitHub repository erraggy/oastools (5 stars, last pushed 4d ago), licensed MIT. It adds 33 tokens to every session and 1,066 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.