ClaudeLoops
/
Test synthesizer for changed files
All loops
Claude CodeMedium 18 min· claude-opus-4

Test synthesizer for changed files

Claude Code writes Vitest + Playwright tests for every file touched in a PR.

NOT DEPLOYEDNOT DEPLOYED
0190ms
Trigger
cron(0 7 * * *) fired · every day · 07:00
021270ms
Agent
claude-opus-4 · in 1170 tok · out 588 tok
03300ms
Tools
github-mcp/github:pulls.create → 200 OK · 230ms
0480ms
Verify
schema check · zod v3 passed
05170ms
Output
changelog updated · v1.4.2
0650ms
Notify
audit log written · runbook link attached
SUCCESS
0%
0 runs
P50
0ms
median
P95
0ms
tail
AVG COST
per run
LAST OK
never
LAST FAIL
never
none
Latency · last 30 runs0 samples
no runs yet
Latest output · what your users see
Openacme/infra #2190
feat: add /health endpoint
11 files+270-120
  • Ran full test suite → 218 passed, 0 failed (12.3s)
  • Coverage delta: +0.4% on `src/lib/*`
  • No breaking changes detected in public API
// press Test to run once · Watch live to keep streaming · Deploy to make it real
The problem

Coverage gaps slip in because writing tests for legacy code feels punishing.

The outcome

Every PR adds tests for the files it changed. Coverage trends up by accident.

Ingredients & skills

Secrets
  • ANTHROPIC_API_KEY
  • GITHUB_TOKEN
Providers
  • Anthropic
  • GitHub
MCP servers
  • github-mcp
  • filesystem-mcp
#claude code#testing#vitest#playwright

How it works

On `pull_request`, Claude Code reads the diff, the file under test, and existing tests in the repo, then synthesizes Vitest unit tests and Playwright E2E tests where appropriate.

Step 1

1 — agents.md for the test synth

Tell the agent the project's test conventions explicitly.

.claude/agents/test-synth.md
# Test synth

For each changed source file:
- Generate Vitest unit tests in `*.test.ts` next to the source.
- If file is in `src/routes/` and not an API route, also generate Playwright tests in `e2e/`.
- Follow the existing test style in this repo; do not introduce new helpers.
- Aim for branch coverage on new lines only.
Step 2

2 — Action

Run on PR, write changes as a follow-up commit.

.github/workflows/test-synth.yml
name: Test synth
on: pull_request
jobs:
  synth:
    runs-on: ubuntu-latest
    permissions: { contents: write, pull-requests: write }
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0, ref: ${{ github.head_ref }} }
      - uses: claudeloops/action@v1
        with:
          locker: test-synth
          agent: .claude/agents/test-synth.md
          model: claude-opus-4
          commit: 'test: synth coverage'
          commit-author: 'claudeloops[bot]'
One-line deploy

The button above runs the same command with your saved config. This is the raw CLI form.

bash
gh locker apply test-synth

Related loops