Draft: chore(skills): add the ar-ci-tools skill for pipeline waits

What

This MR adds the ar-ci-tools skill: two Python commands for GitLab pipelines, with one short SKILL.md that lists them.

Command What it does
ci_wait.py Waits until a pipeline reaches a terminal state, and exits with a code for each state. It waits on an MR head pipeline, the newest pipeline of a branch, or one pipeline id.
ci_evidence.py Collects the evidence that classifies each failed job of a pipeline: allow_failure, pre-script, red-on-target, branch-caused, or unestablished.

The skill calls each command by its path from the repository root, for example .claude/skills/ar-ci-tools/scripts/ci_wait.py --project gitlab-org/ops/artifact-registry --mr 1916 --not-id 2071234567. Each script header is its full contract: usage, output fields, and exit codes. Both commands use one exit convention: 0 success, 1 usage, 2 read failure, and 3 and up for the outcomes of each command.

Why

Agents write pipeline waits and job-status extraction again in almost every session. On the private agent fleet of the author (transcripts from 2026-08 and 2026-09), a sample of 4,319 inline Python snippets and 2,613 jq programs held 192 Python snippets and 634 jq reads of CI status. Waits and sleeps were also in 16% of the helper scripts that agents wrote to /tmp. A skill is found by its description in any session, so one tested command replaces each of these rebuilds.

The two commands remove failures that read as green or as "still running":

  • A wait that reads the MR once, right after a push, can find the previous pipeline and return its old status. ci_wait.py reads the MR again on every poll.
  • A wait keyed on the pushed SHA never ends on this project, because merged-results pipelines run on a merge commit. ci_wait.py waits for a pipeline id that is greater than --not-id.
  • A pipeline that stops at a manual job is not a pass. ci_wait.py exits 5 for it, and exits 8 for a failed pipeline with no blocking failed job.
  • A trace read by job name after a retry shows the clean log of the retry. ci_evidence.py reads each trace by job id.
  • A runner that stops before the job script reads as a failure of the branch. ci_evidence.py classifies it as pre-script, and never as branch-caused.

Overlap with !1667 (closed)

!1667 (closed) (port-workstream-skills, open) adds glab-pipeline-wait to run-workstream. ci_wait.py started as a port of that script, and it is different in these ways:

  • In mr mode, glab-pipeline-wait reads head_pipeline.id one time. ci_wait.py reads the MR again on every poll, and records the ids that the head moved past in superseded[].
  • ci_wait.py waits on a new pipeline id with --not-id, never on the SHA.
  • glab-pipeline-wait exits 1 for a failed pipeline and 3 for usage and read errors. ci_wait.py keeps 1 for usage and 2 for a read failure, so no pipeline outcome has the same code as a wait that could not read.
  • ci_wait.py prints one JSON line with the failed jobs, the allow_failure jobs, and step_script_ran, and takes the project as an argument, not from origin.
  • ci_wait.py also has a --branch mode for a branch with no MR, and a --deadline-epoch for a wait across more than one call.

!1667 (closed) has no equivalent of ci_evidence.py.

This MR does not change a file that !1667 (closed) changes, except .gitlab-ci.yml and .pre-commit-config.yaml. git merge-tree of this branch and the !1667 (closed) branch shows no conflict in either file. !1667 (closed) also adds a shared runner, scripts/skill-scripts-test.sh. If !1667 (closed) merges first, the hook and CI job of this MR can move into that runner.

Overlap with !3037 (closed)

!3037 (closed) adds the ar-gl-tools skill. This MR carries its own copy of scripts/lib/gl.py and scripts/lib/exits.py, which !3037 (closed) also adds. The two copies of exits.py are identical. The two copies of gl.py are different: this copy has no graphql() helper, because no script in this skill calls it, and its module docstring is different. That duplicate is a known cost: the two skills can merge in either order, and neither skill depends on the other. The other option is an import of ../../ar-gl-tools/scripts/lib, which makes this MR wait for !3037 (closed). git merge-tree of the two branches shows no conflict.

Size

The diff is 1,695 added lines, which is more than the 500-line guideline.

File group Lines
Scripts (scripts/*.py, scripts/lib/*.py) 846
Offline tests (*_test.py, run_tests.sh) 720
SKILL.md 91
Wiring (.gitlab-ci.yml, .pre-commit-config.yaml) 38

A split does not make the review smaller. Both scripts share scripts/lib/, and each test suite is only useful with its script. The script headers are long by design, because each header is the contract that the skill points to.

Removed from the port

  • The provenance notes and private finding ids in the script headers. The headers now state each property as a contract.
  • The pointer from ci_evidence.py to a private reference page. The header now states the rule in its own text.
  • The bin/ wrappers and bare command names. The skill calls scripts by path.

Declined in review

  • gl.write() keeps the uncaught TypeError from json.dump for a payload that JSON cannot encode. No script in this skill calls write(). That payload is a programming error in the caller, the same class of error as a payload that is not a dict, which write() rejects with ValueError. The reply is at !3038 (comment 3928674850).

Permissions

.claude/settings.json has no permissions block on main, so this MR does not change it. The SKILL.md front matter uses allowed-tools for both commands, with the same form that mr-watch uses. Both commands only read.

How to verify

sh .claude/skills/ar-ci-tools/scripts/run_tests.sh

The suites fake glab, so they need no network and no token. The ar-ci-tools-skill-tests pre-commit hook and the lint:skill-scripts:ar-ci-tools CI job run the same command.

docs/dev/code-reuse-policy.md is about reference implementations. This MR uses no reference implementation, so the policy does not apply.

🤖 Generated with Claude Code

Edited by Pawel Rozlach

Merge request reports

Loading
Loading