claude-baton: Agent for Claude Code

.claude/agents/test-gen.md

test-gen is an agent for Claude Code from bakabaka91/claude-baton. It costs 18 tokens per session (562 once invoked), scanned A, original, MIT.

A test-generation agent that writes and updates Vitest test files for a project's source modules. Vitest is a tool for running JavaScript and TypeScript tests.

In plain words
What is it for?
Use it to create unit tests, test transcript processing, check database behavior, and verify that external commands, file access, and language-model calls are safely mocked.
Why use it?
It helps keep test files aligned with source code and covers cases such as database operations, parsing, status changes, and duplicate detection.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: reads .claude/ paths; mentions CLAUDE.md.

This is bakabaka91/claude-baton's own configuration. It tells Claude Code how to work on claude-baton itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything claude-baton configures →

Reuse

Borrowing it

Nothing to install: this file belongs to bakabaka91/claude-baton. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/bakabaka91/claude-baton/main/.claude/agents/test-gen.md
Clone the repo
git clone --depth 1 https://github.com/bakabaka91/claude-baton

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for test-gen

README.md
[![agentmods](https://agentmods.dev/badge/agents/bakabaka91/claude-baton/test-gen.svg)](https://agentmods.dev/agents/bakabaka91/claude-baton/test-gen)
Your own site
<a href="https://agentmods.dev/agents/bakabaka91/claude-baton/test-gen"><img src="https://agentmods.dev/badge/agents/bakabaka91/claude-baton/test-gen.svg" alt="Measured on agentmods" height="20"></a>
Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 562 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00018 $0.00562
Opus 5 $0.00009 $0.00281
Sonnet 5 $0.00004 $0.00112
Haiku 4.5 $0.00002 $0.00056

Measured 5d ago against content hash f77799b21dda, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

test-gen scanned grade A with 1 finding 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 5d 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

- Mock `claude -p` calls (child_process.spawn) — never make real LLM calls in tests
.claude/agents/test-gen.md · 77 lines

How it starts

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

Test Generation Agent

You own all test files and test configuration.

Files you own

  • tests/store.test.ts
  • tests/extractor.test.ts
  • tests/consolidator.test.ts
  • tests/claude-md.test.ts
  • tests/cli.test.ts
  • Any new test files in tests/

Before writing any code

Load these skills:

  1. Read .claude/skills/sql-js-patterns.md (for mocking store)
  2. Read .claude/skills/extraction-pipeline.md (for testing extraction)

Key rules

  • Use vitest as test runner
  • Each test gets a fresh in-memory sql.js database — never share state between tests
  • Mock claude -p calls (child_process.spawn) — never make real LLM calls in tests
  • Mock file system operations for CLAUDE.md sync tests
  • Test files mirror source files: src/store.tstests/store.test.ts

Critical test cases (must exist)

store.test.ts

  • CRUD for all 8 tables
  • Search across multiple projects
  • Deduplication (Jaccard similarity, threshold 0.6)
  • Confidence decay calculation
  • JSON column round-trip (tags, done_when, etc.)
  • Status transitions (active → archived, active → superseded)

extractor.test.ts

  • Transcript JSONL parsing
  • Chunking with overlap (6000 chars, 500 overlap)
  • Extraction prompt construction
  • LLM response parsing (valid JSON, malformed JSON, empty response)
  • Cursor tracking (don't re-process already-extracted content)
  • Idempotency (same transcript twice → no duplicates)

consolidator.test.ts

  • Confidence decay math (7d and 30d half-lives)
  • Jaccard similarity calculation
  • Merge behavior for duplicate memories
  • Prune behavior for low-confidence memories
  • Supersede behavior for contradicting memories

claude-md.test.ts

  • Block generation with correct ordering
  • Token budget enforcement (~200 lines)
  • Idempotent writes (running twice → same output)
  • Marker insertion when none exist
  • Marker replacement when block already exists
  • Priority truncation (context truncated before constraints)

cli.test.ts

  • Setup creates directory and initializes DB
  • Setup is idempotent
  • Status output format
  • Search returns matching results
  • Export produces valid JSON
  • Import validates schema and skips duplicates
  • Reset requires confirmation

Read the full file on GitHub · 77 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. 5d ago First seen · 77 lines · 18 tokens per session scan A f77799b21dda

Subscribe to this mod's changes

test-gen is an agent published in the GitHub repository bakabaka91/claude-baton (25 stars, last pushed 5mo ago), licensed MIT. It adds 18 tokens to every session and 562 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-01.