From st4ck
Phase 5 §5.2 — agent-driven test impact analysis. Reads the local git diff, calls get_tests_affected_by_diff, creates test_design_change dev_tasks per affected component. Optionally invokes the propose subworkflow to attach proposed component diffs. Triggered explicitly via `/st4ck:impact` or auto on PostToolUse(Edit/Write) hits inside a cited file.
How this skill is triggered — by the user, by Claude, or both
Slash command
/st4ck:impactThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You analyze a local code diff and surface every QA test whose components cite the changed lines. For each affected component, you create a `test_design_change` dev_task assigned to QA, with optional `proposed_diff` payload.
You analyze a local code diff and surface every QA test whose components cite the changed lines. For each affected component, you create a test_design_change dev_task assigned to QA, with optional proposed_diff payload.
get_tests_affected_by_diff MCP tool with the changed files + line ranges.test_design_change dev_task with the §5.2-ready payload.--propose or by the user explicitly — invoke the propose.md subworkflow per affected component to generate a proposed component diff.| Trigger | Behavior |
|---|---|
User runs /st4ck:impact explicitly | Full skill; ask user whether to invoke propose subworkflow |
PostToolUse hook on Edit/Write of a file matching any cited path (opt-in via hooks/post-edit-scan.sh) | Auto-trigger the skill silently; surface dev_tasks to user only if any are queued |
| User asks "what tests does my diff break?" | Activate the skill; usually skip propose (read-only inspection) |
Confirm a local repo exists. git rev-parse --is-inside-work-tree must return true. If not, error out with: "This skill needs a local git checkout. Run from inside the project repo."
Identify the diff scope. Default: git diff HEAD^ HEAD. If the user passed a base branch (e.g. --base develop): git diff develop...HEAD. If --staged: git diff --cached.
Capture diff metadata:
git rev-parse --show-toplevelgit rev-parse --abbrev-ref HEADgit diff --name-only <range> for the file pathsgit diff -U0 <range> -- <path> hunk headers (@@ -OLD,L +NEW,L @@)[
{
"path": "src/pages/BudgetCreationDialog.tsx",
"changed_line_ranges": [{"start": 142, "end": 148}, {"start": 220, "end": 220}]
}
]
get_tests_affected_by_diffget_tests_affected_by_diff({changed_files})
Returns:
{
"affected_tests": [{"test_id", "test_name", "citations": [...]}],
"affected_components": [{"component_id"}],
"suggested_runs": ["npx st4ck@latest run <test_id> <base_url>"]
}
If affected_components.length === 0, exit silently — nothing to do. Tell the user "No QA tests cite the changed lines."
For each unique component_id in the response:
create_dev_task({
title: "Test design change: <component_name>",
description: <brief 2-line summary>,
source_type: 'test_design_change',
source_id: <component_id>,
assigned_team: 'qa',
priority: 'medium',
body: {
repo_root,
branch,
before_sha,
after_sha,
affected_citations: [...], // per §5.2 schema
suggested_reviewer_actions: [
"read <changed file> at HEAD — confirm component's target UI is gone",
"if flow retired: propose archiving test",
"if flow moved: re-record against new location"
]
}
})
Per plan §5.6, create_dev_task with source_type='test_design_change' server-side fires a test_design_change_queued event on test_coverage_events — the QA Kanban + any session running an authoring skill picks it up automatically. You don't need to broadcast.
propose.md subworkflowIf the user passed --propose (or the explicit slash command activated with that flag), invoke the propose subworkflow per affected component. See propose.md in this skill folder for the full procedure. The subworkflow reads before+after file contents, generates a proposed component update, then patches the dev_task via update_dev_task with body.proposed_diff set + confidence: low | medium | high.
Default: do NOT auto-invoke propose. It's expensive (LLM-driven re-author per component) — only run when explicitly requested.
changed_line_ranges; always provide them.test_design_change_queued event coalesces server-side; you should also rate-limit your dev_task creation if running in a hook.suggested_runs for the user; they decide whether to run.After the skill runs, surface to the user:
Impact analysis (branch: <branch>, range: <before_sha>..<after_sha>):
- <N> affected components
- <M> affected tests
- <K> dev_tasks queued (assigned_team='qa')
- Suggested runs:
npx st4ck@latest run <test_id_1> <base_url>
npx st4ck@latest run <test_id_2> <base_url>
...
If propose was invoked, append:
- Proposed diffs attached to <P> of <K> dev_tasks (confidence: low/medium/high distribution)
test_components.selector_notes.source_citations — the MCP tool will return zero affected tests; exit silently.git diff is in an inconsistent state. Detect via git rev-parse --git-dir checking for MERGE_HEAD / REBASE_HEAD and skip with a note.git diff (working tree vs HEAD) or skip.npx claudepluginhub edo-ceder/st4ck-plugin --plugin st4ckProvides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.