---
title: "Tech Tip #44: Delete dead code and unused dependencies"
description: "The greenest code is the code you delete."
url: https://greencode.ai/tech-tips/44-delete-dead-code/
---

# Tech Tip #44: Delete dead code and unused dependencies

**The greenest code is the code you delete.**

[Watch the video](https://media.greencode.ai/shorts/delete-dead-code-19cee4496122.mp4)

Video created by [explainapaper.com](https://explainapaper.com/?utm_source=greencode.ai&utm_medium=film&utm_campaign=made-by)

### The problem

Unused functions, abandoned feature flags and dependencies nobody calls are still built, tested, scanned, shipped and loaded. A heavy library pulled in for one helper adds weight to every build and deploy.

### The fix you can use today

- Remove code paths and flags that nothing reaches.
- Generate a software bill of materials and remove dependencies nothing imports.
- Replace a heavy library used for one small feature.

GreenCode researchers list dead code and unused libraries as an energy waste to fix.

### Tools that help

- [GreenCode Constitution skill](https://greencode-constitution.org/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): open-source energy principles and a catalogue of 37 energy anti-patterns that an AI coding agent can follow to find and fix waste like this
- [SPDX](https://spdx.dev/?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode): the open standard format for software bills of materials, listing every dependency with version and licence

### How GreenCode helps

GreenCode helps tackle this by mapping a codebase into a searchable index with a complete SPDX software bill of materials, so unused and deficient dependencies can be found and replaced. [More on this](https://greencode.ai/feature/comprehensive-codebase-mapping/).

### Tags

#code-quality#refactoring#cost

### Sources

- [GreenCode Constitution (Kapenekakis et al., GreenAI workshop, ECML PKDD 2026): dead code in Tier 4](https://greencode.ai/publications/greencode-constitution-agent-principles-for-optimizing-code-and-llm-inference-en/)
- [GreenCode Constitution skill, energy anti-patterns: N1 dead code and unused dependencies: binary size, load time and attack surface](https://greencode-constitution.org/skill.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)
- [Software Sustainability Institute, Writing Energy Efficient Code: remove dead code and redundant operations](https://www.software.ac.uk/guide/writing-energy-efficient-code?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)
- [HTTP Archive, Web Almanac 2024, Sustainability: obsolete code and polyfills](https://almanac.httparchive.org/en/2024/sustainability?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)
- [W3C, Web Sustainability Guidelines: review dependencies and remove unused libraries](https://www.w3.org/TR/web-sustainability-guidelines/#dependency-management)

[All GreenCode Tech Tips](https://greencode.ai/tech-tips/)

#### Key Facts

- Tip **#44**
- For **Developers**
- Category **Code efficiency**
- Format **short video**
![GreenCode](https://greencode.ai/wp-content/uploads/2024/12/greencode-logo-website-small-colours-2.webp)

Want this checked on your own system? Talk to the GreenCode team.

[Get in touch](https://greencode.ai/contact/)
