---
title: "Dead code · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/dead-code
updated: 2026-10-20
licence: "All rights reserved"
---

# Dead code

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

> Delete code that nothing calls, flags that never change and packages nobody imports. Version control remembers it, so the codebase does not have to.

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers architecture playbook: https://agentwranglers.se/playbook/architecture/dead-code`.

## Required

- [Delete code that nothing uses](https://agentwranglers.se/playbook/architecture/dead-code/delete-unused-code): Remove unused functions, classes, exports, parameters, routes and files as soon as they stop being used.
- [Remove flags that never change](https://agentwranglers.se/playbook/architecture/dead-code/remove-stale-flags): Delete a feature flag once it is fully on or fully off, along with the branch that no longer runs.
- [Remove unused dependencies](https://agentwranglers.se/playbook/architecture/dead-code/remove-unused-dependencies): Uninstall packages that no code imports. Each one adds install time, attack surface and update work.
- [Delete tests with their feature](https://agentwranglers.se/playbook/architecture/dead-code/delete-tests-with-feature): When you remove a feature, remove its tests, fixtures and settings in the same change.

- Previous: [Data shapes](https://agentwranglers.se/playbook/architecture/data-shapes)
- Next: [Structure](https://agentwranglers.se/playbook/architecture/structure)
- [All chapters](https://agentwranglers.se/playbook/architecture)
