# Impact analysis (`shrk impact`) `shrk impact` answers "what does changing this break?" using SharkCraft's import graph, area map, boundary rules, ownership data, and policy engine. ## Inputs ``` shrk impact # positional: file path or '@scope/x' specifier shrk impact --file shrk impact --specifier shrk impact --since # files changed since git ref shrk impact --staged # staged changes only shrk impact --files a,b,c shrk impact --plan # changes from a saved plan shrk impact --bundle # affected files + plan targets ``` Optional flags: - `--max-depth N` — cap transitive closure depth (default 5). - `--limit N` — cap each list (default 200; over-the-limit lists are reported in `truncations`). - `--json` — emit the full `IImpactAnalysis` payload (schema `sharkcraft.impact-analysis/v2`). ## What the report contains - `inputKind` — which flag combination produced the file list. - `normalizedTargets` — files / paths the report is about. - `directDependents` — files that import a target directly. - `transitiveDependents` — reachable via repeated importer edges. - `dependencyPathExamples` — short, capped example chains. - `affectedAreas` / `affectedPackages` / `affectedPathConventions` — high-level location summaries. - `potentialBoundaryRisks` — boundary rules that may fire. - `affectedPolicies` — policy ids likely relevant. - `affectedOwnership` — owners / required reviewers per file (when `ownership.ts` or CODEOWNERS data is available). - `affectedTemplates` / `affectedPipelines` / `affectedPresets` / `affectedConstructs` — registry entries that reference touched paths. - `likelyTests` — co-located or conventional test files. - `suggestedTestCommands` / `suggestedValidationCommands` / `suggestedReviewCommands`. - `risk` (`low|medium|high|critical`) + `riskReasons`. - `truncations` — lists that exceeded `--limit`. - `diagnostics` — warnings emitted during analysis. ## Risk classification A simple weighted score combining direct/transitive dependent counts, public-API touches, boundary rule density, package count, ownership review status, missing tests, core touches, policy surface touches, and area span. Returns one of `low | medium | high | critical` plus a list of `riskReasons` for transparency. ## MCP `get_impact_analysis` — same payload, read-only. ## Examples ```bash shrk impact src/services/user.service.ts shrk impact --specifier "@shrkcrft/inspector" shrk impact --since main --max-depth 3 shrk impact --bundle 2026-05-13T00-57-50-380Z-generate-a-user-profile-service ``` ## Output formats (R12) ```bash shrk impact --format text|markdown|html|json shrk impact --format html --output impact.html shrk impact --tree # default: include ASCII tree shrk impact --no-tree # skip the tree ``` Self-contained HTML uses inline CSS, no JavaScript, dark/light aware. Risk badge colors: green (low), yellow (medium/high), red (critical). Markdown / text render the same data, including the dependency tree as a plain-text drawing. To render a previously-saved report instead of running impact again: ```bash shrk impact --format json > /tmp/impact.json shrk report impact /tmp/impact.json --format html --output /tmp/impact.html ``` The static report site embeds these reports via `shrk report site --impact ` or `--impact-dir `. ## Graph export (R13) ```bash shrk impact --graph-format mermaid|dot shrk impact --graph-format mermaid --graph-output impact.mmd shrk impact graph --format mermaid|dot shrk report impact --format html --include-graph ``` Mermaid renders a `flowchart LR` with risk-colored node classes; DOT renders a `digraph` ready for `dot -Tsvg`. Truncated transitive dependents appear as a dashed `… N more dependents omitted` node so the report still tells the truth. `--include-graph` on `shrk report impact` embeds the Mermaid/DOT source into the rendered HTML/Markdown without requiring a browser to render it. ## Graph in the report site (R14) ```bash shrk report site --impact /tmp/impact.json --with-impact-graphs --output /tmp/site ``` When `--with-impact-graphs` is set, the report site: - writes a `impact-.mmd` and `impact-.dot` next to each `impact-.html`; - inlines both sources into the impact detail page (collapsed by default) as plain text in `
` blocks — no `