## Lesson — Prevent data loss during partial compiles

**Tags:** cli, persistence, safety
**Scope:** packages/cli/src/commands/compile.ts

When implementing a single-item 'upgrade' flow, ensure the logic doesn't truncate the global collection or overwrite the persistence file with only the partial result. Global flags or array truncations used for targeting can lead to catastrophic data loss of the rest of the collection during the save phase.
