---
title: "Tech Tip #4: Give your AI coding agent energy rules"
description: "Your AI agent optimises for passing tests, not for energy."
url: https://greencode.ai/tech-tips/4-give-your-agent-a-constitution/
---

# Tech Tip #4: Give your AI coding agent energy rules

**Your AI agent optimises for passing tests, not for energy.**

[Watch the video](https://media.greencode.ai/shorts/give-your-agent-a-constitution-ca1eb77334b2.mp4)

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

### The problem

Coding agents change code until tests pass. Left alone they chase speed or style and can break behaviour while 'optimising'. GreenCode's Constitution gives an agent five inviolable rules, correctness first, and 37 ranked anti-patterns to hunt.

### The fix you can use today

- Add an energy skill or rules file to your agent's instructions.
- Make correctness, security and public interfaces non-negotiable in those rules.
- Ask the agent to justify each change and to measure before and after.

GreenCode researchers wrote energy rules for AI coding agents, and the agents saved 25.1% of the energy.

### 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
- [GreenCode Constitution profiler (profile.sh)](https://greencode-constitution.org/skill.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): a script from the Constitution tooling that measures the energy of a command from processor counters, GPU sensors and an optional smart plug, and writes the result as JSON
- [EnergyBench](https://github.com/dragos-ionescu/energy-bench?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode) (GreenCode researchers): an MIT-licensed benchmark that scores LLM-generated code for correctness and for the energy it actually uses

### How GreenCode helps

GreenCode helps tackle this by publishing the Constitution for anyone to use. An AI agent profiles the code, fixes ranked energy anti-patterns, measures again and keeps only the changes that save energy, leaving changes developers can review. [More on this](https://greencode.ai/publications/greencode-constitution-agent-principles-for-optimizing-code-and-llm-inference-en/).

### Tags

#llm#ai-assistants#refactoring

### Sources

- [GreenCode Constitution (Kapenekakis et al., GreenAI workshop, ECML PKDD 2026): five meta-principles, 37 anti-patterns in four tiers; 25.1% saved across 45 problems in six languages](https://greencode.ai/publications/greencode-constitution-agent-principles-for-optimizing-code-and-llm-inference-en/)
- [GreenCode Constitution skill, energy anti-patterns: M1 correctness above all to M5 justify every change](https://greencode-constitution.org/skill.md?utm_source=greencode.ai&utm_medium=referral&utm_campaign=greencode)

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

#### Key Facts

- Tip **#4**
- For **Developers**
- Category **AI and machine learning**
- 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/)
