Use an agent to backfill tests in a stale backend

Claude Code turned a little-documented Node backend into a set of 23 vitest tests after reading the repo guide and source tree.

Done with Claude Code· Intermediate· Nov 2026

What they did
A developer opened an old Node.js backend they had not worked in for a long time and added an AGENTS.md file at the project root. That file described the stack, layout rules, and coding style. They then asked Claude Code to focus on the main application logic and write unit tests with vitest. The agent started by reading AGENTS.md, then walked through src/, created test files piece by piece, and kept running the suite while correcting its own mistakes.
How it went
The job took about fifteen minutes end to end. Claude Code wrote 23 tests total: 19 were green right away, and the other 4 were fixed over two more passes. The developer guessed a manual, chat-driven approach would have needed around ninety minutes.
Tips
Even when the tests pass, review the diff yourself before committing. An agent can make weak assertions that hide a real defect instead of catching it.

Try it yourself with Claude Code

Open [project folder] and first read the repo instructions, including any AGENTS.md, plus the relevant source files. Then add vitest coverage for the main logic in [folders/modules], working in small steps and checking the suite as you go. If a test fails because of your own changes, repair the test code and rerun it. If you uncover a likely product bug, stop and describe it instead of altering application code. Before any irreversible step such as deleting files, replacing existing tests, or submitting changes, pause and ask for approval. When you are done, give me a brief summary of what you covered, the pass count, and any unresolved failures.

Fill in the [brackets]. Agents can make mistakes, so review anything before it is sent, paid or deleted.

Get 3 agent uses like this every morning

With the day's top AI news. Free, and one click to unsubscribe.