Code health: health, risk
repowise health scores every file from deterministic markers across three signals (defect risk, maintainability, performance); repowise risk scores the defect risk of a commit or diff range. Both are zero-LLM and run in seconds.
repowise health
Compute per-file code-health scores from deterministic markers (McCabe complexity, nesting, brain methods, LCOM4 cohesion, god classes, native clone detection, untested hotspots, coverage gradient, git-behavioural risk, and static performance risk), surfaced as three signals: defect risk, maintainability, and performance. Zero LLM calls, just pure Python over tree-sitter + git data.
repowise health [PATH] [OPTIONS]| Parameter | Type | Default | Description |
|---|---|---|---|
--file | string | — | Deep-dive a single file (relative path) |
--module | string | — | Restrict the report to files under this path prefix |
--refactoring-targets | boolean | false | Print top refactoring candidates ranked by impact / effort |
--generate-code | string | — | Generate an actual refactoring patch for one target (file.py::Symbol). The only health flag that calls an LLM; needs a configured provider. |
--trend | boolean | false | Print the last 10 snapshots + declining / predicted-decline alerts |
--badge | boolean | false | Print a ready-to-paste health badge (Markdown) for this repo's README |
--format | string | table | Output: table, json, md |
--repo | string | — | In workspace mode, target a specific repo |
--no-workspace | boolean | false | Force single-repo mode |
--verbose / -v | boolean | false | Show debug logs from the pipeline |
repowise health # KPIs + lowest-scoring files
repowise health --file src/api/server.py # one file in detail
repowise health --module src/api # restrict to a directory
repowise health --refactoring-targets # ranked structured plans (impact / effort)
repowise health --generate-code src/api/server.py::handler # LLM patch for one target
repowise health --trend # snapshot history + alerts
repowise health --format json | jq .kpis # machine-readableCoverage is ingested separately with repowise coverage add <report>, and
repowise health automatically folds in whatever coverage you have already
ingested, no flag needed. coverage add also builds a per-test test-to-code
map when the report carries contexts (a coverage.py .coverage, or coverage run --contexts=test).
repowise init and repowise update populate the health tables
automatically, no separate step needed. repowise status prints a
one-line summary:
Health: 7.4 (avg) · 6.2 (hotspots) · 2.1 (worst: payments/processor.ts)Coverage markers (untested_hotspot, coverage_gap,
coverage_gradient) only fire once you've ingested a report with
repowise coverage add. Per-file
marker overrides live in .repowise/health-rules.json.
--refactoring-targets emits structured, graph-aware fix plans. See
Refactoring intelligence.
repowise risk
Just-in-time change-risk scoring for a commit or diff range. Scores
the defect risk of a change from the same calibrated signals the
health layer uses. No LLM calls, and it works without repowise init
(pure git + learned constants). The revision defaults to HEAD; pass a
base..head range to score a whole branch or PR as one change.
The headline is repo-relative: the change's percentile and review
priority (Below typical / Typical / Elevated) within the repo's own
recent commits, sampled live. The raw 0 to 10 model score is still shown, but
as a secondary, corpus-anchored number.
repowise risk [REVSPEC] [OPTIONS]| Parameter | Type | Default | Description |
|---|---|---|---|
--path | string | — | Path to the git repository (default: current directory) |
--ext | string | — | Comma-separated file suffixes to count (e.g. .py or .ts,.tsx) |
--baseline | number | 200 | Recent commits to sample for the repo-relative percentile. 0 shows only the absolute calibrated band. |
--exclude / -x | string | — | Gitignore-style pattern to exclude. Repeatable; also applies to the baseline. |
--format | string | table | Output: table or json |
--full | boolean | false | Emit the complete tool payload as JSON (implies --format json) |
repowise risk # score HEAD
repowise risk main..HEAD # score a branch / PR range as one change
repowise risk --ext .ts,.tsx # restrict to specific suffixesUse it in a pre-push hook or CI step to flag high-risk changes before
review. For agentic workflows, get_risk exposes
the same signals per file plus PR blast-radius analysis.
repowise risk --target: what history says about these files
A second mode, same command. Instead of scoring a change, --target asks what
the repo's history says about touching specific files: bug-fix pressure,
churn trend, dependents, co-change partners, ownership. This reads the index
(the repo must be indexed), unlike the REVSPEC mode above which is pure git.
It's a thin CLI adapter over the same get_risk MCP
tool.
repowise risk --target PATH [--target PATH ...] [--changed-file PATH ...] [OPTIONS]| Parameter | Type | Default | Description |
|---|---|---|---|
--target / -t | string | — | Score what history says about this file. Repeatable. |
--changed-file | string | — | With --target: PR mode. The response leads with a directive naming what will break, which co-changes and tests are missing, and what to run. Repeatable. |
--format | string | table | Output: table or json |
--full | boolean | false | Emit the complete tool payload as JSON (implies --format json) |
repowise risk --target src/api/auth.py # one file's history
repowise risk -t src/api/auth.py -t src/api/routes.py # several files
repowise risk -t src/api/auth.py --changed-file src/api/auth.py --changed-file src/api/routes.py
# PR mode: directive firstPR mode (--changed-file) leads with a directive: what will break, missing
co-changes, files without tests, and which tests to run. Each --target card
shows hotspot score, dependents, ownership, bug-fix history, co-change
partners, and security signals where present.
Distill: compact command output
Run noisy commands through repowise distill for an errors-first, fully reversible rendering that cuts 60 to 90% of the tokens on tests, builds, git, and searches, with zero error-line loss.
Workspace: multi-repo commands
Manage repos in a repowise workspace: list, add, remove, scan, and pick the default.