Skip to content

Latest commit

 

History

History
569 lines (461 loc) · 37 KB

ci-cd.md

File metadata and controls

569 lines (461 loc) · 37 KB

CI/CD pipelines

This guide shows how devkit diagnoses, fixes, sets up, and watches CI/CD pipelines on GitHub Actions, GitLab CI, Bitbucket Pipelines, and Azure Pipelines. CI confirms a change that already passed locally (see Delivery), so the pipeline itself must be fast, trustworthy, and secure. The cicd skill teaches agents the same method.

dev ci audit                 # diagnose every pipeline in the repository
dev ci audit --fix           # apply the safe GitHub Actions fixes; print snippets for the other hosts
dev ci init --dry-run        # the pipeline devkit would write for this stack and host
dev ci watch                 # follow the runs of HEAD to the end; diagnose a failure
dev ci watch --wait          # the wait an agent arms after a push: its output wakes the agent
dev ci watches               # live watches, and expired ones with the command to re-arm each

Diagnose a pipeline

dev ci audit reads every pipeline in the repository and reports what makes it slow, unreliable, or unsafe. Each finding comes with its severity and the exact fix.

Host Files it reads
GitHub Actions .github/workflows/*.yml
GitLab CI .gitlab-ci.yml and its local include: files
Bitbucket Pipelines bitbucket-pipelines.yml
Azure Pipelines azure-pipelines*.yml, .azure-pipelines/, and the templates they use

It also compares the pipelines with the project's delivery policy: the test gate CI must run and the tag format a release must match (see Delivery › The delivery policy).

Option Effect
--provider github|gitlab|bitbucket|azure Only one host's pipelines
--strict Exit 1 on medium findings too (default: only high and critical)
--fix Apply the safe fixes; see Fix what is safe
--json The report, the exit code, and the applied fixes as JSON
-p PROJECT Another project (id or a unique part of its name)

The command exits with 1 when a high or critical finding remains, 0 otherwise, and 2 outside a repository.

This is a real audit of a small Python project whose workflow pins nothing, sets no permissions, and hides a lint failure (ruff check . || true):

  GitHub Actions  .github/workflows/ci.yml
  actionlint: ran: 0 finding(s) · zizmor: ran: 4 finding(s)

  critical 0 · high 1 · medium 9 · low 4 · info 1  ·  5 fixable with --fix

  Security ─────────────────────────────────────────────────────────────────────
  HIGH     .github/workflows/ci.yml:11  action-not-pinned  [--fix]
           `astral-sh/setup-uv@v6` points at a tag, which its owner can move (third-party code runs with this job's token and secrets)
           fix: pin the full commit SHA with the version in a comment: `uses: owner/repo@<sha> # vX.Y.Z` (`dev ci audit --fix` does it)
  MEDIUM   .github/workflows/ci.yml:1  permissions-missing  [--fix] (also zizmor)
           no `permissions:`: 1 job(s) get the repository's default token, which may write to everything
           fix: add `permissions: contents: read` at the top of the workflow
  …
  Reliability ──────────────────────────────────────────────────────────────────
  MEDIUM   .github/workflows/ci.yml:13  hidden-failure
           `ruff check . || true` ignores its own failure
           fix: remove `|| true`; a gate must fail the job
  …
  Speed ────────────────────────────────────────────────────────────────────────
  MEDIUM   .github/workflows/ci.yml:7  no-job-timeout  [--fix]
           job `test` has no `timeout-minutes` (GitHub's default is 6 hours)
           fix: add `timeout-minutes:` at 1.5 times the job's longest successful run, at least 30 (--fix reads its runs on GitHub)
  …
  Next ─────────────────────────────────────────────────────────────────────────
  dev ci audit --fix   applies the [--fix] items to the working tree
  dev branch new ci/<topic> · dev commit · dev ci --run · dev push · dev pr create

[--fix] marks what --fix can change, and (also zizmor) marks a finding that zizmor reported too.

Severities

Severity Meaning
critical An outside contributor can run code or steal secrets, for example through a privileged trigger
high A real supply chain, token scope, or gate problem: a mutable action, broad write permissions, no tests on pull requests
medium A risk or a waste under common conditions: no scanning, no cache, no timeout, a hidden failure
low A hardening or speed gap with little direct risk
info An observation, such as a runner label that moves

Findings catalog

Each finding has an id, a category, and a default severity. A few severities depend on context; the notes after the tables list them.

Security

Finding Severity What it means
privileged-checkout critical A privileged trigger checks out and runs pull request code
permissions-broad high The GITHUB_TOKEN can write more than the jobs need
action-not-pinned high An action referenced by a tag or branch that can be moved
script-injection high Untrusted text pasted into a shell script
secret-exposure high A secret printed or passed on a command line
self-hosted-public high A self-hosted runner that public pull requests can reach
image-push-unscanned high An image is pushed without a vulnerability scan
permissions-missing medium The GITHUB_TOKEN gets the repository's default permissions
long-lived-cloud-keys medium Long-lived cloud keys where OIDC is available
no-secret-scan medium No secret scanning in the pipeline
no-sast medium No static analysis (SAST) in the pipeline
no-sca medium No dependency vulnerability scanning (SCA) in the pipeline
no-iac-scan medium Infrastructure as code is not scanned
no-container-scan medium Container images are not scanned
no-sbom medium Releases ship without a software bill of materials (SBOM)
no-signing medium Releases are neither signed nor attested
deploy-unprotected medium A deploy without a protected environment or approval
no-actions-updates low Nothing keeps pinned actions up to date

Reliability

Finding Severity What it means
parse-error high A pipeline file cannot be read
floating-image medium A container image without a fixed tag
non-lockfile-install medium Dependencies installed without the lockfile
unpinned-tool medium A tool installed without a fixed version
hidden-failure medium A failure that does not fail the pipeline
retry-masks-flakiness medium Retries that hide flaky tests
yaml-float-version medium A version YAML reads as a number (3.10 becomes 3.1)
runner-latest info A runner image label that moves (ubuntu-latest)

Speed

Finding Severity What it means
no-dependency-cache medium Dependencies are downloaded again on every run
no-auto-cancel medium Superseded runs keep running after a newer push
no-job-timeout medium A hung job runs until the host's limit
no-path-filters low Every part of a monorepo is built for every change
no-test-sharding low A long test job runs on one machine
no-junit-report low No JUnit report: the host cannot show (or re-run) only the failed tests
tool-reinstall low The same tools are installed again in more than one step or job
fail-fast-implicit low A matrix relies on the default fail-fast
auto-cancel-unavailable info The host cannot cancel superseded runs (Bitbucket)

Quality gates

Finding Severity What it means
no-pipeline high No CI pipeline: nothing confirms a change before it lands
no-pr-tests high Tests do not run on pull requests
no-lint medium No lint step
no-typecheck medium The type checker the project configures does not run
test-gate-mismatch medium CI does not run the delivery policy's test gate
no-coverage low Test coverage is not reported

Delivery

Finding Severity What it means
release-not-tag-driven medium Releases are not driven by version tags
tag-format-mismatch medium Tag triggers do not match the policy's tag format
release-without-tests medium A release publishes without running the test gate
publish-unverified low Nothing checks the published artifact

Severities that depend on context:

  • action-not-pinned is high for a third-party action or any branch reference (@main), and low for a first-party action (actions/*, github/*) on a version tag.
  • script-injection is critical on a privileged trigger (pull_request_target, workflow_run, issue_comment, issues) and high on the others.
  • secret-exposure is high when the secret is printed, and medium when it is passed on a command line or traced with set -x.
  • no-lint is medium when the project configures a linter that CI does not run, and low otherwise.
  • no-job-timeout is low on GitLab, Bitbucket, and Azure, whose default limits are shorter than GitHub's six hours.
  • no-signing is low on Bitbucket and Azure, which have no built-in attestations.
  • release-not-tag-driven is high when a job publishes on every push.

actionlint, zizmor, and glab

On GitHub, the audit also runs actionlint (workflow syntax, expressions, and the shell in run: steps) and zizmor --offline (workflow security) when they are installed; on GitLab, it runs glab ci lint when glab is installed and signed in. The line under the host names says what ran:

  actionlint: ran: 0 finding(s) · zizmor: ran: 0 finding(s)

Their findings join the report with the tool's name in the id (actionlint/expression, zizmor/artipacked, glab/lint). When zizmor reports what devkit already found (for example unpinned-uses and action-not-pinned, or template-injection and script-injection), devkit keeps its own finding, which carries the fix, and adds (also zizmor). actionlint's syntax, expression, and credential findings are high, its shellcheck findings low. A rejected GitLab file is the high finding glab/lint. Azure Pipelines has no offline linter, so its pipelines get devkit's static checks only.

Fix what is safe

dev ci audit --fix edits the GitHub workflows in your working tree. It never commits, keeps comments and indentation, and audits again afterward. Four fixes are safe enough to apply without asking:

Finding Fix
permissions-missing permissions: contents: read at the top; a job that needs more asks for it
no-auto-cancel A concurrency group with cancel-in-progress: true for a pull-request-only workflow, otherwise ${{ github.event_name == 'pull_request' }}, so runs on the default branch finish
no-job-timeout timeout-minutes on each job, after runs-on, from the job's recent successful runs on GitHub (see Job timeouts); a job without them, and a job that calls a reusable workflow, are left alone
action-not-pinned The tag's commit SHA, with the most precise version in a comment (@v6 becomes @<sha> # v6.8.0)

Pinning asks GitHub for each tag's commit, and the timeouts for each job's runs, through gh api, so gh must be signed in. A reference that is not a tag (a branch) is skipped, and the report says to pin it to a release by hand. When GitHub cannot be reached, the pins and the timeouts are skipped and the other fixes still apply.

The same project after --fix:

  critical 0 · high 0 · medium 6 · low 3 · info 1

  Fixed (working tree, not committed) ──────────────────────────────────────────
  ✓ .github/workflows/ci.yml: permissions: contents: read
  ✓ .github/workflows/ci.yml: concurrency with cancel-in-progress: ${{ github.event_name == 'pull_request' }}
  ✓ .github/workflows/ci.yml: timeout-minutes: 30 on job `test` (the longest of its 20 recent green run(s) took 9 min)
  ✓ .github/workflows/ci.yml: astral-sh/setup-uv@v6 → d0cc045d04cc… # v6.8.0
  ✓ .github/workflows/ci.yml: actions/checkout@v4 → 11d5960a3267… # v4.4.0
permissions:
  contents: read # least privilege: a job that needs more asks for it

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name == 'pull_request' }} # a newer push replaces a PR run; other runs finish

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 30 # longest recent green run: 9 min
    steps:
      - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
      - uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0

What remains (scanning, the hidden failure, unpinned tools) needs a decision about the project, so the report keeps it with its fix.

On GitLab, Bitbucket, and Azure, --fix changes nothing and prints the snippet to add under each finding instead. From a real GitLab audit:

  MEDIUM   .gitlab-ci.yml:1  floating-image
           job `test` run in `node:latest`, which has no fixed tag and moves
           fix: use a fixed tag, better a digest (name:tag@sha256:…)
             image: node:<version>@sha256:<digest>
  MEDIUM   .gitlab-ci.yml:1  no-auto-cancel
           no job is `interruptible`: GitLab cannot cancel a pipeline that a newer push makes redundant
           fix: mark build and test jobs interruptible (not deploys), and keep the project's auto-cancel setting on
             default:
               interruptible: true
  LOW      .gitlab-ci.yml:3  no-job-timeout
           1 job(s) without `timeout:` (the project default applies, 1 hour unless changed)
           fix: set a default timeout and raise it only where needed
             default:
               timeout: 30m

Job timeouts and the delivery policy

--fix sizes each job's timeout from how long the job really takes. It reads the job's last 20 successful runs on GitHub, takes 1.5 times the longest one, and rounds it up to a multiple of 5 minutes: a job whose slowest green run took 46 minutes gets timeout-minutes: 70, so a slow run that still passes is never cancelled. Each leg of a matrix counts, and the slowest leg decides. A comment on the line says which run it was based on.

The result is never under the optional delivery-policy field job_timeout_minutes (default 30), a whole number of minutes from 5 to 360. Raise it when every job of the project needs a longer minimum:

dev delivery apply --set job_timeout_minutes=45 --why "integration tests take 35 minutes"

When --fix cannot read the runs (the repository has no github.com remote, gh is not signed in, or one of the runs cannot be read), or cannot tell which runs are the job's (it has no successful run yet, or its name: is only an expression, which GitHub shows by its value), it writes no number: the finding stays, and the report says why and to set the timeout by hand at 1.5 times the job's longest successful run. One unreadable run is enough: a history without it could miss the slowest run.

dev ci init uses the same field: when the policy sets it, every generated job gets that timeout. Without it, each job keeps its own limit (15 minutes for lint, 20 for builds, 30 for tests and integration tests); the security and release jobs keep 20 and 30.

Changing a timeout needs no new local run. When every file changed since the last local run is a GitHub workflow that differs only in timeout-minutes, concurrency (group, cancel-in-progress), or comments, dev push, dev pr create, dev pr ready, and dev release keep that run's evidence once actionlint and dev ci audit pass on the workflows, and say what they checked. A changed runner (runs-on), changed permissions, or a newly pinned action changes what a local run exercises, so it needs one. The full rule is in Delivery › When only a CI host setting changed.

Set up a pipeline

dev ci init writes a pipeline for the detected stack and host. It reads the host from the origin remote (GitHub when there is none) and the stack from the lockfiles and build files.

dev ci init --dry-run                   # print the files, and audit them, without writing anything
dev ci init                             # write them into the working tree
dev ci init --provider gitlab           # another host
dev ci init --stack java-gradle         # another stack: python, node, java-maven, java-gradle, go, php, docker
dev ci init --force                     # replace an existing pipeline file

It refuses to overwrite an existing pipeline without --force; run dev ci audit on that one instead, or compare it with --dry-run first. It exits with 1 when the result has a medium or higher finding, or when actionlint rejects it, and 0 otherwise.

Host Files
GitHub Actions .github/workflows/ci.yml, .github/workflows/release.yml, and .github/dependabot.yml when the repository has no Dependabot or Renovate configuration
GitLab CI .gitlab-ci.yml
Bitbucket Pipelines bitbucket-pipelines.yml
Azure Pipelines azure-pipelines.yml

Every generated pipeline:

  • runs on pull requests (merge requests), on pushes to the default branch, and on release tags in the policy's format (vYY.MM.PATCH by default), SemVer and PEP 440 pre-releases included (see Delivery › What the policy does);
  • cancels runs that a newer push makes redundant (Bitbucket cannot);
  • caches dependencies and installs them from the lockfile when the project has one;
  • runs lint, the type checker the project configures, unit tests with a JUnit report, integration tests when the project has them (a docker compose test file on GitHub and Azure), and the build;
  • has a security job: gitleaks (secrets), semgrep (code), osv-scanner (dependencies), trivy (filesystem and IaC), and zizmor (workflows, on GitHub); with a Dockerfile, it also builds the image and scans it with trivy before any push;
  • on a release tag, runs the tests and scans again, then builds an SBOM with syft, writes checksums, attests the files (GitHub) or signs them with cosign (the other hosts), publishes them, and downloads them again to verify them;
  • pins every action by commit SHA and every image by digest (templates/ci/pins.json), and sets least-privilege permissions and a timeout on every job.

When the project has a delivery policy, its test gate is what the test job runs: on devkit, whose gate is python3 -m compileall -q lib bin and unittest on two Pythons, the job runs python -m compileall -q lib bin and python -m unittest discover -s tests -t . once, on the Python the setup step installs. The result audits clean by construction, and the dry run ends like this:

  • added .github/dependabot.yml: weekly, grouped updates keep the pinned actions current
✓ audit: clean (no medium or high findings; 1 low or info)

  Next ─────────────────────────────────────────────────────────────────────────
  dev branch new ci/<topic> · dev commit · dev ci --run · dev push · dev pr create

Deliver the new pipeline like any change, with those commands: one branch, one local run, one push.

GitHub: ci.yml and release.yml

ci.yml runs the checks on pull requests and on the default branch, with caches. release.yml runs on release tags only, and runs the test gate and the scans again without caches: a cache that a pull request could write must never feed a release (zizmor calls this cache poisoning). Its release job is the only one with write permissions:

  release:
    name: Release (tag)
    needs: [test, security]
    runs-on: ubuntu-24.04
    timeout-minutes: 30
    environment: release # add required reviewers in Settings → Environments to approve each release
    permissions:
      contents: write # create the GitHub release and upload its files
      id-token: write # sign the provenance attestation with this workflow's identity (OIDC)
      attestations: write # store the attestation

It archives the source (or collects the build artifacts), writes sbom.spdx.json and SHA256SUMS, attests every file with actions/attest-build-provenance, creates the GitHub release, then downloads the files and checks them with sha256sum -c and gh attestation verify.

dependabot.yml keeps the pinned actions and the dependencies current: one weekly, grouped pull request per ecosystem (github-actions plus the stack's, such as uv, npm, maven, or docker), and new versions wait 14 days, except security updates.

Release signing on GitLab, Bitbucket, and Azure

Host Signing What you set up
GitLab CI Keyless: cosign signs with the pipeline's own OIDC identity (id_tokens: SIGSTORE_ID_TOKEN, audience sigstore) and verifies each file against the project URL and the tag Nothing to store; protect the release environment (Settings → CI/CD → Protected environments) to approve each release
Bitbucket Pipelines cosign with a key pair; files are published to the repository's Downloads Secured repository variables BITBUCKET_ACCESS_TOKEN (a repository access token with write access), COSIGN_PRIVATE_KEY, COSIGN_PASSWORD, and COSIGN_PUBLIC_KEY
Azure Pipelines cosign with a key pair; files are kept as the release pipeline artifact Secret variables COSIGN_PRIVATE_KEY, COSIGN_PASSWORD, and COSIGN_PUBLIC_KEY

Create the key pair once with cosign generate-key-pair and store the three values as secrets on the host, never in the repository. GitLab publishes to its generic package registry and creates the release with the job's own token.

Watch every run

dev ci watch follows the CI/CD runs of one commit until they finish, on all four hosts. You rarely run it yourself: after a git push, dev push, gh pr create, dev pr create, gh pr ready, dev pr ready, gh pr merge, dev pr merge, or dev release in a main session, devkit starts it in the background: one watcher per repository, branch, and commit, where the repository is origin's owner/repo, so a fork and its upstream each get their own. A session that sends a commit devkit already watches joins that watcher. The result reaches every session that sent the commit, each once, at its next hook or in its dev watch --wait. Each result is recorded once, whichever watch of the commit ends first.

devkit's background watch follows a run for the repository's own limit: the longest chain of jobs that need each other, at their timeout-minutes (GitHub's 360 when a job has none, a local reusable workflow counted by its own chain), plus 30 minutes for the queue; at least 90, at most 360. dev ci watch and dev ci watch --wait follow the same limit, unless --timeout gives minutes of its own. A GitHub job that has waited 30 minutes for a runner while nothing else of its commit runs gets one line in the --wait stream, with its next action, and a watch that reaches its limit names it (CI waits for a runner). A job that waits for its concurrency group, or for an environment's approval, is not counted.

A pushed tag gets a watcher only when it can start a run. On GitHub Actions, devkit reads the workflows of the tag's commit as GitHub does: a release trigger, or a push trigger that takes the tag (no filter, a tags or tags-ignore filter that lets it through; a branches filter alone takes no tag). When none does, no watcher starts, and the end-of-turn check asks for no wait. A --auto merge (dev pr merge --auto, gh pr merge --auto) that GitHub did at once is followed like a merge; one that still waits on GitHub starts no watcher.

A PR made ready (dev pr ready, gh pr ready) starts a new run on a commit that often has one already: the draft's push, which CI skipped. Its watch leaves out the runs CI skipped before the command and waits up to five minutes for a run that is not skipped, then reports that run. Where CI does not run on ready (GitHub's default pull_request trigger runs on opened, synchronize and reopened), it reports the commit's earlier run instead. A watch of the draft's push that still runs, an agent's dev ci watch --wait on the commit, and the Stop hook's check for an unwatched run follow the same rule.

dev ci watch                         # the current branch at HEAD
dev ci watch --branch feat/export --sha a1b2c3d --timeout 60
dev ci watch --json                  # the result as JSON

Each run is reported in its host's own word. A run that did not succeed counts as failed, and one that only skipped counts as none, so nothing that stopped early is ever reported as passed:

Result Exit code The runs ended as Meaning
passed 0 success Every run of the commit succeeded
failed 1 failure, cancelled, timed_out, startup_failure, action_required, or a word devkit does not know A run failed or stopped early; the result carries the diagnosis
timeout 3 still queued or running The watch ended first, at its limit (see the start of this section); follow it with dev ci status --watch, or re-arm a wait
none 4 no run, or only skipped, neutral, or stale Nothing verified the commit: the branch has no CI, its workflows skipped it, or origin is no CI host devkit reads

dev release reads the runs of the commit it tags. It refuses when a run failed. While a run is still going, it refuses too, unless a commit with the same tree passed, in its pull request run from this repository, every job still running in the same workflow file: then it names that commit and releases without waiting for main to repeat the run; a job the pull request run did not pass still holds it, even before main lists it (see Delivery › Release).

For each failed run, devkit finds the failed jobs and steps and reads the failed log from its first error, because the errors after it follow from it (gh run view --log-failed on GitHub, glab ci trace on GitLab; Bitbucket and Azure give the job, the step, and the link). The first error is the first line that both reads as an error and says what failed, so a notice before it (claude CLI not found: skipped) is not taken for it. devkit sorts the error into one class and gives one next action; when the first error says too little, the end of the failed log decides:

Class Typical first error Next action
access A secret or variable that is not set, bad credentials, a token without the permission it needs (Resource not accessible by integration, HTTP 401 or 403) Set it in the repository's settings (gh secret set <NAME>) or grant the permission in the workflow's permissions: block (least privilege); no code change fixes it, so rerun once it is set
pipeline Invalid workflow file, an unknown property, an action that cannot be resolved dev ci audit, fix the workflow, check it with actionlint, push once
infrastructure Network errors, rate limits, a lost runner, a full disk Confirm it is not the change, then rerun once: dev run rerun <id> --flaky "<evidence>"
dependencies A version that cannot be resolved, a lockfile out of date Install from the lockfile locally, fix, push once
test A failed assertion or test dev test run --failed, fix for the real reason, dev ci --run --resume, push once
lint A linter, formatter, or type checker The same check locally (dev ci --run), fix, push once
build A compile or packaging error The build command CI runs, fix, dev ci --run --resume, push once
cancelled The run was cancelled or timed out: a newer push, someone cancelled it, or a job ran past its timeout. Never read as a flaky runner Read where it stopped (dev run view <id>); for a timeout, find what hung or ran slow, reproduce it locally, fix, push once; for a newer push, follow that push's run
not_started No log: the job never started, and its check run's annotation names why, such as a runs-on label no runner has Fix the cause its annotation names, then rerun once without a new push
budget (a not_started subclass) An annotation about a spending limit or failed payments: an account limit, not the code The developer checks billing; do not push again, and rerun once the limit is lifted
workflow_invalid GitHub could not start the run (startup_failure), so no job ran dev ci audit and actionlint, fix the file, push once
unknown Anything else Read the log from the first error (dev run view <id> --failed), reproduce, fix, push once

A cancelled run or leg is never not_started: it keeps the class cancelled. dev run view --failed and dev pr checks read a job that never started the same way, from its annotation, shown as one line.

Wait on a run: a watch that wakes the agent

devkit's background watch speaks at the session's next hook, and a hook runs only when the session does something. An idle session waiting for CI never gets there. An agent that waits on a run, or promises to report when CI ends or a release is published, arms a watch that wakes it, in the same turn, names its task id in its reply, and reports the result when the watch fires. Two waits do that. dev watch --wait, the one wait for every devkit event, takes the background watch's result together with the crew's questions and decisions (see Progress and communication › Waiting and waking). dev ci watch --wait follows one run job by job:

dev ci watch --wait --branch feat/export --sha a1b2c3d --timeout 28   # one commit on a branch
dev ci watch --wait --pr 12                  # the PR's head, or its merge commit on the base branch once merged
dev ci watch --wait --tag v26.11.6           # a release tag
dev ci watch --wait                          # what this session last sent to origin

It prints one line per finished job (job tests (3.13) passed · ci #14), then one last line that starts with CI <word> ·: passed, failed, cancelled, timed out, skipped, none, or still running with the command to re-arm it. A failure's last line carries the class, the one next action, and the log link, after the first error lines (marked as untrusted CI output). Every line is flushed when it happens, host errors are retried until the timeout, and the watch ends by itself. When a Monitor's expiry stops it first, it still prints the re-arm line.

Exit code Meaning
0 Passed
1 Failed, cancelled, or timed out
2 Nothing to watch: no target given, and this session sent nothing to origin
3 The watch ended before the run: re-arm it
4 None: no run, or only skipped, neutral, or stale ones

How each agent waits:

Agent What wakes it How to arm the wait
Claude Code A Monitor: one event per output line, at most 30 minutes The Monitor tool with dev ci watch --wait … --timeout 28 and timeout_ms 1800000; when its last line says CI still running, arm it again
Claude Code A background command: one notification when it exits, no time limit Bash with run_in_background and dev ci watch --wait …
Codex Nothing in the background dev ci watch --wait … --timeout 28 in the foreground, with a command timeout longer than 28 minutes; if the run is still going, say plainly that you check it again at the next turn

A session that waits on its own run gets the result from its watch only: the background watch sends it no second message. Another session that sent the same commit still gets it from the background watch.

List the watches

dev ci watches lists the live watches and the ones that stopped before their runs ended: devkit's background watches and the agents' dev ci watch --wait, each with the repository, the branch or tag and commit, when it started, its last event, its expiry, and the agent and session. An expired watch shows the command to arm it again, in the form its agent needs. A watch leaves the list as soon as any watch sees its runs end; records older than three days are removed. dev ci watches --json gives the same list as JSON.

The end-of-turn check

The Stop hook, on Claude Code and on Codex, sends a turn back once when it sent work to origin (a push, a PR created or made ready but not as a draft, a merge, a release, as the background watch reads them) and that commit's CI run has not finished, unless a watch that wakes this agent follows it:

  • Claude Code: a live Monitor or background command, started in this session, running dev ci watch --wait on that commit. A finished foreground run of it does not count.
  • Codex: dev ci watch --wait on that commit, run in the foreground in this turn.
  • Either agent: a live dev watch --wait of this session's main session, while devkit's background watch of that commit runs: the wait takes the result the background watch delivers.

A dev ci watch --wait counts only for the repository it follows: the project its -p names, or else the checkout of the folder it runs in, which is its call's folder or the one a cd before it goes to. A wait in another repository leaves the push unwatched.

devkit's own background watch never counts alone, because it wakes no idle session. An agent's own watch of this session that stopped before its run ended must be armed again too. The message names each run and the exact command for the agent, and the reminder after the push says the same before the turn can end. The run counts as unfinished while the host shows it queued or running, while none has appeared within five minutes of the push (except for a draft PR, whose workflows may skip it), or when the host does not answer within 4 seconds. A run that a watch already saw end, or a remote that is no CI host devkit reads, needs no watch.

How a failure reaches the Release engineer

Every session that sent the commit gets the result: the one whose push started the background watch, and each one that joined it. When a session has a progress run, the result arrives as a crew message from CI watch to the tech lead (Morpheus), the main session, with its next action; otherwise it appears with the session's next tool call or prompt. A failure's message names the run, the failed job and step, the class, the next action, and the log link, followed by the first error lines. It ends with the hand-off: when the fix is not trivial, the tech lead briefs the Release engineer (Link), the crew's CI/CD engineer (dev crew brief link "Fix the failed CI run: <job>, <class>"), at once in auto mode. A speculative fix is never pushed; the failure is reproduced locally first. See The crew.

Logs are untrusted: a pull request title or a contributor's test output can carry text that someone else controls. The excerpt reaches agents marked as data, not instructions, with secrets redacted, and only the first error lines.

Every result is also saved in ~/.local/state/devkit/ci/watch/, recorded in the audit trail (ci.watch), and sent as a desktop notification. The watches themselves are recorded in ~/.local/state/devkit/ci/live/. Set DEVKIT_NO_CI_WATCH=1 to stop the automatic start.

Take over an old project

Before you change an inherited pipeline, find out where it stands, and fix it in order of risk.

  1. Run dev ci audit and dev sec scan, and read the delivery policy with dev delivery.
  2. Turn the findings into work items: dev task add "<finding>" --why "<risk>".
  3. Fix security first (permissions, pinning, injection, secrets), then reliability (lockfile installs, hidden failures), then speed (caches, auto-cancel, timeouts), then the quality gates. dev ci audit --fix does the safe part on GitHub; on the other hosts, paste the snippets it prints.
  4. When the pipeline is beyond repair, compare it with a generated one (dev ci init --dry-run) and replace it with dev ci init --force.
  5. Run what CI runs locally (dev ci --run), then push once and let dev ci watch confirm the single run.

The work is done when dev ci audit reports no high or medium findings, or each remaining one has a task and a reason, and the pipeline ran once on the pull request with a test report.

See also Delivery, Testing, The crew, and Commands › Delivery.