get_health
Code-health scores and marker findings per file across three signals (defect risk, maintainability, performance), exposed to your agent so it can self-check a change before opening a PR.
get_health gives your agent the Code Health
layer directly: a 1–10 score per file across three signals (defect risk,
maintainability, performance), the marker findings behind it, repo-level
KPIs, refactoring targets, and trend alerts. Zero LLM calls; it reads
precomputed metrics.
When to call
- Self-check before a PR. Read the same signals a code-health merge-gate judges the change on. Pass the files you touched and confirm you are not regressing the worst files.
- Before a refactor. Find the lowest-scoring files and the specific markers dragging them down.
- Triage. Dashboard mode returns the repo's worst files ranked, plus the "does the score find the bugs?" stat so the agent knows the score is trustworthy on this repo before acting on it.
Parameters
Prop
Type
Returns
Dashboard mode (no targets):
| Field | Meaning |
|---|---|
kpis.hotspot_health | NLOC-weighted average over the hotspot files |
kpis.average_health | NLOC-weighted average over all files |
kpis.maintainability_average / kpis.performance_average | The maintainability and performance pillar headlines (null until measured) |
kpis.worst_performer | Single lowest-scoring file + score |
lowest_scoring | Ranked worst files with score and top marker |
module_rollup | Per-module NLOC-weighted health rollup |
Targeted mode (targets given): per-file score, the per-dimension
defect_score / maintainability_score / performance_score, the marker
findings (type, severity, line span, reason, and a dimension), and the
score breakdown by category.
Opt-in enrichments
biomarkersreturns the full (uncapped) findings set in dashboard mode. Pair with a dimension name, e.g.include=["biomarkers", "performance"], to narrow to one pillar.accuracyadds adefect_accuracyblock: of the K least-healthy files, how many were recently bug-fixed vs the repo-wide base rate (precision@K +lift), with a per-K table and the flagged files.nullon repos with too little history to be honest.signalsadds asignalsobject on each targeted metric: prior-defect count, change scatter, 90-day churn, primary / recent owner, and graph in / out degree. Honestnullper field when the underlying row is absent.churn_complexityaddschurn_complexitypoints (one per recently-changed file: 90-day commits, max CCN, NLOC, score, churn percentile).- dimension filter narrows findings to one pillar; pair with
"biomarkers"for the full set, e.g.include=["biomarkers", "performance"].
Example
get_health() # dashboard: KPIs + worst files
get_health(include=["accuracy", "churn_complexity"]) # is the score trustworthy + danger zone
get_health(include=["biomarkers", "performance"]) # only performance-pillar findings
get_health(targets=["src/api/server.py"], include=["signals"]) # self-check one file
get_health(targets=["module:src.api"], include=["trend", "refactoring"])Things worth knowing
- Deterministic and offline. The markers run off tree-sitter + git data with calibrated weights: no model calls, reproducible scores.
- Three signals, never blended.
scoreis the defect-calibrated headline; maintainability and performance are co-equal companion views with their own per-file scores anddimension-tagged findings. - Coverage is opt-in. The coverage markers
(
untested_hotspot,coverage_gap,coverage_gradient) only fire once you've ingested a report viarepowise coverage add. - Module targets (
module:foo) expand to every file under the module, so one call covers a whole package. - Refactoring plans carry an id.
include=["refactoring"]returns each plan with asuggestion_id. Pass that id togenerate_refactoring_codeto get refactored code and a unified diff for that one plan.
For the full marker reference, the three-signal model, the
defect-prediction benchmark, and the head-to-head against the leading
commercial tool, see the
Code Health layer page. For the structured
plans behind include=["refactoring"], see
Refactoring intelligence.
get_dead_code
Tiered refactor plan for unused code — high/medium/low confidence findings with per-directory rollups, ownership hotspots, and safe-to-delete impact estimates. Pure graph + SQL, no LLM calls.
generate_refactoring_code
Turns one structured refactoring plan from get_health(include=["refactoring"]) into generated code and a unified diff, grounded on the plan plus the real source it references.