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

# Tech Tip #44: Delete dead code and unused dependencies (video)

## 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)

### Transcript

The greenest code is the code you delete. Old code does not sit still. Unused functions and abandoned feature flags still get built and tested. Libraries nobody calls still get scanned, shipped and loaded. A heavy library pulled in for one helper adds weight to every build. And to every deploy, again and again. Here is the fix you can use today. First, remove code paths and flags that nothing reaches. GreenCode's Constitution skill can help an AI coding agent find waste like this. Next, list every dependency in a software bill of materials. SPDX is the open standard format for that list. Remove the ones nothing imports. Then replace a heavy library used for one small feature. GreenCode researchers list dead code and unused libraries as an energy waste to fix. Less code shipped means less to store, send and load. GreenCode helps tackle this by mapping a codebase into a searchable index. Its full bill of materials shows which dependencies to drop or replace. That was GreenCode Tech Tip number forty-four. Follow for the next tip, and find more on greencode.ai/tech-tips.

[The tip in full](https://greencode.ai/tech-tips/44-delete-dead-code/)

[« Tech Tip #43: Consolidate underused servers](https://greencode.ai/shorts/43-consolidate-underused-servers/)[Tech Tip #45: A green cloud doesn't fix wasteful software »](https://greencode.ai/shorts/45-green-cloud-is-not-enough/)

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

#### Key Facts

- Tip **#44**
- For **Developers**
- Length **1:14**
- Category **Code efficiency**
![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/)
