Main is red on the integration tests
3 pipelines failed on the default branch since yesterday. 1 is still red: acme/api, job test:integration, commit 9f3c2a1 by Lena.
Every morning: GitLab pipelines that failed on the default branch since yesterday, with the failing job, error line, author and whether it is still red.
Reads
You get
The card on the right is a sample. Yours shows your own numbers and updates in place every run.
What lands on your board
3 pipelines failed on the default branch since yesterday. 1 is still red: acme/api, job test:integration, commit 9f3c2a1 by Lena.
A red default branch blocks everyone who rebases onto it, yet GitLab only emails the person who pushed, and that email lands next to fifty others. By standup half the team has hit it on their own and nobody knows who is fixing it.
The agent checks every project you list, finds pipelines that failed on the default branch since yesterday, reads the failing job's log and names the commit and author. If a later pipeline passed, the failure is marked as fixed, so the card only turns red when main is red right now.
Use the list in the prompt, or GET /api/v4/groups/:id/projects?include_subgroups=true&archived=false. Read each project's default_branch; not every repository uses main.
GET /api/v4/projects/:id/pipelines?ref=<default_branch>&status=failed&updated_after=<24 hours ago, ISO 8601>&order_by=updated_at&sort=desc. Keep id, sha, source and web_url.
GET /api/v4/projects/:id/pipelines/:pipeline_id/jobs?scope[]=failed and skip jobs with allow_failure: true. Note stage, name, failure_reason and commit.author_name, then read the last 40 lines of GET /api/v4/projects/:id/jobs/:job_id/trace and keep the first line that reads as an error.
GET /api/v4/projects/:id/pipelines/latest?ref=<default_branch>. If it passed, mark the failure as fixed and say by which commit. If it failed on the same job, it is still broken.
Still-red projects first, with job, error line, commit and author; fixed failures after, one line each. Flag a job that failed three or more times this week as likely flaky.
With BRIEFKIN_TOKEN set, the agent sends the result as one card that updates in place every run. Without it, you get the report in the chat.
Pick your agent, where the data comes from and how to schedule it; the commands below follow.
One command. It puts the SKILL.md in ~/.claude/skills and in ~/.agents/skills, which Codex, Cursor, Gemini CLI, Copilot CLI and OpenCode read too.
shellcurl -fsSL https://briefkin.dev/skills/gitlab-failed-pipelines-on-main/install | shAsk Claude Code:
promptRun the gitlab-failed-pipelines-on-main skillOr paste the prompt instead of installing:
promptUsing the GitLab REST API (read only), for each of my projects find pipelines on the default branch that failed in the last 24 hours: GET /api/v4/projects/:id/pipelines?ref=<default_branch>&status=failed&updated_after=<24h ago>. For each, list failed jobs (GET /projects/:id/pipelines/:pipeline_id/jobs?scope[]=failed), skip allow_failure jobs, and read the end of the job log (GET /projects/:id/jobs/:job_id/trace) to find the first real error line. Give the stage, job, error line, commit SHA and author. Then check the latest pipeline on that branch (GET /projects/:id/pipelines/latest?ref=<branch>) and say whether the branch is still red or was fixed, and by which commit. Put still-red projects first and flag jobs that failed three or more times this week.Every day at 8:30, from cron on any machine where Claude Code is signed in:
crontab30 8 * * * claude -p "Run the gitlab-failed-pipelines-on-main skill"Add it with crontab -e. A laptop asleep at that time runs it when it wakes if you use launchd or Task Scheduler instead; GitHub Actions works for the API route.
Connect Briefkin once with curl -fsSL https://briefkin.dev/install | sh and every run lands on your board as a report card. How setup works
SKILL.md---
name: gitlab-failed-pipelines-on-main
description: "Every morning: GitLab pipelines that failed on the default branch since yesterday, with the failing job, error line, author and whether it is still red. Use when the user asks for this, or when it runs on a schedule."
---
# GitLab failed pipelines on main
Every morning: GitLab pipelines that failed on the default branch since yesterday, with the failing job, error line, author and whether it is still red.
A red default branch blocks everyone who rebases onto it, yet GitLab only emails the person who pushed, and that email lands next to fifty others. By standup half the team has hit it on their own and nobody knows who is fixing it.
The agent checks every project you list, finds pipelines that failed on the default branch since yesterday, reads the failing job's log and names the commit and author. If a later pipeline passed, the failure is marked as fixed, so the card only turns red when main is red right now.
## Two ways to get the data
Use the API or MCP route when you have an MCP server, a CLI or an API token for the app. Otherwise, if you can drive a browser the user is signed in to (Claude in Chrome, a Playwright or Chrome DevTools MCP server), use the browser route. Say which one you used.
## Route A: API or MCP server
### What you need
- A GitLab token with `read_api` for the projects (Reporter role or higher) in `GITLAB_TOKEN`; `GITLAB_URL` for self-managed.
- Or the GitLab MCP server at `https://<your-gitlab>/api/v4/mcp`.
If something is missing, say what and stop; do not invent numbers.
### Steps
1. **Pick the projects and their default branch** (GitLab): Use the list in the prompt, or `GET /api/v4/groups/:id/projects?include_subgroups=true&archived=false`. Read each project's `default_branch`; not every repository uses `main`.
2. **List failed pipelines since yesterday** (GitLab): `GET /api/v4/projects/:id/pipelines?ref=<default_branch>&status=failed&updated_after=<24 hours ago, ISO 8601>&order_by=updated_at&sort=desc`. Keep `id`, `sha`, `source` and `web_url`.
3. **Find the failing job and its error** (GitLab): `GET /api/v4/projects/:id/pipelines/:pipeline_id/jobs?scope[]=failed` and skip jobs with `allow_failure: true`. Note `stage`, `name`, `failure_reason` and `commit.author_name`, then read the last 40 lines of `GET /api/v4/projects/:id/jobs/:job_id/trace` and keep the first line that reads as an error.
4. **Check whether it is still red** (GitLab): `GET /api/v4/projects/:id/pipelines/latest?ref=<default_branch>`. If it passed, mark the failure as fixed and say by which commit. If it failed on the same job, it is still broken.
5. **Report**: Still-red projects first, with job, error line, commit and author; fixed failures after, one line each. Flag a job that failed three or more times this week as likely flaky.
## Route B: the browser
### What you need
- Signed in to GitLab with an account that has at least the Reporter role on each project, so job logs open.
If something is missing, say what and stop; do not invent numbers.
### Steps
Start at https://gitlab.com/dashboard/projects. The user is signed in already; never type passwords or codes, and ask if a sign-in page appears.
1. **Open each project's pipeline list**: From the projects dashboard (replace the host for self-managed), open the first project to check, then in the left sidebar **Build > Pipelines**. The project's default branch is shown on the project home page next to the branch picker; it is not always `main`.
2. **Filter to failed pipelines on the default branch**: In the filter bar above the list choose **Status** `Failed` and **Branch name** `<default branch>`. Keep the rows whose created time is within the last 24 hours and note the pipeline ID, the commit title and the author avatar next to it.
3. **Open the failing job and read the error**: Click the pipeline, open the **Failed jobs** tab and skip jobs marked as allowed to fail. Open the job, scroll to the end of the log and copy the first line that reads as an error, plus the job name and stage.
4. **Check whether the branch is still red**: Go back to **Pipelines**, clear the Status filter and keep the branch filter. If the top row passed, the failure is fixed and its commit title says by what; if it failed on the same job, the branch is still red.
5. **Repeat and report**: Do the same for every project in the list. Still-red projects first with job, error line, commit and author; fixed failures after in one line each. A job that appears three or more times in this week's failed list is likely flaky.
Note: With more than a few projects this route gets slow, since each failure means three pages; the API route checks a group in one pass. Job logs longer than a few thousand lines are truncated in the browser view and need the **Show complete raw** link.
## The report
- **Still red**: project, pipeline, failing stage and job, error line, commit and author.
- **Fixed since**: failures a later pipeline already cleared, with the fixing commit.
- **Flaky**: jobs that failed three or more times this week.
- One line on who should look first.
## Post it to Briefkin
When `BRIEFKIN_TOKEN` is set, or `~/.config/briefkin/env` exists (the installer from https://briefkin.dev/docs writes it), also send the result to the user's Briefkin board as one card. Keep the `item_key` the same on every run so the card updates in place, use a new `event_id` per run, and put today's real numbers in place of the example ones. If the request fails, say so once and carry on.
```bash
[ -n "${BRIEFKIN_TOKEN:-}" ] || . ~/.config/briefkin/env
curl -sS -X POST "${BRIEFKIN_URL:-https://briefkin.dev}/v1/events" \
-H "authorization: Bearer $BRIEFKIN_TOKEN" \
-H "content-type: application/json" \
-d @- <<'JSON'
{
"v": 1,
"event_id": "gitlab-failed-pipelines-on-main/<date of this run, e.g. 2026-10-16>",
"item_key": "gitlab-failed-pipelines-on-main",
"project": "acme",
"source": "GitLab failed pipelines on main skill",
"kind": "update",
"title": "Main is red on the integration tests",
"summary": "**3** pipelines failed on the default branch since yesterday. **1** is still red: acme/api, job `test:integration`, commit `9f3c2a1` by Lena.",
"work_state": "failed",
"widget": [
{
"type": "Table",
"props": {
"columns": [
"Project",
"Job",
"Commit",
"Now"
],
"rows": [
[
"acme/api",
"test:integration",
"9f3c2a1 Lena",
"Still failing"
],
[
"acme/web",
"lint",
"1d07e4b Tom",
"Fixed by 5a9e310"
],
[
"acme/infra",
"plan:staging",
"c41b8d2 Sam",
"Fixed by retry"
]
]
}
},
{
"type": "Log",
"props": {
"lines": [
{
"time": "06:12",
"text": "Running tests/integration/webhooks.test.ts",
"level": "info"
},
{
"time": "06:14",
"text": "Expected status 200, received 502 on POST /hooks/retry",
"level": "error"
},
{
"time": "06:14",
"text": "ERROR: Job failed: exit code 1",
"level": "error"
}
]
}
},
{
"type": "Badges",
"props": {
"items": [
{
"label": "Still red 1",
"tone": "bad"
},
{
"label": "Fixed 2",
"tone": "ok"
},
{
"label": "test:integration failed 3x this week",
"tone": "warn"
}
]
}
}
]
}
JSON
```
Widgets come from the Briefkin catalog (https://briefkin.dev/v1/catalog). Without a token, just give the user the report.
## Run it on a schedule
Suggested: Every day at 8:30 (`30 8 * * *`). From cron, with the agent signed in on that machine:
```bash
30 8 * * * claude -p "Run the gitlab-failed-pipelines-on-main skill"
# Codex: codex exec, Gemini CLI: gemini -p, Copilot CLI: copilot -p, OpenCode: opencode run
```
Or use the agent's own scheduler (Claude Code routines, Codex automations, Claude or ChatGPT scheduled tasks): https://briefkin.dev/skills/gitlab-failed-pipelines-on-main#schedule
Source: https://briefkin.dev/skills/gitlab-failed-pipelines-on-main
A GitLab token with read_api for the projects (Reporter role or higher) in GITLAB_TOKEN; GITLAB_URL for self-managed.
Or the GitLab MCP server at https://<your-gitlab>/api/v4/mcp.
https://gitlab.com/api/v4/mcp (Self-Managed and Dedicated instances use their own host), generally available on Free, Premium and Ultimate since GitLab 19.5. In Claude Code, run claude mcp add -s user --transport http GitLab https://gitlab.com/api/v4/mcp; in Codex, codex mcp add GitLab --url https://gitlab.com/api/v4/mcp and then codex mcp login GitLab; in Cursor, add it to mcp.json with "type": "http". Clients sign in with OAuth and the mcp scope, and on GitLab.com the top-level group has to allow MCP access first. The merge_requests and ci toolsets are on by default (docs).glab CLI. glab mr list --reviewer=@me and glab ci list --status=failed cover the same reports; set GITLAB_TOKEN (and GITLAB_HOST for your own instance) for scheduled runs.read_api scope and store it in GITLAB_TOKEN.read_api lets the agent read whatever the token's user can see but not comment, approve or merge; a project or group token limits that to the projects in the report.
No. The jobs list leaves out retried jobs unless you pass include_retried=true, so a job that failed once and passed on retry shows its final state. The pipeline itself still appears in the failed list only if it ended failed.
Scheduled pipelines on the default branch are included, since they run on that ref; add source=push to the query if you only care about pushes. Merge request pipelines run on other refs and stay out.
No. The skill runs with your own agent and gives you the report in the chat. With a Briefkin token set, each run also posts it to your board as a report card, so you can glance at it instead of asking again.
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot CLI, OpenCode, Windsurf and Amp all read SKILL.md files. The install command puts it in ~/.claude/skills and ~/.agents/skills, where they look. ChatGPT, the Claude app and Grok take the prompt instead. Pick your agent under "Install and run it" and the commands change to match.
Yes. Switch the data source to "Your browser" and the steps change to the GitLab pages themselves: the agent opens gitlab.com/dashboard/projects in a browser you are signed in to and reads the numbers off the page. Claude Code, Codex, Cursor, Claude app and ChatGPT can drive a browser out of the box; Gemini CLI, Copilot CLI and OpenCode need a Playwright or Chrome DevTools MCP server first. It is slower than the API and needs you signed in, so it suits a report you run by hand or from a scheduler on your own computer.
Skills are free to use with any agent. Briefkin is where their results land: one board for every report, number and question your agents send, with a ping when something needs you.
Free during the open beta. No card.