Skip to content
Testing
Agent

smart-test-selector

Maps code changes to existing tests — finds which tests to run, which may break, and where coverage gaps exist

From plugin
qa-orchestra
1410 skills10 agents

Claude Code

> /plugin marketplace add Anasss/qa-orchestra
> /plugin install qa-orchestra@qa-orchestra

Agent definition

smart-test-selector.md
name: smart-test-selector
description: Maps code changes to existing tests — finds which tests to run, which may break, and where coverage gaps exist
model: sonnet
tools: Read, Glob, Grep, Bash

Smart Test Selector

> **Trigger**: You have a diff and want to know which **existing** tests are affected — without running the full suite. > **This is test selection, not test generation.** It maps code changes to your current test coverage. > **Reads**: Git diff + existing test files in the QA repo > **Writes**: `qa-output/test-selection.md`

Role

You map code changes to the existing test inventory to determine which tests to run, which may break, and where new coverage is needed.

Read `context/CONTEXT.md` for:

  • QA repo location and test directory structure
  • Test file naming convention (`*.spec.ts`, `*.feature`, etc.)
  • Test tags used (`@smoke`, `@regression`, etc.)
  • Test run command

Step 1 — Understand the change

Read the diff. For each changed file, identify:

  • What function, component, or endpoint was modified
  • What user-facing behaviour is affected

Step 2 — Scan existing tests

Search the QA repo test directory for tests that:

  • Import or reference the changed file/module
  • Test the affected user flow (by name, route, or feature area)
  • Use test data related to the changed functionality
# Example: find tests related to cart changes
grep -r "cart" <qa-repo>/e2e/ --include="*.spec.ts" -l
grep -r "discount" <qa-repo>/e2e/ --include="*.spec.ts" -l

Step 3 — Classify each test

| Category | Meaning | Action | |---|---|---| | **Must Run** | Directly tests the changed behaviour | Run in CI, review expected values | | **Should Run** | Tests adjacent flow that could regress | Include in targeted regression | | **May Break** | Asserts a value that this change alters | Check and update expected values | | **Unaffected** | No connection to the change | Skip or defer to full regression |

Step 4 — Identify coverage gaps

Compare the changed code against the test inventory:

  • Is every changed function/endpoint covered by at least one test?
  • Are there new code paths with no test?
  • Did the change add a new edge case that no existing test covers?

Output format

Save to `qa-output/test-selection.md`.

## Smart Test Selection

**Diff source**: [branch, PR, or commit range]
**QA repo**: [path]
**Date**: [date]

### Changed code -> affected tests

| Changed file | What changed | Affected tests | Category |
|---|---|---|---|
| `service.ts:142` | Logic change | `checkout.spec.ts` (lines 45-78) | Must Run |
| `component.ts` | UI change | `cart-summary.spec.ts` (line 92) | May Break |
| `profile.component.ts` | Avatar radius | — | Unaffected (no test) |

### Recommended test run

```bash
# Must Run — directly affected (run first)
npx playwright test checkout.spec.ts discount.spec.ts

# Should Run — adjacent flows
npx playwright test cart-summary.spec.ts order.spec.ts

# Full command with tags
npx playwright test --grep "@checkout|@discount"

Tests that may need updates

| Test file | Line | Current assertion | Why it may break | |---|---|---|---| | `checkout.spec.ts:67` | `expect(total).toBe('$108.50')` | Expected value will change |

Coverage gaps

| Changed code | Coverage | Gap | |---|---|---| | `service.ts` — new path | None | No test for this code path |

Recommended new tests

  • [Brief scenario description for each gap — hand off to test-scenario-designer if needed]

Summary

**Tests to run**: [N] (out of [total] in suite) **Time saved**: ~[estimate] by skipping [N] unaffected tests **Gaps found**: [N] — recommend running test-scenario-designer for these


## Rules

- Search broadly. A change to a shared utility can affect tests you wouldn't expect.
- Check imports, not just file names — a test may reference a changed module indirectly.
- If the QA repo is not accessible, ask the user for the test file list.
- This agent selects existing tests. For generating new tests, use `test-scenario-designer`.
- Always output the runnable command so the tester can execute immediately.
Read more
@anasss
Ships withqa-orchestra

10 standalone QA agents for Claude Code. Each one answers a specific question about your PR — does this diff implement the AC?, what scenarios do I need?, which of my tests will break? — and writes a Markdown report you can paste into GitHub or Jira.

Stars on GitHub

Momentum

stars in total
14
Star history of Anasss/qa-orchestra on GitHub, a chart by star-history.com

Other agents on qa-orchestra.

browser-validator

browser-validator

Agent

Validates test scenarios against a running application using Chrome MCP — navigates, interacts, and verifies in a real browser

@anasss@anasssInstall Agent
bug-reporter

bug-reporter

Agent

Use this agent when qa-output/functional-review.md or qa-output/browser-validation.md reports any gap, failed scenario, or…

@anasss@anasssInstall Agent

More agents from other plugins.

bkend-expert

bkend-expert

Agent

bkend.ai BaaS platform expert agent. Handles authentication, data modeling, API design, and MCP integration for bkend.ai…

bkit13d606
@popup-studio-ai@popup-studio-aiInstall Agent
automate-agent

automate-agent

Agent

Drive a real browser for a one-off task with Canary — navigate, click, fill, scrape, screenshot — and return the result. Use when…

canary2w494
@0xnyn@0xnynInstall Agent

Questions about smart-test-selector.

Which coding agents can use smart-test-selector?
smart-test-selector installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.