The Vibe Coder's Handbook · Part 6.1 of 14

Vibe Coder #6.1: CI/CD, the Vibe Way – Don't Let the Driver Run the Weighbridge

A hook in the agent's session is a scale the driver calibrates himself. We move the gates to GitHub Actions: a gate that trips on a shallow checkout, a PR that switches its own gate off, scripts taken from the base branch, CODEOWNERS and a required status check.

13 min read Artificial Intelligence / AI

This post is also available in Turkish →
A highway weighbridge at dusk: a truck on the scale platform behind a lowered red-and-white barrier, and in the foreground a dial on the scale terminal with a lead calibration seal hanging on a wire, the weighbridge metaphor for a CI pipeline for AI agents.

We closed the previous chapter with a confession: the test seal and the mine gate only run inside the agent's own session. If the agent turns the hook off, if you commit by hand, or if you switch to a tool without hooks, nobody is checking. This chapter moves those gates to the one place every change has to pass through: the pipeline. In short, a CI pipeline for AI agents. The examples use GitHub Actions. The same idea works on other CI services, but my trial runs and doc checks were done for GitHub.

The metaphor is a truck and a weighbridge. A hook in the agent's session is like a scale the trucker bolted onto his own trailer. Useful, but he controls the calibration. The weighbridge on the highway doesn't belong to the driver. It still needs two things: a barrier you can't drive around, and a calibration seal the driver can't tamper with. We build all three in this chapter, and I'll show how each one gets bypassed.

What does CI/CD look like when an agent writes the code?#

Classic CI (continuous integration) builds, tests and reports on every change. CD (continuous delivery or deployment) ships what passes. Two things change in vibe mode: the agent makes most of the commits, and the agent often writes the pipeline YAML too. The driver is building the weighbridge that will weigh his own truck.

Here is the definition I work from: in vibe coding, CI is the checkpoint the agent can't skip, can't switch off and can't recalibrate. If any one of those three is missing, what you have is a report, not a gate. The sections below take those three conditions in turn.

Building the weighbridge: hook commands in the pipeline#

In 5.2 we wired the tests, and in 5.3 the mine gate, to the agent's Stop hook. Here are the same commands as a job that runs on every pull request:

YAML
name: kantar
​
on:
  pull_request:
    branches: [main]
​
permissions:
  contents: read
​
jobs:
  kantar:
    runs-on: ubuntu-24.04
    timeout-minutes: 10
    env:
      TABAN: origin/${{ github.base_ref }}
    steps:
      - uses: actions/checkout@v6
​
      - uses: shivammathur/setup-php@v2
        with:
          php-version: '8.3'
          tools: phpunit:9.6
          coverage: none
​
      - name: Taban dalını getir
        run: git fetch --no-tags --depth=1 origin "${TABAN#origin/}"
​
      - name: Sözdizimi
        run: find src tests -name '*.php' -print0 | xargs -0 -n1 php -l
​
      - name: Testler
        run: phpunit --fail-on-skipped --fail-on-incomplete
​
      - name: Mayın kapısı (tabandaki sürümle)
        run: |
          git show "$TABAN:mayin-kapisi.php" > "$RUNNER_TEMP/mayin-kapisi.php"
          php "$RUNNER_TEMP/mayin-kapisi.php" "$TABAN"

The names are Turkish, carried over from the earlier chapters: kantar is the weighbridge, TABAN is the base branch, mayin-kapisi.php is the mine gate from 5.3. A few lines need a reason:

  • permissions: contents: read: the job only reads code. Claude Code's GitHub Actions docs give the same advice: grant the workflow only the permissions it needs.
  • --fail-on-skipped: closes the shortcut from 5.2, where every test was marked "skipped" and PHPUnit still exited 0.
  • No paths: filter. On purpose. You'll see why shortly.
  • setup-php is an MIT-licensed action maintained by Shivam Mathur. tools: phpunit:9.6 pins the PHPUnit version, which is the one I ran my trials with.

The test seal isn't in the list, because it doesn't travel. test-muhru.php wrote its seal to .git/tdd-muhur.json, and the .git directory is never committed. A fresh CI checkout simply doesn't have that file. At the end of 5.2 I said the last word belongs to CI. In CI, the seal's job is taken over by the calibration seal I'll describe below: CODEOWNERS.

First weighing: the gate trips on a shallow checkout#

I didn't run this workflow on GitHub. I built a local replica instead (15.11.2026, PHP 8.3.6 CLI, PHPUnit 9.6.17): a bare "origin" repository, a main branch, an ajan/kampanya branch opened by the agent, and the equivalent of the merge commit GitHub creates for a pull request (refs/pull/N/merge). On the CI side I used the actions/checkout default: fetch-depth 1, a single commit.

The agent's branch holds a cousin of the 5.3 mines: a new class that runs a campaign formula through eval() and interpolates the product ID into SQL, plus one happy-path test. PHPUnit says OK (4 tests, 4 assertions).

Without the step that fetches the base branch, the gate says this:

Bash
$ php mayin-kapisi.php origin/main
Git komutu başarısız: git diff --name-only --diff-filter=ACMR 'origin/main'
$ echo $?
1

("Git command failed.") A shallow checkout has no origin/main ref. The good news: the gate fails closed. Exit 1, red job. The bad news: for the wrong reason. The first person (or agent) to see it will decide "CI is broken" and delete the step. You don't need full history to fix it; git diff <base> compares two trees and doesn't look for a common ancestor. Fetching the tip of the base branch is enough:

Bash
$ git fetch --no-tags --depth=1 origin main
$ php mayin-kapisi.php origin/main
src/KampanyaFormulu.php:14: query() değişkenle kurulan sorgu — prepare() ve parametre kullan
src/KampanyaFormulu.php:17: eval() — formülü veri yap, kod yapma
2 mayın. Kapı kapalı.
$ echo $?
2

Two findings, the SQL built from a variable and the eval(), and "2 mines, gate closed". Since the merge commit is "base + PR", its diff against the base is exactly what the PR brings in. Tests green, gate red: the lesson of 5.3 holds in CI too.

When the driver recalibrates the scale#

The agent hit the gate. On its next commit it can fix the code. Or it can fix the gate:

PHP
declare(strict_types=1);
​
exit(0); // Geçici: kampanya acil, kapı yanlış alarm veriyor.

(The comment reads "Temporary: urgent campaign, the gate is raising false alarms.") No malice required. This is the CI version of the reward hacking we looked at in 5.2: you asked for passing checks, and the checks pass. In the replica, the gate from the PR exited 0. That's why the last step in the workflow takes the gate from the base branch, not from the PR. Against the same PR:

Bash
$ git show origin/main:mayin-kapisi.php > "$RUNNER_TEMP/mayin-kapisi.php"
$ php "$RUNNER_TEMP/mayin-kapisi.php" origin/main
src/KampanyaFormulu.php:14: query() değişkenle kurulan sorgu — prepare() ve parametre kullan
src/KampanyaFormulu.php:17: eval() — formülü veri yap, kod yapma
2 mayın. Kapı kapalı.
$ echo $?
2

That only protects the script, though. The workflow file comes from the PR as well. GitHub's page on securely using pull_request_target states it plainly when comparing the two events: pull_request runs the workflow file from the pull request's merge commit. Editing kantar.yml inside a PR means recalibrating the very weighbridge that will weigh that PR.

There's another trap. According to GitHub's troubleshooting page for required status checks, a job skipped by a conditional (if:) reports "Success". So a PR that adds a one-line condition to the job can pass the required check green. The same page says a workflow skipped by path, branch or commit-message filtering leaves its checks "Pending", which blocks the merge, and advises against requiring workflows that can be skipped. That's why there is no paths: filter.

Is pull_request_target the answer? It does take the workflow from the default branch. But the same page says this event gets the base repository's secrets and a write-capable token, and that code from the PR must only ever be inspected as data, never executed. Running tests is executing PR code. You'd be protecting the scale from the driver by handing him the keys.

The calibration seal: CODEOWNERS#

On GitHub, the CODEOWNERS file decides who can touch the calibration:

Metin
# Kantarın ayarı: bu yollara dokunan PR, sahibinin onayı olmadan birleşmez.
/.github/          @HalitYesil
/tests/            @HalitYesil
/phpunit.xml       @HalitYesil
/mayin-kapisi.php  @HalitYesil

(The comment: "Weighbridge calibration: a PR touching these paths doesn't merge without the owner's approval.") Three details from the docs. GitHub reads the file from the PR's base branch, so the agent can't make itself an owner by editing CODEOWNERS inside the PR. The file itself needs an owner; the /.github/ line covers it along with the workflows. And order matters: the last matching pattern wins. Owners also need write access to the repository.

On its own, the file only requests reviews. To make it a lock, the branch rule (a ruleset or a protected branch) needs "Require review from Code Owners" turned on. Then a PR touching those paths can't merge without the owner's approval. The tests/ line is the CI counterpart of the 5.2 seal: the agent can propose new tests or change existing ones, but neither reaches the main branch without your sign-off.

The barrier: required status checks#

A weighbridge by the side of the road is easy to drive past. A red workflow doesn't stop a merge by itself. For that, the kantar job has to be selected as a required status check in the branch rule. Four details from the rulesets and protected branches docs:

  • The seven-day rule: a check can only be selected as required if it has completed successfully in that repository within the past seven days. Run the workflow once first.
  • Where the check comes from: anyone or any integration with write access can set the state of a status check. You can tie it to a specific GitHub App; then, if anyone else sets it, merging is blocked.
  • Admins: classic branch protection rules don't apply to repository admins by default. Unless "Do not allow bypassing the above settings" is on, an admin drives under the barrier. If the agent pushes with your account, the agent is that admin.
  • Plans: on GitHub Free, rulesets and protected branches are only available for public repositories. For a private repository you need Pro, Team or Enterprise Cloud.

Weigh the YAML the agent writes#

The other side of vibe mode is that the agent writes the pipeline too. Ask for "a workflow that runs tests on PRs" and you may get something like this. I wrote it myself, not an agent, putting in two patterns we often see in agent output:

YAML
name: ci
​
on: pull_request
​
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - name: PR başlığını yaz
        run: echo "Test ediliyor - ${{ github.event.pull_request.title }}"
      - name: Testler
        run: vendor/bin/phpunit || true

actionlint is an MIT-licensed static checker for GitHub Actions workflows by rhysd. I installed 1.7.12 along with shellcheck. My first version of the echo line said "Test ediliyor:" with a colon, and actionlint couldn't even parse the file as YAML (mapping values are not allowed in this context): a colon followed by a space in an unquoted value is a key-value separator in YAML. With the colon gone, the real warning showed up:

Metin
ajan.yml:11:40: "github.event.pull_request.title" is potentially untrusted. avoid using it directly in inline scripts. instead, pass it through an environment variable.

An attacker writes the PR title; dropped straight into run:, it can become part of a shell command. The vendor/bin/phpunit || true line in the same file got no comment from actionlint. Fair enough: the syntax is fine, the logic isn't. || true pins the weighbridge needle at zero. What catches it isn't a linter but your approval on the .github/ line. I ran the same check on my own kantar.yml: exit 0.

Putting a model on the weighbridge: an inspector, not a barrier#

All three ecosystems have an agent action that runs on pull requests. I read the docs on 15.11.2026 and didn't run any of them for this post.

Action What it does Who can trigger it
anthropics/claude-code-action@v1 Responds to @claude mentions, or runs on every PR with a prompt; the review example leaves findings as inline PR comments On issue and PR events the triggering user needs write access; bot actors are rejected by default
openai/codex-action@v1 Installs the Codex CLI and runs codex exec with the permissions you set; the last message lands in the final-message output Only users with write access by default; safety-strategy defaults to drop-sudo
google-github-actions/run-gemini-cli Runs Gemini CLI with a prompt; ships pull request review and issue triage examples; Apache-2.0 The README's best practices recommend branch protection and restricting PR approvers

The last column of the 5.3 table applies here too. A model reviewer is a second pair of eyes: it posts findings as PR comments, and the agent or you fix them. Don't make it a required check. A verdict that can differ between two runs on the same diff doesn't belong on a barrier.

Two more notes. First, input: PR descriptions, commit messages and issue text are data going into the model, and instructions can hide inside them. The Codex docs recommend sanitizing those inputs and checking hidden text such as HTML comments. Second, secrets: GitHub doesn't pass secrets other than GITHUB_TOKEN to runs triggered from forks, which is why Claude's review example only works on PRs from branches in the same repository. And there's the bill: every run burns Actions minutes and model tokens; the Claude docs suggest capping turns with --max-turns.

The CD side: who holds the key to production#

What passes the weighbridge goes on the road. On GitHub, that gate is an environment. Per the environments docs, you can list up to six users or teams as required reviewers, and an optional setting stops whoever started a deployment from approving it. A deployment job can't read the environment's secrets until a required reviewer approves. You can also restrict which branches may deploy by name pattern.

Don't give the agent a server key. Put the key in the environment, put the environment behind approval, and let only main deploy. The plan limit is stricter here: on Free, Pro and Team, required reviewers are only available for public repositories.

When isn't it enough?#

  • The weighbridge only weighs what's on the road. An agent that copies files straight to a server or connects to the database never meets CI. That's the job of the agent's permission settings, as in Urban Renewal #1.
  • A seal only works if someone reads it. In a forty-file PR, a two-line change under .github/ is easy to miss. Put "propose pipeline changes in a separate PR" into your rules file. A rules file only asks, but it lightens your review load.
  • On a solo project, the barrier stops you too. That's a cost. It's also the barrier that stops an agent pushing straight to main at midnight because something is "urgent".

We built the weighbridge, lowered the barrier and sealed the calibration. All of it lives inside the repository. But an agent's work doesn't always end with a commit: a webhook fires, a table changes, an email goes out. The next chapter, Vibe Coder #6.2: n8n and Workflow Architecture, looks at workflows outside the code. The full series and the list of published chapters is on the Vibe Coder's Handbook page (in Turkish).

The driver may mean well and the load may be right. The weighbridge weighs it anyway. Stay with technology.

Comments

0 comments

Leave a comment

Replying to

Comments appear after approval. Your email address is never shared. How is your personal data processed?