Dewei Zhai

2026-09-01

Keep or Sweep: a structured way to remove redundancy

Use evidence, the deletion counterfactual, and retention duties to decide whether code, files, documents, or mechanisms should stay or go.

AI agents can add code, documentation, a Skill, or another adapter in minutes. As creation gets cheaper, repositories expand rapidly.

Every new entity creates an ongoing cost. It must be updated, and its overlap or conflicts with other entities must be managed. It also enlarges the agent’s context. More Skills dilute attention; conflicting instructions make agent behaviour unpredictable.

An entity therefore needs to deliver more value than it costs to maintain. A useful first test is: without it, would the agent act incorrectly or become meaningfully slower? If neither happens, the entity usually has no reason to remain.

Keep or Sweep is a structured way to decide whether one bounded asset should remain. It uses a few standards:

  1. Usage evidence: who uses it, what triggers it, and what does it produce?
  2. Deletion counterfactual: whose observable behaviour gets worse if it disappears?
  3. Role: is it a source of truth, projection, or adapter?
  4. Replacement: can an existing mechanism provide equivalent behaviour?
  5. Maintenance: who updates it, detects drift, and repairs failures?
  6. Retention: must it remain as historical, audit, or compliance evidence?

The central rule is simple: unknown does not mean unused. Missing evidence leads to a pause, not an automatic deletion.

Decision tree

Keep or Sweep decision treeA decision tree leading to pause, archive, deletion, keep, or repair.NoYesUnknownNoYesYesNoYesNoBound one assetand inventory read-onlyEnough evidence?Pause and namemissing evidenceWould deletion worsenobservable behaviour?Pause and namemissing evidenceRetention duty?Credible maintenance?ArchiveRecommend deletionKeepRepair or replace

A deletion recommendation is an analysis result, not permission to delete. Execution still requires explicit authorisation, a recovery path, and post-change verification.

To use the method with Codex or Claude Code, download Keep or Sweep. The repository contains the installer and complete Skill.


Got thoughts on this? Talk it through with my agent, or send me a note.