arXiv:2611.23203cs.SENov 2026

Manuscript Offprint

arXiv:2611.23203

Identifying and Repairing Energy Smells with Agent Skills

Mohammadjavad Mehditabar, Saurabhsingh Rajput, Tushar Sharma

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Energy smells are inefficient implementations that waste energy. Once code reaches production, these smells become costlier and riskier to fix, so energy efficiency checks should shift left, i.e., move earlier in the development lifecycle, to where code is written. Existing energy smell tools rely on fixed static rules and do not measure energy savings, whereas LLM-based optimizers mostly target execution time and rarely ground their changes in concrete smell definitions. To address both limitations, we present Dr. Greens, an agent skill that detects and repairs energy smells in Python code within the developer’s coding environment. The skill grounds the coding agent in our taxonomy of 12 energy smells and 65 root causes, augmented with repair guidance drawn from 230 measured cases. The skill also encapsulates a static analyzer and an independent verifier to confirm behavior preservation and energy saving for each attempted repair. We evaluated Dr. Greens in 18 sessions on three open-source repositories, with two models and three skill configurations. Of the 258 measured repairs, 68.6% saved energy, with a median saving of 24.9%. Compared with a baseline skill that lacks the taxonomy, the full skill found more energy smells with verified savings in all three repositories with both models. Dr. Greens helps developers detect energy hotspots and fix them reliably without altering program behavior, which makes energy-efficient development more feasible.

I Introduction

Software runs on computational resources that consume electricity and the consumption is steadily increasing. Data centers’ electricity demand grew by 17% in 2025 and is projected to double by 2030 [1]. Inefficient code patterns waste energy that may seem to cost little in a single run, but scale up to a significant waste across millions of executions [2]. Such wasteful code patterns are energy smells [3, 2].

However, unlike traditional code smells energy smells cannot be detected and resolved reliably statically alone. Whether a pattern wastes energy depends on several factors including hardware, input workload [2, 4], the measurement methods [5, 6]. Detecting and repairing energy smells therefore requires measurements under realistic inputs.

Despite the importance of energy-efficient software, only 18% of 122 surveyed programmers reported considering energy-efficiency during implementation [7]. As a result, inefficiencies accumulate unchecked [8], and AI-generated code makes this even worse [9]. Once code reaches production, similar to bugs in software systems, energy smells are costlier and riskier to fix, however, often de-prioritized over more prominent bugs and issues [8, 7, 10]. In this paper, we emphasize that energy-efficiency checks should therefore shift left, i.e., move earlier in the development lifecycle, so that inefficiencies are detected and corrected earlier before they become part of the production. Given developers’ increasing use of LLM-based coding agents [11], implementing energy-efficiency checks for coding agents is desirable and rational.

Existing approaches leave four key gaps. First, static analysis tools rely on pre-defined, hand-written rules [12, 13, 14, 15]. Due to that, they cannot reason about runtime context or verify energy savings. Agentic refactoring approaches that rely on static analyzers inherits these weaknesses and can even degrade energy efficiency [16]. Second, LLM-based optimizers mainly target execution time [17, 18, 19, 20, 21], which does not consistently predict energy [2]. Third, most approaches, such as EffiSkill [20] and ECO [21], lack an iterative optimization mechanism guided by measured energy consumption. LASSI-EE [22] measures energy, but through a fixed workflow for GPU-related code. Finally, most approaches target code optimization at a small scope. EffiSkill and EnergAgent [23] target competitive programming problems, refactor single scripts or functions. Therefore, these approaches cannot directly spot and refactor inefficiencies in real-world code.

We present Dr. Greens, an agent skill [24] for Claude. A skill is a reusable unit of documented expertise that gives a coding agent domain knowledge, a working procedure, and executable tools [24]. It runs inside the developer’s coding agent and activates in response to a developer prompt, even when the developer does not explicitly ask for it. Our skill grounds the agent in our published taxonomy of 12 energy smells and 65 root causes [2]. The agent flags suspected smells, confirms each against the repair reference for its root cause, and repairs the confirmed ones, running and measuring code at every step. It submits each repair to a verifier that checks behavior against the original and measures both versions, on inputs from a separate generator [25, 26] so that the agent cannot tailor them to its repairs. After the session, we re-measure every repair and recommend only those that preserve behavior and save energy. On three open-source Python repositories with two models, 68.6% of the measured repairs save energy, with a median saving of 24.9%, a promising result given how context and hardware-dependent energy is. Our results also show that adding the taxonomy and the static analyzer to the skill leads the agent to find more energy smells.

In summary, this paper main contribution is Dr. Greens, to the best of our knowledge the first agent skill that detects and repairs energy smells in Python code, grounded in our published energy smell taxonomy. It equips the agent with our detailed knowledge cards, a detection and repair guide for each of the 65 root causes, built on 230 measured before-and-after cases, and with a static analyzer of 40 new rules and 31 Ruff rules that covers 49 root causes. We make the skill, the analyzer, and the measurement data accessible publicly in a replication package [27].

References (31)