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

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

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

### Transcript

Your AI agent optimises for passing tests, not for energy. Coding agents change code until the tests pass. Left alone, they chase speed or style. And while optimising, they can quietly break what the code does. Here is the fix you can use today. Give your agent written energy rules, as a skill or a rules file. Make correctness, security and public interfaces rules it can never break. Ask it to explain each change. And ask it to measure energy before and after. GreenCode researchers wrote energy rules for AI coding agents. The agents saved twenty-five point one percent of the energy. That was across forty-five problems, in six programming languages. The rules put correctness first, then list thirty-seven kinds of waste to hunt. You can start with the GreenCode Constitution skill, which gives your agent these rules. Then check the results using tools like its profiler and EnergyBench. GreenCode helps tackle this by publishing the Constitution for anyone to use. The agent keeps only what saves energy, in changes developers can review. That was GreenCode Tech Tip number four. Follow for the next tip, and find more on greencode.ai/tech-tips.

[The tip in full](https://greencode.ai/tech-tips/4-give-your-agent-a-constitution/)

[« Tech Tip #3: Measure before and after, on the same setup](https://greencode.ai/shorts/3-measure-before-and-after/)[Tech Tip #5: Forecast load before you scale »](https://greencode.ai/shorts/5-forecast-before-you-scale/)

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

#### Key Facts

- Tip **#4**
- For **Developers**
- Length **1:16**
- Category **AI and machine learning**
![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/)
