Write missing unit tests for legacy code
DifficultyMedium
SetupSome code
Best forDeveloper
ToolsClaude Code, OpenAI Codex CLI, Cursor, Aider
The problem
Untested legacy code makes every change risky.
How the agent works
The agent reads a module, writes characterization tests that capture current behavior, runs them, and iterates until they pass, then reports coverage gains.
Setup steps
- Pick one module at a time
- Ask for tests of current behavior, not desired behavior
- Run tests in the loop
- Review for meaningless assertions
- Commit in small PRs
Tools that can do this
- Claude Code
- OpenAI Codex CLI
- Cursor
- Aider
Not ranked and not sponsored. Check each vendor's current features and pricing.
Human in the loop
Developer reviews tests.
Risks and guardrails
Agents may write tests that assert bugs; label them as characterization tests.
ROI notes
Makes refactors safer.
Also useful: investigate failures in production logs.
Related playbooks
Get a first-pass review on every pull request
Reviewers are a bottleneck and miss routine issues.
Hand well-scoped issues to a coding agent
Small bugs and chores sit in the backlog because nobody has time.
Upgrade dependencies and fix breaking changes
Framework and library upgrades are postponed because the migration work is tedious.