Remove Code
Process
- Understand the capability to remove (not just files): What user-facing or internal capability is being removed?
- Trace dependencies before deleting anything:
- All references to the functionality across the codebase
- Code that ONLY exists to support this feature (can be fully deleted)
- Code that is SHARED with other features (must be preserved)
- Database migrations, config entries, env vars, feature flags, documentation that reference it
- Present the trace: List everything to delete and everything to modify, grouped by file. Wait for user review.
- Execute deletion:
- Fully dead files: delete
- Partially dead files: remove only dead parts
- Update imports, exports, index files
- Remove or update related tests
- Verify:
- Run the project's check command
- Grep for remaining references to removed code (function names, class names, route paths, config keys) — there are always stragglers
Rules
- Describe the CAPABILITY being removed, not files — this finds things you forgot about
- Always verify with a full check run after deletion
- Do deletion in its own PR, separate from any new feature work
- Check
.agents/common-mistakes/for any removal-specific patterns before executing - Big-output discipline. Heavy command output (project check, full
git diff, repo-wide search, long log, large fetch) goes to/tmp/hawk-remove-code-<step>.log, thenrg -n '<pattern>' /tmp/hawk-remove-code-<step>.log | head -50extracts what you need. Read only the required lines from the file. See README → Big-output discipline.