Inspiration

Every developer knows the frustration: you push a commit, grab a coffee, come back — and the pipeline is still running. Or worse, it failed for the same reason it failed last week. Most teams only look at their CI/CD pipelines when something breaks. Nobody has time to audit job durations, spot redundant steps, or optimize caching strategies. The result? Thousands of compute minutes wasted every month on pipelines that could run in half the time. I wanted to build something that fixes this silently, automatically, before it costs you.

What it does

PipelineLens is a GitLab Duo AI agent that analyzes your CI/CD pipelines and identifies exactly where compute minutes are being wasted. You simply ask it to analyze your project — or trigger the flow from an issue or MR — and it:

  • Fetches your recent pipeline jobs and their logs
  • Identifies waste: missing caches, redundant jobs, unnecessary triggers, jobs running on every branch when they shouldn't
  • Delivers a structured report with a concrete fix for each problem
  • Estimates how many minutes you could save per pipeline run No dashboards to configure. No reports to read. Just actionable recommendations, directly inside your GitLab workflow.

How I built it

PipelineLens is built entirely on the GitLab Duo Agent Platform — no external services, no webhooks, no infrastructure to maintain. It consists of two components: 1. A custom Agent — powered by a system prompt that instructs it to think like a CI/CD cost optimization expert. It uses GitLab's native tools (get_job_logs, gitlab_api_get, get_repository_file) to fetch real pipeline data and reason about waste patterns. 2. A custom Flow — an autonomous multi-step workflow that can be triggered from any issue or MR by mentioning @ai-pipelinelens-flow. It runs in the background and posts the full optimization report as a comment.

Challenges

The biggest challenge was prompt engineering for structured output. Getting the agent to consistently produce a well-formatted table with accurate job-level recommendations — rather than generic advice — required careful iteration on the system prompt. The second challenge was scoping the analysis correctly. The agent needs to distinguish between jobs that are genuinely wasteful versus jobs that are slow for legitimate reasons. Teaching it that nuance through the prompt alone was the core technical problem.

What I learned

  • How to build and deploy custom agents on the GitLab Duo Agent Platform from scratch
  • How flows differ from agents — and when to use each
  • How to design a system prompt that produces structured, actionable output
  • That the biggest wins in CI/CD optimization are almost always the simplest ones: add a cache, add a rule, remove a duplicate job

What's next

  • Automatic MR creation with the suggested fixes applied directly to .gitlab-ci.yml
  • Recurring analysis triggered on a schedule, not just on demand
  • Cross-project benchmarking — compare your pipeline efficiency against similar projects

Built With

  • gitlab
  • gitlab-ci/cd
  • gitlab-duo-agent-platform
  • gitlab-flows
  • yaml
Share this project:

Updates