Inspiration
The Green Software Foundation has created excellent, vendor-neutral standards for measuring software carbon emissions — the Software Carbon Intensity (SCI) specification (ISO/IEC 21031:2024), the Carbon Aware SDK, and the Impact Framework. These tools exist. The methodology is rigorous. The gap is automation.
Research published in 2025 studied 2.2 million CI/CD pipeline runs and found that pipelines emit between 150 and 995 metric tonnes of CO₂ equivalent per organisation per year. Existing tools like ECO-CI (Green Coding Berlin) and the GSF Impact Framework require manual configuration per project. There is no tool that applies GSF standards automatically, continuously, and intelligently to every pipeline in a GitLab instance.
We built GreenPipe to close this gap: the first GitLab Duo Agent that implements GSF standards natively, enhanced with AI-powered urgency classification and carbon-aware scheduling.
What It Does
GreenPipe is a GitLab Duo Agent that monitors every CI/CD pipeline automatically:
1. Implements GSF Standards
- Calculates Software Carbon Intensity (SCI) per ISO/IEC 21031:2024 using the canonical formula
SCI = ((E × I) + M) / R - Fetches real-time and forecast grid carbon intensity from the GSF Carbon Aware SDK
- Estimates energy consumption using the GSF Impact Framework's Teads curve with SPECpower runner TDP mapping (ECO-CI approach)
- Records GSF compliance metadata per pipeline run
2. Adds AI Intelligence (Unique Contribution)
- Fine-tuned DistilBERT NLP model classifies commit messages as
urgent,normal, ordeferrable - Distinguishes critical security hotfixes from deferrable documentation updates automatically
- INT8 dynamic quantization reduces model energy use by 58% compared to full-precision FP32
- Keyword-based fallback ensures reliability when the ML model is absent
3. Takes Autonomous Action (Not Just Reports)
- Auto-deferral engine with 3 safe modes:
recommend-only,approval-required,auto-execute - Cancels deferrable pipelines and reschedules to low-carbon windows via GitLab Pipeline Schedules
- Policy guardrails: protected branches, minimum savings thresholds, max delay hours
- Full audit trail via
DeferralAuditRecorddatabase table
4. Profiles Code for Energy Efficiency (Anthropic Claude)
@greenpipe optimizeanalyses MR diffs for energy inefficiencies using Claude- Identifies N+1 queries, missing caching, unbounded loops, sync I/O patterns
- Returns structured suggestions with estimated energy impact per issue
5. Multi-Region Carbon Comparison
@greenpipe regionscompares carbon intensity across runner locations simultaneously- Ranks regions by optimal window + carbon savings, with policy-filtered allowed regions
6. Gamified Contributor Impact
@greenpipe leaderboardshows carbon-efficiency rankings per contributor- Tracks avg SCI score, deferred pipeline count, and CO₂e saved per developer
- Ranked by lowest average SCI score with gamification UX (rank icons, motivational footer)
7. Automates What Others Measure Manually
- Pipeline completion webhook triggers automatic SCI analysis and MR comment on every run
- 11 on-demand
@greenpipecommands in MR comments - Historical analytics track CO₂e trends, top consumers, savings, and leaderboard over time
- Zero developer action required — install once via GitLab webhook, then it runs forever
How We Built It
GSF Standards Layer:
| Standard | Role |
|---|---|
| SCI ISO/IEC 21031:2024 | Canonical carbon formula: SCI = ((E × I) + M) / R |
| GSF Carbon Aware SDK | Real-time + 24-hour forecast grid carbon intensity |
| GSF Impact Framework — Teads Curve | CPU utilisation → energy estimation |
| ECO-CI SPECpower approach | GitLab runner TDP hardware mapping |
AI / NLP Layer:
- DistilBERT fine-tuned on 256 labeled commit message examples (50 urgent, 92 normal, 114 deferrable)
- INT8 dynamic quantization via
torch.quantization.quantize_dynamic(): 73% smaller model, 59% faster inference, 58% less energy - Keyword-based fallback classifier for zero-dependency production reliability
Backend:
- FastAPI 0.135+ with async SQLAlchemy 2.x and asyncpg driver
- PostgreSQL for historical pipeline analytics (optional — all endpoints gracefully degrade without it)
- httpx client for GSF Carbon Aware SDK with 1-hour TTL cache (97% API call reduction)
- python-gitlab wrapper with lazy import for zero-cost startup when token is absent
Anthropic Claude Integration:
- Claude-powered code efficiency profiler (
src/services/code_analyzer.py) - Structured JSON output with line ranges, issue types, energy impact ratings, and suggested fixes
- Hybrid AI architecture: tiny INT8 DistilBERT for fast urgency routing + Claude for deep code analysis
GitLab Duo Agent:
AGENTS.mdagent manifest per GitLab Duo Agent Platform specification.gitlab/agents/greenpipe/config.yaml— Duo Agent Platform registrationtemplates/greenpipe-ci.yml— one-click CI/CD component template- Six agent tool endpoints:
analyze_pipeline,generate_sci_report,suggest_scheduling,classify_urgency,analyze_code_efficiency,compare_regions - Two webhook endpoints: pipeline completion trigger +
@greenpipemention handler (11 commands) - Webhook HMAC token verification via
X-Gitlab-Tokenheader with timing-safe comparison
Security Hardening:
- Input validation: Pydantic
max_lengthon all user-facing string fields, 500KB diff limit - Markdown injection prevention via
_sanitize_md()in all MR comments - Exception detail scrubbing — no internal errors leaked to clients
- Bounded carbon intensity cache (max 256 entries with eviction)
Test Suite:
- 299 tests across 11 test files, zero external dependencies
- DB-unavailable graceful fallback tested explicitly in analytics test suite
Challenges
Runner hardware mapping: Mapping GitLab SaaS runner type strings to SPECpower CPU TDP values requires careful cross-referencing of GitLab's runner specifications against the ECO-CI SPECpower database. We documented all mappings in docs/GSF_ALIGNMENT.md with citations.
Carbon Aware SDK availability: The GSF Carbon Aware SDK public endpoint is intermittently unavailable. We implemented a comprehensive regional fallback with IEA/ElectricityMaps 2024 averages, ensuring the agent never blocks on carbon data.
NLP accuracy vs. deployment size: Full-precision DistilBERT is too large for fast inference in a hackathon environment. INT8 dynamic quantization reduced the model to 73% of its original size while maintaining accuracy within a few percent of the FP32 baseline.
Graceful degradation at every layer: Making all five analytics endpoints return valid (empty) responses without a database connection required careful exception-boundary design. Every external dependency — GitLab API, Carbon Aware SDK, PostgreSQL — has a tested fallback path.
Accomplishments
- First GitLab-native implementation of the GSF SCI standard (ISO/IEC 21031:2024)
- Autonomous pipeline deferral — closed-loop agent that cancels + reschedules deferrable pipelines
- Claude-powered code profiling — AI-driven energy efficiency analysis of MR diffs
- Multi-region carbon comparison — parallel async queries across 5+ regions to find greenest runner
- Contributor leaderboard — gamified carbon-efficiency rankings driving developer engagement
- Energy estimates within ±15% of ECO-CI published benchmarks across representative runner types
- Agent response time under 2 seconds per pipeline analysis (keyword fallback mode)
- INT8 quantized NLP model: 58% less energy than full-precision FP32 equivalent
- 299 passing tests across 11 test files, zero external dependencies required
- 35% of demo pipelines classified as deferrable → estimated 22% carbon reduction if scheduled to Carbon Aware SDK windows
- Security hardened: input validation, markdown sanitization, exception scrubbing, timing-safe HMAC
- GSF contribution materials prepared: Green Software Pattern proposal, Impact Framework plugin spec, community case study
What We Learned
GSF standards are comprehensive but need tooling: The SCI specification, Carbon Aware SDK, and Impact Framework are mature and well-documented. What the ecosystem lacks is automation. GreenPipe demonstrates that plugging these standards into a CI/CD agent is both feasible and impactful.
Energy estimation accuracy is achievable without telemetry: By combining the Teads curve with SPECpower TDP mappings, GreenPipe achieves ±15% accuracy against ECO-CI measured benchmarks without any runtime CPU telemetry from the runner.
INT8 quantization is a practical win: Applying PyTorch INT8 dynamic quantization to DistilBERT delivered a 73% model size reduction and 59% inference speedup with negligible accuracy loss. Every ML service should consider this — it aligns directly with the GSF Sustainable Design criteria.
Carbon-aware scheduling has asymmetric impact: Even a conservative estimate of 20% reduction for deferrable pipelines compounds significantly at scale. If 35% of all GitLab pipelines were shifted to lower-carbon windows, the aggregate CO₂e reduction would be in the hundreds of tonnes annually across the platform.
What's Next
GSF Contributions (post-hackathon):
- Submit
NLP-Driven Carbon-Aware CI/CD Schedulingas a Green Software Pattern topatterns.greensoftware.foundation - Contribute the
gitlab-runner-energyplugin to the GSF Impact Framework repository - Publish the commit message urgency classification dataset as an open benchmark
Technical Roadmap:
- Contribute CPU telemetry support via GitLab Runner job metrics API (replaces 50% default utilisation assumption)
- Queue-based architecture (Celery/RQ) for high-throughput projects (>100 pipelines/day)
- Multi-platform expansion: GitHub Actions, CircleCI, Jenkins (same GSF standards layer, different webhook adapters)
- Embodied carbon improvements using manufacturer EPD data and the GSF SCI Guide hardware lifecycle tables
Built With
- agent
- alembic
- asyncpg
- aware
- carbon
- distilbert
- duo
- eco-ci
- fastapi
- framework
- gitlab
- gsf
- httpx
- impact
- int8
- iso/iec
- platform
- postgresql
- pydantic
- pytest
- python-gitlab
- pytorch
- quantization
- sdk
- specpower
- sqlalchemy
Log in or sign up for Devpost to join the conversation.