Smarter Week

How to automate it

How to automate “write unit and integration tests”

Here are 2 ways to spend less time on this, best first. Each comes with steps you can follow today and, for AI fixes, a prompt to copy.

45 min
typically, a few times a week
60%
of the time can be automated
Easy
to set up

Fix 1 of 2

AIBest fix

Have AI write the tests, then you check what they actually assert

Coding agents write good first-pass unit and integration tests in your existing style. Your job shifts to checking the cases and assertions are meaningful.

Typically saves about 45% of the time10 min to set up
  1. 1Point the agent at the file or function and an existing test file to copy the style from.
  2. 2Use the prompt below; ask for edge cases explicitly.
  3. 3Run the tests and make sure at least one fails if you break the code on purpose.
  4. 4Delete tests that only check mocks or repeat the implementation.
Prompt to copy
Write tests for [FILE OR FUNCTION] using [TEST FRAMEWORK], following the style of [EXISTING TEST FILE]. Cover the main behavior, edge cases ([EMPTY INPUT, LIMITS, ERRORS]), and any bug fixed recently in [AREA]. Prefer real objects over mocks where it is cheap. Run the tests, fix failures in the tests (not in the code), and list any behavior that looks like a bug instead of changing it.

Tools: Claude Code, OpenAI Codex, Cursor, GitHub Copilot agent mode or Devin Desktop (ex-Windsurf)

Fix 2 of 2

AI

Hand well-scoped tasks to a coding agent and review its pull request

Coding agents like Claude Code, OpenAI Codex, Cursor's agent and GitHub Copilot's coding agent can read the repo, make multi-file changes and run the tests. They do best on clear, bounded tasks you can review quickly.

Typically saves about 30% of the time30 min to set up
  1. 1Check which coding agent your company approves and that it has access to the repo.
  2. 2Add a short instructions file to the repo (CLAUDE.md, AGENTS.md or .cursor/rules) with how to build, test and the conventions to follow.
  3. 3Give it a ticket-sized task with acceptance criteria, using the prompt below.
  4. 4Let it run the tests; read the diff as carefully as a colleague's PR.
  5. 5Start with tests, refactors, small features and config changes before larger work.
Prompt to copy
Task: [WHAT TO BUILD OR CHANGE]. Context: [RELEVANT FILES OR MODULES]. Acceptance criteria: [LIST]. Constraints: follow the existing patterns in [EXAMPLE FILE], do not add new dependencies, do not change public APIs unless needed. First read the relevant code and give me a short plan. After I approve, make the change, add or update tests, run the test suite and linter, and summarize what you changed and anything you were unsure about.

Tools: Claude Code, OpenAI Codex, Cursor, GitHub Copilot agent mode or Devin Desktop (ex-Windsurf)

Quick wins

Have you tried…

Have you had AI write tests for code you just wrote?
A coding assistant can write unit and integration tests in your existing style. You check that the assertions really test the behavior.

Who does this task

Roles in our library that list this as one of their common tasks. Each guide covers the rest of that role’s week.

HourLeak · the 8-minute work audit

How many hours does this cost you?

The free 8-minute check works out where your week goes and gives you your top fixes. The team scan does the same for everyone and adds it up, so you know which leaks to fix first.

Answers are anonymous. Leaders only see team totals.

Other common tasks for Software engineers