---
title: ['Abusing Git Trailers', 'for Faster CI/CD']
description: "A git trailer is a Key: value line at the bottom of a commit message. Our agents use one to tell CI which checks they already ran, and the PR build skips those. The trailer is a claim, so main runs every step again."
---

In [Don't Run It Twice](/dont-run-it-twice/), I wrote about why our CI skips the checks an agent has already run. This is more on the how: using git trailers.

A trailer is a `Key: value` line at the bottom of a commit message, under a blank line[^2]. You may have seen them as `Signed-off-by` and `Co-authored-by`[^1] against your commit.

<pre style="font-size: 14px; overflow-x: auto;"><code>$ git commit -m "Fix the stale cache" --trailer "Checks-Run: tsc, lint, unit"
$ git log -1 --format='%(trailers:key=Checks-Run,valueonly)'
tsc, lint, unit</code></pre>

We have a hook that has coding agents run `tsc`, lint and the unit tests before they push. In the vast majority of cases this is running on a cloud VM somewhere.

CI used to repeat this on every push. And since we care about CI/CD times this was an aggressive fan-out to keep cycle times short.

My solution: the agent's commit records what it ran as a trailer, like the `Checks-Run` line above. The build on a PR/branch reads the trailer off the commit and skips the steps it lists. Everything else runs as normal.

The trailer travels with the commit, so CI has it the moment it has the code. There's no cache to stand up and no service to call.

 Like [a PR description](/cold-read/), a trailer is a claim, not a proof. So only the PR build accepts the trailers. `main` runs every step again, whatever the trailer says.

The trailer took about three minutes off each PR build[^4]. The wall-clock time was the obvious win, but the bigger one was contention. Fewer Buildkite agents (the build-runner kind of agent) get spun up, fewer jobs sit waiting for one, and the ones that stay warm cache better. It's queuing theory at work: waits grow non-linearly as a pool gets busier, so shedding a little load cuts a lot of waiting. At 100+ PRs a day that is a lot of build minutes.

Yes, it's a poor man's Bazel[^3]. If your agents already run the checks before they push, give it a shot.

### FOOTNOTES

[^1]: GitHub reads `Co-authored-by` to [credit a second author](https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors) on a commit.

[^2]: The plumbing is [`git interpret-trailers`](https://git-scm.com/docs/git-interpret-trailers), and `git commit --trailer` and the `%(trailers)` placeholder in `git log` use the same parsing. Keys are limited to letters, numbers and hyphens.

[^3]: [Bazel](https://bazel.build/remote/caching) hashes each step and looks the hash up in a shared cache. Mine goes on what a hook saw the agent run.

[^4]: Builds were 10+ minutes overall, but now ~1.5 minutes.