5 Claude Prompts for Testing Strategies (Copy & Paste)

You will finish with a test plan you can defend in review: what to test first, which layer each test belongs in, and which gaps you are choosing on purpose. These five Claude prompts walk from feature description to a plan with names on it, and they assume you would rather have four useful tests than forty that all check the same path.

What to know before you paste

  • Paste the feature description, not just the ticket title. Claude needs to know what the code is supposed to do before it can rank what breaks.
  • Name your stack and test runner. Suggestions that ignore your tooling are not worth the read.
  • Give it the code you are unsure about. Vague inputs produce generic checklists that could apply to any repository.

The prompts

1. Order by what hurts most

Here is the feature: [feature]. List what to test in order of what would hurt most if it broke, and say why the first item is first.

What it does: Ranks tests by consequence instead of by convenience.

How to use: replace [feature]; if the top item is the easiest test, the ranking is wrong.

2. Layer map for this codebase

Given this repository structure: [structure], say where the tests should live and what kind of test each layer needs. Describe layers, not ratios.

What it does: Puts the right test at the right level before anyone writes one.

How to use: replace [structure]; check the mapping against the folders that already exist.

3. Harvest the edge cases

List the edge cases for this code: [code]. Group them by input shape, state and timing.

What it does: Turns one function into a checklist of the ways it can go wrong.

How to use: replace [code]; keep the groups, they are the test names you were about to invent.

4. Bug report into a failing test

Here is a bug report: [bug]. Write the test that would have caught it, then name the smallest code change that makes the test pass.

What it does: Fixes the process, not just the report.

How to use: replace [bug]; commit the failing test first so the fix has something to prove.

5. Trim a slow suite

Here are my tests with their runtimes: [test list]. Tell me which to merge, which to restructure with mocks, and which to delete.

What it does: Cuts the suite that everyone skips because it takes too long.

How to use: replace [test list]; delete only tests covered elsewhere, never the only test of a risky path.

FAQ

How much coverage is enough?

Enough that the risky paths are exercised, which coverage percentage does not tell you. A suite can hit every line and still never test what happens when the network drops. Read coverage as a map of what was never executed, not as a score.

Should I test private methods?

Test through the public surface and you get freedom to refactor. When a private method is complex enough to need its own tests, that is usually a hint it wants to be its own module with a public function.

Unit or integration first?

Integration first when the risk lives in the wiring: serialization, database constraints, auth. Unit first when the risk lives in the logic. Most real features have both, so the question is which one you write today.

How do I test code that talks to a database?

Use a real database in a container or a throwaway schema for the tests that depend on constraints and queries, and fakes for the ones that only need a repository. Mocks that emulate SQL tend to test the mock.

When is a flaky test worth keeping?

When the flakiness is telling you about a real race or an unstable dependency. Fix or quarantine it with an owner and a date. A flaky test with no owner trains the team to ignore red builds.

Keep going

Want more like this? Browse the full free library at GuPrompt.

Leave a Comment