Guides

Remove dead code only with evidence

Use an existing repository analyzer to remove unused exports, files, branches, or dependencies without deleting dynamic or externally consumed paths.

Answers: use a coding agent to remove dead code safely · Updated

SHORT ANSWER

Dead-code cleanup starts only when the project already has a trustworthy unused-code, dependency, compiler, or coverage analyzer. Every deletion must survive checks for reflection, dynamic imports, registration, configuration, generated code, public exports, and external consumers.

01

Let existing tooling produce the list

Run the analyzer the repository already trusts and record its exact command. Do not introduce a new analyzer merely to create work.

  • Deduplicate findings against earlier dispositions.
  • Keep the analyzer output as evidence.
  • Treat low coverage and text-search absence as insufficient proof.
02

Challenge every deletion

Before removing a finding, rule out dynamic and external references that static analysis may not see. Uncertainty is a reason to park the item, not permission to delete it.

  • Protect public APIs, migrations, entry points, and compatibility shims.
  • Rerun the analyzer and project gate after each coherent deletion.
  • Never weaken the analyzer to produce a clean report.
03

Finish with both analyzer and build clean

A completed shift has no actionable analyzer findings, records every uncertain consumer, and passes the repository’s final build or package check.

Run the dead-code cleanup ready shift using only the analyzer already configured in this repository. Park every uncertain reference.
TRY IT

Start with a bounded prompt

This prompt names the outcome and preserves Nightshift’s review boundary. Paste it into the supported coding host from the project you want to change.

Run the dead-code cleanup shift using only this repository's existing analyzer. Confirm dynamic, public, generated, and external references before each deletion.
BOUNDARIES

What this workflow does not claim

  • No analyzer means the shift is unsupported; text search or intuition alone is insufficient evidence.
  • Public APIs, migrations, entry points, and uncertain dynamic references stay untouched.
SOURCES

Evidence and sources

These links support the released behavior, public outcomes, or problem language described on this page.

dead-code-cleanup contractThe released analyzer-led dead-code contract.Open evidence ↗Versioned Quality skillThe released quality survey and disposition workflow.Open evidence ↗Versioned workflow contractThe shipped one-item loop, decision boundary, gates, recovery, and clock-out behavior.Open evidence ↗
RELATED QUESTIONS

Continue from the question you have

remove unused exports automaticallyRead the answer →remove unused dependencies with evidenceRead the answer →automate repository maintenanceRead the answer →