YAGNI reduction audit

opensip yagni is an advisory audit that surfaces evidence-backed opportunities to reduce code while preserving behavior. It emits ranked candidates with proof strength, preservation arguments, and validation steps — not automatic rewrites.

Scope (ADR-0064): yagni ships two bundled detectors: unused-config-surface (config-surface reduction) and duplicate-body-candidate (exact-duplicate TypeScript function bodies). Duplicate detection uses the shared @opensip-cli/clone-detection substrate — yagni builds its own TypeScript inventory (buildTsInventory, no @opensip-cli/graph dependency) and stays complete with graph uninstalled. Near-duplicate analysis remains graph-only (graph:near-duplicate-function-body). See ADR-0064.

Quick start

opensip yagni
opensip yagni --json
opensip yagni --min-confidence high
opensip yagni packages/cli/src

Exit code is 0 by default (failOnErrors: 0, failOnWarnings: 0). Findings are recommendations, not gate failures.

Command surface

| Flag / arg | Meaning |

|---|---|

| [paths...] | Limit analysis to one or more directory subtrees |

| --json | Emit the canonical SignalEnvelope |

| --min-confidence <level> | Filter to low, medium, or high (default medium) |

| --detector <slug> | Run only named detectors (repeatable) |

| --category <name> | Filter by metadata.yagni.reductionCategory (repeatable) |

| --include-tests | Include test and fixture code |

| --verbose | Show evidence, validation steps, and low-confidence findings |

| --report-to, --open | Host report delivery (same as other tools) |

Common flags: --cwd, --quiet, --debug, --api-key.

Bundled detectors

| Detector | Category | Graph |

|---|---|---|

| unused-config-surface | config | no |

| duplicate-body-candidate | dedupe | no |

duplicate-body-candidate is TypeScript-only: yagni walks .ts/.tsx files, hashes normalized function bodies, and calls findDuplicateBodies from @opensip-cli/clone-detection — the same algorithm + curation policy graph:duplicated-function-body uses. A cross-tool parity test guards against the 430-vs-0 divergence class (ADR-0064).

Configuration

yagni:
  failOnErrors: 0
  failOnWarnings: 0
  defaultMinConfidence: medium
  includeTests: false
  disabledDetectors: []
  detectorSettings: {}

Finding model

Each signal carries metadata.yagni:

Human output

On a TTY (and without [paths...] or --json), opensip yagni uses the shared live-run shell (@opensip-cli/cli-live + @opensip-cli/cli-ui): banner, YAGNI Audit header, progress stages, then the compact summary line and shared footer hints — the same chrome as fit, graph, and sim.

The non-TTY / piped path renders a static presentation. Default view shows high + medium confidence candidates grouped by confidence, with a net: ~N LOC possible footer. Low-confidence findings and the per-detector detail block appear only with --verbose or in JSON (matching fit/graph compact-vs-verbose gating).

Suppressions

Per ADR-0014:

The yagni-ignore-hygiene fitness check audits directive quality out of band.