---
title: "Delete code that nothing uses · Agent Wranglers"
url: https://agentwranglers.se/playbook/architecture/dead-code/delete-unused-code
updated: 2026-10-20
licence: "All rights reserved"
---

# Delete code that nothing uses

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

- Level: Required
- Chapter: [Dead code](https://agentwranglers.se/playbook/architecture/dead-code)
- Rule: Remove unused functions, classes, exports, parameters, routes and files as soon as they stop being used.
- How: Run a dead code finder in the build. Delete what it reports, or mark an entry point it missed. Dead code misleads readers and agents, who copy it and keep it alive. Old code in comments goes too, as the [comments chapter](https://agentwranglers.se/playbook/architecture/comments/no-commented-out-code) explains.
- Check: A tool fails the build on new unused code. Examples are knip, vulture, and PHPStan with a dead code extension such as shipmonk/dead-code-detector.

Example:

```ts
// Bad: kept "just in case", and an agent will copy it
export function legacyPriceWithVat(price: number) { return price * 1.25; }

// Good: deleted, with the history in version control
```

```python
# Bad: kept "just in case", and vulture reports it as unused
def legacy_price_with_vat(price):
    return price * 1.25

# Good: deleted, with the history in version control
```

**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/delete-unused-code`.

- Next: [Remove flags that never change](https://agentwranglers.se/playbook/architecture/dead-code/remove-stale-flags)
- [Dead code](https://agentwranglers.se/playbook/architecture/dead-code)
