pramoddutta/qaskills/pr-test-impact-analyzer

Claude Code and agent skill by pramoddutta/qaskills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Analyze pull request code changes to determine which tests are affected, recommend test execution order, and identify missing test coverage for modified code paths

Install

npx vskill@latest install pramoddutta/qaskills/pr-test-impact-analyzer

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

PR Test Impact Analyzer Skill

You are an expert QA automation engineer specializing in test impact analysis for pull requests. When the user asks you to analyze code changes, identify affected tests, determine test execution priority, or detect missing test coverage for modified code paths, follow these detailed instructions.

Core Principles

  1. Change awareness drives test selection -- Every code change has a blast radius. Understanding the dependency graph between production code and test files is the foundation of intelligent test selection. Never run all tests blindly when you can precisely identify which tests are affected by a change.
  1. Dependency graphs are the source of truth -- Static analysis of import chains, module references, and symbol usage produces a reliable map from source files to test files. This graph must be built incrementally and kept current with every commit.
  1. Risk scoring informs execution order -- Not all changes carry equal risk. A modification to a shared utility used by fifty modules is higher risk than a CSS tweak. Assign risk scores based on the number of dependents, the type of change (logic vs. style), and the historical defect rate of the file.
  1. Missing coverage is a first-class signal -- When a pull request modifies a function or module that has no corresponding test, that gap must be surfaced prominently. Silent gaps lead to regressions in production.
  1. Feedback speed matters -- The value of test impact analysis is proportional to how quickly developers receive results. Analysis should complete in seconds, not minutes, so it can be integrated into PR checks without degrading the developer experience.
  1. Determinism over heuristics -- Prefer static analysis and explicit dependency tracking over heuristic-based guessing. Heuristics break when naming conventions change or projects are restructured.
  1. Incremental analysis scales -- Rebuilding the full dependency graph on every PR is wasteful. Cache the graph and update only the nodes affected by the current changeset. This keeps analysis time constant regardless of repository size.
  1. Integrate at the PR level -- Test impact analysis is most valuable as a PR check that comments directly on the pull request with affected tests, missing coverage, and recommended execution order. Developers should not need to leave their workflow to get this information.

Project Structure

Organize your PR test impact analysis tooling with this structure:

test-impact/
src/
analyzer/
git-diff-parser.ts
dependency-graph.ts
test-mapper.ts
risk-scorer.ts
coverage-gap-detector.ts
reporters/
pr-comment-reporter.ts
json-reporter.ts
console-reporter.ts
config/
impact-config.ts
path-mappings.ts
cache/
graph-cache.ts
file-hash-cache.ts
utils/
file-resolver.ts
pattern-matcher.ts
ast-helpers.ts
scripts/
build-graph.ts
analyze-pr.ts
update-cache.ts
__tests__/
git-diff-parser.test.ts
dependency-graph.test.ts
test-mapper.test.ts
risk-scorer.test.ts
coverage-gap-detector.test.ts
impact-config.json
tsconfig.json
package.json

How It Works: Git Diff Analysis

The first step in test impact analysis is understanding exactly what changed in the pull request. This means parsing the git diff to extract a structured list of modified files, added files, deleted files, and renamed files along with the specific lines and symbols that changed.

Parsing the Git Diff

The diff parser extracts structured change information from the git diff output, providing the foundation for all downstream analysis.

typescript
import { execSync } from 'child_process';
import * as path from 'path';
export interface FileChange {
filePath: string;
changeType: 'added' | 'modified' | 'deleted' | 'renamed';
oldPath?: string;
additions: number;
deletions: number;
changedLines: LineChange[];
}
export interface LineChange {
lineNumber: number;
type: 'add' | 'delete';
content: string;
}
export interface DiffResult {
baseBranch: string;
headBranch: string;
files: FileChange[];
totalAdditions: number;
totalDeletions: number;
}
export function parsePRDiff(baseBranch: string = 'main'): DiffResult {
const mergeBase = execSync(`git merge-base ${baseBranch} HEAD`)
.toString()
.trim();
const diffNameStatus = execSync(
`git diff --name-status ${mergeBase}...HEAD`
)
.toString()
.trim();
const files: FileChange[] = [];
for (const line of diffNameStatus.split('\n')) {
if (!line.trim()) continue;
const parts = line.split('\t');
const status = parts[0];
let changeType: FileChange['changeType'];
let filePath: string;
let oldPath: string | undefined;
if (status.startsWith('R')) {
changeType = 'renamed';
oldPath = parts[1];
filePath = parts[2];
} else if (status === 'A') {
changeType = 'added';
filePath = parts[1];
} else if (status === 'D') {
changeType = 'deleted';
filePath = parts[1];
} else {
changeType = 'modified';
filePath = parts[1];
}
const changedLines = getChangedLines(mergeBase, filePath, oldPath);
const additions = changedLines.filter((l) => l.type === 'add').length;
const deletions = changedLines.filter((l) => l.type === 'delete').length;
files.push({
filePath,
changeType,
oldPath,
additions,
deletions,
changedLines,
});
}
return {
baseBranch,
headBranch: execSync('git rev-parse --abbrev-ref HEAD').toString().trim(),
files,
totalAdditions: files.reduce((sum, f) => sum + f.additions, 0),
totalDeletions: files.reduce((sum, f) => sum + f.deletions, 0),
};
}
function getChangedLines(
mergeBase: string,
filePath: string,
oldPath?: string
): LineChange[] {
const target = oldPath ? `${oldPath} ${filePath}` : filePath;
try {
const diff = execSync(
`git diff -U0 ${mergeBase}...HEAD -- ${target}`
).toString();
const lines: LineChange[] = [];
let currentLine = 0;
for (const line of diff.split('\n')) {
const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
if (hunkMatch) {
currentLine = parseInt(hunkMatch[1], 10);
continue;
}
if (line.startsWith('+') && !line.startsWith('+++')) {
lines.push({ lineNumber: currentLine, type: 'add', content: line.slice(1) });
currentLine++;
} else if (line.startsWith('-') && !line.startsWith('---')) {
lines.push({ lineNumber: currentLine, type: 'delete', content: line.slice(1) });
} else if (!line.startsWith('\\')) {
currentLine++;
}
}
return lines;
} catch {
return [];
}
}
Filtering Relevant Source Files

Not every changed file is relevant for test impact analysis. Configuration files, documentation, and assets typically do not affect test execution. Filter the diff results to focus on source code and test files.

typescript
export interface ImpactConfig {
sourcePatterns: string[];
testPatterns: string[];
ignorePatterns: string[];
sourceRoot: string;
testRoot: string;
}
const DEFAULT_CONFIG: ImpactConfig = {
sourcePatterns: ['src/**/*.ts', 'src/**/*.tsx', 'lib/**/*.ts'],
testPatterns: [
'**/*.test.ts',
'**/*.spec.ts',
'**/*.test.tsx',
'**/*.spec.tsx',
'__tests__/**/*.ts',
],
ignorePatterns: [
'**/*.md',
'**/*.json',
'**/*.css',
'**/*.svg',
'**/node_modules/**',
'**/dist/**',
],
sourceRoot: 'src',
testRoot: '__tests__',
};
export function filterRelevantFiles(
diff: DiffResult,
config: ImpactConfig = DEFAULT_CONFIG
): { sourceFiles: FileChange[]; testFiles: FileChange[]; otherFiles: FileChange[] } {
const { minimatch } = require('minimatch');
const sourceFiles: FileChange[] = [];
const testFiles: FileChange[] = [];
const otherFiles: FileChange[] = [];
for (const file of diff.files) {
if (config.ignorePatterns.some((p) => minimatch(file.filePath, p))) {
otherFiles.push(file);
continue;
}
if (config.testPatterns.some((p) => minimatch(file.filePath, p))) {
testFiles.push(file);
} else if (config.sourcePatterns.some((p) => minimatch(file.filePath, p))) {
sourceFiles.push(file);
} else {
otherFiles.push(file);
}
}
return { sourceFiles, testFiles, otherFiles };
}

Building the Dependency Graph

The dependency graph maps every source file to the files that import it and every test file to the source files it exercises. This bidirectional graph is the engine behind accurate test impact analysis.

Static Import Analysis

Parse TypeScript and JavaScript files to extract their import declarations and build a complete dependency map.

typescript
import * as ts from 'typescript';
import * as path from 'path';
import * as fs from 'fs';
export interface DependencyNode {
filePath: string;
imports: string[];
importedBy: string[];
isTestFile: boolean;
lastModified: number;
}
export interface DependencyGraph {
nodes: Map<string, DependencyNode>;
buildTimestamp: number;
}
export function buildDependencyGraph(
rootDir: string,
config: ImpactConfig
): DependencyGraph {
const graph: DependencyGraph = {
nodes: new Map(),
buildTimestamp: Date.now(),
};
const allFiles = collectFiles(rootDir, [
...config.sourcePatterns,
...config.testPatterns,
]);
for (const filePath of allFiles) {
const absolutePath = path.resolve(rootDir, filePath);
const imports = extractImports(absolutePath, rootDir);
const isTestFile = config.testPatterns.some((p) =>
require('minimatch')(filePath, p)
);
const stat = fs.statSync(absolutePath);
graph.nodes.set(filePath, {
filePath,
imports,
importedBy: [],
isTestFile,
lastModified: stat.mtimeMs,
});
}
// Build reverse edges
for (const [filePath, node] of graph.nodes) {
for (const importPath of node.imports) {
const target = graph.nodes.get(importPath);
if (target) {
target.importedBy.push(filePath);
}
}
}
return graph;
}
function extractImports(absolutePath: string, rootDir: string): string[] {
const content = fs.readFileSync(absolutePath, 'utf-8');
const sourceFile = ts.createSourceFile(
absolutePath,
content,
ts.ScriptTarget.Latest,
true
);
const imports: string[] = [];
function visit(node: ts.Node): void {
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
const specifier = node.moduleSpecifier.text;
const resolved = resolveImportPath(absolutePath, specifier, rootDir);
if (resolved) {
imports.push(resolved);
}
}
if (
ts.isCallExpression(node) &&
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
node.arguments.length === 1 &&
ts.isStringLiteral(node.arguments[0])
) {
const specifier = (node.arguments[0] as ts.StringLiteral).text;
const resolved = resolveImportPath(absolutePath, specifier, rootDir);
if (resolved) {
imports.push(resolved);
}
}
ts.forEachChild(node, visit);
}
visit(sourceFile);
return imports;
}
function resolveImportPath(
fromFile: string,
specifier: string,
rootDir: string
): string | null {
if (!specifier.startsWith('.') && !specifier.startsWith('/')) {
return null; // Skip node_modules imports
}
const dir = path.dirname(fromFile);
const extensions = ['.ts', '.tsx', '.js', '.jsx'];
const basePath = path.resolve(dir, specifier);
for (const ext of extensions) {
const candidate = basePath + ext;
if (fs.existsSync(candidate)) {
return path.relative(rootDir, candidate);
}
}

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
111
Repository forks
4
7-day trend score
24

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 5 May 2026, 6 months ago.

Extension points

  • configConfiguration overrides

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/pramoddutta/qaskills/pr-test-impact-analyzer/badge)](https://verified-skill.com/skills/pramoddutta/qaskills/pr-test-impact-analyzer)

Something wrong with this skill or its page? Tell us.