Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

2.5 KB
Raw Blame

frontmatter: | description: Print the tests whose coverage intersects a change's changed lines — for a commit, base..head range, or staged diff. allowed-tools: Bash(repowise impacted-tests:*), Read


Repowise Impacted Tests

Map a change to the tests that actually exercise its changed lines, using the per-test coverage map from repowise coverage add. No LLM, no network — an index lookup. Useful as a pre-merge / CI gate ("run these 40, not all 4,000").

Steps

  1. If .repowise/ doesn't exist: "This repo isn't indexed yet. Run {{cmd:init}} first." Stop.
  2. Resolve the target from $ARGUMENTS, run repowise impacted-tests, and present the test ids. Be honest about gaps (see Notes).

Choosing the revspec

  • No args → repowise impacted-tests (staged changes; same as --staged)
  • A commit SHA → repowise impacted-tests <sha>
  • A range / PR / branch → repowise impacted-tests <base>..<head> (e.g. repowise impacted-tests main..HEAD)
  • "staged" → repowise impacted-tests --staged

Useful flags:

  • --format list — test ids one per line (pipe to xargs pytest)
  • --format json — full report
  • --format args — one line of runner arguments, or :all when the whole suite must run; reasons go to stderr. --runner pytest|go|jest|files|auto picks the argument shape
  • --path <dir> — point at a different repo
repowise impacted-tests main..HEAD --format list | xargs pytest

Notes

  • Line-precise answers need a per-test map from repowise coverage add on a report with contexts. If none is ingested, the command still prompts to run {{cmd:coverage}} / repowise coverage add. It does not invent an empty "no tests needed" result.
  • A changed file with no coverage rows gets candidates instead, in a table headed "NOT coverage-backed", each carrying a via marker: changed-test (the changed file is itself a test), call-graph or import-graph (a test file that reaches it, no ingest needed), or filename-pattern (a name-shaped guess). Report them as candidates. Only via: coverage proves a test executed the change.
  • A file none of those can speak to is "unknown, run the full suite".
  • In CI, --format args prints :all whenever the selection is not certain (lockfiles, build or CI config, a changed file no test reaches, an index built at neither end of the change). Run everything when you see it.
  • For a whole-change repo-relative review priority, use {{cmd:risk}}. For per-file blast radius / tests_to_run, use the get_risk MCP tool.