Blog

Writing CI config agents can't quietly get wrong

When a coding agent edits CI config, the dangerous mistakes are the silent ones. How cigen turns them into errors an agent can read and fix, and the gaps it still has.

Coding agents edit CI config as readily as any other file. An agent is good at YAML that looks right, and that’s the problem: CI config that looks right and is wrong often runs anyway. A misspelled key is ignored, a path filter misses the file that changed, a job skips, and the check is green. Nobody reads the workflow closely enough to notice, because it passed.

cigen is built for that reader. The aim is that every mistake an agent can make in the config either fails with a message it can act on or can’t happen in the first place. It isn’t all the way there, and the gaps are listed at the end.

Unknown keys are errors

Every level of a cigen config is strict: the top level, workflow settings, jobs and module parameters. A key cigen doesn’t know is an error that names the file and the key’s path, and says what to write instead. Here an agent has brought a habit from another CI system (requires) and mistyped image:

# cigen.yml
# error: unknown key `requires`
provider: github
workflows:
  ci:
    jobs:
      build:
        imgae: rust:1.90
        steps:
          - run: cargo build
      test:
        image: rust:1.90
        requires: [build]
        steps:
          - run: cargo test

cigen validate prints:

error: cigen.yml (at workflows.ci.jobs.build.imgae): unknown key `imgae`
  help: did you mean `image`?
error: cigen.yml (at workflows.ci.jobs.test.requires): unknown key `requires`
  help: `requires` is now `needs`.

The config has 2 problems. `cigen validate --format json` lists them as data.

The suggestions cover three cases: a close match (imgae), a key from an older cigen or another CI system (requires, runs-on, resource_class), and a key that belongs to one provider, which goes into a github: or circleci: block instead. Each job is checked on its own, so one broken job doesn’t hide the problems in the others.

Steps are the exception. A step keeps every key it’s given, so if:, shell: or continue-on-error: reach the provider untouched, and those keys are part of the job’s hash. The GitHub provider still fails on a key a GitHub step can’t have, and names the job and step.

Errors are data

An agent reads JSON more reliably than prose. cigen validate --format json prints the same problems as fields:

{
  "valid": false,
  "config": "cigen.yml",
  "errors": [
    {
      "file": "cigen.yml",
      "line": null,
      "path": ["workflows", "ci", "jobs", "build", "imgae"],
      "message": "unknown key `imgae`",
      "suggestion": "did you mean `image`?"
    }
  ]
}

line is set for YAML syntax errors. Every command (generate, validate, hash) reports config errors the same way, and the JSON schemas in the repository’s schemas/v1/ are generated from the same types as the loader, so an editor or an agent that validates against them agrees with cigen about what’s allowed.

Inputs an agent doesn’t have to list

The quietest mistake in skipping CI is an input nobody listed. If a job’s inputs miss the script it runs, changing the script leaves the job skipping. Asking an agent to list every file just moves the mistake to the agent.

So cigen adds the inputs that are easy to forget to every job’s hash: the job’s own definition, the commands it uses, the project files its steps name (sh scripts/check.sh), local actions, the root toolchain pins and the lockfiles (derived inputs). Each rule includes too much rather than too little, because an extra input costs a rerun and a missing one costs a false green check.

The generated files aren’t the source

cigen writes .github/workflows/ from the config in .cigen/, so there’s one place to change and the output is checked by tests. In cigen’s own repository the agent instructions say it plainly: never edit the generated workflows by hand, change .cigen/ and regenerate. Output is deterministic, so a regenerated file only changes when the config did, and a diff an agent produces is easy to review.

What it doesn’t catch yet

  • Within one job, only the first unknown key is reported. Fix it, and the next one appears (#61).
  • Commands still accept unknown keys.
  • Some inputs are still easy to miss: files that a named script mentions aren’t followed, and a moving image tag such as rust:latest isn’t resolved to a digest (known gaps).
  • A wrong value of the right type, such as a glob that matches nothing you meant, isn’t an error.

The docs are also served as plain Markdown for agents, with /llms.txt as the index, so an agent can read the same reference a person does.