GitHub
Skip to content

GitHub Actions

How readerly detects GitHub Actions, prints text with file annotations on stderr, escapes them, caps them at 10, and what agents in CI get instead.

On GitHub Actions, a readerly command prints the text report without color or prompts, and writes workflow commands on stderr so the pull request marks the lines. createOut does this when it detects the runner. You call nothing.

detect() reads GITHUB_ACTIONS from the environment and returns reader: "ci" with ci: { name: "github-actions" }. The runner sets the variable on every job. A CI set to 0, false, no or off turns CI detection off, see the CI table.

The profile for that run, from resolveProfile with no flags:

FieldValueprofile.why
formattextdetected ci (CI:github-actions)
colorfalsestdout is not a TTY
interactivefalsereader is ci
budgetInfinityno budget for ci on text
annotations"github"

profile.annotations is "github" only when the reader is ci, the provider is github-actions and the format is text. --format json, --format jsonl and --json turn annotations off. Annotations are a side channel next to text, not a format.

The acme check example from test/golden/check.ts exits 1. On stdout, GitHub Actions gets:

✖ 2 errors, 1 warning in 212 files (0.8s)

error ACME001  src/app.ts:14:3  Route handler reads process.env at module scope
├▶ why: The value is fixed at build time
╰▶ fix: Read it inside the handler
error ACME004  src/db.ts:3:1  Top-level await in a server entry
╰▶ fix: Move the call into the plugin setup
warn  ACME010  vite.config.ts:8:5  Alias shadows a workspace package

next: acme check --fix   (applies 2 safe fixes)
next: acme explain <code>   (explains one code)
text

The command asks "Apply 2 safe fixes?" at a terminal. In CI nobody can answer, so out.confirm takes its default and adds the next: acme check --fix line instead. The row cap is off in CI, so every finding prints.

On stderr, GitHub Actions gets:

::error title=ACME001,file=src/app.ts,line=14,col=3::Route handler reads process.env at module scope
::error title=ACME004,file=src/db.ts,line=3,col=1::Top-level await in a server entry
::warning title=ACME010,file=vite.config.ts,line=8,col=5::Alias shadows a workspace package
text

Annotations go to stderr so acme check > report.txt keeps the file free of workflow commands, and the runner still reads them.

The text renderer calls githubAnnotations from readerly/github. A custom renderer or another tool can call it too. It takes DiagnosticRecords and a cap, 10 by default, returns one line per annotation, and prints nothing itself:

import type { DiagnosticRecord } from "readerly";
import { githubAnnotations } from "readerly/github";

const records: DiagnosticRecord[] = [
  {
    severity: "error",
    code: "ACME020",
    message: "Port 3000:3001 is taken, 100% of the time",
    docs: "https://acme.dev/codes/ACME020",
    file: "src/a,b.ts",
    line: 2,
    column: 7,
  },
  { severity: "warn", message: "No file, so no annotation" },
  { severity: "info", message: "Infos never get one", file: "src/app.ts" },
];

process.stderr.write(githubAnnotations(records));
annotate.ts

It writes one line:

::error title=ACME020,file=src/a%2Cb.ts,line=2,col=7::Port 3000:3001 is taken, 100%25 of the time%0Ahttps://acme.dev/codes/ACME020
text
  • Errors become ::error and warnings ::warning. Infos and records without a file are skipped and don't use up the cap.
  • The cap counts each kind on its own, in input order: at most 10 errors and 10 warnings.
  • title is the code, then come file, line and col. A range on one line adds endLine and endColumn. A range over several lines gives line and endLine only.
  • docs goes on a second line of the message.
  • Messages escape %, \r and \n. Property values also escape : and ,.

A readerly CLI needs no flag on the runner:

name: check
on: [push, pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 24
      - run: npm ci
      - run: npx acme check
.github/workflows/check.yml

The step fails when acme check exits 1, and the pull request shows each annotation on its line.

An agent that runs on a runner reads the output, so it gets the agent format. AI_AGENT and strong markers such as CLAUDECODE win over CI. Weak markers never do. With AI_AGENT=claude-code and GITHUB_ACTIONS=true, acme check prints the same compact report an agent gets on a laptop, byte for byte, and nothing on stderr. Annotations need text. See coding agents for the markers.