Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

Developer staring at a dashboard showing a 41-minute CI pipeline duration, with a graph and code editor in the…
Products & LaunchesBreakthroughScore: 100

How to Cut CI Pipeline Time 78% with Claude Code: Profile First, Fix Second

Command: ask Claude Code to pull CI timings to JSON with zero analysis, then run a second pass on medians. The author cut 41-min CI to 9-min using Claude Code's data-first pipeline profiling.

·23h ago·4 min read··16 views·AI-Generated·Report error
Share:
Source: dev.tovia devto_claudecode, medium_claudeMulti-Source
How do I use Claude Code to profile and speed up my slow CI pipeline?

Use Claude Code to extract per-job timings from your CI provider's API into a JSON file first, then analyze separately. This developer cut a 41-minute pipeline to 9 minutes by profiling with real data before touching config, using median durations to pick the top 3 bottlenecks.

TL;DR

Stop guessing at slow CI. Use Claude Code to pull real timing data from your CI API, then let the median — not vibes — pick your optimization target.

Key Takeaways

  • Command: ask Claude Code to pull CI timings to JSON with zero analysis, then run a second pass on medians.
  • The author cut 41-min CI to 9-min using Claude Code's data-first pipeline profiling.

The Problem: 41 Minutes Changes Team Behavior

How We Cut CI/CD Pipeline Time by 66%: From 40 Minutes to 13 Minutes ...

A 41-minute CI pipeline doesn't just cost time. It changes how engineers work. Developers stopped pushing small fixes — they batched three days of work into one giant PR. When that PR went red, nobody knew which of fourteen changes broke it.

With six engineers pushing four times a day, that's 16 hours of pipeline time daily, plus queueing on a runner pool that could only handle six concurrent jobs. Some afternoons, "CI is slow" meant an hour of queue time on top of the 41 minutes.

The author had tried fixing it twice before. Both times: opened the CI config, found something that "looked slow," added a cache key, declared victory. Both times it got 3-4 minutes faster and drifted back within a month.

The root cause of those failures: never actually measuring where the 41 minutes went. That's not profiling — that's vibes.

The Technique: Data-First Pipeline Profiling with Claude Code

The fix that worked: treat the pipeline like a performance bug in an application. Get real timing data first. Don't touch a line of config until the data says where the time is.

Step 1: Extract Data with Zero Analysis

Every CI provider exposes per-step timings through its API. The author asked Claude Code to pull the last 50 successful runs on main and flatten them into a sortable file.

The critical prompt constraint:

"Pull the last 50 successful pipeline runs from the CI API. For each run, extract every job and step with its duration in seconds. Write it to ci-timings.json. Do not analyze it yet, do not suggest fixes, and do not open the CI config. I only want the data."

That "do not suggest fixes yet" line is everything. If you ask an agent to fetch data and fix a problem in the same breath, it will start proposing fixes from the first thing it sees, and everything downstream becomes an argument for that first guess.

The resulting script was ~60 lines of Python using urllib to hit the CI API, extracting job name, stage, queue time, and duration into JSON rows.

Step 2: Let the Median Pick the Target

Second pass, on the file only:

"Read ci-timings.json. Group by job name. For each job, report median duration, p90, and median queue time. Sort by median duration descending. Tell me what fraction of total wall-clock the top 3 jobs account for. No recommendations yet."

The output reordered the author's entire mental model:

test:integration 18m 40s 26m 10s 4m 02s build:docker 9m 55s 11m 30s 0m 12s test:unit 6m 20s 7m 05s 3m 40s lint 2m 50s 3m 00s 3m 55s

Two wrong assumptions revealed:

  1. build:docker wasn't the villain — it's the one people complain about because it's visible. But test:integration was 2x slower.
  2. Queue time was a hidden costtest:integration and lint were both waiting 4 minutes in queue, wasting runner slots.

Why It Works

This works because it applies the same discipline as profiling a slow endpoint: collect data, then analyze. Claude Code is excellent at both, but only when you enforce separation. The first pass builds a factual baseline. The second pass surfaces the median, not the average — medians resist the skew of one bad run.

How To Apply It

  1. Write a prompt that forbids analysis. Tell Claude Code to extract CI data to ci-timings.json and stop. No recommendations.
  2. Run a second prompt on the file only. Ask for medians, p90s, and queue times sorted descending. Ask what fraction of wall-clock the top 3 jobs consume.
  3. Fix the top 3 only. The author's fixes were "boring" — parallelizing integration tests, caching Docker layers properly, and reducing queue contention — but they were targeted at real data.

Result: 41 minutes → 9 minutes in two afternoons.

A Note on Claude Code's Current Capabilities

This workflow is even more powerful with recent Claude Code models. With Opus 4.6 and the latest Claude Code, the agent can write the extraction script, run it, and produce the analysis table in one session — as long as you enforce the two-pass discipline. The separation of concerns is what makes it reliable, not the model's raw power.


Source: dev.to

Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from multiple verified sources, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

Claude Code users should adopt a two-pass discipline for any performance work. The biggest mistake people make is combining data collection and analysis in one prompt — the agent anchors on the first pattern it sees and everything becomes an argument for that guess. Enforce a hard boundary: pass one extracts data to a file with explicit instructions to not analyze; pass two works only on that file. For CI specifically, always ask for medians and queue times, not just averages. The author discovered that `build:docker` — the job everyone complained about — was only 9m55s median, while `test:integration` was 18m40s and had 4 minutes of invisible queue time. Target the top 3 jobs by median duration, and always check queue times separately — they represent wasted runner capacity. Finally, this workflow is a template for any "slow thing" investigation: build, deploy, test, or even local dev tooling. The 60-line extraction script pattern applies to any CI provider with an API. Save the prompt in your CLAUDE.md or as a slash command so the next time CI drifts back to slow, you re-profile in minutes instead of afternoons.
This story is part of
Claude Code's 'Harness' Consolidation: How Anthropic Is Eating the Agentic Coding Stack from the Inside
Anthropic's Claude Code is absorbing the agent workflow stack — CLAUDE.md conventions, MCP servers, and orchestration layers — turning open standards into internal plumbing.

Mentioned in this article

Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Products & Launches

View all