Infrawrench connects to 150+ providers, finds everything you run on them, and gives your team one place to run, watch and secure it all and keep the bill in check, with AI agents that ask before they act.
Sign in and everything is already there: accounts, terminals, dashboards and history, shared with everyone you work with. Free to start; the audit log and API keys are on the paid plan.
One workspace for the team
Invite teammates and share every account, dashboard and budget. Roles decide who can read, who can act and who holds the credentials.
Terminals in the browser
SSH into servers, exec into pods and tunnel to a database through a bastion, with no VPN, local client or kubeconfig.
Alerts that find you
Budget and resource alerts go to Slack, Microsoft Teams and the mobile app, not to a laptop that is closed.
AI chat and workflows
Chat history follows you everywhere you sign in, and workflows run on a schedule, on a push or when a budget trips.
Audit log, API keys and SDKs
Every action is recorded against a person or agent. Drive the same API from scoped keys and nine generated SDKs.
On call from your phone
The iOS and Android app has dashboards, resources, chat and terminals for when you are away from your desk.
Also from Infrawrench
Nibblets keep watch while you're away.
Nibblets are always-on AI agents, each drawn as a hamster you can dress up. They keep working between messages, wake on schedules and heartbeats, and message you when they have something to say. Give one a scoped identity in Infrawrench and it can look after your clouds overnight.
Each nibblet you switch on gets its own Infrawrench identity. What it does shows under its name in the audit log, and revoking one leaves the rest alone.
Only the scopes you tick
Choose what each nibblet may do, from reading resources to running commands, and which providers it may touch. It never gets more than you have.
Runs on your own machine
Open source and self-hosted. Each nibblet lives in its own container, remembers between conversations and wakes on schedules and heartbeats.
Close a dozen consoles.
Start on your laptop for free. Invite your team when you want shared accounts, roles and on-call.
Local-first and free. Credentials stay encrypted on your machine, and no account is required. Prefer nothing to install?Use the cloud app instead →
Use with your coding agent
Connect the hosted MCP server and add our skills to your repo: your agent can list resources, chart metrics and costs, page on-call, and move your CI over.
MCP server
Run in your terminal
claude mcp add --transport http infrawrench https://app.infrawrench.com/api/mcp
Signs in through your browser on first connect (OAuth), with tools for resources, costs, workflows, CI, SQL, SSH, and more.
Skills
Infrawrench CLIInspect accounts, resources, metrics and costs from the terminal with the infrawrench CLI.
Install: run in your repository
for f in SKILL.md; do curl -fsSL --create-dirs -o ".claude/skills/infrawrench-cli/$f" "https://infrawrench.com/skills/infrawrench-cli/$f"; done
.claude/skills/infrawrench-cli/SKILL.md
---
name: infrawrench-cli
description: Use the infrawrench CLI to inspect accounts, resources, metrics, and costs from the terminal. Trigger when asked to list or check infrastructure from the shell, script against Infrawrench data (--json), page on-call, or push cost rows.
---
# infrawrench CLI
The Infrawrench desktop app doubles as the `infrawrench` CLI: same local
accounts, same cloud session, same organizations. Enable the shell command
once from the desktop app's sidebar footer, or run `infrawrench cli install`.
For scripting, always pass `--json` — every listing/data command supports it.
Text mode (the default) renders ANSI tables and charts for humans.
## Commands
- `infrawrench` / `infrawrench tui` — interactive dashboard (needs a TTY)
- `login` / `logout` / `whoami` — cloud session (browser PKCE)
- `orgs` — list organizations
- `accounts` — list accounts (local + every org by default)
- `resources --account <id|name> [--type <typeId>]` — list an account's resources
- `resource <id>` — one resource's fields & outputs
- `metrics <id> [--last 6h] [--series cpu] [--local]` — metric charts
- `costs [--last 30d] [--group-by provider|account|service|region|resource]` — org cost graphs
- `costs push --source <name> [--file rows.json]` — push your own cost rows (stdin when no file)
- `page <message> --source <name> [--key k] [--title t] [--cooldown min] [--voice]` — alert on-call
- `page clear --source <name> [--key k]` — drop a page key's cooldown after recovery
- `cli install|uninstall|status` — manage the shell command
## Flags
- `--org <id|name>` or `--local` — scope to one org / the local desktop workspace (mutually exclusive)
- `-a, --account <id|name>` — account for resource commands
- `--json` / `--text` — output mode (mutually exclusive; default text)
- `--last 30m|6h|7d|2w` or `--from` / `--to` — time range for metrics & costs
- `--no-color`, `-v/--version`, `-h/--help`
Exit codes: `0` ok, `1` runtime error, `2` usage error. Errors print as a
single line on stderr.
## Examples
```sh
infrawrench resources --account prod-aws --json | jq '.[].name'
infrawrench metrics res_abc123 --last 6h --series cpu
infrawrench costs --org acme --last 30d --group-by service
echo '[{"amount": 12.5, "service": "ci"}]' | infrawrench costs push --source ci
infrawrench page "db replica lagging" --source poller --key db-lag --cooldown 30
```
## Behavior to know
- While the desktop app is open, the CLI runs read-only against the shared
database, and `login`/`logout` hand off to the app.
- Cloud `resources` listings sync the account first so rows reflect the
provider now; on sync failure the CLI warns on stderr and serves cached rows.
- Bare `infrawrench` without a TTY prints help instead of launching the TUI.
`NO_COLOR` or a non-TTY stdout disables ANSI colors.
Environment files (.infraenv)Writes and fixes a repository's .infraenv, the committed file that says where every environment variable comes from, without ever putting a secret in it.
Install: run in your repository
for f in SKILL.md references/format.md references/migrate.md; do curl -fsSL --create-dirs -o ".claude/skills/infraenv/$f" "https://infrawrench.com/skills/infraenv/$f"; done
.claude/skills/infraenv/SKILL.md
---
name: infraenv
description: "Create, edit, check and pull .infraenv files, Infrawrench's committed replacement for .env: each variable is a literal, a resource output (resource()) or an organization secret (secret()). Use when asked to set up, migrate or change a project's environment variables or .env file in a repository that uses Infrawrench, to add a database URL or API key to the environment, or to fix `infraenv check` / `infrawrench env check` problems."
---
# Environment files (.infraenv)
A project that uses Infrawrench commits `.infraenv` instead of `.env`. It lists every environment variable and says where its value comes from, so it is reviewed and versioned like code, and it never holds a secret value. `infraenv pull` (the `@infrawrench/infraenv` npm package) or `infrawrench env pull` (the desktop app's CLI) resolves it into a normal `.env` that starts with `# Auto-generated by Infrawrench. Do not edit.` The user-facing guide is https://infrawrench.com/docs/features/env-files. Read `references/format.md` before writing anything beyond a simple variable, and `references/migrate.md` when converting an existing `.env`.
## Rules
- **Never write a secret value into `.infraenv`**, and never copy one out of `.env` into it, a commit message or chat. A secret becomes a `secret("NAME")` reference (an organization secret the user creates in Infrawrench) or a `resource(...)` reference to where it already lives.
- **Never edit the generated `.env`.** Change `.infraenv` and pull again. A `.env` without the generated header is hand-written: do not overwrite it unless the user says so (`--force`).
- **Prefer references by name** (`resource("<plugin>/<type>", "<display name>", "<output>")`). They resolve in whichever organization pulls the file. Pin by id (`resource("<id>", "<output>")`) only when the user wants one exact resource or a name is ambiguous.
- **Do not add `[infrawrench] org`** unless the user asks to pin the file to one organization.
- Keep `.env` (the output) in `.gitignore`.
## Process
1. **Find the file.** `.infraenv` at the repository root (or the one the user names). If there is none, create it with `infraenv check` passing afterwards (see `references/migrate.md` when a `.env` exists).
2. **Find the values' sources.** With the Infrawrench MCP server connected, `list_env_sources` searches the organization's resources and lists each one's outputs with a suggested variable name; `describe_env_file` checks a draft. Without it, ask the user which resource or secret each variable should come from; do not guess ids.
3. **Write the variables.** Shared values go in `[env]`; what differs per environment goes in `[env.<name>]`, or better, in a substitution: `[vars]` / `[vars.<name>]` plus `${name}` inside the reference, so one line serves every environment. Put a `# <Plugin>: <resource name> (<output>)` comment above each reference.
4. **Check.** Run `infraenv check` (or `infrawrench env check`, or the `describe_env_file` tool). It reports syntax errors with line numbers, references that match nothing or several resources, outputs a type does not have, secrets that do not exist or have no value, and substitutions with no value. Fix every problem; report any that need the user (a secret to create, an account to connect).
5. **For Infrawrench CI**, a job loads the file with `env-file:`; `check_ci_env_file` (MCP) says what each variable would give a job on a given branch and what to grant first. In CI, `secret()` reads the repository's CI secrets, not the organization's.
6. **Pull only if asked.** `infraenv pull [--env <name>]` writes `.env` with the real values. Do not print the values; the commands never do in text mode.
## Commands
| npm package (`npx infraenv` or `node_modules/.bin/infraenv`) | Desktop CLI | What it does |
| ------------------------------------------------------------ | ---------------------------------- | -------------------------------------------------------------------- |
| `infraenv check [--var k=v]` | `infrawrench env check` | What each reference points at, and every problem. Exit 1 on any. |
| `infraenv pull [--env <name>] [--var k=v] [--stdout]` | `infrawrench env pull` | Resolve and write `.env` (mode 0600). Exit 1 if a variable failed. |
| `infraenv install` / `uninstall` / `status` | `infrawrench env hooks install` | Git hooks that pull again when a commit changes `.infraenv`. |
| | `infrawrench env init --from .env` | A new `.infraenv` with one `secret("KEY")` line per `.env` key. |
| `await config()` from `@infrawrench/infraenv` (in code) | | Load `.infraenv` into `process.env` at startup; keeps set variables. |
The npm package reads `INFRAWRENCH_API_KEY` (an `iwk_` key) when it is set, else the key `infraenv login` stored; the desktop CLI uses the desktop app's sign-in. In a third-party CI, set `INFRAWRENCH_API_KEY` and run `npx @infrawrench/infraenv pull --env <name>`; in Infrawrench CI, a job's `env-file:` key loads the file without a key.
## Example
```ini
[vars]
stage = dev
[env]
NODE_ENV = development
# Neon: storefront / dev (Connection string)
DATABASE_URL = resource("neon/neon-branch", "storefront / ${stage}", "connectionString")
STRIPE_SECRET_KEY = secret("STRIPE_SECRET_KEY_${stage}")
[vars.production]
stage = main
[env.production]
NODE_ENV = production
```
.claude/skills/infraenv/references/format.md
# The .infraenv format
A dotenv file with INI sections. Lines before any section belong to `[env]`, so a `.env` of plain values is already a valid `.infraenv`. `#` starts a comment line.
## Sections
| Section | Holds |
| --------------- | ----------------------------------------------------------------------------------------------------------------- |
| `[infrawrench]` | Optional settings: `output = .env` (where pull writes, relative to the file), `org = <id>` (pins the org; avoid). |
| `[vars]` | Substitutions for every environment: `name = value`. Never environment variables themselves. |
| `[env]` | Variables every environment gets. |
| `[vars.<name>]` | Substitutions for one environment, over `[vars]`. |
| `[env.<name>]` | Variables for one environment, over `[env]`. Variables it does not mention are inherited. |
Environment names use letters, digits, `-` and `_`. Variable and substitution names use letters, digits and `_`, not starting with a digit.
## Values
| Written as | Meaning |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `development`, `"two words"`, `'raw $text'` | A literal. Quote it if it has spaces or `#`. A quoted value is always a literal, even `"secret(\"x\")"`. |
| `resource("<plugin>/<type>", "<name>", "<output>")` | An output of the synced resource with that plugin id, resource type id and display name, in the pulling organization. |
| `resource("<plugin>/<type>@<account>", "<name>", "<output>")` | The same, in the account with that display name. Use when two accounts have a resource of that name. |
| `resource("<id>", "<output>")` | An output of one resource by its id (`plugin:account:external-id`). Only resolves in the organization that owns it. |
| `secret("<NAME>")` | The organization secret with that name (the same store Infrawrench workflows use). |
Arguments are double-quoted strings with `\"` and `\\` escapes. Plugin ids, type ids and output keys come from `list_env_sources` (or the Infrawrench app's picker); never invent them.
## Substitutions
`${name}` inside the arguments of `resource()` and `secret()` is replaced before lookup. Values, lowest first: `[vars]`, the built-in `environment` (the environment being pulled), `[vars.<environment>]`, then `--var name=value`. A name with no value is a problem on that variable. Substitution never applies to literals: `HINT = ${HOME}` stays as written. `$${` is a literal `${` inside a reference.
## Resolution
- Pulling `--env production` gives `[env]` with `[env.production]` laid over it; no `--env` gives `[env]` alone.
- A variable whose source fails (no match, several matches, no value, a provider error) is reported with its line and left out of `.env`; the rest are written.
- In Infrawrench CI, a job's `env-file:` key loads the file, but only resources the repository is granted and the repository's CI secrets resolve there.
.claude/skills/infraenv/references/migrate.md
# Converting an existing .env
The goal is a committed `.infraenv` with the same keys and no secret values.
1. **Read the keys, not the values aloud.** List the keys in `.env` (and `.env.example`, `.env.production` and the like, if present). You may look at a value only to classify it; never repeat it.
2. **Classify each key:**
- **Not secret** (ports, feature flags, public URLs, `NODE_ENV`): keep it as a literal.
- **Comes from infrastructure** (database URLs, cache URLs, bucket names, endpoints, API keys a provider issues): find the resource with `list_env_sources` and write a by-name `resource()` reference with the output the key needs.
- **A secret with no resource behind it** (a third-party API key): write `secret("KEY")` and tell the user to create the organization secret `KEY` in Infrawrench (Environment files, or Settings) with the value from their `.env`. Do not create it for them with the value from the file unless they ask.
3. **Split environments.** Values that differ between the user's `.env.<stage>` files become `[env.<stage>]` overrides, or a `[vars]` substitution when only part of a name changes.
4. **Write `.infraenv`, then check it** with `infraenv check` (or `infrawrench env check`) and fix every problem.
5. **Leave the old `.env` alone.** The first pull refuses to overwrite a `.env` without the generated header; the user decides when to pass `--force`. Make sure `.env` is gitignored, and suggest `infraenv install` (or `infrawrench env hooks install`) so it regenerates when `.infraenv` changes.
`infrawrench env init --from .env` does steps 1 and 2 crudely (every key becomes `secret("KEY")`); use it as a start, then replace each line with the right kind.
Migrate from GitHub ActionsConverts a repository's GitHub Actions workflows into Infrawrench CI pipelines, job by job, and reports what could not move.
Install: run in your repository
for f in SKILL.md references/actions.md references/limits.md references/mapping.md references/monorepos.md; do curl -fsSL --create-dirs -o ".claude/skills/migrate-github-actions/$f" "https://infrawrench.com/skills/migrate-github-actions/$f"; done
.claude/skills/migrate-github-actions/SKILL.md
---
name: migrate-github-actions
description: Convert GitHub Actions workflows (.github/workflows/*.yml) into Infrawrench CI pipelines (.infrawrench/ci/*.yml). Use when asked to move a repository's CI from GitHub Actions to Infrawrench CI, or to translate a workflow, job, step or action into Infrawrench CI.
---
# Migrate GitHub Actions to Infrawrench CI
Infrawrench CI runs the pipelines in a repository's `.infrawrench/ci/` folder on every push and pull request. Each job is one script (or one tool) that runs in its own WebAssembly sandbox over an in-memory snapshot of the commit, with the dependencies already installed from the lockfile. There are no steps, no marketplace actions and no runner images: most of a GitHub Actions job's steps either disappear or become lines of one script.
The reference for every key is the runner's README, `ci-runner/README.md` in the Infrawrench repository, and the user-facing guide is https://infrawrench.com/docs/features/ci. Read the files under `references/` when the step below says so; they are written to be read one at a time.
## Process
1. **Inventory.** Read every file in `.github/workflows/`. For each workflow, list its triggers, its jobs, what each job runs on (`runs-on`), the actions it uses, its services, the secrets and variables it reads, and which jobs depend on which. Note reusable workflows (`workflow_call`) and composite actions (`.github/actions/`), which are inlined, not called.
2. **Classify each job** into one of three groups, and tell the user the result before writing files:
- **Runs on the runner**: bash, Node, Python, Go, PHP, TypeScript type checks, formatters, Postgres or ClickHouse tests, deployment CLIs. Most jobs.
- **Becomes a cloud job** (`cloud:`): anything that needs Docker, a native binary with no WebAssembly build, a GPU, or a real Linux machine. Rust is not one of these: it compiles with `tools: [builtin:[email protected]]` (see `references/limits.md`). It runs on one of the organization's connected cloud accounts, which an admin has to opt in to CI first.
- **Stays on GitHub Actions**: macOS and Windows jobs, and anything relying on an event Infrawrench CI does not have (see `references/limits.md`).
3. **Write one pipeline per workflow**, `.infrawrench/ci/<same-name>.yml`, starting with the schema comment so editors validate it:
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/Infrawrench/Infrawrench/main/ci-runner/schema/ci.schema.json
```
Translate the triggers, jobs, expressions and environment variables with `references/mapping.md`, and replace each action with `references/actions.md`.
4. **Move dependency installs to the workspace.** Delete `actions/setup-*`, `actions/checkout` and `npm ci` / `pnpm install` / `pip install -r` steps, and list the package managers under `workspace.deps` instead. Dependencies are installed once per commit and checked against the lockfile; install scripts do not run, so a `postinstall` that generates code (Prisma, protobuf) becomes an explicit line in the jobs that need it.
5. **Split big jobs.** A job that runs a whole monorepo's tests or type checks (`turbo run test`, `nx affected`, `pnpm -r test`) becomes a `packages:` job, one job per workspace package, with the task cache. Read `references/monorepos.md`. This is usually the largest speed-up of the migration.
6. **Check the limits.** Read `references/limits.md` and fix anything it flags: the 10-minute default timeout, the 2 GiB default memory, pipes in scripts, and the checkout having no `.git`.
7. **List what the user has to do in Infrawrench**, since an agent cannot do it:
- Add every secret and variable the pipelines read under **CI → Secrets and variables** (names only: never write a secret's value into a file).
- Turn on what jobs borrow under **CI → CI access**: connections that run cloud jobs, connections lent with `connections:`, SSH keys lent with `ssh-keys:`.
- Tick **Run CI** for the repository's GitHub account if it is not on yet.
8. **Validate.** Push to a branch and open a pull request. A pipeline file that does not parse fails at once with a job named **Pipeline file** whose output gives every error with its path in the file (`jobs.test.timeout: ...`). With the Infrawrench MCP server connected, `list_ci_runs` and `get_ci_job_log` read the results without leaving the editor.
9. **Run both side by side, then switch.** Keep the GitHub Actions workflows until the Infrawrench runs pass on the same commits. Then delete the migrated workflows (or the migrated jobs, for a workflow that keeps some), and change branch protection to require **Infrawrench CI / pull request**, the check that covers every job of the run.
## Rules that catch people out
- **A job is one script.** `run:` is bash with `set -euo pipefail`. Join a GitHub job's `run` steps into one `run: |` block in order. Use `if:` on a job, not on a line; inside the script, use shell conditionals.
- **Secrets only in `env:`.** `${{ secrets.NAME }}` works only as an `env:` value. Map it to a variable and read the variable in the script.
- **Pick an environment.** Every job without `cloud:` names `using:`: `env:bash@5`, `env:bash-node@24`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, or a tool such as `builtin:[email protected]`. Versions are pinned; a bare name is an error.
- **Jobs in `needs:` hand files on with `artifacts:`**, not with upload and download actions. Files for people to download from the run are `downloads:`.
- **Pull requests from forks** run only after a maintainer approves them, get no secrets, and never run cloud jobs. There is no `pull_request_target` equivalent.
## What to hand back
Finish with a short report: each workflow and job, where it went (runner, cloud job, stayed on GitHub Actions) and why, the secrets and variables to add, the CI access to turn on, and anything you were unsure of. Do not claim speed-ups you have not measured.
# Replacing actions
There are no actions. Each `uses:` step is dropped, becomes workspace or job configuration, or becomes a command in the job's script. When an action is not listed here, read what it runs (its `action.yml` and entry point) and do that in the script: most wrap a CLI that runs in `env:bash-node@24` with `npx` or a pinned global install. Pin every version.
## Setup and checkout
| Action | Replacement |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions/checkout` | Drop it. Every job starts in the commit's files at `/app`. There is no `.git`; see `limits.md` for jobs that need history. |
| `actions/setup-node`, `pnpm/action-setup` | `using: env:bash-node@24` (Node 24, `npm`, `pnpm`, `npx`), and `workspace: { deps: [pnpm] }` (or `[npm]` for `package-lock.json`) instead of the install step. |
| `oven-sh/setup-bun` | `tools: [builtin:bun@1]` (Bun 1.4.4) on `using: env:bash@5`, and `bun install --frozen-lockfile` in the script, or `deps: [{ bun: { native: true } }]` when no install script matters; read `limits.md`. |
| `actions/setup-python` | `using: env:[email protected]`, and `deps: [pip]` (reads `pylock.toml` or `requirements.txt`; `- pip: { file: requirements/ci.txt }` for another). |
| `actions/setup-go` | `using: env:[email protected]` (1.23 to 1.27), and `deps: [go]` for `go.sum`. |
| `shivammathur/setup-php` | `using: env:[email protected]` (8.1 to 8.5), and `deps: [composer]`. |
| `dtolnay/rust-toolchain`, `actions-rs/*` | `tools: [builtin:[email protected]]` in an `env:bash@5` job (rustfmt and clippy included), with `workspace: { deps: [cargo] }`; see `limits.md`. A non-host `targets:` needs a cloud job. |
| `Swatinem/rust-cache` | Nothing: crates come from `deps: [cargo]`. To keep `target/` between runs, `cache: { key: ..., paths: [target] }`. |
| `ruby/setup-ruby` | `using: env:[email protected]` (or `@3.4`), and `deps: [bundler]` instead of `bundler-cache: true`; see `limits.md` for Rails. |
| `actions/setup-java`, `setup-dotnet` | No environment for these yet. Make the job a cloud job with an `image:` that has the runtime. |
## Caches and files between jobs
| Action | Replacement |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `actions/cache` for `node_modules`, `~/.npm`, `~/.cache/pip`, `~/go/pkg` | Drop it: `workspace.deps` installs are cached by the runners. Go's build cache is kept on its own. |
| `actions/cache` for anything else | `cache: { key, restore-keys, paths }` with `${{ hashFiles('...') }}` in the key. Saved only when the job passes. Pull requests save to a scope the default branch never reads. |
| `actions/cache` for `.turbo` or `.nx` | Drop it and use the task cache instead (`task-cache:`), which skips whole jobs. See `monorepos.md`. |
| `actions/upload-artifact` + `download-artifact` between jobs | `artifacts: [dist]` on the producing job; every job that `needs:` it starts with those files where they were left. |
| `actions/upload-artifact` for people | `downloads: [report.html]`, or `{ paths, retention: 7d, when: always }`. Text files are masked for secrets; binary files are not, so never put a secret in one. |
## GitHub itself
Every one of these needs `github-token:` with the permissions it used, and `tools: [builtin:[email protected]]` for the `gh` command. The token is for the run's own repository, lasts an hour from when the run starts, and is never given to a fork's pull request.
| Action | Replacement |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `softprops/action-gh-release`, `ncipollo/release-action` | `gh release create "$TAG" dist/* --notes-file NOTES.md` with `github-token: { contents: write }`. |
| `peter-evans/create-pull-request` | Clone the repository in the script (the checkout has no `.git`), commit, push a branch and `gh pr create`, with `github-token: { contents: write, pull-requests: write }`. |
| `actions/github-script` | `gh api ...` in the script, or a Node script reading `GITHUB_TOKEN`. |
| `stefanzweifel/git-auto-commit-action` (formatters, codegen) | Make the job a check instead: `changes: fail` fails it when the formatter changes a file. To commit back, clone the repository in the script with `github-token: { contents: write }`. |
| `actions/labeler`, `actions/stale`, issue automation | These react to events Infrawrench CI does not have. Keep them on GitHub Actions. |
## Clouds and deployments
Credentials are lent, not stored: an admin turns a connection on for CI under **CI access**, and the job names it. Do not move cloud keys into secrets when a connection can be lent.
| Action | Replacement |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `aws-actions/configure-aws-credentials` | `using: env:[email protected]` and `connections: [<connection name>]`: the `aws` CLI is signed in with the lent session. |
| `google-github-actions/auth` + `setup-gcloud` | `using: env:gcloud@593` and `connections: [<name>]`: `gcloud` and `bq` use the lent access token. |
| `azure/login` | `using: env:[email protected]` and `connections: [<name>]`: `az` signs in with the lent service principal. |
| `azure/setup-kubectl`, `azure/k8s-*`, `deliverybot/helm` | `tools: [builtin:[email protected]]` and `connections: [<cluster connection>]`, which writes a kubeconfig and sets `KUBECONFIG`. Helm has no builtin: run it in a cloud job. |
| `webfactory/ssh-agent`, `appleboy/ssh-action`, `appleboy/scp-action` | `ssh-keys: [<key name>]` (the key's owner turns on **Use in CI jobs**) or a lent SSH host connection, and `tools: [builtin:[email protected]]` (add `builtin:[email protected]` for `scp`). |
| `amondnet/vercel-action` | `tools: [builtin:vercel@65]`, `VERCEL_TOKEN` from a secret in `env:`, then `vercel deploy --prod --yes`. |
| `cloudflare/wrangler-action` | `tools: [builtin:wrangler@4]`, `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in `env:`, then `wrangler deploy`. |
| `neondatabase/create-branch-action` | `tools: [builtin:neon@9]`, `NEON_API_KEY` in `env:`, then `neon branches create ...`. |
| `docker/login-action`, `docker/build-push-action`, `docker/setup-buildx-action` | A build job: `cloud: aws/build` (CodeBuild), `gcp/build` (Cloud Build), `azure/build` (ACR Tasks) or `docker/build` (your own Docker host), with `docker build` and `docker push` in `run:`. Write the image digest to an output for the deploy job. |
## Testing and reporting
| Action | Replacement |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `codecov/codecov-action` | Upload with Codecov's CLI in the script (`npx`), `CODECOV_TOKEN` in `env:`. |
| `dorny/test-reporter`, `mikepenz/action-junit-report` | Keep the JUnit file with `downloads: { paths: [junit.xml], when: always }`. The run page and the GitHub check show each job's result. |
| `microsoft/playwright-github-action` | Browsers do not run in a job. Run end-to-end browser tests as a cloud job with an image that has the browsers. |
# What changes, and what does not move
Check each migrated job against this list before handing back.
## Defaults that differ
- **Timeout: 10 minutes**, not 6 hours. Set `timeout:` (`30m`, `2h`, at most `6h`) on any job that can run longer. A job that prints nothing and uses no CPU for 5 minutes is stopped as stuck.
- **Memory: 2 GiB** per job, up to `16GiB` with `memory:`. Large test suites and bundlers usually want `4GiB` or more; a job over its limit fails and its report says so.
- **CPU: a share of one vCPU** per job, not a machine of its own, and its programs are told 1 CPU (`nproc`, `os.cpu_count()`, `os.availableParallelism()`), so anything that sizes its workers from the CPU count (`pytest -n auto`, Vitest, Jest, `cargo`, `make -j$(nproc)`) runs one. A job that builds or tests in parallel (`make -j`, `go test -p`, `cargo`, a test runner's workers) gets `cpus:` (1 to 64), whether or not it ran on a larger runner, and is then told that many: `-n auto` and `nproc` follow it, and a hard-coded count becomes `$IWCI_CPUS`. Billing follows: a job with `cpus: 4` is charged four vCPUs for as long as it runs.
- **One environment per job.** There is no image with everything installed. Pick the `using:` environment for the job's language, and add other tools with `tools: [builtin:...]`.
## Scripts
- **Pipes do not fail the script.** A pipeline reports only its last command's status, even with `pipefail`: `npm test | tee log.txt` passes when the tests fail. Write `npm test > log.txt 2>&1` and print the file afterwards, or drop the pipe.
- **No terminal.** Standard input is empty and nothing is a TTY, so prompts fail and colour is usually off. Pass non-interactive flags (`--yes`, `-y`, `--ci`).
- **No `sudo` and no `apt-get`.** The job's file system is its own; install command-line tools with `npm i -g` or `pnpm add -g` (pinned) in `env:bash-node`, or `pip install` in `env:python`. A system package means a cloud job.
- **Hard links work within the job's own files** (`ln`, `fs.linkSync`, `os.link`): the names are one file, with one inode number and a link count. A link to or from another mount (`/usr/local/bin`, the run's scratch directory) fails with `EXDEV`, which programs that link fall back to copying on, and caches, artifacts and `changes:` keep each name as a file of its own. Symbolic links work.
## The checkout
- **No `.git`.** Jobs get the commit's files, not a repository: `git log`, `git describe`, `git diff origin/main` and tools that read history (changelog generators, semantic-release) fail. Clone in the script when history is needed, with `github-token: { contents: read }` for a private repository: `git clone --depth=50 "https://github.com/$GH_REPO.git" /tmp/repo`.
- **No submodules** and **no Git LFS content** (a file kept in LFS is its pointer). Fetch them in the script if a job needs them.
- What changed in the push is still known: use `paths:` on a job or `changed('glob')` in `if:` instead of `git diff`.
## Languages and native code
- **Node 24 only** on the runner (`env:bash-node@24`). A matrix over older Node versions becomes one job on 24, or cloud jobs for the others.
- **Native Node addons** load only when the package ships a WebAssembly (`wasm32-wasi`) build: Vite 8, Vitest, Rolldown, tsdown, oxc and the Astro compiler do. A dependency with only native binaries (some image, database and crypto libraries) needs a cloud job.
- **npm**: `deps: [npm]` installs from `package-lock.json` (lockfile version 2 or 3; a version 1 lockfile needs `npm install --lockfile-version 3` with npm 7 or later). Do not keep `npm ci` in a job: npm refuses packages whose `os` list leaves out the job's platform. `npm run` scripts find their dependencies' commands in `node_modules/.bin`, as on a developer's machine.
- **Yarn lockfiles** are not installed by `workspace.deps` (it supports pnpm, npm, Bun, Go, Cargo, pip, Composer and Bundler). Convert with `pnpm import` and commit `pnpm-lock.yaml`.
- **Bun** is `tools: [builtin:bun@1]` (Bun 1.4.4, whose newest build `@1`, `@1.4` and `@1.4.4` all pick; `@1.3` and other versions do not exist), the real Bun run natively in a sandbox. Use it with `using: env:bash@5`, which has no `node`, so Bun runs package scripts, `#!/usr/bin/env node` bins and install scripts itself, and install in the job with `bun install --frozen-lockfile`, which gets the Linux builds of turbo, oxlint, esbuild and the like. `deps: [{ bun: { native: true } }]` instead installs once per lockfile, cached and checked against its hashes, with `node_modules/.bin` and the Linux builds of turbo and oxlint, so `bunx turbo` and `bun run lint` work over it; it runs no install scripts, and esbuild, Rollup and Lightning CSS are their slower WebAssembly builds there. Without `native: true` it has no native packages, and Bun fails over it. In `env:bash-node@24`, `node` is a WebAssembly Node (`process.platform` is `wasi`), and Bun runs install scripts with it, so a `postinstall` that loads a native package fails there. In `env:bash@5`, a file run with `bun run ./script.mts` that spawns `node` finds no `node`: link one, `ln -s "$(command -v bun)" /tmp/bin/node`, with `/tmp/bin` first on `PATH`. `env:bash@5` has no `npm`; use `bunx npm@11`. `cache:` `/root/.bun/install/cache`, keyed on `hashFiles('bun.lock')`, saves the downloads.
- **Ruby** (`env:[email protected]`, `@4.0`): gems with C extensions install only through `deps: [bundler]`, which has builds of the ones a `rails new` app locks (nokogiri, sqlite3, puma, bootsnap and the rest) at those versions; another one, or another version, fails the install naming the versions that have a build, and `- bundler: { without-extensions: [name] }` installs a gem the jobs never load without it. A Rails app needs `gem "tzinfo-data"` on every platform (no zoneinfo here; drop `platforms:`, then `bundle lock`) and `gem "selenium-webdriver", require: false` (it refuses to load here). No `fork`: Rails tests run in one process (`PARALLEL_WORKERS=1` is set), and system tests need a browser, so a cloud job. `bundle exec ruby` loses the bundle's settings; use `bin/rails`, `bundle exec rake` or `ruby -rbundler/setup`.
- **Rust**: `using: env:bash@5` with `tools: [builtin:[email protected]]` (rustc, cargo, rustdoc, rustfmt, clippy, and GCC 13 with binutils for linking and for build scripts that compile C), and `workspace: { deps: [cargo] }` so crates come from `Cargo.lock` with no network. Give build and test jobs `memory: 4GiB` to `8GiB` (the `target/` directory counts). The builtin's version is the toolchain: `rust-toolchain.toml` is ignored and there is no `rustup`, so `rustup target add` and cross builds need a cloud job, as do crates that link a system library (OpenSSL without `vendored`) or need a C++ compiler. A built binary runs from the script as on Linux. It needs a runner with the native sandbox; a job on one without fails saying so.
- **Native binaries from npm packages** (Turborepo's `turbo`, sherif, and others that pick a per-platform optional dependency): `workspace: { deps: [{ pnpm: { native: true } }] }` (or `bun`) and `tools: [builtin:[email protected]]` on the `env:bash-node@24` job that runs them. Without both, the binary is missing or does not start. TypeScript 7 (`tsc` from `typescript@7`) works the same way. A tool that loads a native Node addon in-process with no WebAssembly build (oxlint) runs under Bun instead: `tools: [builtin:[email protected], builtin:[email protected]]` and `bun node_modules/oxlint/bin/oxlint`. A project that pins pnpm 12 (`packageManager` or `engines.pnpm`) switches to it in a job with `native: true` on its pnpm dep and `tools: [builtin:[email protected]]`.
- **Java, .NET, Swift**: no environment yet. Cloud jobs.
## Services and containers
- **Postgres** (`env:postgres@18`, PGlite: many connections, `pgcrypto`) and **ClickHouse** (`env:[email protected]`) run as `services:` inside the job. Postgres runs one transaction at a time and shares `SET`, advisory locks and `LISTEN` across connections, so tests that depend on concurrent transactions need a real Postgres in a cloud job.
- **Any other service image** (Redis, MySQL, Elasticsearch, a vendor emulator): start it in a cloud job (`cloud: { provider: docker, kind: container }` or a VM with Docker), or, when it is a Node or Python program, as a `services:` entry running that program.
- **No Docker on the runner.** `docker build`, `docker run` and `docker compose` go in a cloud job: `kind: build` for building and pushing images, `kind: vm` or `container` for running them.
- **No browsers.** Playwright, Cypress and Puppeteer tests run as cloud jobs.
## Events and features with no equivalent
Keep these on GitHub Actions, or say what the user could do instead:
- Triggers other than push, pull request, schedule and manual: tags, releases, `workflow_run`, `issues`, `issue_comment`, `pull_request_target`, `repository_dispatch`, `merge_group`.
- macOS and Windows runners.
- GitHub Pages deployment through `actions/deploy-pages` (deploying the built site with a CLI from a job works).
- Job-level `concurrency`, `continue-on-error`, `fail-fast`, matrix `include:`.
- `environment:` protection rules and required reviewers. CI access limits what each repository and branch may use, and a fork's pull request waits for a maintainer's approval.
- OIDC (`id-token: write`) to a cloud. Lend the cloud's connection instead (`connections:`), which needs no stored key either.
# GitHub Actions to Infrawrench CI: key by key
Unknown keys are an error, so leave out anything without a row here rather than carrying it over.
## Workflow level
| GitHub Actions | Infrawrench CI |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `name:` | `name:` (required) |
| `on: push` with `branches`, `paths` | `on: { push: { branches, paths } }` |
| `branches-ignore`, `paths-ignore` | The same list with each pattern quoted and prefixed with `!`: `paths: ["!docs/**"]` |
| `on: pull_request` with `branches`, `paths` | `on: { pull-request: { branches, paths } }`. `types:` has no equivalent; every opened or updated pull request runs. |
| `on: schedule` with `cron` | `on: { schedule: [{ cron: "0 3 * * *" }] }`, UTC, runs the default branch's head |
| `on: workflow_dispatch` with `inputs` | `on: { manual: { inputs } }`: types `string`, `boolean`, `choice` (with `options`), `number` |
| `on: push: tags`, `release`, `workflow_run`, and others | No equivalent: tag pushes start nothing. Keep the workflow on GitHub Actions, or start it by hand. |
| `env:` at the top | No top-level `env`. Repeat it on each job, or share it with a YAML anchor (`env: &env {...}`, then `env: *env`). |
| `concurrency:` | `concurrency:` at the top only, `{ group, cancel-in-progress }`. A job-level `concurrency` has no equivalent. |
| `permissions:` | Per job, `github-token: { contents: write, pull-requests: write }`. No token at all unless a job asks. |
| `defaults.run.working-directory` | `cwd:` on each job, absolute: `/app/<dir>` |
| `defaults.run.shell` | Always bash. A Python or Node step becomes `python - <<'EOF'` or `node -e` in the script, or a script file it runs. |
## Job level
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `runs-on: ubuntu-*` | Nothing: the job runs on the runners. Choose `using:` for the language instead. |
| `runs-on:` a larger runner (`ubuntu-latest-8-cores`, `ubuntu-24.04-16core`) | `cpus: N` (1 to 64), the runner's vCPU count, so the job holds whole vCPUs rather than a share of one. Its scripts read the number from `$IWCI_CPUS` (`-j"$IWCI_CPUS"`). Billed at those vCPUs. Size `memory:` separately. |
| `runs-on: self-hosted` or a label | `cloud:` on a connected account (`aws/vm`, `gcp/container`, `docker/container`, `kind: host` for an existing machine over SSH). |
| `steps:` | One `run: \|` script, the `run` steps joined in order. Each `uses:` step is replaced as in `actions.md`. |
| `needs:` | `needs:` |
| `if:` | `if:` on the job. Functions: `success()`, `failure()`, `always()`, `contains`, `startsWith`, `endsWith`, `changed('glob')`. No `cancelled()`, `format`, `toJSON`, `fromJSON` or `hashFiles` here. |
| step-level `if:` | A shell `if` in the script, or a separate job with its own `if:`. |
| `strategy.matrix` | `matrix: [a, b]` (read as `${{ matrix }}`) or named axes `{ node: [22, 24], os: [x] }` (read as `${{ matrix.node }}`), with `exclude:`. Up to 64 entries. No `include:`: write those as separate jobs. |
| `fail-fast`, `max-parallel` | Leave out. Every entry runs; the runner schedules them. |
| `continue-on-error` | Leave out. Let the dependents run anyway with `if: always()`, and read `${{ needs.<job>.result }}`. |
| `timeout-minutes: 30` | `timeout: 30m`. The default is 10 minutes (GitHub's is 6 hours), the most 6 hours. Set it on anything that can take longer than 10 minutes. |
| `env:` | `env:`. `${{ secrets.X }}` works only here. |
| `outputs:` + `$GITHUB_OUTPUT` | `outputs: [name]` and `echo "name=value" >> "$IWCI_OUTPUT"`. Writing an undeclared name fails the job. A matrix job cannot have outputs. |
| `services:` (Docker images) | `services:` with `env:postgres@18` (`run: pglite-server`) or `env:[email protected]`, reached as `postgres:5432`. Other images: see `limits.md`. |
| `container:` | No equivalent on the runner. Choose the matching `using:` environment, or make it a cloud job with `image:`. |
| `environment:` | No equivalent. What a branch may use is set in **CI access** (connections, SSH keys and resources per repository and branch). |
| `uses: ./.github/workflows/x.yml` | Inline the called workflow's jobs into this pipeline. |
## Expressions
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------- | --------------------------------------------------------------------- |
| `${{ github.sha }}` | `${{ commit.sha }}` (`${{ commit.short-sha }}` for the short form) |
| `${{ github.ref_name }}`, `github.head_ref` | `${{ commit.branch }}` |
| `${{ github.event_name }}` | `${{ event }}`: `push`, `pull-request`, `schedule` or `manual` |
| `${{ github.event.pull_request.number }}` | `${{ pull-request.number }}` (empty unless a pull request) |
| `${{ github.workflow }}` | `${{ pipeline.name }}` |
| `${{ github.repository }}` | `$GH_REPO` in a job with `github-token:`; otherwise write it out |
| `${{ inputs.x }}` / `${{ github.event.inputs.x }}` | `${{ inputs.x }}`, never inside `run:`: map it in `env:` and quote it |
| `${{ vars.X }}` | `${{ vars.X }}` |
| `${{ secrets.X }}` | `${{ secrets.X }}`, in `env:` values only |
| `${{ needs.a.outputs.b }}`, `${{ needs.a.result }}` | The same |
| `${{ matrix.x }}` | The same; a one-axis list is `${{ matrix }}` |
| `${{ env.X }}` | `$X` in the script |
| `${{ runner.os }}`, `${{ runner.temp }}` | Always Linux-like; use `/tmp` |
| `${{ hashFiles('x') }}` | Only in a `cache:` `key` or `restore-keys` |
## Environment variables in scripts
| GitHub Actions | Infrawrench CI |
| --------------------------- | ---------------------------------------------------------------------------------- |
| `GITHUB_SHA` | `IWCI_COMMIT` |
| `GITHUB_REF_NAME` | `IWCI_BRANCH` |
| `GITHUB_WORKSPACE` | `/app` (the clone, and every job's default working directory) |
| `GITHUB_OUTPUT` | `IWCI_OUTPUT` |
| `GITHUB_ENV`, `GITHUB_PATH` | Not needed: the job is one script, so `export` and `PATH=...` carry to later lines |
| `GITHUB_STEP_SUMMARY` | No equivalent; keep a report with `downloads:` |
| `GITHUB_TOKEN` | Set only in a job with `github-token:` (also `GH_TOKEN`) |
| `RUNNER_TEMP` | `/tmp`. Files shared by the run's jobs go in `/tmp/workflow` (`$IWCI_SCRATCH`) |
| `CI` | `CI=true` |
# Monorepos: from a few big jobs to a job per package
On GitHub Actions every job pays for its own machine, checkout and install, so monorepo workflows usually have a handful of jobs that each run one task across every package (`turbo run test`, `nx affected -t lint`, `pnpm -r typecheck`). In Infrawrench CI a job costs none of that, so write one job definition per task and let it expand to one job per workspace package. Each package's job is its own row and log in the run, and the task cache skips the ones a change cannot affect.
## The shape
```yaml
name: Test
on:
push:
branches: [main]
pull-request: {}
workspace:
deps: [pnpm]
jobs:
build:
packages: { has-script: [build] }
needs: ["^build"]
using: env:bash-node@24
run: pnpm run build
artifacts: [dist]
task-cache: true
typecheck:
packages: { has: [tsconfig.json] }
needs: ["^build"]
using: builtin:[email protected]
args: [--noEmit]
task-cache: true
test:
packages: { has-script: [test] }
needs: [build]
using: env:bash-node@24
run: pnpm test
task-cache: true
memory: 4GiB
```
- **`packages:`** expands a job over the workspace (`pnpm-workspace.yaml`, or `workspaces` in the root `package.json`). `true` is every package. Narrow it with `only:` (globs over directory or name, `!` excludes), `has:` (files the package has), `has-script:` (scripts it defines) or `scripts:` (a glob its script's command must match). Each job runs in its package's directory and reads `${{ package.name }}` and `${{ package.dir }}`.
- **`needs: ["^build"]`** waits for `build` in each package this one depends on, like Turborepo's `dependsOn: ["^build"]`. `needs: [build]` in a `packages:` job means the same package's `build`. A plain job that needs a `packages:` job waits for all of its packages.
- **`artifacts:`** in a `packages:` job are relative to the package, so each package's `dist/` reaches the jobs that depend on it.
- **One slow package** can be split further: give it its own job with `only:` and a `matrix:` of shards, and leave the rest alone.
## The task cache
`task-cache: true` skips a job when nothing it reads has changed since a run of it passed, and hands on that run's log, outputs and artifacts as if it had run. Use it on every deterministic job: builds, type checks, tests, linters, formatters.
```yaml
task-cache:
inputs: [src/**, tsconfig.json, "!src/**/*.md"] # relative to the package; default: every file in it
root-inputs: [tsconfig.base.json, .eslintrc.cjs] # relative to the repository root
artifacts: false # see below
```
- **The key** covers the job's definition, the exact version of every tool and environment it uses, the lockfiles, the files its inputs match, and the bytes of every artifact it is handed. A job downstream of a change reruns only when what it is handed actually changed.
- **Name every file outside the package that a job reads** in `root-inputs:` (shared tsconfig, lint and test config, fixtures). A file the key leaves out can change without rerunning the job.
- **`artifacts: false`** leaves handed-on artifacts out of the key, for a job that only passes them along (a bundler that keeps workspace dependencies external), so a change at the bottom of the graph does not rebuild everything above it. Only when the job's result does not depend on them.
- **Cannot be task-cached:** a job that reads a secret, is lent anything (`connections:`, `ssh-keys:`), has `github-token:`, keeps `downloads:` or runs on a cloud account. Keep those jobs small and put them after the cached ones.
- A cache hit is not billed, takes no slot or memory, and a run where every job hits never installs dependencies. Pull requests keep their own results: nothing a pull request saves is used on the default branch.
## Translating common commands
| GitHub Actions step | Infrawrench CI |
| --------------------------------------------- | ------------------------------------------------------------------------------------- |
| `turbo run build` / `nx run-many -t build` | A `build` job with `packages:`, `needs: ["^build"]`, `artifacts: [dist]` |
| `turbo run test --filter=...[origin/main]` | A `test` job with `packages:` and `task-cache: true`: the cache does the filtering |
| `nx affected -t lint` | A `lint` job with `packages: { has-script: [lint] }` and `task-cache: true` |
| `pnpm -r --parallel typecheck` | A `typecheck` job with `packages:` and `using: builtin:[email protected]` |
| `pnpm --filter web test` | A job with `packages: { only: [apps/web] }`, or a plain job with `cwd: /app/apps/web` |
| A `paths-filter` step choosing which jobs run | `paths:` on each job, or `if: changed('apps/web/**')` |
Keep `turbo` or `nx` out of the jobs once they are split: each job runs one package's script directly, and the task cache replaces their caches.
git.infrawrench.com and Infrawrench CIWorks in a repository on git.infrawrench.com the way its reviewers read it: records the work on each push, answers what they send back, and writes CI jobs that put notes on the branch's page.
Install: run in your repository
for f in SKILL.md references/ci-notes.md references/connect.md references/trace.md; do curl -fsSL --create-dirs -o ".claude/skills/infrawrench-git/$f" "https://infrawrench.com/skills/infrawrench-git/$f"; done
.claude/skills/infrawrench-git/SKILL.md
---
name: infrawrench-git
description: Work in a Git repository hosted on git.infrawrench.com (its remote is git.infrawrench.com) and with Infrawrench CI (.infrawrench/ci/*.yml). Use when writing or reviewing code on a branch there, when the infrawrench-git MCP server is connected or should be, when asked to record a trace, answer reviewer instructions or report findings, or when writing a CI job that should leave must-fix, should-fix, note, doubt, decision, step or evidence notes on a branch's page.
---
# git.infrawrench.com and Infrawrench CI
git.infrawrench.com is a Git forge where a branch is reviewed as a record of versions. Every push to a branch that is not the default branch makes a version, and the branch's page shows what there is to read about that version before its code: what the agent that wrote it recorded (its trace), what reviewers and CI jobs found (findings), and what reviewers sent back (instructions). There are no pull requests to open: a branch gets its page at its first push.
You are in such a repository when `git remote -v` names `git.infrawrench.com`. The user-facing guides are https://infrawrench.com/docs/features/git-branches and https://infrawrench.com/docs/features/git-agents-and-mcp. Read the files under `references/` when a step below says so.
## Connect
The forge's MCP server is `https://git.infrawrench.com/mcp`, usually added under the name `infrawrench-git`. If its tools (`record_trace`, `get_branch`, ...) are not available, tell the user how to add it: `references/connect.md` has the command for Claude Code, Codex and Cursor. Call `whoami` once when you are unsure whether you can write. Tools take a repository as `owner/name` and a branch by its name.
## When you write code on a branch
1. **Start.** Given a task with no branch yet, call `start_work` with the ask: it makes the branch and its page, as a draft. When the task is one of the repository's open issues, pass its number as `issue` instead: the page takes the issue's title and description and closes the issue when it is merged into the default branch. Then `git fetch origin && git switch <branch>`. If a branch already exists, check it out and call `get_branch` to see where it stands.
2. **Record as you work**, with `record_trace`, not only at the end. `references/trace.md` has the kinds and their fields. In short: one `ask`, a `step` for each piece of work, a `decision` when you chose between alternatives, `evidence` whenever you ran a check (the command, its exit code, the lines of output that show the result, failures too), and a `doubt` for anything you are unsure of, skipped or could not verify. Reviewers read doubts first.
3. **Record before you push.** Entries wait on the branch and are attached to the version the next push makes. Then `git push`. A `secret_files_pending` failure kept nothing: send the same entries again in a minute.
4. **After a push**, call `get_branch` for the branch's state, `list_instructions` for what reviewers sent back and `list_findings` for what reviewers and CI found.
5. **Answer instructions.** For each one you take on: `mark_instruction_delivered`, do the work, record it, `mark_instruction_answered`, then push. If you decide not to do what was asked, record why (a `decision` or a `doubt`) and still mark it answered. An instruction whose `source` is `conflict` means the branch no longer merges cleanly into its base: fetch the base, rebase onto it (or merge it in), resolve every conflict it lists, run the checks again, and push (`git push --force-with-lease` after a rebase). The forge sends one by itself when a push leaves the branch conflicting, and marks it answered when a later push resolves it. An instruction whose `source` is `ci_failure` lists the checks that failed on the branch's newest commit, with a link to each run (`GET /api/repos/<owner>/<repo>/ci/runs/<run id>`, with the Git credential your machine has for the forge as a Bearer token, has every job's output; the branch token cannot read it). Read the output and decide: if the branch caused it, fix it, run the check, and push; if it did not (a flaky test, an outage, a failure the base has too), change nothing, record a `decision` saying why, and mark it answered. The forge sends one by itself once a commit's checks have settled with a failure, and marks it answered when a later push passes.
6. **Hand it over when it is done.** The branch's page is a draft until it is marked ready for review. After your last push, call `mark_ready_when_checks_pass`: the page leaves draft by itself the moment every check on its head has passed (and every check the base branch requires has reported), or now if they already have. A failing check keeps it a draft and the request waits for your fix. `enabled: false` withdraws it, and a person who marks the page by hand cancels it. It never merges.
7. **Fix what must be fixed.** An open `must_fix` finding holds the branch's merge until it is fixed, dismissed by a person, or overridden by an administrator. You cannot dismiss or override one: fix it and push, or record a `doubt` saying why you think it is wrong.
## When you review a branch
Read the change with `get_branch` and `get_version_diff`, then call `report_finding`: a `severity` (`must_fix` only for what must not merge, `should_fix`, `note`), a short `title`, a `body`, the `path` and lines, and `evidence`. Set `complete: true` when the list is everything you find on that version, so your earlier findings that are not in it are marked fixed. Report under a `reviewer` name of your own (`claude-review`).
## Images and videos
A trace entry, a finding and an ask are Markdown, and can show a screenshot or a short recording (a UI before and after a change, a failing test's screen). Call `upload_media` with the file as base64 (3 MB at most) and put the `markdown` it answers in what you write next. For a larger file or a video, post the bytes to the repository's upload address with the same token: `curl -fsS --data-binary @shot.png -H "Authorization: Bearer <token>" "https://git.infrawrench.com/<owner>/<name>/uploads?name=shot.png"` answers the same JSON. Images: PNG, JPEG, GIF, WebP, AVIF up to 10 MB; videos: MP4, WebM, QuickTime up to 90 MB. Never upload a screenshot that shows a secret.
## Infrawrench CI
A repository's pipelines are the YAML files in `.infrawrench/ci/`. They run on every push and on each branch page's new version, and their results are on the branch's **Checks** tab. A pipeline has `name:`, `on:` (`push`, `pull-request`, `schedule`, `manual`) and `jobs:`; a job is one script (`run:`) in an environment (`using: env:bash-node@24`) or on a Linux machine (`platform: linux`). Do not guess the rest: the guide is https://infrawrench.com/docs/features/ci and every key is in `ci-runner/README.md` of the Infrawrench repository.
A CI job can put notes on the branch's page by printing lines, with no token and no API call:
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
`::must-fix`, `::should-fix` and `::note` become findings; `::doubt`, `::decision`, `::step` and `::evidence` become trace entries. Read `references/ci-notes.md` before writing a job that prints them: it has the parameters, the escapes, the limits, what a passing job marks fixed, and a job that turns a linter's JSON report into notes. Use this when a check already runs in CI (a linter, a type checker, a test report); use `report_finding` when you are the reviewer yourself.
## Secret files
A repository may have secret files (`filter=iwsecret` in `.gitattributes`): what is committed is a pointer, or a YAML or JSON skeleton whose values are `"iwsecret:1:..."` tokens. `get_branch` and `start_work` list a branch's secret files in `secretFiles` with `secretRules`; `secretFilesPending` means the forge was still listing them, so call `get_branch` again in a few seconds. When there are any, run `infrawrench git secret install` after checking the repository out, so they are readable in your checkout (if the person you work for may read them) and uploaded when you push. A file that stays a pointer is one you cannot read: leave it as it is.
- You may read and edit these files in your checkout.
- Never put a value from them into a trace entry (asks, steps, decisions, evidence, doubts), a finding, an instruction answer, a commit message, a branch's title or description, or command output you record. Refer to a secret by its path and key name: "changed `database.password` in `config/prod.yaml`".
- Never print one in a command whose output you record as evidence.
- Never copy one into a file that is not secret. The forge refuses an agent's push that does.
- When reviewing, a pointer or a token is not a placeholder or a bug: it is how the file is committed.
- A CI job that needs one names it in `secret-files:` (paths written out, at most 32). It gets the file only on a branch the repository lends secret files to CI on; turning that on is an administrator's choice in the repository's settings, never yours.
## Never
- **Never put a secret in a trace entry, a finding or a CI note.** Tokens, keys and passwords are masked before anything is stored, but masking recognises shapes and names, not every secret, and everyone who can read the repository reads the notes. Leave them out, and do not print what a secret protects.
- **Never report as one of the forge's own reviewers.** `general`, `security`, `tests`, `terraform` and `intent` are refused, and so is any name that starts with `ci:`, which is how Infrawrench CI names a job's findings (`ci:<pipeline>/<job>`). An agent kind of `ci` is refused for a trace in the same way.
- **Never mark an instruction answered for work you did not do**, and never push to the default branch to get around a branch's page.
- **Do not invent pipeline keys or note parameters.** An unknown parameter makes a note command malformed: it is ignored, and the job's reason on the run's page says how many were.
# Notes from a CI job
A job of a repository on git.infrawrench.com leaves notes on the branch page of the commit it ran on by printing one line per note, to its output or its errors. Nothing else is needed: no token, no API call, no tool.
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
The line starts at its first character with `::`, the command, a space and the parameters when there are any, `::`, then the message. An indented line, or a command in the middle of a line, is not read.
## Commands
| Command | Becomes |
| -------------- | ------------------------------------------------------------------ |
| `::must-fix` | A finding that must be fixed. While it is open it holds the merge. |
| `::should-fix` | A finding that should be fixed. |
| `::note` | A finding that is a note. |
| `::doubt` | A trace entry of kind `doubt`. |
| `::decision` | A trace entry of kind `decision`. |
| `::step` | A trace entry of kind `step`. |
| `::evidence` | A trace entry of kind `evidence`. |
There is no `::ask` and no trace `note`: `::note` is the finding. Other names after `::` (`::group::`, `::error`) are other tools' commands and are left alone, so a typo in a command's name is silently not a note.
## Parameters
| Parameter | Value |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | A path from the repository's root (`src/db.ts`). Not absolute, no `..`. Left out, the note is about the whole change. |
| `line` | The line, from 1, in the file as it is at the run's commit. Needs `file`. |
| `end_line` | The last line of a range. Needs `line`, and is not before it. |
| `title` | A finding's title (up to 200 characters), or a bold first line on a trace entry. Without one, a finding's title is its message's first line. |
| `needs_code` | `true` or `false`: show the lines under the note's text. Left out, it is `true` when there is a `line`. |
Parameters are separated by commas, each given once, in any order. All are optional. A finding with a `title` may have an empty message; a trace entry needs a message.
## Escapes
| Write | For |
| ----- | ------------------------------------------ |
| `%25` | `%` |
| `%0A` | A line break (`%0D` for a carriage return) |
| `%3A` | `:` in a parameter's value |
| `%2C` | `,` in a parameter's value |
Escape `%` first, then the others, whenever the text comes from a tool's output. A message needs only `%25`, `%0A` and `%0D`; a parameter's value needs all of them.
## What happens to them
- **Where.** On the open branch page of the run's commit, on the version that commit's push made. A run on a branch with no open page (the default branch, a schedule) leaves nothing, and so does a run of a commit the branch has been force pushed past.
- **Findings** are reported by the reviewer `ci:<pipeline>/<job>`, with a link to the line of the job's log that printed them.
- **The same finding on the next push is the same finding.** It is told apart by job, `file` and title, never by line. So keep titles stable: use the rule's id (`no-explicit-any`), not a sentence with a line number or a count in it. A finding a person dismissed stays dismissed.
- **A passing job marks fixed** what it reported before and did not print this time. A failing job fixes nothing, so a job that reports and then fails keeps its findings open until a later run passes without them.
- **Trace entries** of a job are replaced when the job runs again on the same commit. A run of a branch proposed from a fork leaves findings only.
- **A must-fix** holds the merge like any must-fix, and is sent to the agent that writes the branch as an instruction.
## Limits
- 100 notes per job, 1,000 per run. Print the worst first when a tool can report more.
- A message is at most 8 KiB after its escapes are read; a `file` at most 1,024 characters.
- A command over a limit, or a malformed one (a parameter not in the table, a `line` that is not a number, a `file` outside the repository, no message), leaves no note. The job's reason on the run's page counts them: `2 note commands ignored (2 malformed).` Check it after the first run of a new job.
## Secrets
The commands are read from the run's log as it is stored, where the organization's secrets are already `***`, and each note is masked again by shape before it is kept. Everyone who can read the repository reads the notes, so never print a secret, and do not print what one protects (a customer's record, a private URL).
## A linter's JSON as notes
On a Linux machine (`platform: linux`), whose image has `jq`:
```yaml
name: lint
on:
pull-request: {}
jobs:
eslint:
platform: linux
run: |
npm ci
status=0
npx eslint . --format json --output-file eslint.json || status=$?
jq -r --arg root "$PWD" '
def esc: gsub("%"; "%25") | gsub("\r"; "%0D") | gsub("\n"; "%0A");
def param: esc | gsub(":"; "%3A") | gsub(","; "%2C");
.[]
| (.filePath | ltrimstr($root + "/")) as $file
| .messages[]
| (if .severity == 2 then "must-fix" else "should-fix" end) as $command
| (if .line then ",line=\(.line)" else "" end) as $line
| "::\($command) file=\($file | param)\($line),title=\(.ruleId // "eslint" | param)::\(.message | esc)"
' eslint.json
exit "$status"
```
In a sandboxed environment (`using: env:bash-node@24`), which has no `jq`, the same with Node:
```yaml
jobs:
eslint:
using: env:bash-node@24
run: |
status=0
pnpm exec eslint . --format json --output-file eslint.json || status=$?
node -e '
const esc = (s) => String(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
const param = (s) => esc(s).replace(/:/g, "%3A").replace(/,/g, "%2C");
const root = process.cwd() + "/";
for (const file of JSON.parse(require("fs").readFileSync("eslint.json", "utf8"))) {
const path = file.filePath.startsWith(root) ? file.filePath.slice(root.length) : file.filePath;
for (const m of file.messages) {
const command = m.severity === 2 ? "must-fix" : "should-fix";
const line = m.line ? `,line=${m.line}` : "";
console.log(`::${command} file=${param(path)}${line},title=${param(m.ruleId ?? "eslint")}::${esc(m.message)}`);
}
}
'
exit "$status"
```
Both print the notes whether or not the linter passed, then end with the linter's own status, so the job still fails when it should. Write the report to a file and read the file: in a sandboxed environment a pipe reports only its last command's status.
# Connecting the forge's MCP server
The server is one address, `https://git.infrawrench.com/mcp`, over Streamable HTTP. A client that supports OAuth needs only the address: the first call opens the user's browser on git.infrawrench.com to sign in and allow the application. Adding a server is the user's to do; give them the command for their client.
## Claude Code
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp
```
Then `/mcp` inside Claude Code, pick `infrawrench-git` and sign in.
## Codex
```sh
codex mcp add infrawrench-git --url https://git.infrawrench.com/mcp
codex mcp login infrawrench-git
```
## Cursor
In `~/.cursor/mcp.json`, or `.cursor/mcp.json` in the project:
```json
{
"mcpServers": {
"infrawrench-git": {
"url": "https://git.infrawrench.com/mcp"
}
}
}
```
## Without a browser
A client that cannot open a browser sends a personal access token (`iwg_...`, made under **Settings > Access tokens** on git.infrawrench.com, with the `repo:write` scope to record traces and report findings) in the `Authorization` header:
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp \
--header "Authorization: Bearer $IWG_TOKEN"
```
Read the token from the environment. Never write it into a file that is committed, a trace entry or a note.
## A token for one branch
An agent that works on one branch does not need a person's whole access. Ask the forge for a token for that branch, with any credential that can write the repository (a personal access token, an organisation's API key):
```sh
curl -fsS -X POST -H "Authorization: Bearer $IWG_TOKEN" \
https://git.infrawrench.com/api/repos/<owner>/<repository>/branches/<branch>/agent/token
```
`<branch>` is the branch's name as one URL segment (`work%2Fadd-rate-limits`). The answer is `{ "token", "expiresAt", "branch" }`. The token lasts six hours; ask again for another. Send it as the MCP server's `Authorization: Bearer` header, or to the API.
It records that branch's trace, lists its instructions and marks them delivered and answered, and lists and reports findings on it. It does nothing else: it cannot clone or push, reach another branch or repository, send or withdraw an instruction, or dismiss a finding. With it, `whoami` answers `kind: "agent"` and the `branch`, and `get_branch`, `get_version_diff`, `list_my_branches` and `start_work` are refused.
A thread git.infrawrench.com starts in T3 Code is told to ask for one with the machine's own Git credential and to keep it in a file in the worktree's Git directory. Never print the token, and never put it in a message, a commit or a trace.
## Calling a tool without a client
A session that has not loaded the server's tools can still call them: each call is one `POST` of a JSON-RPC request, and `tools/list` in place of `tools/call` describes every tool.
```sh
curl -fsS https://git.infrawrench.com/mcp \
-H "Authorization: Bearer $INFRAWRENCH_GIT_TOKEN" \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"record_trace","arguments":{"repository":"acme/infra","branch":"work/add-rate-limits","entries":[{"kind":"decision","body":"A token bucket, not a fixed window: bursts are fine here."}]}}}'
```
## What a connection may do
| Scope | Allows |
| ------------ | -------------------------------------------------------------------------------------- |
| `repo:read` | Read the repositories the user can read, with their branches, reviews and traces. |
| `repo:write` | Push, record traces, answer instructions, report findings and start work, as the user. |
A connection never does more than its user can, and never administers a repository. `whoami` says whose credential it is and whether it can write.
## The tools
| Tool | Use |
| ----------------------------- | --------------------------------------------------------------------------------------------------------- |
| `whoami` | Whose credential this is, whether it can write, and the branch of a branch token. |
| `list_my_branches` | Open branches that involve the user and have something new. |
| `get_branch` | A branch's page, state, versions, and how many instructions and findings are open. |
| `get_version_diff` | A version's diff: the whole change, that version alone, or since an earlier version. |
| `record_trace` | Record the ask, steps, decisions, evidence and doubts of the work on a branch. |
| `list_instructions` | What reviewers sent to the agent that writes the branch. |
| `mark_instruction_delivered` | Say an instruction has reached you. |
| `mark_instruction_answered` | Say which version answers an instruction. Left out, it is the next push. |
| `mark_ready_when_checks_pass` | Ask that the branch's draft page be marked ready for review once its checks pass. |
| `list_findings` | What reviewers and CI jobs found on a branch. |
| `report_finding` | Report a reviewer's findings on a version. |
| `start_work` | Create a branch and its page, as a draft, from an ask or an open issue (`issue`), before any code exists. |
# Recording a trace
`record_trace` takes `repository` (`owner/name`), `branch` (not the default branch) and one or more `entries`, in the order they happened. Send several in one call. The branch does not have to exist yet.
## Kinds
| Kind | Record it when |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| `ask` | Once, at the start: what you were asked to do, in the person's words. |
| `step` | After each meaningful piece of work: what you changed and why, with `anchors` to the files. |
| `decision` | You chose between alternatives: what you chose, what you rejected and why. |
| `evidence` | You ran tests, a build, a linter or any check: the command, its exit code, the output. Failures too. |
| `doubt` | You are unsure, skipped something, or could not verify something. Reviewers read these first. |
| `note` | Anything else a reviewer should know. |
## An entry
| Field | Value |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `kind` | One of the kinds above. |
| `body` | Markdown, a few sentences: what and why. At most 32 KB. |
| `anchors` | The files and lines the entry is about: `[{ "path": "src/db.ts", "start_line": 40, "end_line": 48 }]`. Lines are optional. |
| `needs_code` | `true` only when a reader has to see the code at the anchor to understand the entry. Defaults to `true` when a line is given. |
| `evidence` | For `evidence`: `command`, `exit_code`, `output` (an excerpt; past 16 KB its start and end are kept), `ci_run_id` or `url`. |
```json
{
"repository": "acme/infra",
"branch": "feature/rate-limits",
"entries": [
{ "kind": "ask", "body": "Limit sign-in attempts to five a minute per address." },
{
"kind": "decision",
"body": "Counted in Postgres, not in memory: the API runs on several instances.",
"anchors": [{ "path": "src/auth/limits.ts", "start_line": 12, "end_line": 30 }],
"needs_code": false
},
{
"kind": "evidence",
"body": "The new tests pass.",
"evidence": {
"command": "pnpm test src/auth",
"exit_code": 0,
"output": "Tests 14 passed (14)"
}
},
{
"kind": "doubt",
"body": "Addresses behind one proxy share a limit. I did not change how the address is read."
}
]
}
```
## How it reaches the page
- Entries wait on the branch and are attached to the version the branch's **next push** makes. Record first, push after. Entries recorded after a push belong to the next one.
- A branch holds at most 1,000 entries waiting for a push, and entries nobody pushes after are dropped after 30 days.
- A note shows the lines it is about under its text when `needs_code` is true. Most decisions and doubts stand on their own: leave it `false` for those, even when they have an anchor. Every entry with an anchor hangs on its lines in the file's diff either way.
- Recording needs write access to the repository.
## Secrets
Every entry is masked before it is stored: known token formats, private key blocks, passwords in URLs, `Authorization` and `Cookie` headers, values given to names such as `TOKEN` or `PASSWORD`. That catches mistakes; it cannot know a secret that has no shape and no name. Do not paste a command's output without reading it, and never record a secret on purpose.
## Instructions
`list_instructions` lists what is still to do (`queued` and `delivered`). An instruction is a review comment, a finding or a reviewer's own words, written out as it was when sent. For each one: `mark_instruction_delivered` when you take it on, then do the work, record it, and call `mark_instruction_answered` just before you push (leave `version` out and it is tied to the version that push makes). A `must_fix` finding on a branch you are named as the agent of arrives as an instruction on its own, whether a reviewer or a CI job raised it.
Signs in through your browser on first connect (OAuth), with tools for resources, costs, workflows, CI, SQL, SSH, and more.
Skills
Infrawrench CLIInspect accounts, resources, metrics and costs from the terminal with the infrawrench CLI.
.cursor/rules/infrawrench-cli.mdc
---
description: Use the infrawrench CLI to inspect accounts, resources, metrics, and costs from the terminal. Trigger when asked to list or check infrastructure from the shell, script against Infrawrench data (--json), page on-call, or push cost rows.
alwaysApply: false
---
# infrawrench CLI
The Infrawrench desktop app doubles as the `infrawrench` CLI: same local
accounts, same cloud session, same organizations. Enable the shell command
once from the desktop app's sidebar footer, or run `infrawrench cli install`.
For scripting, always pass `--json` — every listing/data command supports it.
Text mode (the default) renders ANSI tables and charts for humans.
## Commands
- `infrawrench` / `infrawrench tui` — interactive dashboard (needs a TTY)
- `login` / `logout` / `whoami` — cloud session (browser PKCE)
- `orgs` — list organizations
- `accounts` — list accounts (local + every org by default)
- `resources --account <id|name> [--type <typeId>]` — list an account's resources
- `resource <id>` — one resource's fields & outputs
- `metrics <id> [--last 6h] [--series cpu] [--local]` — metric charts
- `costs [--last 30d] [--group-by provider|account|service|region|resource]` — org cost graphs
- `costs push --source <name> [--file rows.json]` — push your own cost rows (stdin when no file)
- `page <message> --source <name> [--key k] [--title t] [--cooldown min] [--voice]` — alert on-call
- `page clear --source <name> [--key k]` — drop a page key's cooldown after recovery
- `cli install|uninstall|status` — manage the shell command
## Flags
- `--org <id|name>` or `--local` — scope to one org / the local desktop workspace (mutually exclusive)
- `-a, --account <id|name>` — account for resource commands
- `--json` / `--text` — output mode (mutually exclusive; default text)
- `--last 30m|6h|7d|2w` or `--from` / `--to` — time range for metrics & costs
- `--no-color`, `-v/--version`, `-h/--help`
Exit codes: `0` ok, `1` runtime error, `2` usage error. Errors print as a
single line on stderr.
## Examples
```sh
infrawrench resources --account prod-aws --json | jq '.[].name'
infrawrench metrics res_abc123 --last 6h --series cpu
infrawrench costs --org acme --last 30d --group-by service
echo '[{"amount": 12.5, "service": "ci"}]' | infrawrench costs push --source ci
infrawrench page "db replica lagging" --source poller --key db-lag --cooldown 30
```
## Behavior to know
- While the desktop app is open, the CLI runs read-only against the shared
database, and `login`/`logout` hand off to the app.
- Cloud `resources` listings sync the account first so rows reflect the
provider now; on sync failure the CLI warns on stderr and serves cached rows.
- Bare `infrawrench` without a TTY prints help instead of launching the TUI.
`NO_COLOR` or a non-TTY stdout disables ANSI colors.
Environment files (.infraenv)Writes and fixes a repository's .infraenv, the committed file that says where every environment variable comes from, without ever putting a secret in it.
.cursor/rules/infraenv.mdc
---
description: Create, edit, check and pull .infraenv files, Infrawrench's committed replacement for .env: each variable is a literal, a resource output (resource()) or an organization secret (secret()). Use when asked to set up, migrate or change a project's environment variables or .env file in a repository that uses Infrawrench, to add a database URL or API key to the environment, or to fix `infraenv check` / `infrawrench env check` problems.
alwaysApply: false
---
# Environment files (.infraenv)
A project that uses Infrawrench commits `.infraenv` instead of `.env`. It lists every environment variable and says where its value comes from, so it is reviewed and versioned like code, and it never holds a secret value. `infraenv pull` (the `@infrawrench/infraenv` npm package) or `infrawrench env pull` (the desktop app's CLI) resolves it into a normal `.env` that starts with `# Auto-generated by Infrawrench. Do not edit.` The user-facing guide is https://infrawrench.com/docs/features/env-files. Read the "The .infraenv format" section below before writing anything beyond a simple variable, and the "Converting an existing .env" section below when converting an existing `.env`.
## Rules
- **Never write a secret value into `.infraenv`**, and never copy one out of `.env` into it, a commit message or chat. A secret becomes a `secret("NAME")` reference (an organization secret the user creates in Infrawrench) or a `resource(...)` reference to where it already lives.
- **Never edit the generated `.env`.** Change `.infraenv` and pull again. A `.env` without the generated header is hand-written: do not overwrite it unless the user says so (`--force`).
- **Prefer references by name** (`resource("<plugin>/<type>", "<display name>", "<output>")`). They resolve in whichever organization pulls the file. Pin by id (`resource("<id>", "<output>")`) only when the user wants one exact resource or a name is ambiguous.
- **Do not add `[infrawrench] org`** unless the user asks to pin the file to one organization.
- Keep `.env` (the output) in `.gitignore`.
## Process
1. **Find the file.** `.infraenv` at the repository root (or the one the user names). If there is none, create it with `infraenv check` passing afterwards (see the "Converting an existing .env" section below when a `.env` exists).
2. **Find the values' sources.** With the Infrawrench MCP server connected, `list_env_sources` searches the organization's resources and lists each one's outputs with a suggested variable name; `describe_env_file` checks a draft. Without it, ask the user which resource or secret each variable should come from; do not guess ids.
3. **Write the variables.** Shared values go in `[env]`; what differs per environment goes in `[env.<name>]`, or better, in a substitution: `[vars]` / `[vars.<name>]` plus `${name}` inside the reference, so one line serves every environment. Put a `# <Plugin>: <resource name> (<output>)` comment above each reference.
4. **Check.** Run `infraenv check` (or `infrawrench env check`, or the `describe_env_file` tool). It reports syntax errors with line numbers, references that match nothing or several resources, outputs a type does not have, secrets that do not exist or have no value, and substitutions with no value. Fix every problem; report any that need the user (a secret to create, an account to connect).
5. **For Infrawrench CI**, a job loads the file with `env-file:`; `check_ci_env_file` (MCP) says what each variable would give a job on a given branch and what to grant first. In CI, `secret()` reads the repository's CI secrets, not the organization's.
6. **Pull only if asked.** `infraenv pull [--env <name>]` writes `.env` with the real values. Do not print the values; the commands never do in text mode.
## Commands
| npm package (`npx infraenv` or `node_modules/.bin/infraenv`) | Desktop CLI | What it does |
| ------------------------------------------------------------ | ---------------------------------- | -------------------------------------------------------------------- |
| `infraenv check [--var k=v]` | `infrawrench env check` | What each reference points at, and every problem. Exit 1 on any. |
| `infraenv pull [--env <name>] [--var k=v] [--stdout]` | `infrawrench env pull` | Resolve and write `.env` (mode 0600). Exit 1 if a variable failed. |
| `infraenv install` / `uninstall` / `status` | `infrawrench env hooks install` | Git hooks that pull again when a commit changes `.infraenv`. |
| | `infrawrench env init --from .env` | A new `.infraenv` with one `secret("KEY")` line per `.env` key. |
| `await config()` from `@infrawrench/infraenv` (in code) | | Load `.infraenv` into `process.env` at startup; keeps set variables. |
The npm package reads `INFRAWRENCH_API_KEY` (an `iwk_` key) when it is set, else the key `infraenv login` stored; the desktop CLI uses the desktop app's sign-in. In a third-party CI, set `INFRAWRENCH_API_KEY` and run `npx @infrawrench/infraenv pull --env <name>`; in Infrawrench CI, a job's `env-file:` key loads the file without a key.
## Example
```ini
[vars]
stage = dev
[env]
NODE_ENV = development
# Neon: storefront / dev (Connection string)
DATABASE_URL = resource("neon/neon-branch", "storefront / ${stage}", "connectionString")
STRIPE_SECRET_KEY = secret("STRIPE_SECRET_KEY_${stage}")
[vars.production]
stage = main
[env.production]
NODE_ENV = production
```
## The .infraenv format
A dotenv file with INI sections. Lines before any section belong to `[env]`, so a `.env` of plain values is already a valid `.infraenv`. `#` starts a comment line.
### Sections
| Section | Holds |
| --------------- | ----------------------------------------------------------------------------------------------------------------- |
| `[infrawrench]` | Optional settings: `output = .env` (where pull writes, relative to the file), `org = <id>` (pins the org; avoid). |
| `[vars]` | Substitutions for every environment: `name = value`. Never environment variables themselves. |
| `[env]` | Variables every environment gets. |
| `[vars.<name>]` | Substitutions for one environment, over `[vars]`. |
| `[env.<name>]` | Variables for one environment, over `[env]`. Variables it does not mention are inherited. |
Environment names use letters, digits, `-` and `_`. Variable and substitution names use letters, digits and `_`, not starting with a digit.
### Values
| Written as | Meaning |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `development`, `"two words"`, `'raw $text'` | A literal. Quote it if it has spaces or `#`. A quoted value is always a literal, even `"secret(\"x\")"`. |
| `resource("<plugin>/<type>", "<name>", "<output>")` | An output of the synced resource with that plugin id, resource type id and display name, in the pulling organization. |
| `resource("<plugin>/<type>@<account>", "<name>", "<output>")` | The same, in the account with that display name. Use when two accounts have a resource of that name. |
| `resource("<id>", "<output>")` | An output of one resource by its id (`plugin:account:external-id`). Only resolves in the organization that owns it. |
| `secret("<NAME>")` | The organization secret with that name (the same store Infrawrench workflows use). |
Arguments are double-quoted strings with `\"` and `\\` escapes. Plugin ids, type ids and output keys come from `list_env_sources` (or the Infrawrench app's picker); never invent them.
### Substitutions
`${name}` inside the arguments of `resource()` and `secret()` is replaced before lookup. Values, lowest first: `[vars]`, the built-in `environment` (the environment being pulled), `[vars.<environment>]`, then `--var name=value`. A name with no value is a problem on that variable. Substitution never applies to literals: `HINT = ${HOME}` stays as written. `$${` is a literal `${` inside a reference.
### Resolution
- Pulling `--env production` gives `[env]` with `[env.production]` laid over it; no `--env` gives `[env]` alone.
- A variable whose source fails (no match, several matches, no value, a provider error) is reported with its line and left out of `.env`; the rest are written.
- In Infrawrench CI, a job's `env-file:` key loads the file, but only resources the repository is granted and the repository's CI secrets resolve there.
## Converting an existing .env
The goal is a committed `.infraenv` with the same keys and no secret values.
1. **Read the keys, not the values aloud.** List the keys in `.env` (and `.env.example`, `.env.production` and the like, if present). You may look at a value only to classify it; never repeat it.
2. **Classify each key:**
- **Not secret** (ports, feature flags, public URLs, `NODE_ENV`): keep it as a literal.
- **Comes from infrastructure** (database URLs, cache URLs, bucket names, endpoints, API keys a provider issues): find the resource with `list_env_sources` and write a by-name `resource()` reference with the output the key needs.
- **A secret with no resource behind it** (a third-party API key): write `secret("KEY")` and tell the user to create the organization secret `KEY` in Infrawrench (Environment files, or Settings) with the value from their `.env`. Do not create it for them with the value from the file unless they ask.
3. **Split environments.** Values that differ between the user's `.env.<stage>` files become `[env.<stage>]` overrides, or a `[vars]` substitution when only part of a name changes.
4. **Write `.infraenv`, then check it** with `infraenv check` (or `infrawrench env check`) and fix every problem.
5. **Leave the old `.env` alone.** The first pull refuses to overwrite a `.env` without the generated header; the user decides when to pass `--force`. Make sure `.env` is gitignored, and suggest `infraenv install` (or `infrawrench env hooks install`) so it regenerates when `.infraenv` changes.
`infrawrench env init --from .env` does steps 1 and 2 crudely (every key becomes `secret("KEY")`); use it as a start, then replace each line with the right kind.
Migrate from GitHub ActionsConverts a repository's GitHub Actions workflows into Infrawrench CI pipelines, job by job, and reports what could not move.
.cursor/rules/migrate-github-actions.mdc
---
description: Convert GitHub Actions workflows (.github/workflows/*.yml) into Infrawrench CI pipelines (.infrawrench/ci/*.yml). Use when asked to move a repository's CI from GitHub Actions to Infrawrench CI, or to translate a workflow, job, step or action into Infrawrench CI.
alwaysApply: false
---
# Migrate GitHub Actions to Infrawrench CI
Infrawrench CI runs the pipelines in a repository's `.infrawrench/ci/` folder on every push and pull request. Each job is one script (or one tool) that runs in its own WebAssembly sandbox over an in-memory snapshot of the commit, with the dependencies already installed from the lockfile. There are no steps, no marketplace actions and no runner images: most of a GitHub Actions job's steps either disappear or become lines of one script.
The reference for every key is the runner's README, `ci-runner/README.md` in the Infrawrench repository, and the user-facing guide is https://infrawrench.com/docs/features/ci. Read the sections below when the step below says so; they are written to be read one at a time.
## Process
1. **Inventory.** Read every file in `.github/workflows/`. For each workflow, list its triggers, its jobs, what each job runs on (`runs-on`), the actions it uses, its services, the secrets and variables it reads, and which jobs depend on which. Note reusable workflows (`workflow_call`) and composite actions (`.github/actions/`), which are inlined, not called.
2. **Classify each job** into one of three groups, and tell the user the result before writing files:
- **Runs on the runner**: bash, Node, Python, Go, PHP, TypeScript type checks, formatters, Postgres or ClickHouse tests, deployment CLIs. Most jobs.
- **Becomes a cloud job** (`cloud:`): anything that needs Docker, a native binary with no WebAssembly build, a GPU, or a real Linux machine. Rust is not one of these: it compiles with `tools: [builtin:[email protected]]` (see the "What changes, and what does not move" section below). It runs on one of the organization's connected cloud accounts, which an admin has to opt in to CI first.
- **Stays on GitHub Actions**: macOS and Windows jobs, and anything relying on an event Infrawrench CI does not have (see the "What changes, and what does not move" section below).
3. **Write one pipeline per workflow**, `.infrawrench/ci/<same-name>.yml`, starting with the schema comment so editors validate it:
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/Infrawrench/Infrawrench/main/ci-runner/schema/ci.schema.json
```
Translate the triggers, jobs, expressions and environment variables with the "GitHub Actions to Infrawrench CI: key by key" section below, and replace each action with the "Replacing actions" section below.
4. **Move dependency installs to the workspace.** Delete `actions/setup-*`, `actions/checkout` and `npm ci` / `pnpm install` / `pip install -r` steps, and list the package managers under `workspace.deps` instead. Dependencies are installed once per commit and checked against the lockfile; install scripts do not run, so a `postinstall` that generates code (Prisma, protobuf) becomes an explicit line in the jobs that need it.
5. **Split big jobs.** A job that runs a whole monorepo's tests or type checks (`turbo run test`, `nx affected`, `pnpm -r test`) becomes a `packages:` job, one job per workspace package, with the task cache. Read the "Monorepos: from a few big jobs to a job per package" section below. This is usually the largest speed-up of the migration.
6. **Check the limits.** Read the "What changes, and what does not move" section below and fix anything it flags: the 10-minute default timeout, the 2 GiB default memory, pipes in scripts, and the checkout having no `.git`.
7. **List what the user has to do in Infrawrench**, since an agent cannot do it:
- Add every secret and variable the pipelines read under **CI → Secrets and variables** (names only: never write a secret's value into a file).
- Turn on what jobs borrow under **CI → CI access**: connections that run cloud jobs, connections lent with `connections:`, SSH keys lent with `ssh-keys:`.
- Tick **Run CI** for the repository's GitHub account if it is not on yet.
8. **Validate.** Push to a branch and open a pull request. A pipeline file that does not parse fails at once with a job named **Pipeline file** whose output gives every error with its path in the file (`jobs.test.timeout: ...`). With the Infrawrench MCP server connected, `list_ci_runs` and `get_ci_job_log` read the results without leaving the editor.
9. **Run both side by side, then switch.** Keep the GitHub Actions workflows until the Infrawrench runs pass on the same commits. Then delete the migrated workflows (or the migrated jobs, for a workflow that keeps some), and change branch protection to require **Infrawrench CI / pull request**, the check that covers every job of the run.
## Rules that catch people out
- **A job is one script.** `run:` is bash with `set -euo pipefail`. Join a GitHub job's `run` steps into one `run: |` block in order. Use `if:` on a job, not on a line; inside the script, use shell conditionals.
- **Secrets only in `env:`.** `${{ secrets.NAME }}` works only as an `env:` value. Map it to a variable and read the variable in the script.
- **Pick an environment.** Every job without `cloud:` names `using:`: `env:bash@5`, `env:bash-node@24`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, or a tool such as `builtin:[email protected]`. Versions are pinned; a bare name is an error.
- **Jobs in `needs:` hand files on with `artifacts:`**, not with upload and download actions. Files for people to download from the run are `downloads:`.
- **Pull requests from forks** run only after a maintainer approves them, get no secrets, and never run cloud jobs. There is no `pull_request_target` equivalent.
## What to hand back
Finish with a short report: each workflow and job, where it went (runner, cloud job, stayed on GitHub Actions) and why, the secrets and variables to add, the CI access to turn on, and anything you were unsure of. Do not claim speed-ups you have not measured.
## Replacing actions
There are no actions. Each `uses:` step is dropped, becomes workspace or job configuration, or becomes a command in the job's script. When an action is not listed here, read what it runs (its `action.yml` and entry point) and do that in the script: most wrap a CLI that runs in `env:bash-node@24` with `npx` or a pinned global install. Pin every version.
### Setup and checkout
| Action | Replacement |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions/checkout` | Drop it. Every job starts in the commit's files at `/app`. There is no `.git`; see the "What changes, and what does not move" section for jobs that need history. |
| `actions/setup-node`, `pnpm/action-setup` | `using: env:bash-node@24` (Node 24, `npm`, `pnpm`, `npx`), and `workspace: { deps: [pnpm] }` (or `[npm]` for `package-lock.json`) instead of the install step. |
| `oven-sh/setup-bun` | `tools: [builtin:bun@1]` (Bun 1.4.4) on `using: env:bash@5`, and `bun install --frozen-lockfile` in the script, or `deps: [{ bun: { native: true } }]` when no install script matters; read the "What changes, and what does not move" section. |
| `actions/setup-python` | `using: env:[email protected]`, and `deps: [pip]` (reads `pylock.toml` or `requirements.txt`; `- pip: { file: requirements/ci.txt }` for another). |
| `actions/setup-go` | `using: env:[email protected]` (1.23 to 1.27), and `deps: [go]` for `go.sum`. |
| `shivammathur/setup-php` | `using: env:[email protected]` (8.1 to 8.5), and `deps: [composer]`. |
| `dtolnay/rust-toolchain`, `actions-rs/*` | `tools: [builtin:[email protected]]` in an `env:bash@5` job (rustfmt and clippy included), with `workspace: { deps: [cargo] }`; see the "What changes, and what does not move" section. A non-host `targets:` needs a cloud job. |
| `Swatinem/rust-cache` | Nothing: crates come from `deps: [cargo]`. To keep `target/` between runs, `cache: { key: ..., paths: [target] }`. |
| `ruby/setup-ruby` | `using: env:[email protected]` (or `@3.4`), and `deps: [bundler]` instead of `bundler-cache: true`; see the "What changes, and what does not move" section for Rails. |
| `actions/setup-java`, `setup-dotnet` | No environment for these yet. Make the job a cloud job with an `image:` that has the runtime. |
### Caches and files between jobs
| Action | Replacement |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `actions/cache` for `node_modules`, `~/.npm`, `~/.cache/pip`, `~/go/pkg` | Drop it: `workspace.deps` installs are cached by the runners. Go's build cache is kept on its own. |
| `actions/cache` for anything else | `cache: { key, restore-keys, paths }` with `${{ hashFiles('...') }}` in the key. Saved only when the job passes. Pull requests save to a scope the default branch never reads. |
| `actions/cache` for `.turbo` or `.nx` | Drop it and use the task cache instead (`task-cache:`), which skips whole jobs. See the "Monorepos: from a few big jobs to a job per package" section. |
| `actions/upload-artifact` + `download-artifact` between jobs | `artifacts: [dist]` on the producing job; every job that `needs:` it starts with those files where they were left. |
| `actions/upload-artifact` for people | `downloads: [report.html]`, or `{ paths, retention: 7d, when: always }`. Text files are masked for secrets; binary files are not, so never put a secret in one. |
### GitHub itself
Every one of these needs `github-token:` with the permissions it used, and `tools: [builtin:[email protected]]` for the `gh` command. The token is for the run's own repository, lasts an hour from when the run starts, and is never given to a fork's pull request.
| Action | Replacement |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `softprops/action-gh-release`, `ncipollo/release-action` | `gh release create "$TAG" dist/* --notes-file NOTES.md` with `github-token: { contents: write }`. |
| `peter-evans/create-pull-request` | Clone the repository in the script (the checkout has no `.git`), commit, push a branch and `gh pr create`, with `github-token: { contents: write, pull-requests: write }`. |
| `actions/github-script` | `gh api ...` in the script, or a Node script reading `GITHUB_TOKEN`. |
| `stefanzweifel/git-auto-commit-action` (formatters, codegen) | Make the job a check instead: `changes: fail` fails it when the formatter changes a file. To commit back, clone the repository in the script with `github-token: { contents: write }`. |
| `actions/labeler`, `actions/stale`, issue automation | These react to events Infrawrench CI does not have. Keep them on GitHub Actions. |
### Clouds and deployments
Credentials are lent, not stored: an admin turns a connection on for CI under **CI access**, and the job names it. Do not move cloud keys into secrets when a connection can be lent.
| Action | Replacement |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `aws-actions/configure-aws-credentials` | `using: env:[email protected]` and `connections: [<connection name>]`: the `aws` CLI is signed in with the lent session. |
| `google-github-actions/auth` + `setup-gcloud` | `using: env:gcloud@593` and `connections: [<name>]`: `gcloud` and `bq` use the lent access token. |
| `azure/login` | `using: env:[email protected]` and `connections: [<name>]`: `az` signs in with the lent service principal. |
| `azure/setup-kubectl`, `azure/k8s-*`, `deliverybot/helm` | `tools: [builtin:[email protected]]` and `connections: [<cluster connection>]`, which writes a kubeconfig and sets `KUBECONFIG`. Helm has no builtin: run it in a cloud job. |
| `webfactory/ssh-agent`, `appleboy/ssh-action`, `appleboy/scp-action` | `ssh-keys: [<key name>]` (the key's owner turns on **Use in CI jobs**) or a lent SSH host connection, and `tools: [builtin:[email protected]]` (add `builtin:[email protected]` for `scp`). |
| `amondnet/vercel-action` | `tools: [builtin:vercel@65]`, `VERCEL_TOKEN` from a secret in `env:`, then `vercel deploy --prod --yes`. |
| `cloudflare/wrangler-action` | `tools: [builtin:wrangler@4]`, `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in `env:`, then `wrangler deploy`. |
| `neondatabase/create-branch-action` | `tools: [builtin:neon@9]`, `NEON_API_KEY` in `env:`, then `neon branches create ...`. |
| `docker/login-action`, `docker/build-push-action`, `docker/setup-buildx-action` | A build job: `cloud: aws/build` (CodeBuild), `gcp/build` (Cloud Build), `azure/build` (ACR Tasks) or `docker/build` (your own Docker host), with `docker build` and `docker push` in `run:`. Write the image digest to an output for the deploy job. |
### Testing and reporting
| Action | Replacement |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `codecov/codecov-action` | Upload with Codecov's CLI in the script (`npx`), `CODECOV_TOKEN` in `env:`. |
| `dorny/test-reporter`, `mikepenz/action-junit-report` | Keep the JUnit file with `downloads: { paths: [junit.xml], when: always }`. The run page and the GitHub check show each job's result. |
| `microsoft/playwright-github-action` | Browsers do not run in a job. Run end-to-end browser tests as a cloud job with an image that has the browsers. |
## What changes, and what does not move
Check each migrated job against this list before handing back.
### Defaults that differ
- **Timeout: 10 minutes**, not 6 hours. Set `timeout:` (`30m`, `2h`, at most `6h`) on any job that can run longer. A job that prints nothing and uses no CPU for 5 minutes is stopped as stuck.
- **Memory: 2 GiB** per job, up to `16GiB` with `memory:`. Large test suites and bundlers usually want `4GiB` or more; a job over its limit fails and its report says so.
- **CPU: a share of one vCPU** per job, not a machine of its own, and its programs are told 1 CPU (`nproc`, `os.cpu_count()`, `os.availableParallelism()`), so anything that sizes its workers from the CPU count (`pytest -n auto`, Vitest, Jest, `cargo`, `make -j$(nproc)`) runs one. A job that builds or tests in parallel (`make -j`, `go test -p`, `cargo`, a test runner's workers) gets `cpus:` (1 to 64), whether or not it ran on a larger runner, and is then told that many: `-n auto` and `nproc` follow it, and a hard-coded count becomes `$IWCI_CPUS`. Billing follows: a job with `cpus: 4` is charged four vCPUs for as long as it runs.
- **One environment per job.** There is no image with everything installed. Pick the `using:` environment for the job's language, and add other tools with `tools: [builtin:...]`.
### Scripts
- **Pipes do not fail the script.** A pipeline reports only its last command's status, even with `pipefail`: `npm test | tee log.txt` passes when the tests fail. Write `npm test > log.txt 2>&1` and print the file afterwards, or drop the pipe.
- **No terminal.** Standard input is empty and nothing is a TTY, so prompts fail and colour is usually off. Pass non-interactive flags (`--yes`, `-y`, `--ci`).
- **No `sudo` and no `apt-get`.** The job's file system is its own; install command-line tools with `npm i -g` or `pnpm add -g` (pinned) in `env:bash-node`, or `pip install` in `env:python`. A system package means a cloud job.
- **Hard links work within the job's own files** (`ln`, `fs.linkSync`, `os.link`): the names are one file, with one inode number and a link count. A link to or from another mount (`/usr/local/bin`, the run's scratch directory) fails with `EXDEV`, which programs that link fall back to copying on, and caches, artifacts and `changes:` keep each name as a file of its own. Symbolic links work.
### The checkout
- **No `.git`.** Jobs get the commit's files, not a repository: `git log`, `git describe`, `git diff origin/main` and tools that read history (changelog generators, semantic-release) fail. Clone in the script when history is needed, with `github-token: { contents: read }` for a private repository: `git clone --depth=50 "https://github.com/$GH_REPO.git" /tmp/repo`.
- **No submodules** and **no Git LFS content** (a file kept in LFS is its pointer). Fetch them in the script if a job needs them.
- What changed in the push is still known: use `paths:` on a job or `changed('glob')` in `if:` instead of `git diff`.
### Languages and native code
- **Node 24 only** on the runner (`env:bash-node@24`). A matrix over older Node versions becomes one job on 24, or cloud jobs for the others.
- **Native Node addons** load only when the package ships a WebAssembly (`wasm32-wasi`) build: Vite 8, Vitest, Rolldown, tsdown, oxc and the Astro compiler do. A dependency with only native binaries (some image, database and crypto libraries) needs a cloud job.
- **npm**: `deps: [npm]` installs from `package-lock.json` (lockfile version 2 or 3; a version 1 lockfile needs `npm install --lockfile-version 3` with npm 7 or later). Do not keep `npm ci` in a job: npm refuses packages whose `os` list leaves out the job's platform. `npm run` scripts find their dependencies' commands in `node_modules/.bin`, as on a developer's machine.
- **Yarn lockfiles** are not installed by `workspace.deps` (it supports pnpm, npm, Bun, Go, Cargo, pip, Composer and Bundler). Convert with `pnpm import` and commit `pnpm-lock.yaml`.
- **Bun** is `tools: [builtin:bun@1]` (Bun 1.4.4, whose newest build `@1`, `@1.4` and `@1.4.4` all pick; `@1.3` and other versions do not exist), the real Bun run natively in a sandbox. Use it with `using: env:bash@5`, which has no `node`, so Bun runs package scripts, `#!/usr/bin/env node` bins and install scripts itself, and install in the job with `bun install --frozen-lockfile`, which gets the Linux builds of turbo, oxlint, esbuild and the like. `deps: [{ bun: { native: true } }]` instead installs once per lockfile, cached and checked against its hashes, with `node_modules/.bin` and the Linux builds of turbo and oxlint, so `bunx turbo` and `bun run lint` work over it; it runs no install scripts, and esbuild, Rollup and Lightning CSS are their slower WebAssembly builds there. Without `native: true` it has no native packages, and Bun fails over it. In `env:bash-node@24`, `node` is a WebAssembly Node (`process.platform` is `wasi`), and Bun runs install scripts with it, so a `postinstall` that loads a native package fails there. In `env:bash@5`, a file run with `bun run ./script.mts` that spawns `node` finds no `node`: link one, `ln -s "$(command -v bun)" /tmp/bin/node`, with `/tmp/bin` first on `PATH`. `env:bash@5` has no `npm`; use `bunx npm@11`. `cache:` `/root/.bun/install/cache`, keyed on `hashFiles('bun.lock')`, saves the downloads.
- **Ruby** (`env:[email protected]`, `@4.0`): gems with C extensions install only through `deps: [bundler]`, which has builds of the ones a `rails new` app locks (nokogiri, sqlite3, puma, bootsnap and the rest) at those versions; another one, or another version, fails the install naming the versions that have a build, and `- bundler: { without-extensions: [name] }` installs a gem the jobs never load without it. A Rails app needs `gem "tzinfo-data"` on every platform (no zoneinfo here; drop `platforms:`, then `bundle lock`) and `gem "selenium-webdriver", require: false` (it refuses to load here). No `fork`: Rails tests run in one process (`PARALLEL_WORKERS=1` is set), and system tests need a browser, so a cloud job. `bundle exec ruby` loses the bundle's settings; use `bin/rails`, `bundle exec rake` or `ruby -rbundler/setup`.
- **Rust**: `using: env:bash@5` with `tools: [builtin:[email protected]]` (rustc, cargo, rustdoc, rustfmt, clippy, and GCC 13 with binutils for linking and for build scripts that compile C), and `workspace: { deps: [cargo] }` so crates come from `Cargo.lock` with no network. Give build and test jobs `memory: 4GiB` to `8GiB` (the `target/` directory counts). The builtin's version is the toolchain: `rust-toolchain.toml` is ignored and there is no `rustup`, so `rustup target add` and cross builds need a cloud job, as do crates that link a system library (OpenSSL without `vendored`) or need a C++ compiler. A built binary runs from the script as on Linux. It needs a runner with the native sandbox; a job on one without fails saying so.
- **Native binaries from npm packages** (Turborepo's `turbo`, sherif, and others that pick a per-platform optional dependency): `workspace: { deps: [{ pnpm: { native: true } }] }` (or `bun`) and `tools: [builtin:[email protected]]` on the `env:bash-node@24` job that runs them. Without both, the binary is missing or does not start. TypeScript 7 (`tsc` from `typescript@7`) works the same way. A tool that loads a native Node addon in-process with no WebAssembly build (oxlint) runs under Bun instead: `tools: [builtin:[email protected], builtin:[email protected]]` and `bun node_modules/oxlint/bin/oxlint`. A project that pins pnpm 12 (`packageManager` or `engines.pnpm`) switches to it in a job with `native: true` on its pnpm dep and `tools: [builtin:[email protected]]`.
- **Java, .NET, Swift**: no environment yet. Cloud jobs.
### Services and containers
- **Postgres** (`env:postgres@18`, PGlite: many connections, `pgcrypto`) and **ClickHouse** (`env:[email protected]`) run as `services:` inside the job. Postgres runs one transaction at a time and shares `SET`, advisory locks and `LISTEN` across connections, so tests that depend on concurrent transactions need a real Postgres in a cloud job.
- **Any other service image** (Redis, MySQL, Elasticsearch, a vendor emulator): start it in a cloud job (`cloud: { provider: docker, kind: container }` or a VM with Docker), or, when it is a Node or Python program, as a `services:` entry running that program.
- **No Docker on the runner.** `docker build`, `docker run` and `docker compose` go in a cloud job: `kind: build` for building and pushing images, `kind: vm` or `container` for running them.
- **No browsers.** Playwright, Cypress and Puppeteer tests run as cloud jobs.
### Events and features with no equivalent
Keep these on GitHub Actions, or say what the user could do instead:
- Triggers other than push, pull request, schedule and manual: tags, releases, `workflow_run`, `issues`, `issue_comment`, `pull_request_target`, `repository_dispatch`, `merge_group`.
- macOS and Windows runners.
- GitHub Pages deployment through `actions/deploy-pages` (deploying the built site with a CLI from a job works).
- Job-level `concurrency`, `continue-on-error`, `fail-fast`, matrix `include:`.
- `environment:` protection rules and required reviewers. CI access limits what each repository and branch may use, and a fork's pull request waits for a maintainer's approval.
- OIDC (`id-token: write`) to a cloud. Lend the cloud's connection instead (`connections:`), which needs no stored key either.
## GitHub Actions to Infrawrench CI: key by key
Unknown keys are an error, so leave out anything without a row here rather than carrying it over.
### Workflow level
| GitHub Actions | Infrawrench CI |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `name:` | `name:` (required) |
| `on: push` with `branches`, `paths` | `on: { push: { branches, paths } }` |
| `branches-ignore`, `paths-ignore` | The same list with each pattern quoted and prefixed with `!`: `paths: ["!docs/**"]` |
| `on: pull_request` with `branches`, `paths` | `on: { pull-request: { branches, paths } }`. `types:` has no equivalent; every opened or updated pull request runs. |
| `on: schedule` with `cron` | `on: { schedule: [{ cron: "0 3 * * *" }] }`, UTC, runs the default branch's head |
| `on: workflow_dispatch` with `inputs` | `on: { manual: { inputs } }`: types `string`, `boolean`, `choice` (with `options`), `number` |
| `on: push: tags`, `release`, `workflow_run`, and others | No equivalent: tag pushes start nothing. Keep the workflow on GitHub Actions, or start it by hand. |
| `env:` at the top | No top-level `env`. Repeat it on each job, or share it with a YAML anchor (`env: &env {...}`, then `env: *env`). |
| `concurrency:` | `concurrency:` at the top only, `{ group, cancel-in-progress }`. A job-level `concurrency` has no equivalent. |
| `permissions:` | Per job, `github-token: { contents: write, pull-requests: write }`. No token at all unless a job asks. |
| `defaults.run.working-directory` | `cwd:` on each job, absolute: `/app/<dir>` |
| `defaults.run.shell` | Always bash. A Python or Node step becomes `python - <<'EOF'` or `node -e` in the script, or a script file it runs. |
### Job level
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `runs-on: ubuntu-*` | Nothing: the job runs on the runners. Choose `using:` for the language instead. |
| `runs-on:` a larger runner (`ubuntu-latest-8-cores`, `ubuntu-24.04-16core`) | `cpus: N` (1 to 64), the runner's vCPU count, so the job holds whole vCPUs rather than a share of one. Its scripts read the number from `$IWCI_CPUS` (`-j"$IWCI_CPUS"`). Billed at those vCPUs. Size `memory:` separately. |
| `runs-on: self-hosted` or a label | `cloud:` on a connected account (`aws/vm`, `gcp/container`, `docker/container`, `kind: host` for an existing machine over SSH). |
| `steps:` | One `run: \|` script, the `run` steps joined in order. Each `uses:` step is replaced as in the "Replacing actions" section. |
| `needs:` | `needs:` |
| `if:` | `if:` on the job. Functions: `success()`, `failure()`, `always()`, `contains`, `startsWith`, `endsWith`, `changed('glob')`. No `cancelled()`, `format`, `toJSON`, `fromJSON` or `hashFiles` here. |
| step-level `if:` | A shell `if` in the script, or a separate job with its own `if:`. |
| `strategy.matrix` | `matrix: [a, b]` (read as `${{ matrix }}`) or named axes `{ node: [22, 24], os: [x] }` (read as `${{ matrix.node }}`), with `exclude:`. Up to 64 entries. No `include:`: write those as separate jobs. |
| `fail-fast`, `max-parallel` | Leave out. Every entry runs; the runner schedules them. |
| `continue-on-error` | Leave out. Let the dependents run anyway with `if: always()`, and read `${{ needs.<job>.result }}`. |
| `timeout-minutes: 30` | `timeout: 30m`. The default is 10 minutes (GitHub's is 6 hours), the most 6 hours. Set it on anything that can take longer than 10 minutes. |
| `env:` | `env:`. `${{ secrets.X }}` works only here. |
| `outputs:` + `$GITHUB_OUTPUT` | `outputs: [name]` and `echo "name=value" >> "$IWCI_OUTPUT"`. Writing an undeclared name fails the job. A matrix job cannot have outputs. |
| `services:` (Docker images) | `services:` with `env:postgres@18` (`run: pglite-server`) or `env:[email protected]`, reached as `postgres:5432`. Other images: see the "What changes, and what does not move" section. |
| `container:` | No equivalent on the runner. Choose the matching `using:` environment, or make it a cloud job with `image:`. |
| `environment:` | No equivalent. What a branch may use is set in **CI access** (connections, SSH keys and resources per repository and branch). |
| `uses: ./.github/workflows/x.yml` | Inline the called workflow's jobs into this pipeline. |
### Expressions
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------- | --------------------------------------------------------------------- |
| `${{ github.sha }}` | `${{ commit.sha }}` (`${{ commit.short-sha }}` for the short form) |
| `${{ github.ref_name }}`, `github.head_ref` | `${{ commit.branch }}` |
| `${{ github.event_name }}` | `${{ event }}`: `push`, `pull-request`, `schedule` or `manual` |
| `${{ github.event.pull_request.number }}` | `${{ pull-request.number }}` (empty unless a pull request) |
| `${{ github.workflow }}` | `${{ pipeline.name }}` |
| `${{ github.repository }}` | `$GH_REPO` in a job with `github-token:`; otherwise write it out |
| `${{ inputs.x }}` / `${{ github.event.inputs.x }}` | `${{ inputs.x }}`, never inside `run:`: map it in `env:` and quote it |
| `${{ vars.X }}` | `${{ vars.X }}` |
| `${{ secrets.X }}` | `${{ secrets.X }}`, in `env:` values only |
| `${{ needs.a.outputs.b }}`, `${{ needs.a.result }}` | The same |
| `${{ matrix.x }}` | The same; a one-axis list is `${{ matrix }}` |
| `${{ env.X }}` | `$X` in the script |
| `${{ runner.os }}`, `${{ runner.temp }}` | Always Linux-like; use `/tmp` |
| `${{ hashFiles('x') }}` | Only in a `cache:` `key` or `restore-keys` |
### Environment variables in scripts
| GitHub Actions | Infrawrench CI |
| --------------------------- | ---------------------------------------------------------------------------------- |
| `GITHUB_SHA` | `IWCI_COMMIT` |
| `GITHUB_REF_NAME` | `IWCI_BRANCH` |
| `GITHUB_WORKSPACE` | `/app` (the clone, and every job's default working directory) |
| `GITHUB_OUTPUT` | `IWCI_OUTPUT` |
| `GITHUB_ENV`, `GITHUB_PATH` | Not needed: the job is one script, so `export` and `PATH=...` carry to later lines |
| `GITHUB_STEP_SUMMARY` | No equivalent; keep a report with `downloads:` |
| `GITHUB_TOKEN` | Set only in a job with `github-token:` (also `GH_TOKEN`) |
| `RUNNER_TEMP` | `/tmp`. Files shared by the run's jobs go in `/tmp/workflow` (`$IWCI_SCRATCH`) |
| `CI` | `CI=true` |
## Monorepos: from a few big jobs to a job per package
On GitHub Actions every job pays for its own machine, checkout and install, so monorepo workflows usually have a handful of jobs that each run one task across every package (`turbo run test`, `nx affected -t lint`, `pnpm -r typecheck`). In Infrawrench CI a job costs none of that, so write one job definition per task and let it expand to one job per workspace package. Each package's job is its own row and log in the run, and the task cache skips the ones a change cannot affect.
### The shape
```yaml
name: Test
on:
push:
branches: [main]
pull-request: {}
workspace:
deps: [pnpm]
jobs:
build:
packages: { has-script: [build] }
needs: ["^build"]
using: env:bash-node@24
run: pnpm run build
artifacts: [dist]
task-cache: true
typecheck:
packages: { has: [tsconfig.json] }
needs: ["^build"]
using: builtin:[email protected]
args: [--noEmit]
task-cache: true
test:
packages: { has-script: [test] }
needs: [build]
using: env:bash-node@24
run: pnpm test
task-cache: true
memory: 4GiB
```
- **`packages:`** expands a job over the workspace (`pnpm-workspace.yaml`, or `workspaces` in the root `package.json`). `true` is every package. Narrow it with `only:` (globs over directory or name, `!` excludes), `has:` (files the package has), `has-script:` (scripts it defines) or `scripts:` (a glob its script's command must match). Each job runs in its package's directory and reads `${{ package.name }}` and `${{ package.dir }}`.
- **`needs: ["^build"]`** waits for `build` in each package this one depends on, like Turborepo's `dependsOn: ["^build"]`. `needs: [build]` in a `packages:` job means the same package's `build`. A plain job that needs a `packages:` job waits for all of its packages.
- **`artifacts:`** in a `packages:` job are relative to the package, so each package's `dist/` reaches the jobs that depend on it.
- **One slow package** can be split further: give it its own job with `only:` and a `matrix:` of shards, and leave the rest alone.
### The task cache
`task-cache: true` skips a job when nothing it reads has changed since a run of it passed, and hands on that run's log, outputs and artifacts as if it had run. Use it on every deterministic job: builds, type checks, tests, linters, formatters.
```yaml
task-cache:
inputs: [src/**, tsconfig.json, "!src/**/*.md"] # relative to the package; default: every file in it
root-inputs: [tsconfig.base.json, .eslintrc.cjs] # relative to the repository root
artifacts: false # see below
```
- **The key** covers the job's definition, the exact version of every tool and environment it uses, the lockfiles, the files its inputs match, and the bytes of every artifact it is handed. A job downstream of a change reruns only when what it is handed actually changed.
- **Name every file outside the package that a job reads** in `root-inputs:` (shared tsconfig, lint and test config, fixtures). A file the key leaves out can change without rerunning the job.
- **`artifacts: false`** leaves handed-on artifacts out of the key, for a job that only passes them along (a bundler that keeps workspace dependencies external), so a change at the bottom of the graph does not rebuild everything above it. Only when the job's result does not depend on them.
- **Cannot be task-cached:** a job that reads a secret, is lent anything (`connections:`, `ssh-keys:`), has `github-token:`, keeps `downloads:` or runs on a cloud account. Keep those jobs small and put them after the cached ones.
- A cache hit is not billed, takes no slot or memory, and a run where every job hits never installs dependencies. Pull requests keep their own results: nothing a pull request saves is used on the default branch.
### Translating common commands
| GitHub Actions step | Infrawrench CI |
| --------------------------------------------- | ------------------------------------------------------------------------------------- |
| `turbo run build` / `nx run-many -t build` | A `build` job with `packages:`, `needs: ["^build"]`, `artifacts: [dist]` |
| `turbo run test --filter=...[origin/main]` | A `test` job with `packages:` and `task-cache: true`: the cache does the filtering |
| `nx affected -t lint` | A `lint` job with `packages: { has-script: [lint] }` and `task-cache: true` |
| `pnpm -r --parallel typecheck` | A `typecheck` job with `packages:` and `using: builtin:[email protected]` |
| `pnpm --filter web test` | A job with `packages: { only: [apps/web] }`, or a plain job with `cwd: /app/apps/web` |
| A `paths-filter` step choosing which jobs run | `paths:` on each job, or `if: changed('apps/web/**')` |
Keep `turbo` or `nx` out of the jobs once they are split: each job runs one package's script directly, and the task cache replaces their caches.
git.infrawrench.com and Infrawrench CIWorks in a repository on git.infrawrench.com the way its reviewers read it: records the work on each push, answers what they send back, and writes CI jobs that put notes on the branch's page.
.cursor/rules/infrawrench-git.mdc
---
description: Work in a Git repository hosted on git.infrawrench.com (its remote is git.infrawrench.com) and with Infrawrench CI (.infrawrench/ci/*.yml). Use when writing or reviewing code on a branch there, when the infrawrench-git MCP server is connected or should be, when asked to record a trace, answer reviewer instructions or report findings, or when writing a CI job that should leave must-fix, should-fix, note, doubt, decision, step or evidence notes on a branch's page.
alwaysApply: false
---
# git.infrawrench.com and Infrawrench CI
git.infrawrench.com is a Git forge where a branch is reviewed as a record of versions. Every push to a branch that is not the default branch makes a version, and the branch's page shows what there is to read about that version before its code: what the agent that wrote it recorded (its trace), what reviewers and CI jobs found (findings), and what reviewers sent back (instructions). There are no pull requests to open: a branch gets its page at its first push.
You are in such a repository when `git remote -v` names `git.infrawrench.com`. The user-facing guides are https://infrawrench.com/docs/features/git-branches and https://infrawrench.com/docs/features/git-agents-and-mcp. Read the sections below when a step below says so.
## Connect
The forge's MCP server is `https://git.infrawrench.com/mcp`, usually added under the name `infrawrench-git`. If its tools (`record_trace`, `get_branch`, ...) are not available, tell the user how to add it: the "Connecting the forge's MCP server" section below has the command for Claude Code, Codex and Cursor. Call `whoami` once when you are unsure whether you can write. Tools take a repository as `owner/name` and a branch by its name.
## When you write code on a branch
1. **Start.** Given a task with no branch yet, call `start_work` with the ask: it makes the branch and its page, as a draft. When the task is one of the repository's open issues, pass its number as `issue` instead: the page takes the issue's title and description and closes the issue when it is merged into the default branch. Then `git fetch origin && git switch <branch>`. If a branch already exists, check it out and call `get_branch` to see where it stands.
2. **Record as you work**, with `record_trace`, not only at the end. the "Recording a trace" section below has the kinds and their fields. In short: one `ask`, a `step` for each piece of work, a `decision` when you chose between alternatives, `evidence` whenever you ran a check (the command, its exit code, the lines of output that show the result, failures too), and a `doubt` for anything you are unsure of, skipped or could not verify. Reviewers read doubts first.
3. **Record before you push.** Entries wait on the branch and are attached to the version the next push makes. Then `git push`. A `secret_files_pending` failure kept nothing: send the same entries again in a minute.
4. **After a push**, call `get_branch` for the branch's state, `list_instructions` for what reviewers sent back and `list_findings` for what reviewers and CI found.
5. **Answer instructions.** For each one you take on: `mark_instruction_delivered`, do the work, record it, `mark_instruction_answered`, then push. If you decide not to do what was asked, record why (a `decision` or a `doubt`) and still mark it answered. An instruction whose `source` is `conflict` means the branch no longer merges cleanly into its base: fetch the base, rebase onto it (or merge it in), resolve every conflict it lists, run the checks again, and push (`git push --force-with-lease` after a rebase). The forge sends one by itself when a push leaves the branch conflicting, and marks it answered when a later push resolves it. An instruction whose `source` is `ci_failure` lists the checks that failed on the branch's newest commit, with a link to each run (`GET /api/repos/<owner>/<repo>/ci/runs/<run id>`, with the Git credential your machine has for the forge as a Bearer token, has every job's output; the branch token cannot read it). Read the output and decide: if the branch caused it, fix it, run the check, and push; if it did not (a flaky test, an outage, a failure the base has too), change nothing, record a `decision` saying why, and mark it answered. The forge sends one by itself once a commit's checks have settled with a failure, and marks it answered when a later push passes.
6. **Hand it over when it is done.** The branch's page is a draft until it is marked ready for review. After your last push, call `mark_ready_when_checks_pass`: the page leaves draft by itself the moment every check on its head has passed (and every check the base branch requires has reported), or now if they already have. A failing check keeps it a draft and the request waits for your fix. `enabled: false` withdraws it, and a person who marks the page by hand cancels it. It never merges.
7. **Fix what must be fixed.** An open `must_fix` finding holds the branch's merge until it is fixed, dismissed by a person, or overridden by an administrator. You cannot dismiss or override one: fix it and push, or record a `doubt` saying why you think it is wrong.
## When you review a branch
Read the change with `get_branch` and `get_version_diff`, then call `report_finding`: a `severity` (`must_fix` only for what must not merge, `should_fix`, `note`), a short `title`, a `body`, the `path` and lines, and `evidence`. Set `complete: true` when the list is everything you find on that version, so your earlier findings that are not in it are marked fixed. Report under a `reviewer` name of your own (`claude-review`).
## Images and videos
A trace entry, a finding and an ask are Markdown, and can show a screenshot or a short recording (a UI before and after a change, a failing test's screen). Call `upload_media` with the file as base64 (3 MB at most) and put the `markdown` it answers in what you write next. For a larger file or a video, post the bytes to the repository's upload address with the same token: `curl -fsS --data-binary @shot.png -H "Authorization: Bearer <token>" "https://git.infrawrench.com/<owner>/<name>/uploads?name=shot.png"` answers the same JSON. Images: PNG, JPEG, GIF, WebP, AVIF up to 10 MB; videos: MP4, WebM, QuickTime up to 90 MB. Never upload a screenshot that shows a secret.
## Infrawrench CI
A repository's pipelines are the YAML files in `.infrawrench/ci/`. They run on every push and on each branch page's new version, and their results are on the branch's **Checks** tab. A pipeline has `name:`, `on:` (`push`, `pull-request`, `schedule`, `manual`) and `jobs:`; a job is one script (`run:`) in an environment (`using: env:bash-node@24`) or on a Linux machine (`platform: linux`). Do not guess the rest: the guide is https://infrawrench.com/docs/features/ci and every key is in `ci-runner/README.md` of the Infrawrench repository.
A CI job can put notes on the branch's page by printing lines, with no token and no API call:
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
`::must-fix`, `::should-fix` and `::note` become findings; `::doubt`, `::decision`, `::step` and `::evidence` become trace entries. Read the "Notes from a CI job" section below before writing a job that prints them: it has the parameters, the escapes, the limits, what a passing job marks fixed, and a job that turns a linter's JSON report into notes. Use this when a check already runs in CI (a linter, a type checker, a test report); use `report_finding` when you are the reviewer yourself.
## Secret files
A repository may have secret files (`filter=iwsecret` in `.gitattributes`): what is committed is a pointer, or a YAML or JSON skeleton whose values are `"iwsecret:1:..."` tokens. `get_branch` and `start_work` list a branch's secret files in `secretFiles` with `secretRules`; `secretFilesPending` means the forge was still listing them, so call `get_branch` again in a few seconds. When there are any, run `infrawrench git secret install` after checking the repository out, so they are readable in your checkout (if the person you work for may read them) and uploaded when you push. A file that stays a pointer is one you cannot read: leave it as it is.
- You may read and edit these files in your checkout.
- Never put a value from them into a trace entry (asks, steps, decisions, evidence, doubts), a finding, an instruction answer, a commit message, a branch's title or description, or command output you record. Refer to a secret by its path and key name: "changed `database.password` in `config/prod.yaml`".
- Never print one in a command whose output you record as evidence.
- Never copy one into a file that is not secret. The forge refuses an agent's push that does.
- When reviewing, a pointer or a token is not a placeholder or a bug: it is how the file is committed.
- A CI job that needs one names it in `secret-files:` (paths written out, at most 32). It gets the file only on a branch the repository lends secret files to CI on; turning that on is an administrator's choice in the repository's settings, never yours.
## Never
- **Never put a secret in a trace entry, a finding or a CI note.** Tokens, keys and passwords are masked before anything is stored, but masking recognises shapes and names, not every secret, and everyone who can read the repository reads the notes. Leave them out, and do not print what a secret protects.
- **Never report as one of the forge's own reviewers.** `general`, `security`, `tests`, `terraform` and `intent` are refused, and so is any name that starts with `ci:`, which is how Infrawrench CI names a job's findings (`ci:<pipeline>/<job>`). An agent kind of `ci` is refused for a trace in the same way.
- **Never mark an instruction answered for work you did not do**, and never push to the default branch to get around a branch's page.
- **Do not invent pipeline keys or note parameters.** An unknown parameter makes a note command malformed: it is ignored, and the job's reason on the run's page says how many were.
## Notes from a CI job
A job of a repository on git.infrawrench.com leaves notes on the branch page of the commit it ran on by printing one line per note, to its output or its errors. Nothing else is needed: no token, no API call, no tool.
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
The line starts at its first character with `::`, the command, a space and the parameters when there are any, `::`, then the message. An indented line, or a command in the middle of a line, is not read.
### Commands
| Command | Becomes |
| -------------- | ------------------------------------------------------------------ |
| `::must-fix` | A finding that must be fixed. While it is open it holds the merge. |
| `::should-fix` | A finding that should be fixed. |
| `::note` | A finding that is a note. |
| `::doubt` | A trace entry of kind `doubt`. |
| `::decision` | A trace entry of kind `decision`. |
| `::step` | A trace entry of kind `step`. |
| `::evidence` | A trace entry of kind `evidence`. |
There is no `::ask` and no trace `note`: `::note` is the finding. Other names after `::` (`::group::`, `::error`) are other tools' commands and are left alone, so a typo in a command's name is silently not a note.
### Parameters
| Parameter | Value |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | A path from the repository's root (`src/db.ts`). Not absolute, no `..`. Left out, the note is about the whole change. |
| `line` | The line, from 1, in the file as it is at the run's commit. Needs `file`. |
| `end_line` | The last line of a range. Needs `line`, and is not before it. |
| `title` | A finding's title (up to 200 characters), or a bold first line on a trace entry. Without one, a finding's title is its message's first line. |
| `needs_code` | `true` or `false`: show the lines under the note's text. Left out, it is `true` when there is a `line`. |
Parameters are separated by commas, each given once, in any order. All are optional. A finding with a `title` may have an empty message; a trace entry needs a message.
### Escapes
| Write | For |
| ----- | ------------------------------------------ |
| `%25` | `%` |
| `%0A` | A line break (`%0D` for a carriage return) |
| `%3A` | `:` in a parameter's value |
| `%2C` | `,` in a parameter's value |
Escape `%` first, then the others, whenever the text comes from a tool's output. A message needs only `%25`, `%0A` and `%0D`; a parameter's value needs all of them.
### What happens to them
- **Where.** On the open branch page of the run's commit, on the version that commit's push made. A run on a branch with no open page (the default branch, a schedule) leaves nothing, and so does a run of a commit the branch has been force pushed past.
- **Findings** are reported by the reviewer `ci:<pipeline>/<job>`, with a link to the line of the job's log that printed them.
- **The same finding on the next push is the same finding.** It is told apart by job, `file` and title, never by line. So keep titles stable: use the rule's id (`no-explicit-any`), not a sentence with a line number or a count in it. A finding a person dismissed stays dismissed.
- **A passing job marks fixed** what it reported before and did not print this time. A failing job fixes nothing, so a job that reports and then fails keeps its findings open until a later run passes without them.
- **Trace entries** of a job are replaced when the job runs again on the same commit. A run of a branch proposed from a fork leaves findings only.
- **A must-fix** holds the merge like any must-fix, and is sent to the agent that writes the branch as an instruction.
### Limits
- 100 notes per job, 1,000 per run. Print the worst first when a tool can report more.
- A message is at most 8 KiB after its escapes are read; a `file` at most 1,024 characters.
- A command over a limit, or a malformed one (a parameter not in the table, a `line` that is not a number, a `file` outside the repository, no message), leaves no note. The job's reason on the run's page counts them: `2 note commands ignored (2 malformed).` Check it after the first run of a new job.
### Secrets
The commands are read from the run's log as it is stored, where the organization's secrets are already `***`, and each note is masked again by shape before it is kept. Everyone who can read the repository reads the notes, so never print a secret, and do not print what one protects (a customer's record, a private URL).
### A linter's JSON as notes
On a Linux machine (`platform: linux`), whose image has `jq`:
```yaml
name: lint
on:
pull-request: {}
jobs:
eslint:
platform: linux
run: |
npm ci
status=0
npx eslint . --format json --output-file eslint.json || status=$?
jq -r --arg root "$PWD" '
def esc: gsub("%"; "%25") | gsub("\r"; "%0D") | gsub("\n"; "%0A");
def param: esc | gsub(":"; "%3A") | gsub(","; "%2C");
.[]
| (.filePath | ltrimstr($root + "/")) as $file
| .messages[]
| (if .severity == 2 then "must-fix" else "should-fix" end) as $command
| (if .line then ",line=\(.line)" else "" end) as $line
| "::\($command) file=\($file | param)\($line),title=\(.ruleId // "eslint" | param)::\(.message | esc)"
' eslint.json
exit "$status"
```
In a sandboxed environment (`using: env:bash-node@24`), which has no `jq`, the same with Node:
```yaml
jobs:
eslint:
using: env:bash-node@24
run: |
status=0
pnpm exec eslint . --format json --output-file eslint.json || status=$?
node -e '
const esc = (s) => String(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
const param = (s) => esc(s).replace(/:/g, "%3A").replace(/,/g, "%2C");
const root = process.cwd() + "/";
for (const file of JSON.parse(require("fs").readFileSync("eslint.json", "utf8"))) {
const path = file.filePath.startsWith(root) ? file.filePath.slice(root.length) : file.filePath;
for (const m of file.messages) {
const command = m.severity === 2 ? "must-fix" : "should-fix";
const line = m.line ? `,line=${m.line}` : "";
console.log(`::${command} file=${param(path)}${line},title=${param(m.ruleId ?? "eslint")}::${esc(m.message)}`);
}
}
'
exit "$status"
```
Both print the notes whether or not the linter passed, then end with the linter's own status, so the job still fails when it should. Write the report to a file and read the file: in a sandboxed environment a pipe reports only its last command's status.
## Connecting the forge's MCP server
The server is one address, `https://git.infrawrench.com/mcp`, over Streamable HTTP. A client that supports OAuth needs only the address: the first call opens the user's browser on git.infrawrench.com to sign in and allow the application. Adding a server is the user's to do; give them the command for their client.
### Claude Code
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp
```
Then `/mcp` inside Claude Code, pick `infrawrench-git` and sign in.
### Codex
```sh
codex mcp add infrawrench-git --url https://git.infrawrench.com/mcp
codex mcp login infrawrench-git
```
### Cursor
In `~/.cursor/mcp.json`, or `.cursor/mcp.json` in the project:
```json
{
"mcpServers": {
"infrawrench-git": {
"url": "https://git.infrawrench.com/mcp"
}
}
}
```
### Without a browser
A client that cannot open a browser sends a personal access token (`iwg_...`, made under **Settings > Access tokens** on git.infrawrench.com, with the `repo:write` scope to record traces and report findings) in the `Authorization` header:
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp \
--header "Authorization: Bearer $IWG_TOKEN"
```
Read the token from the environment. Never write it into a file that is committed, a trace entry or a note.
### A token for one branch
An agent that works on one branch does not need a person's whole access. Ask the forge for a token for that branch, with any credential that can write the repository (a personal access token, an organisation's API key):
```sh
curl -fsS -X POST -H "Authorization: Bearer $IWG_TOKEN" \
https://git.infrawrench.com/api/repos/<owner>/<repository>/branches/<branch>/agent/token
```
`<branch>` is the branch's name as one URL segment (`work%2Fadd-rate-limits`). The answer is `{ "token", "expiresAt", "branch" }`. The token lasts six hours; ask again for another. Send it as the MCP server's `Authorization: Bearer` header, or to the API.
It records that branch's trace, lists its instructions and marks them delivered and answered, and lists and reports findings on it. It does nothing else: it cannot clone or push, reach another branch or repository, send or withdraw an instruction, or dismiss a finding. With it, `whoami` answers `kind: "agent"` and the `branch`, and `get_branch`, `get_version_diff`, `list_my_branches` and `start_work` are refused.
A thread git.infrawrench.com starts in T3 Code is told to ask for one with the machine's own Git credential and to keep it in a file in the worktree's Git directory. Never print the token, and never put it in a message, a commit or a trace.
### Calling a tool without a client
A session that has not loaded the server's tools can still call them: each call is one `POST` of a JSON-RPC request, and `tools/list` in place of `tools/call` describes every tool.
```sh
curl -fsS https://git.infrawrench.com/mcp \
-H "Authorization: Bearer $INFRAWRENCH_GIT_TOKEN" \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"record_trace","arguments":{"repository":"acme/infra","branch":"work/add-rate-limits","entries":[{"kind":"decision","body":"A token bucket, not a fixed window: bursts are fine here."}]}}}'
```
### What a connection may do
| Scope | Allows |
| ------------ | -------------------------------------------------------------------------------------- |
| `repo:read` | Read the repositories the user can read, with their branches, reviews and traces. |
| `repo:write` | Push, record traces, answer instructions, report findings and start work, as the user. |
A connection never does more than its user can, and never administers a repository. `whoami` says whose credential it is and whether it can write.
### The tools
| Tool | Use |
| ----------------------------- | --------------------------------------------------------------------------------------------------------- |
| `whoami` | Whose credential this is, whether it can write, and the branch of a branch token. |
| `list_my_branches` | Open branches that involve the user and have something new. |
| `get_branch` | A branch's page, state, versions, and how many instructions and findings are open. |
| `get_version_diff` | A version's diff: the whole change, that version alone, or since an earlier version. |
| `record_trace` | Record the ask, steps, decisions, evidence and doubts of the work on a branch. |
| `list_instructions` | What reviewers sent to the agent that writes the branch. |
| `mark_instruction_delivered` | Say an instruction has reached you. |
| `mark_instruction_answered` | Say which version answers an instruction. Left out, it is the next push. |
| `mark_ready_when_checks_pass` | Ask that the branch's draft page be marked ready for review once its checks pass. |
| `list_findings` | What reviewers and CI jobs found on a branch. |
| `report_finding` | Report a reviewer's findings on a version. |
| `start_work` | Create a branch and its page, as a draft, from an ask or an open issue (`issue`), before any code exists. |
## Recording a trace
`record_trace` takes `repository` (`owner/name`), `branch` (not the default branch) and one or more `entries`, in the order they happened. Send several in one call. The branch does not have to exist yet.
### Kinds
| Kind | Record it when |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| `ask` | Once, at the start: what you were asked to do, in the person's words. |
| `step` | After each meaningful piece of work: what you changed and why, with `anchors` to the files. |
| `decision` | You chose between alternatives: what you chose, what you rejected and why. |
| `evidence` | You ran tests, a build, a linter or any check: the command, its exit code, the output. Failures too. |
| `doubt` | You are unsure, skipped something, or could not verify something. Reviewers read these first. |
| `note` | Anything else a reviewer should know. |
### An entry
| Field | Value |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `kind` | One of the kinds above. |
| `body` | Markdown, a few sentences: what and why. At most 32 KB. |
| `anchors` | The files and lines the entry is about: `[{ "path": "src/db.ts", "start_line": 40, "end_line": 48 }]`. Lines are optional. |
| `needs_code` | `true` only when a reader has to see the code at the anchor to understand the entry. Defaults to `true` when a line is given. |
| `evidence` | For `evidence`: `command`, `exit_code`, `output` (an excerpt; past 16 KB its start and end are kept), `ci_run_id` or `url`. |
```json
{
"repository": "acme/infra",
"branch": "feature/rate-limits",
"entries": [
{ "kind": "ask", "body": "Limit sign-in attempts to five a minute per address." },
{
"kind": "decision",
"body": "Counted in Postgres, not in memory: the API runs on several instances.",
"anchors": [{ "path": "src/auth/limits.ts", "start_line": 12, "end_line": 30 }],
"needs_code": false
},
{
"kind": "evidence",
"body": "The new tests pass.",
"evidence": {
"command": "pnpm test src/auth",
"exit_code": 0,
"output": "Tests 14 passed (14)"
}
},
{
"kind": "doubt",
"body": "Addresses behind one proxy share a limit. I did not change how the address is read."
}
]
}
```
### How it reaches the page
- Entries wait on the branch and are attached to the version the branch's **next push** makes. Record first, push after. Entries recorded after a push belong to the next one.
- A branch holds at most 1,000 entries waiting for a push, and entries nobody pushes after are dropped after 30 days.
- A note shows the lines it is about under its text when `needs_code` is true. Most decisions and doubts stand on their own: leave it `false` for those, even when they have an anchor. Every entry with an anchor hangs on its lines in the file's diff either way.
- Recording needs write access to the repository.
### Secrets
Every entry is masked before it is stored: known token formats, private key blocks, passwords in URLs, `Authorization` and `Cookie` headers, values given to names such as `TOKEN` or `PASSWORD`. That catches mistakes; it cannot know a secret that has no shape and no name. Do not paste a command's output without reading it, and never record a secret on purpose.
### Instructions
`list_instructions` lists what is still to do (`queued` and `delivered`). An instruction is a review comment, a finding or a reviewer's own words, written out as it was when sent. For each one: `mark_instruction_delivered` when you take it on, then do the work, record it, and call `mark_instruction_answered` just before you push (leave `version` out and it is tied to the version that push makes). A `must_fix` finding on a branch you are named as the agent of arrives as an instruction on its own, whether a reviewer or a CI job raised it.
---
applyTo: '**'
description: Use the infrawrench CLI to inspect accounts, resources, metrics, and costs from the terminal. Trigger when asked to list or check infrastructure from the shell, script against Infrawrench data (--json), page on-call, or push cost rows.
---
# infrawrench CLI
The Infrawrench desktop app doubles as the `infrawrench` CLI: same local
accounts, same cloud session, same organizations. Enable the shell command
once from the desktop app's sidebar footer, or run `infrawrench cli install`.
For scripting, always pass `--json` — every listing/data command supports it.
Text mode (the default) renders ANSI tables and charts for humans.
## Commands
- `infrawrench` / `infrawrench tui` — interactive dashboard (needs a TTY)
- `login` / `logout` / `whoami` — cloud session (browser PKCE)
- `orgs` — list organizations
- `accounts` — list accounts (local + every org by default)
- `resources --account <id|name> [--type <typeId>]` — list an account's resources
- `resource <id>` — one resource's fields & outputs
- `metrics <id> [--last 6h] [--series cpu] [--local]` — metric charts
- `costs [--last 30d] [--group-by provider|account|service|region|resource]` — org cost graphs
- `costs push --source <name> [--file rows.json]` — push your own cost rows (stdin when no file)
- `page <message> --source <name> [--key k] [--title t] [--cooldown min] [--voice]` — alert on-call
- `page clear --source <name> [--key k]` — drop a page key's cooldown after recovery
- `cli install|uninstall|status` — manage the shell command
## Flags
- `--org <id|name>` or `--local` — scope to one org / the local desktop workspace (mutually exclusive)
- `-a, --account <id|name>` — account for resource commands
- `--json` / `--text` — output mode (mutually exclusive; default text)
- `--last 30m|6h|7d|2w` or `--from` / `--to` — time range for metrics & costs
- `--no-color`, `-v/--version`, `-h/--help`
Exit codes: `0` ok, `1` runtime error, `2` usage error. Errors print as a
single line on stderr.
## Examples
```sh
infrawrench resources --account prod-aws --json | jq '.[].name'
infrawrench metrics res_abc123 --last 6h --series cpu
infrawrench costs --org acme --last 30d --group-by service
echo '[{"amount": 12.5, "service": "ci"}]' | infrawrench costs push --source ci
infrawrench page "db replica lagging" --source poller --key db-lag --cooldown 30
```
## Behavior to know
- While the desktop app is open, the CLI runs read-only against the shared
database, and `login`/`logout` hand off to the app.
- Cloud `resources` listings sync the account first so rows reflect the
provider now; on sync failure the CLI warns on stderr and serves cached rows.
- Bare `infrawrench` without a TTY prints help instead of launching the TUI.
`NO_COLOR` or a non-TTY stdout disables ANSI colors.
Environment files (.infraenv)Writes and fixes a repository's .infraenv, the committed file that says where every environment variable comes from, without ever putting a secret in it.
.github/instructions/infraenv.instructions.md
---
applyTo: '**'
description: Create, edit, check and pull .infraenv files, Infrawrench's committed replacement for .env: each variable is a literal, a resource output (resource()) or an organization secret (secret()). Use when asked to set up, migrate or change a project's environment variables or .env file in a repository that uses Infrawrench, to add a database URL or API key to the environment, or to fix `infraenv check` / `infrawrench env check` problems.
---
# Environment files (.infraenv)
A project that uses Infrawrench commits `.infraenv` instead of `.env`. It lists every environment variable and says where its value comes from, so it is reviewed and versioned like code, and it never holds a secret value. `infraenv pull` (the `@infrawrench/infraenv` npm package) or `infrawrench env pull` (the desktop app's CLI) resolves it into a normal `.env` that starts with `# Auto-generated by Infrawrench. Do not edit.` The user-facing guide is https://infrawrench.com/docs/features/env-files. Read the "The .infraenv format" section below before writing anything beyond a simple variable, and the "Converting an existing .env" section below when converting an existing `.env`.
## Rules
- **Never write a secret value into `.infraenv`**, and never copy one out of `.env` into it, a commit message or chat. A secret becomes a `secret("NAME")` reference (an organization secret the user creates in Infrawrench) or a `resource(...)` reference to where it already lives.
- **Never edit the generated `.env`.** Change `.infraenv` and pull again. A `.env` without the generated header is hand-written: do not overwrite it unless the user says so (`--force`).
- **Prefer references by name** (`resource("<plugin>/<type>", "<display name>", "<output>")`). They resolve in whichever organization pulls the file. Pin by id (`resource("<id>", "<output>")`) only when the user wants one exact resource or a name is ambiguous.
- **Do not add `[infrawrench] org`** unless the user asks to pin the file to one organization.
- Keep `.env` (the output) in `.gitignore`.
## Process
1. **Find the file.** `.infraenv` at the repository root (or the one the user names). If there is none, create it with `infraenv check` passing afterwards (see the "Converting an existing .env" section below when a `.env` exists).
2. **Find the values' sources.** With the Infrawrench MCP server connected, `list_env_sources` searches the organization's resources and lists each one's outputs with a suggested variable name; `describe_env_file` checks a draft. Without it, ask the user which resource or secret each variable should come from; do not guess ids.
3. **Write the variables.** Shared values go in `[env]`; what differs per environment goes in `[env.<name>]`, or better, in a substitution: `[vars]` / `[vars.<name>]` plus `${name}` inside the reference, so one line serves every environment. Put a `# <Plugin>: <resource name> (<output>)` comment above each reference.
4. **Check.** Run `infraenv check` (or `infrawrench env check`, or the `describe_env_file` tool). It reports syntax errors with line numbers, references that match nothing or several resources, outputs a type does not have, secrets that do not exist or have no value, and substitutions with no value. Fix every problem; report any that need the user (a secret to create, an account to connect).
5. **For Infrawrench CI**, a job loads the file with `env-file:`; `check_ci_env_file` (MCP) says what each variable would give a job on a given branch and what to grant first. In CI, `secret()` reads the repository's CI secrets, not the organization's.
6. **Pull only if asked.** `infraenv pull [--env <name>]` writes `.env` with the real values. Do not print the values; the commands never do in text mode.
## Commands
| npm package (`npx infraenv` or `node_modules/.bin/infraenv`) | Desktop CLI | What it does |
| ------------------------------------------------------------ | ---------------------------------- | -------------------------------------------------------------------- |
| `infraenv check [--var k=v]` | `infrawrench env check` | What each reference points at, and every problem. Exit 1 on any. |
| `infraenv pull [--env <name>] [--var k=v] [--stdout]` | `infrawrench env pull` | Resolve and write `.env` (mode 0600). Exit 1 if a variable failed. |
| `infraenv install` / `uninstall` / `status` | `infrawrench env hooks install` | Git hooks that pull again when a commit changes `.infraenv`. |
| | `infrawrench env init --from .env` | A new `.infraenv` with one `secret("KEY")` line per `.env` key. |
| `await config()` from `@infrawrench/infraenv` (in code) | | Load `.infraenv` into `process.env` at startup; keeps set variables. |
The npm package reads `INFRAWRENCH_API_KEY` (an `iwk_` key) when it is set, else the key `infraenv login` stored; the desktop CLI uses the desktop app's sign-in. In a third-party CI, set `INFRAWRENCH_API_KEY` and run `npx @infrawrench/infraenv pull --env <name>`; in Infrawrench CI, a job's `env-file:` key loads the file without a key.
## Example
```ini
[vars]
stage = dev
[env]
NODE_ENV = development
# Neon: storefront / dev (Connection string)
DATABASE_URL = resource("neon/neon-branch", "storefront / ${stage}", "connectionString")
STRIPE_SECRET_KEY = secret("STRIPE_SECRET_KEY_${stage}")
[vars.production]
stage = main
[env.production]
NODE_ENV = production
```
## The .infraenv format
A dotenv file with INI sections. Lines before any section belong to `[env]`, so a `.env` of plain values is already a valid `.infraenv`. `#` starts a comment line.
### Sections
| Section | Holds |
| --------------- | ----------------------------------------------------------------------------------------------------------------- |
| `[infrawrench]` | Optional settings: `output = .env` (where pull writes, relative to the file), `org = <id>` (pins the org; avoid). |
| `[vars]` | Substitutions for every environment: `name = value`. Never environment variables themselves. |
| `[env]` | Variables every environment gets. |
| `[vars.<name>]` | Substitutions for one environment, over `[vars]`. |
| `[env.<name>]` | Variables for one environment, over `[env]`. Variables it does not mention are inherited. |
Environment names use letters, digits, `-` and `_`. Variable and substitution names use letters, digits and `_`, not starting with a digit.
### Values
| Written as | Meaning |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `development`, `"two words"`, `'raw $text'` | A literal. Quote it if it has spaces or `#`. A quoted value is always a literal, even `"secret(\"x\")"`. |
| `resource("<plugin>/<type>", "<name>", "<output>")` | An output of the synced resource with that plugin id, resource type id and display name, in the pulling organization. |
| `resource("<plugin>/<type>@<account>", "<name>", "<output>")` | The same, in the account with that display name. Use when two accounts have a resource of that name. |
| `resource("<id>", "<output>")` | An output of one resource by its id (`plugin:account:external-id`). Only resolves in the organization that owns it. |
| `secret("<NAME>")` | The organization secret with that name (the same store Infrawrench workflows use). |
Arguments are double-quoted strings with `\"` and `\\` escapes. Plugin ids, type ids and output keys come from `list_env_sources` (or the Infrawrench app's picker); never invent them.
### Substitutions
`${name}` inside the arguments of `resource()` and `secret()` is replaced before lookup. Values, lowest first: `[vars]`, the built-in `environment` (the environment being pulled), `[vars.<environment>]`, then `--var name=value`. A name with no value is a problem on that variable. Substitution never applies to literals: `HINT = ${HOME}` stays as written. `$${` is a literal `${` inside a reference.
### Resolution
- Pulling `--env production` gives `[env]` with `[env.production]` laid over it; no `--env` gives `[env]` alone.
- A variable whose source fails (no match, several matches, no value, a provider error) is reported with its line and left out of `.env`; the rest are written.
- In Infrawrench CI, a job's `env-file:` key loads the file, but only resources the repository is granted and the repository's CI secrets resolve there.
## Converting an existing .env
The goal is a committed `.infraenv` with the same keys and no secret values.
1. **Read the keys, not the values aloud.** List the keys in `.env` (and `.env.example`, `.env.production` and the like, if present). You may look at a value only to classify it; never repeat it.
2. **Classify each key:**
- **Not secret** (ports, feature flags, public URLs, `NODE_ENV`): keep it as a literal.
- **Comes from infrastructure** (database URLs, cache URLs, bucket names, endpoints, API keys a provider issues): find the resource with `list_env_sources` and write a by-name `resource()` reference with the output the key needs.
- **A secret with no resource behind it** (a third-party API key): write `secret("KEY")` and tell the user to create the organization secret `KEY` in Infrawrench (Environment files, or Settings) with the value from their `.env`. Do not create it for them with the value from the file unless they ask.
3. **Split environments.** Values that differ between the user's `.env.<stage>` files become `[env.<stage>]` overrides, or a `[vars]` substitution when only part of a name changes.
4. **Write `.infraenv`, then check it** with `infraenv check` (or `infrawrench env check`) and fix every problem.
5. **Leave the old `.env` alone.** The first pull refuses to overwrite a `.env` without the generated header; the user decides when to pass `--force`. Make sure `.env` is gitignored, and suggest `infraenv install` (or `infrawrench env hooks install`) so it regenerates when `.infraenv` changes.
`infrawrench env init --from .env` does steps 1 and 2 crudely (every key becomes `secret("KEY")`); use it as a start, then replace each line with the right kind.
Migrate from GitHub ActionsConverts a repository's GitHub Actions workflows into Infrawrench CI pipelines, job by job, and reports what could not move.
---
applyTo: '**'
description: Convert GitHub Actions workflows (.github/workflows/*.yml) into Infrawrench CI pipelines (.infrawrench/ci/*.yml). Use when asked to move a repository's CI from GitHub Actions to Infrawrench CI, or to translate a workflow, job, step or action into Infrawrench CI.
---
# Migrate GitHub Actions to Infrawrench CI
Infrawrench CI runs the pipelines in a repository's `.infrawrench/ci/` folder on every push and pull request. Each job is one script (or one tool) that runs in its own WebAssembly sandbox over an in-memory snapshot of the commit, with the dependencies already installed from the lockfile. There are no steps, no marketplace actions and no runner images: most of a GitHub Actions job's steps either disappear or become lines of one script.
The reference for every key is the runner's README, `ci-runner/README.md` in the Infrawrench repository, and the user-facing guide is https://infrawrench.com/docs/features/ci. Read the sections below when the step below says so; they are written to be read one at a time.
## Process
1. **Inventory.** Read every file in `.github/workflows/`. For each workflow, list its triggers, its jobs, what each job runs on (`runs-on`), the actions it uses, its services, the secrets and variables it reads, and which jobs depend on which. Note reusable workflows (`workflow_call`) and composite actions (`.github/actions/`), which are inlined, not called.
2. **Classify each job** into one of three groups, and tell the user the result before writing files:
- **Runs on the runner**: bash, Node, Python, Go, PHP, TypeScript type checks, formatters, Postgres or ClickHouse tests, deployment CLIs. Most jobs.
- **Becomes a cloud job** (`cloud:`): anything that needs Docker, a native binary with no WebAssembly build, a GPU, or a real Linux machine. Rust is not one of these: it compiles with `tools: [builtin:[email protected]]` (see the "What changes, and what does not move" section below). It runs on one of the organization's connected cloud accounts, which an admin has to opt in to CI first.
- **Stays on GitHub Actions**: macOS and Windows jobs, and anything relying on an event Infrawrench CI does not have (see the "What changes, and what does not move" section below).
3. **Write one pipeline per workflow**, `.infrawrench/ci/<same-name>.yml`, starting with the schema comment so editors validate it:
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/Infrawrench/Infrawrench/main/ci-runner/schema/ci.schema.json
```
Translate the triggers, jobs, expressions and environment variables with the "GitHub Actions to Infrawrench CI: key by key" section below, and replace each action with the "Replacing actions" section below.
4. **Move dependency installs to the workspace.** Delete `actions/setup-*`, `actions/checkout` and `npm ci` / `pnpm install` / `pip install -r` steps, and list the package managers under `workspace.deps` instead. Dependencies are installed once per commit and checked against the lockfile; install scripts do not run, so a `postinstall` that generates code (Prisma, protobuf) becomes an explicit line in the jobs that need it.
5. **Split big jobs.** A job that runs a whole monorepo's tests or type checks (`turbo run test`, `nx affected`, `pnpm -r test`) becomes a `packages:` job, one job per workspace package, with the task cache. Read the "Monorepos: from a few big jobs to a job per package" section below. This is usually the largest speed-up of the migration.
6. **Check the limits.** Read the "What changes, and what does not move" section below and fix anything it flags: the 10-minute default timeout, the 2 GiB default memory, pipes in scripts, and the checkout having no `.git`.
7. **List what the user has to do in Infrawrench**, since an agent cannot do it:
- Add every secret and variable the pipelines read under **CI → Secrets and variables** (names only: never write a secret's value into a file).
- Turn on what jobs borrow under **CI → CI access**: connections that run cloud jobs, connections lent with `connections:`, SSH keys lent with `ssh-keys:`.
- Tick **Run CI** for the repository's GitHub account if it is not on yet.
8. **Validate.** Push to a branch and open a pull request. A pipeline file that does not parse fails at once with a job named **Pipeline file** whose output gives every error with its path in the file (`jobs.test.timeout: ...`). With the Infrawrench MCP server connected, `list_ci_runs` and `get_ci_job_log` read the results without leaving the editor.
9. **Run both side by side, then switch.** Keep the GitHub Actions workflows until the Infrawrench runs pass on the same commits. Then delete the migrated workflows (or the migrated jobs, for a workflow that keeps some), and change branch protection to require **Infrawrench CI / pull request**, the check that covers every job of the run.
## Rules that catch people out
- **A job is one script.** `run:` is bash with `set -euo pipefail`. Join a GitHub job's `run` steps into one `run: |` block in order. Use `if:` on a job, not on a line; inside the script, use shell conditionals.
- **Secrets only in `env:`.** `${{ secrets.NAME }}` works only as an `env:` value. Map it to a variable and read the variable in the script.
- **Pick an environment.** Every job without `cloud:` names `using:`: `env:bash@5`, `env:bash-node@24`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, or a tool such as `builtin:[email protected]`. Versions are pinned; a bare name is an error.
- **Jobs in `needs:` hand files on with `artifacts:`**, not with upload and download actions. Files for people to download from the run are `downloads:`.
- **Pull requests from forks** run only after a maintainer approves them, get no secrets, and never run cloud jobs. There is no `pull_request_target` equivalent.
## What to hand back
Finish with a short report: each workflow and job, where it went (runner, cloud job, stayed on GitHub Actions) and why, the secrets and variables to add, the CI access to turn on, and anything you were unsure of. Do not claim speed-ups you have not measured.
## Replacing actions
There are no actions. Each `uses:` step is dropped, becomes workspace or job configuration, or becomes a command in the job's script. When an action is not listed here, read what it runs (its `action.yml` and entry point) and do that in the script: most wrap a CLI that runs in `env:bash-node@24` with `npx` or a pinned global install. Pin every version.
### Setup and checkout
| Action | Replacement |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions/checkout` | Drop it. Every job starts in the commit's files at `/app`. There is no `.git`; see the "What changes, and what does not move" section for jobs that need history. |
| `actions/setup-node`, `pnpm/action-setup` | `using: env:bash-node@24` (Node 24, `npm`, `pnpm`, `npx`), and `workspace: { deps: [pnpm] }` (or `[npm]` for `package-lock.json`) instead of the install step. |
| `oven-sh/setup-bun` | `tools: [builtin:bun@1]` (Bun 1.4.4) on `using: env:bash@5`, and `bun install --frozen-lockfile` in the script, or `deps: [{ bun: { native: true } }]` when no install script matters; read the "What changes, and what does not move" section. |
| `actions/setup-python` | `using: env:[email protected]`, and `deps: [pip]` (reads `pylock.toml` or `requirements.txt`; `- pip: { file: requirements/ci.txt }` for another). |
| `actions/setup-go` | `using: env:[email protected]` (1.23 to 1.27), and `deps: [go]` for `go.sum`. |
| `shivammathur/setup-php` | `using: env:[email protected]` (8.1 to 8.5), and `deps: [composer]`. |
| `dtolnay/rust-toolchain`, `actions-rs/*` | `tools: [builtin:[email protected]]` in an `env:bash@5` job (rustfmt and clippy included), with `workspace: { deps: [cargo] }`; see the "What changes, and what does not move" section. A non-host `targets:` needs a cloud job. |
| `Swatinem/rust-cache` | Nothing: crates come from `deps: [cargo]`. To keep `target/` between runs, `cache: { key: ..., paths: [target] }`. |
| `ruby/setup-ruby` | `using: env:[email protected]` (or `@3.4`), and `deps: [bundler]` instead of `bundler-cache: true`; see the "What changes, and what does not move" section for Rails. |
| `actions/setup-java`, `setup-dotnet` | No environment for these yet. Make the job a cloud job with an `image:` that has the runtime. |
### Caches and files between jobs
| Action | Replacement |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `actions/cache` for `node_modules`, `~/.npm`, `~/.cache/pip`, `~/go/pkg` | Drop it: `workspace.deps` installs are cached by the runners. Go's build cache is kept on its own. |
| `actions/cache` for anything else | `cache: { key, restore-keys, paths }` with `${{ hashFiles('...') }}` in the key. Saved only when the job passes. Pull requests save to a scope the default branch never reads. |
| `actions/cache` for `.turbo` or `.nx` | Drop it and use the task cache instead (`task-cache:`), which skips whole jobs. See the "Monorepos: from a few big jobs to a job per package" section. |
| `actions/upload-artifact` + `download-artifact` between jobs | `artifacts: [dist]` on the producing job; every job that `needs:` it starts with those files where they were left. |
| `actions/upload-artifact` for people | `downloads: [report.html]`, or `{ paths, retention: 7d, when: always }`. Text files are masked for secrets; binary files are not, so never put a secret in one. |
### GitHub itself
Every one of these needs `github-token:` with the permissions it used, and `tools: [builtin:[email protected]]` for the `gh` command. The token is for the run's own repository, lasts an hour from when the run starts, and is never given to a fork's pull request.
| Action | Replacement |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `softprops/action-gh-release`, `ncipollo/release-action` | `gh release create "$TAG" dist/* --notes-file NOTES.md` with `github-token: { contents: write }`. |
| `peter-evans/create-pull-request` | Clone the repository in the script (the checkout has no `.git`), commit, push a branch and `gh pr create`, with `github-token: { contents: write, pull-requests: write }`. |
| `actions/github-script` | `gh api ...` in the script, or a Node script reading `GITHUB_TOKEN`. |
| `stefanzweifel/git-auto-commit-action` (formatters, codegen) | Make the job a check instead: `changes: fail` fails it when the formatter changes a file. To commit back, clone the repository in the script with `github-token: { contents: write }`. |
| `actions/labeler`, `actions/stale`, issue automation | These react to events Infrawrench CI does not have. Keep them on GitHub Actions. |
### Clouds and deployments
Credentials are lent, not stored: an admin turns a connection on for CI under **CI access**, and the job names it. Do not move cloud keys into secrets when a connection can be lent.
| Action | Replacement |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `aws-actions/configure-aws-credentials` | `using: env:[email protected]` and `connections: [<connection name>]`: the `aws` CLI is signed in with the lent session. |
| `google-github-actions/auth` + `setup-gcloud` | `using: env:gcloud@593` and `connections: [<name>]`: `gcloud` and `bq` use the lent access token. |
| `azure/login` | `using: env:[email protected]` and `connections: [<name>]`: `az` signs in with the lent service principal. |
| `azure/setup-kubectl`, `azure/k8s-*`, `deliverybot/helm` | `tools: [builtin:[email protected]]` and `connections: [<cluster connection>]`, which writes a kubeconfig and sets `KUBECONFIG`. Helm has no builtin: run it in a cloud job. |
| `webfactory/ssh-agent`, `appleboy/ssh-action`, `appleboy/scp-action` | `ssh-keys: [<key name>]` (the key's owner turns on **Use in CI jobs**) or a lent SSH host connection, and `tools: [builtin:[email protected]]` (add `builtin:[email protected]` for `scp`). |
| `amondnet/vercel-action` | `tools: [builtin:vercel@65]`, `VERCEL_TOKEN` from a secret in `env:`, then `vercel deploy --prod --yes`. |
| `cloudflare/wrangler-action` | `tools: [builtin:wrangler@4]`, `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in `env:`, then `wrangler deploy`. |
| `neondatabase/create-branch-action` | `tools: [builtin:neon@9]`, `NEON_API_KEY` in `env:`, then `neon branches create ...`. |
| `docker/login-action`, `docker/build-push-action`, `docker/setup-buildx-action` | A build job: `cloud: aws/build` (CodeBuild), `gcp/build` (Cloud Build), `azure/build` (ACR Tasks) or `docker/build` (your own Docker host), with `docker build` and `docker push` in `run:`. Write the image digest to an output for the deploy job. |
### Testing and reporting
| Action | Replacement |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `codecov/codecov-action` | Upload with Codecov's CLI in the script (`npx`), `CODECOV_TOKEN` in `env:`. |
| `dorny/test-reporter`, `mikepenz/action-junit-report` | Keep the JUnit file with `downloads: { paths: [junit.xml], when: always }`. The run page and the GitHub check show each job's result. |
| `microsoft/playwright-github-action` | Browsers do not run in a job. Run end-to-end browser tests as a cloud job with an image that has the browsers. |
## What changes, and what does not move
Check each migrated job against this list before handing back.
### Defaults that differ
- **Timeout: 10 minutes**, not 6 hours. Set `timeout:` (`30m`, `2h`, at most `6h`) on any job that can run longer. A job that prints nothing and uses no CPU for 5 minutes is stopped as stuck.
- **Memory: 2 GiB** per job, up to `16GiB` with `memory:`. Large test suites and bundlers usually want `4GiB` or more; a job over its limit fails and its report says so.
- **CPU: a share of one vCPU** per job, not a machine of its own, and its programs are told 1 CPU (`nproc`, `os.cpu_count()`, `os.availableParallelism()`), so anything that sizes its workers from the CPU count (`pytest -n auto`, Vitest, Jest, `cargo`, `make -j$(nproc)`) runs one. A job that builds or tests in parallel (`make -j`, `go test -p`, `cargo`, a test runner's workers) gets `cpus:` (1 to 64), whether or not it ran on a larger runner, and is then told that many: `-n auto` and `nproc` follow it, and a hard-coded count becomes `$IWCI_CPUS`. Billing follows: a job with `cpus: 4` is charged four vCPUs for as long as it runs.
- **One environment per job.** There is no image with everything installed. Pick the `using:` environment for the job's language, and add other tools with `tools: [builtin:...]`.
### Scripts
- **Pipes do not fail the script.** A pipeline reports only its last command's status, even with `pipefail`: `npm test | tee log.txt` passes when the tests fail. Write `npm test > log.txt 2>&1` and print the file afterwards, or drop the pipe.
- **No terminal.** Standard input is empty and nothing is a TTY, so prompts fail and colour is usually off. Pass non-interactive flags (`--yes`, `-y`, `--ci`).
- **No `sudo` and no `apt-get`.** The job's file system is its own; install command-line tools with `npm i -g` or `pnpm add -g` (pinned) in `env:bash-node`, or `pip install` in `env:python`. A system package means a cloud job.
- **Hard links work within the job's own files** (`ln`, `fs.linkSync`, `os.link`): the names are one file, with one inode number and a link count. A link to or from another mount (`/usr/local/bin`, the run's scratch directory) fails with `EXDEV`, which programs that link fall back to copying on, and caches, artifacts and `changes:` keep each name as a file of its own. Symbolic links work.
### The checkout
- **No `.git`.** Jobs get the commit's files, not a repository: `git log`, `git describe`, `git diff origin/main` and tools that read history (changelog generators, semantic-release) fail. Clone in the script when history is needed, with `github-token: { contents: read }` for a private repository: `git clone --depth=50 "https://github.com/$GH_REPO.git" /tmp/repo`.
- **No submodules** and **no Git LFS content** (a file kept in LFS is its pointer). Fetch them in the script if a job needs them.
- What changed in the push is still known: use `paths:` on a job or `changed('glob')` in `if:` instead of `git diff`.
### Languages and native code
- **Node 24 only** on the runner (`env:bash-node@24`). A matrix over older Node versions becomes one job on 24, or cloud jobs for the others.
- **Native Node addons** load only when the package ships a WebAssembly (`wasm32-wasi`) build: Vite 8, Vitest, Rolldown, tsdown, oxc and the Astro compiler do. A dependency with only native binaries (some image, database and crypto libraries) needs a cloud job.
- **npm**: `deps: [npm]` installs from `package-lock.json` (lockfile version 2 or 3; a version 1 lockfile needs `npm install --lockfile-version 3` with npm 7 or later). Do not keep `npm ci` in a job: npm refuses packages whose `os` list leaves out the job's platform. `npm run` scripts find their dependencies' commands in `node_modules/.bin`, as on a developer's machine.
- **Yarn lockfiles** are not installed by `workspace.deps` (it supports pnpm, npm, Bun, Go, Cargo, pip, Composer and Bundler). Convert with `pnpm import` and commit `pnpm-lock.yaml`.
- **Bun** is `tools: [builtin:bun@1]` (Bun 1.4.4, whose newest build `@1`, `@1.4` and `@1.4.4` all pick; `@1.3` and other versions do not exist), the real Bun run natively in a sandbox. Use it with `using: env:bash@5`, which has no `node`, so Bun runs package scripts, `#!/usr/bin/env node` bins and install scripts itself, and install in the job with `bun install --frozen-lockfile`, which gets the Linux builds of turbo, oxlint, esbuild and the like. `deps: [{ bun: { native: true } }]` instead installs once per lockfile, cached and checked against its hashes, with `node_modules/.bin` and the Linux builds of turbo and oxlint, so `bunx turbo` and `bun run lint` work over it; it runs no install scripts, and esbuild, Rollup and Lightning CSS are their slower WebAssembly builds there. Without `native: true` it has no native packages, and Bun fails over it. In `env:bash-node@24`, `node` is a WebAssembly Node (`process.platform` is `wasi`), and Bun runs install scripts with it, so a `postinstall` that loads a native package fails there. In `env:bash@5`, a file run with `bun run ./script.mts` that spawns `node` finds no `node`: link one, `ln -s "$(command -v bun)" /tmp/bin/node`, with `/tmp/bin` first on `PATH`. `env:bash@5` has no `npm`; use `bunx npm@11`. `cache:` `/root/.bun/install/cache`, keyed on `hashFiles('bun.lock')`, saves the downloads.
- **Ruby** (`env:[email protected]`, `@4.0`): gems with C extensions install only through `deps: [bundler]`, which has builds of the ones a `rails new` app locks (nokogiri, sqlite3, puma, bootsnap and the rest) at those versions; another one, or another version, fails the install naming the versions that have a build, and `- bundler: { without-extensions: [name] }` installs a gem the jobs never load without it. A Rails app needs `gem "tzinfo-data"` on every platform (no zoneinfo here; drop `platforms:`, then `bundle lock`) and `gem "selenium-webdriver", require: false` (it refuses to load here). No `fork`: Rails tests run in one process (`PARALLEL_WORKERS=1` is set), and system tests need a browser, so a cloud job. `bundle exec ruby` loses the bundle's settings; use `bin/rails`, `bundle exec rake` or `ruby -rbundler/setup`.
- **Rust**: `using: env:bash@5` with `tools: [builtin:[email protected]]` (rustc, cargo, rustdoc, rustfmt, clippy, and GCC 13 with binutils for linking and for build scripts that compile C), and `workspace: { deps: [cargo] }` so crates come from `Cargo.lock` with no network. Give build and test jobs `memory: 4GiB` to `8GiB` (the `target/` directory counts). The builtin's version is the toolchain: `rust-toolchain.toml` is ignored and there is no `rustup`, so `rustup target add` and cross builds need a cloud job, as do crates that link a system library (OpenSSL without `vendored`) or need a C++ compiler. A built binary runs from the script as on Linux. It needs a runner with the native sandbox; a job on one without fails saying so.
- **Native binaries from npm packages** (Turborepo's `turbo`, sherif, and others that pick a per-platform optional dependency): `workspace: { deps: [{ pnpm: { native: true } }] }` (or `bun`) and `tools: [builtin:[email protected]]` on the `env:bash-node@24` job that runs them. Without both, the binary is missing or does not start. TypeScript 7 (`tsc` from `typescript@7`) works the same way. A tool that loads a native Node addon in-process with no WebAssembly build (oxlint) runs under Bun instead: `tools: [builtin:[email protected], builtin:[email protected]]` and `bun node_modules/oxlint/bin/oxlint`. A project that pins pnpm 12 (`packageManager` or `engines.pnpm`) switches to it in a job with `native: true` on its pnpm dep and `tools: [builtin:[email protected]]`.
- **Java, .NET, Swift**: no environment yet. Cloud jobs.
### Services and containers
- **Postgres** (`env:postgres@18`, PGlite: many connections, `pgcrypto`) and **ClickHouse** (`env:[email protected]`) run as `services:` inside the job. Postgres runs one transaction at a time and shares `SET`, advisory locks and `LISTEN` across connections, so tests that depend on concurrent transactions need a real Postgres in a cloud job.
- **Any other service image** (Redis, MySQL, Elasticsearch, a vendor emulator): start it in a cloud job (`cloud: { provider: docker, kind: container }` or a VM with Docker), or, when it is a Node or Python program, as a `services:` entry running that program.
- **No Docker on the runner.** `docker build`, `docker run` and `docker compose` go in a cloud job: `kind: build` for building and pushing images, `kind: vm` or `container` for running them.
- **No browsers.** Playwright, Cypress and Puppeteer tests run as cloud jobs.
### Events and features with no equivalent
Keep these on GitHub Actions, or say what the user could do instead:
- Triggers other than push, pull request, schedule and manual: tags, releases, `workflow_run`, `issues`, `issue_comment`, `pull_request_target`, `repository_dispatch`, `merge_group`.
- macOS and Windows runners.
- GitHub Pages deployment through `actions/deploy-pages` (deploying the built site with a CLI from a job works).
- Job-level `concurrency`, `continue-on-error`, `fail-fast`, matrix `include:`.
- `environment:` protection rules and required reviewers. CI access limits what each repository and branch may use, and a fork's pull request waits for a maintainer's approval.
- OIDC (`id-token: write`) to a cloud. Lend the cloud's connection instead (`connections:`), which needs no stored key either.
## GitHub Actions to Infrawrench CI: key by key
Unknown keys are an error, so leave out anything without a row here rather than carrying it over.
### Workflow level
| GitHub Actions | Infrawrench CI |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `name:` | `name:` (required) |
| `on: push` with `branches`, `paths` | `on: { push: { branches, paths } }` |
| `branches-ignore`, `paths-ignore` | The same list with each pattern quoted and prefixed with `!`: `paths: ["!docs/**"]` |
| `on: pull_request` with `branches`, `paths` | `on: { pull-request: { branches, paths } }`. `types:` has no equivalent; every opened or updated pull request runs. |
| `on: schedule` with `cron` | `on: { schedule: [{ cron: "0 3 * * *" }] }`, UTC, runs the default branch's head |
| `on: workflow_dispatch` with `inputs` | `on: { manual: { inputs } }`: types `string`, `boolean`, `choice` (with `options`), `number` |
| `on: push: tags`, `release`, `workflow_run`, and others | No equivalent: tag pushes start nothing. Keep the workflow on GitHub Actions, or start it by hand. |
| `env:` at the top | No top-level `env`. Repeat it on each job, or share it with a YAML anchor (`env: &env {...}`, then `env: *env`). |
| `concurrency:` | `concurrency:` at the top only, `{ group, cancel-in-progress }`. A job-level `concurrency` has no equivalent. |
| `permissions:` | Per job, `github-token: { contents: write, pull-requests: write }`. No token at all unless a job asks. |
| `defaults.run.working-directory` | `cwd:` on each job, absolute: `/app/<dir>` |
| `defaults.run.shell` | Always bash. A Python or Node step becomes `python - <<'EOF'` or `node -e` in the script, or a script file it runs. |
### Job level
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `runs-on: ubuntu-*` | Nothing: the job runs on the runners. Choose `using:` for the language instead. |
| `runs-on:` a larger runner (`ubuntu-latest-8-cores`, `ubuntu-24.04-16core`) | `cpus: N` (1 to 64), the runner's vCPU count, so the job holds whole vCPUs rather than a share of one. Its scripts read the number from `$IWCI_CPUS` (`-j"$IWCI_CPUS"`). Billed at those vCPUs. Size `memory:` separately. |
| `runs-on: self-hosted` or a label | `cloud:` on a connected account (`aws/vm`, `gcp/container`, `docker/container`, `kind: host` for an existing machine over SSH). |
| `steps:` | One `run: \|` script, the `run` steps joined in order. Each `uses:` step is replaced as in the "Replacing actions" section. |
| `needs:` | `needs:` |
| `if:` | `if:` on the job. Functions: `success()`, `failure()`, `always()`, `contains`, `startsWith`, `endsWith`, `changed('glob')`. No `cancelled()`, `format`, `toJSON`, `fromJSON` or `hashFiles` here. |
| step-level `if:` | A shell `if` in the script, or a separate job with its own `if:`. |
| `strategy.matrix` | `matrix: [a, b]` (read as `${{ matrix }}`) or named axes `{ node: [22, 24], os: [x] }` (read as `${{ matrix.node }}`), with `exclude:`. Up to 64 entries. No `include:`: write those as separate jobs. |
| `fail-fast`, `max-parallel` | Leave out. Every entry runs; the runner schedules them. |
| `continue-on-error` | Leave out. Let the dependents run anyway with `if: always()`, and read `${{ needs.<job>.result }}`. |
| `timeout-minutes: 30` | `timeout: 30m`. The default is 10 minutes (GitHub's is 6 hours), the most 6 hours. Set it on anything that can take longer than 10 minutes. |
| `env:` | `env:`. `${{ secrets.X }}` works only here. |
| `outputs:` + `$GITHUB_OUTPUT` | `outputs: [name]` and `echo "name=value" >> "$IWCI_OUTPUT"`. Writing an undeclared name fails the job. A matrix job cannot have outputs. |
| `services:` (Docker images) | `services:` with `env:postgres@18` (`run: pglite-server`) or `env:[email protected]`, reached as `postgres:5432`. Other images: see the "What changes, and what does not move" section. |
| `container:` | No equivalent on the runner. Choose the matching `using:` environment, or make it a cloud job with `image:`. |
| `environment:` | No equivalent. What a branch may use is set in **CI access** (connections, SSH keys and resources per repository and branch). |
| `uses: ./.github/workflows/x.yml` | Inline the called workflow's jobs into this pipeline. |
### Expressions
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------- | --------------------------------------------------------------------- |
| `${{ github.sha }}` | `${{ commit.sha }}` (`${{ commit.short-sha }}` for the short form) |
| `${{ github.ref_name }}`, `github.head_ref` | `${{ commit.branch }}` |
| `${{ github.event_name }}` | `${{ event }}`: `push`, `pull-request`, `schedule` or `manual` |
| `${{ github.event.pull_request.number }}` | `${{ pull-request.number }}` (empty unless a pull request) |
| `${{ github.workflow }}` | `${{ pipeline.name }}` |
| `${{ github.repository }}` | `$GH_REPO` in a job with `github-token:`; otherwise write it out |
| `${{ inputs.x }}` / `${{ github.event.inputs.x }}` | `${{ inputs.x }}`, never inside `run:`: map it in `env:` and quote it |
| `${{ vars.X }}` | `${{ vars.X }}` |
| `${{ secrets.X }}` | `${{ secrets.X }}`, in `env:` values only |
| `${{ needs.a.outputs.b }}`, `${{ needs.a.result }}` | The same |
| `${{ matrix.x }}` | The same; a one-axis list is `${{ matrix }}` |
| `${{ env.X }}` | `$X` in the script |
| `${{ runner.os }}`, `${{ runner.temp }}` | Always Linux-like; use `/tmp` |
| `${{ hashFiles('x') }}` | Only in a `cache:` `key` or `restore-keys` |
### Environment variables in scripts
| GitHub Actions | Infrawrench CI |
| --------------------------- | ---------------------------------------------------------------------------------- |
| `GITHUB_SHA` | `IWCI_COMMIT` |
| `GITHUB_REF_NAME` | `IWCI_BRANCH` |
| `GITHUB_WORKSPACE` | `/app` (the clone, and every job's default working directory) |
| `GITHUB_OUTPUT` | `IWCI_OUTPUT` |
| `GITHUB_ENV`, `GITHUB_PATH` | Not needed: the job is one script, so `export` and `PATH=...` carry to later lines |
| `GITHUB_STEP_SUMMARY` | No equivalent; keep a report with `downloads:` |
| `GITHUB_TOKEN` | Set only in a job with `github-token:` (also `GH_TOKEN`) |
| `RUNNER_TEMP` | `/tmp`. Files shared by the run's jobs go in `/tmp/workflow` (`$IWCI_SCRATCH`) |
| `CI` | `CI=true` |
## Monorepos: from a few big jobs to a job per package
On GitHub Actions every job pays for its own machine, checkout and install, so monorepo workflows usually have a handful of jobs that each run one task across every package (`turbo run test`, `nx affected -t lint`, `pnpm -r typecheck`). In Infrawrench CI a job costs none of that, so write one job definition per task and let it expand to one job per workspace package. Each package's job is its own row and log in the run, and the task cache skips the ones a change cannot affect.
### The shape
```yaml
name: Test
on:
push:
branches: [main]
pull-request: {}
workspace:
deps: [pnpm]
jobs:
build:
packages: { has-script: [build] }
needs: ["^build"]
using: env:bash-node@24
run: pnpm run build
artifacts: [dist]
task-cache: true
typecheck:
packages: { has: [tsconfig.json] }
needs: ["^build"]
using: builtin:[email protected]
args: [--noEmit]
task-cache: true
test:
packages: { has-script: [test] }
needs: [build]
using: env:bash-node@24
run: pnpm test
task-cache: true
memory: 4GiB
```
- **`packages:`** expands a job over the workspace (`pnpm-workspace.yaml`, or `workspaces` in the root `package.json`). `true` is every package. Narrow it with `only:` (globs over directory or name, `!` excludes), `has:` (files the package has), `has-script:` (scripts it defines) or `scripts:` (a glob its script's command must match). Each job runs in its package's directory and reads `${{ package.name }}` and `${{ package.dir }}`.
- **`needs: ["^build"]`** waits for `build` in each package this one depends on, like Turborepo's `dependsOn: ["^build"]`. `needs: [build]` in a `packages:` job means the same package's `build`. A plain job that needs a `packages:` job waits for all of its packages.
- **`artifacts:`** in a `packages:` job are relative to the package, so each package's `dist/` reaches the jobs that depend on it.
- **One slow package** can be split further: give it its own job with `only:` and a `matrix:` of shards, and leave the rest alone.
### The task cache
`task-cache: true` skips a job when nothing it reads has changed since a run of it passed, and hands on that run's log, outputs and artifacts as if it had run. Use it on every deterministic job: builds, type checks, tests, linters, formatters.
```yaml
task-cache:
inputs: [src/**, tsconfig.json, "!src/**/*.md"] # relative to the package; default: every file in it
root-inputs: [tsconfig.base.json, .eslintrc.cjs] # relative to the repository root
artifacts: false # see below
```
- **The key** covers the job's definition, the exact version of every tool and environment it uses, the lockfiles, the files its inputs match, and the bytes of every artifact it is handed. A job downstream of a change reruns only when what it is handed actually changed.
- **Name every file outside the package that a job reads** in `root-inputs:` (shared tsconfig, lint and test config, fixtures). A file the key leaves out can change without rerunning the job.
- **`artifacts: false`** leaves handed-on artifacts out of the key, for a job that only passes them along (a bundler that keeps workspace dependencies external), so a change at the bottom of the graph does not rebuild everything above it. Only when the job's result does not depend on them.
- **Cannot be task-cached:** a job that reads a secret, is lent anything (`connections:`, `ssh-keys:`), has `github-token:`, keeps `downloads:` or runs on a cloud account. Keep those jobs small and put them after the cached ones.
- A cache hit is not billed, takes no slot or memory, and a run where every job hits never installs dependencies. Pull requests keep their own results: nothing a pull request saves is used on the default branch.
### Translating common commands
| GitHub Actions step | Infrawrench CI |
| --------------------------------------------- | ------------------------------------------------------------------------------------- |
| `turbo run build` / `nx run-many -t build` | A `build` job with `packages:`, `needs: ["^build"]`, `artifacts: [dist]` |
| `turbo run test --filter=...[origin/main]` | A `test` job with `packages:` and `task-cache: true`: the cache does the filtering |
| `nx affected -t lint` | A `lint` job with `packages: { has-script: [lint] }` and `task-cache: true` |
| `pnpm -r --parallel typecheck` | A `typecheck` job with `packages:` and `using: builtin:[email protected]` |
| `pnpm --filter web test` | A job with `packages: { only: [apps/web] }`, or a plain job with `cwd: /app/apps/web` |
| A `paths-filter` step choosing which jobs run | `paths:` on each job, or `if: changed('apps/web/**')` |
Keep `turbo` or `nx` out of the jobs once they are split: each job runs one package's script directly, and the task cache replaces their caches.
git.infrawrench.com and Infrawrench CIWorks in a repository on git.infrawrench.com the way its reviewers read it: records the work on each push, answers what they send back, and writes CI jobs that put notes on the branch's page.
---
applyTo: '**'
description: Work in a Git repository hosted on git.infrawrench.com (its remote is git.infrawrench.com) and with Infrawrench CI (.infrawrench/ci/*.yml). Use when writing or reviewing code on a branch there, when the infrawrench-git MCP server is connected or should be, when asked to record a trace, answer reviewer instructions or report findings, or when writing a CI job that should leave must-fix, should-fix, note, doubt, decision, step or evidence notes on a branch's page.
---
# git.infrawrench.com and Infrawrench CI
git.infrawrench.com is a Git forge where a branch is reviewed as a record of versions. Every push to a branch that is not the default branch makes a version, and the branch's page shows what there is to read about that version before its code: what the agent that wrote it recorded (its trace), what reviewers and CI jobs found (findings), and what reviewers sent back (instructions). There are no pull requests to open: a branch gets its page at its first push.
You are in such a repository when `git remote -v` names `git.infrawrench.com`. The user-facing guides are https://infrawrench.com/docs/features/git-branches and https://infrawrench.com/docs/features/git-agents-and-mcp. Read the sections below when a step below says so.
## Connect
The forge's MCP server is `https://git.infrawrench.com/mcp`, usually added under the name `infrawrench-git`. If its tools (`record_trace`, `get_branch`, ...) are not available, tell the user how to add it: the "Connecting the forge's MCP server" section below has the command for Claude Code, Codex and Cursor. Call `whoami` once when you are unsure whether you can write. Tools take a repository as `owner/name` and a branch by its name.
## When you write code on a branch
1. **Start.** Given a task with no branch yet, call `start_work` with the ask: it makes the branch and its page, as a draft. When the task is one of the repository's open issues, pass its number as `issue` instead: the page takes the issue's title and description and closes the issue when it is merged into the default branch. Then `git fetch origin && git switch <branch>`. If a branch already exists, check it out and call `get_branch` to see where it stands.
2. **Record as you work**, with `record_trace`, not only at the end. the "Recording a trace" section below has the kinds and their fields. In short: one `ask`, a `step` for each piece of work, a `decision` when you chose between alternatives, `evidence` whenever you ran a check (the command, its exit code, the lines of output that show the result, failures too), and a `doubt` for anything you are unsure of, skipped or could not verify. Reviewers read doubts first.
3. **Record before you push.** Entries wait on the branch and are attached to the version the next push makes. Then `git push`. A `secret_files_pending` failure kept nothing: send the same entries again in a minute.
4. **After a push**, call `get_branch` for the branch's state, `list_instructions` for what reviewers sent back and `list_findings` for what reviewers and CI found.
5. **Answer instructions.** For each one you take on: `mark_instruction_delivered`, do the work, record it, `mark_instruction_answered`, then push. If you decide not to do what was asked, record why (a `decision` or a `doubt`) and still mark it answered. An instruction whose `source` is `conflict` means the branch no longer merges cleanly into its base: fetch the base, rebase onto it (or merge it in), resolve every conflict it lists, run the checks again, and push (`git push --force-with-lease` after a rebase). The forge sends one by itself when a push leaves the branch conflicting, and marks it answered when a later push resolves it. An instruction whose `source` is `ci_failure` lists the checks that failed on the branch's newest commit, with a link to each run (`GET /api/repos/<owner>/<repo>/ci/runs/<run id>`, with the Git credential your machine has for the forge as a Bearer token, has every job's output; the branch token cannot read it). Read the output and decide: if the branch caused it, fix it, run the check, and push; if it did not (a flaky test, an outage, a failure the base has too), change nothing, record a `decision` saying why, and mark it answered. The forge sends one by itself once a commit's checks have settled with a failure, and marks it answered when a later push passes.
6. **Hand it over when it is done.** The branch's page is a draft until it is marked ready for review. After your last push, call `mark_ready_when_checks_pass`: the page leaves draft by itself the moment every check on its head has passed (and every check the base branch requires has reported), or now if they already have. A failing check keeps it a draft and the request waits for your fix. `enabled: false` withdraws it, and a person who marks the page by hand cancels it. It never merges.
7. **Fix what must be fixed.** An open `must_fix` finding holds the branch's merge until it is fixed, dismissed by a person, or overridden by an administrator. You cannot dismiss or override one: fix it and push, or record a `doubt` saying why you think it is wrong.
## When you review a branch
Read the change with `get_branch` and `get_version_diff`, then call `report_finding`: a `severity` (`must_fix` only for what must not merge, `should_fix`, `note`), a short `title`, a `body`, the `path` and lines, and `evidence`. Set `complete: true` when the list is everything you find on that version, so your earlier findings that are not in it are marked fixed. Report under a `reviewer` name of your own (`claude-review`).
## Images and videos
A trace entry, a finding and an ask are Markdown, and can show a screenshot or a short recording (a UI before and after a change, a failing test's screen). Call `upload_media` with the file as base64 (3 MB at most) and put the `markdown` it answers in what you write next. For a larger file or a video, post the bytes to the repository's upload address with the same token: `curl -fsS --data-binary @shot.png -H "Authorization: Bearer <token>" "https://git.infrawrench.com/<owner>/<name>/uploads?name=shot.png"` answers the same JSON. Images: PNG, JPEG, GIF, WebP, AVIF up to 10 MB; videos: MP4, WebM, QuickTime up to 90 MB. Never upload a screenshot that shows a secret.
## Infrawrench CI
A repository's pipelines are the YAML files in `.infrawrench/ci/`. They run on every push and on each branch page's new version, and their results are on the branch's **Checks** tab. A pipeline has `name:`, `on:` (`push`, `pull-request`, `schedule`, `manual`) and `jobs:`; a job is one script (`run:`) in an environment (`using: env:bash-node@24`) or on a Linux machine (`platform: linux`). Do not guess the rest: the guide is https://infrawrench.com/docs/features/ci and every key is in `ci-runner/README.md` of the Infrawrench repository.
A CI job can put notes on the branch's page by printing lines, with no token and no API call:
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
`::must-fix`, `::should-fix` and `::note` become findings; `::doubt`, `::decision`, `::step` and `::evidence` become trace entries. Read the "Notes from a CI job" section below before writing a job that prints them: it has the parameters, the escapes, the limits, what a passing job marks fixed, and a job that turns a linter's JSON report into notes. Use this when a check already runs in CI (a linter, a type checker, a test report); use `report_finding` when you are the reviewer yourself.
## Secret files
A repository may have secret files (`filter=iwsecret` in `.gitattributes`): what is committed is a pointer, or a YAML or JSON skeleton whose values are `"iwsecret:1:..."` tokens. `get_branch` and `start_work` list a branch's secret files in `secretFiles` with `secretRules`; `secretFilesPending` means the forge was still listing them, so call `get_branch` again in a few seconds. When there are any, run `infrawrench git secret install` after checking the repository out, so they are readable in your checkout (if the person you work for may read them) and uploaded when you push. A file that stays a pointer is one you cannot read: leave it as it is.
- You may read and edit these files in your checkout.
- Never put a value from them into a trace entry (asks, steps, decisions, evidence, doubts), a finding, an instruction answer, a commit message, a branch's title or description, or command output you record. Refer to a secret by its path and key name: "changed `database.password` in `config/prod.yaml`".
- Never print one in a command whose output you record as evidence.
- Never copy one into a file that is not secret. The forge refuses an agent's push that does.
- When reviewing, a pointer or a token is not a placeholder or a bug: it is how the file is committed.
- A CI job that needs one names it in `secret-files:` (paths written out, at most 32). It gets the file only on a branch the repository lends secret files to CI on; turning that on is an administrator's choice in the repository's settings, never yours.
## Never
- **Never put a secret in a trace entry, a finding or a CI note.** Tokens, keys and passwords are masked before anything is stored, but masking recognises shapes and names, not every secret, and everyone who can read the repository reads the notes. Leave them out, and do not print what a secret protects.
- **Never report as one of the forge's own reviewers.** `general`, `security`, `tests`, `terraform` and `intent` are refused, and so is any name that starts with `ci:`, which is how Infrawrench CI names a job's findings (`ci:<pipeline>/<job>`). An agent kind of `ci` is refused for a trace in the same way.
- **Never mark an instruction answered for work you did not do**, and never push to the default branch to get around a branch's page.
- **Do not invent pipeline keys or note parameters.** An unknown parameter makes a note command malformed: it is ignored, and the job's reason on the run's page says how many were.
## Notes from a CI job
A job of a repository on git.infrawrench.com leaves notes on the branch page of the commit it ran on by printing one line per note, to its output or its errors. Nothing else is needed: no token, no API call, no tool.
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
The line starts at its first character with `::`, the command, a space and the parameters when there are any, `::`, then the message. An indented line, or a command in the middle of a line, is not read.
### Commands
| Command | Becomes |
| -------------- | ------------------------------------------------------------------ |
| `::must-fix` | A finding that must be fixed. While it is open it holds the merge. |
| `::should-fix` | A finding that should be fixed. |
| `::note` | A finding that is a note. |
| `::doubt` | A trace entry of kind `doubt`. |
| `::decision` | A trace entry of kind `decision`. |
| `::step` | A trace entry of kind `step`. |
| `::evidence` | A trace entry of kind `evidence`. |
There is no `::ask` and no trace `note`: `::note` is the finding. Other names after `::` (`::group::`, `::error`) are other tools' commands and are left alone, so a typo in a command's name is silently not a note.
### Parameters
| Parameter | Value |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | A path from the repository's root (`src/db.ts`). Not absolute, no `..`. Left out, the note is about the whole change. |
| `line` | The line, from 1, in the file as it is at the run's commit. Needs `file`. |
| `end_line` | The last line of a range. Needs `line`, and is not before it. |
| `title` | A finding's title (up to 200 characters), or a bold first line on a trace entry. Without one, a finding's title is its message's first line. |
| `needs_code` | `true` or `false`: show the lines under the note's text. Left out, it is `true` when there is a `line`. |
Parameters are separated by commas, each given once, in any order. All are optional. A finding with a `title` may have an empty message; a trace entry needs a message.
### Escapes
| Write | For |
| ----- | ------------------------------------------ |
| `%25` | `%` |
| `%0A` | A line break (`%0D` for a carriage return) |
| `%3A` | `:` in a parameter's value |
| `%2C` | `,` in a parameter's value |
Escape `%` first, then the others, whenever the text comes from a tool's output. A message needs only `%25`, `%0A` and `%0D`; a parameter's value needs all of them.
### What happens to them
- **Where.** On the open branch page of the run's commit, on the version that commit's push made. A run on a branch with no open page (the default branch, a schedule) leaves nothing, and so does a run of a commit the branch has been force pushed past.
- **Findings** are reported by the reviewer `ci:<pipeline>/<job>`, with a link to the line of the job's log that printed them.
- **The same finding on the next push is the same finding.** It is told apart by job, `file` and title, never by line. So keep titles stable: use the rule's id (`no-explicit-any`), not a sentence with a line number or a count in it. A finding a person dismissed stays dismissed.
- **A passing job marks fixed** what it reported before and did not print this time. A failing job fixes nothing, so a job that reports and then fails keeps its findings open until a later run passes without them.
- **Trace entries** of a job are replaced when the job runs again on the same commit. A run of a branch proposed from a fork leaves findings only.
- **A must-fix** holds the merge like any must-fix, and is sent to the agent that writes the branch as an instruction.
### Limits
- 100 notes per job, 1,000 per run. Print the worst first when a tool can report more.
- A message is at most 8 KiB after its escapes are read; a `file` at most 1,024 characters.
- A command over a limit, or a malformed one (a parameter not in the table, a `line` that is not a number, a `file` outside the repository, no message), leaves no note. The job's reason on the run's page counts them: `2 note commands ignored (2 malformed).` Check it after the first run of a new job.
### Secrets
The commands are read from the run's log as it is stored, where the organization's secrets are already `***`, and each note is masked again by shape before it is kept. Everyone who can read the repository reads the notes, so never print a secret, and do not print what one protects (a customer's record, a private URL).
### A linter's JSON as notes
On a Linux machine (`platform: linux`), whose image has `jq`:
```yaml
name: lint
on:
pull-request: {}
jobs:
eslint:
platform: linux
run: |
npm ci
status=0
npx eslint . --format json --output-file eslint.json || status=$?
jq -r --arg root "$PWD" '
def esc: gsub("%"; "%25") | gsub("\r"; "%0D") | gsub("\n"; "%0A");
def param: esc | gsub(":"; "%3A") | gsub(","; "%2C");
.[]
| (.filePath | ltrimstr($root + "/")) as $file
| .messages[]
| (if .severity == 2 then "must-fix" else "should-fix" end) as $command
| (if .line then ",line=\(.line)" else "" end) as $line
| "::\($command) file=\($file | param)\($line),title=\(.ruleId // "eslint" | param)::\(.message | esc)"
' eslint.json
exit "$status"
```
In a sandboxed environment (`using: env:bash-node@24`), which has no `jq`, the same with Node:
```yaml
jobs:
eslint:
using: env:bash-node@24
run: |
status=0
pnpm exec eslint . --format json --output-file eslint.json || status=$?
node -e '
const esc = (s) => String(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
const param = (s) => esc(s).replace(/:/g, "%3A").replace(/,/g, "%2C");
const root = process.cwd() + "/";
for (const file of JSON.parse(require("fs").readFileSync("eslint.json", "utf8"))) {
const path = file.filePath.startsWith(root) ? file.filePath.slice(root.length) : file.filePath;
for (const m of file.messages) {
const command = m.severity === 2 ? "must-fix" : "should-fix";
const line = m.line ? `,line=${m.line}` : "";
console.log(`::${command} file=${param(path)}${line},title=${param(m.ruleId ?? "eslint")}::${esc(m.message)}`);
}
}
'
exit "$status"
```
Both print the notes whether or not the linter passed, then end with the linter's own status, so the job still fails when it should. Write the report to a file and read the file: in a sandboxed environment a pipe reports only its last command's status.
## Connecting the forge's MCP server
The server is one address, `https://git.infrawrench.com/mcp`, over Streamable HTTP. A client that supports OAuth needs only the address: the first call opens the user's browser on git.infrawrench.com to sign in and allow the application. Adding a server is the user's to do; give them the command for their client.
### Claude Code
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp
```
Then `/mcp` inside Claude Code, pick `infrawrench-git` and sign in.
### Codex
```sh
codex mcp add infrawrench-git --url https://git.infrawrench.com/mcp
codex mcp login infrawrench-git
```
### Cursor
In `~/.cursor/mcp.json`, or `.cursor/mcp.json` in the project:
```json
{
"mcpServers": {
"infrawrench-git": {
"url": "https://git.infrawrench.com/mcp"
}
}
}
```
### Without a browser
A client that cannot open a browser sends a personal access token (`iwg_...`, made under **Settings > Access tokens** on git.infrawrench.com, with the `repo:write` scope to record traces and report findings) in the `Authorization` header:
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp \
--header "Authorization: Bearer $IWG_TOKEN"
```
Read the token from the environment. Never write it into a file that is committed, a trace entry or a note.
### A token for one branch
An agent that works on one branch does not need a person's whole access. Ask the forge for a token for that branch, with any credential that can write the repository (a personal access token, an organisation's API key):
```sh
curl -fsS -X POST -H "Authorization: Bearer $IWG_TOKEN" \
https://git.infrawrench.com/api/repos/<owner>/<repository>/branches/<branch>/agent/token
```
`<branch>` is the branch's name as one URL segment (`work%2Fadd-rate-limits`). The answer is `{ "token", "expiresAt", "branch" }`. The token lasts six hours; ask again for another. Send it as the MCP server's `Authorization: Bearer` header, or to the API.
It records that branch's trace, lists its instructions and marks them delivered and answered, and lists and reports findings on it. It does nothing else: it cannot clone or push, reach another branch or repository, send or withdraw an instruction, or dismiss a finding. With it, `whoami` answers `kind: "agent"` and the `branch`, and `get_branch`, `get_version_diff`, `list_my_branches` and `start_work` are refused.
A thread git.infrawrench.com starts in T3 Code is told to ask for one with the machine's own Git credential and to keep it in a file in the worktree's Git directory. Never print the token, and never put it in a message, a commit or a trace.
### Calling a tool without a client
A session that has not loaded the server's tools can still call them: each call is one `POST` of a JSON-RPC request, and `tools/list` in place of `tools/call` describes every tool.
```sh
curl -fsS https://git.infrawrench.com/mcp \
-H "Authorization: Bearer $INFRAWRENCH_GIT_TOKEN" \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"record_trace","arguments":{"repository":"acme/infra","branch":"work/add-rate-limits","entries":[{"kind":"decision","body":"A token bucket, not a fixed window: bursts are fine here."}]}}}'
```
### What a connection may do
| Scope | Allows |
| ------------ | -------------------------------------------------------------------------------------- |
| `repo:read` | Read the repositories the user can read, with their branches, reviews and traces. |
| `repo:write` | Push, record traces, answer instructions, report findings and start work, as the user. |
A connection never does more than its user can, and never administers a repository. `whoami` says whose credential it is and whether it can write.
### The tools
| Tool | Use |
| ----------------------------- | --------------------------------------------------------------------------------------------------------- |
| `whoami` | Whose credential this is, whether it can write, and the branch of a branch token. |
| `list_my_branches` | Open branches that involve the user and have something new. |
| `get_branch` | A branch's page, state, versions, and how many instructions and findings are open. |
| `get_version_diff` | A version's diff: the whole change, that version alone, or since an earlier version. |
| `record_trace` | Record the ask, steps, decisions, evidence and doubts of the work on a branch. |
| `list_instructions` | What reviewers sent to the agent that writes the branch. |
| `mark_instruction_delivered` | Say an instruction has reached you. |
| `mark_instruction_answered` | Say which version answers an instruction. Left out, it is the next push. |
| `mark_ready_when_checks_pass` | Ask that the branch's draft page be marked ready for review once its checks pass. |
| `list_findings` | What reviewers and CI jobs found on a branch. |
| `report_finding` | Report a reviewer's findings on a version. |
| `start_work` | Create a branch and its page, as a draft, from an ask or an open issue (`issue`), before any code exists. |
## Recording a trace
`record_trace` takes `repository` (`owner/name`), `branch` (not the default branch) and one or more `entries`, in the order they happened. Send several in one call. The branch does not have to exist yet.
### Kinds
| Kind | Record it when |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| `ask` | Once, at the start: what you were asked to do, in the person's words. |
| `step` | After each meaningful piece of work: what you changed and why, with `anchors` to the files. |
| `decision` | You chose between alternatives: what you chose, what you rejected and why. |
| `evidence` | You ran tests, a build, a linter or any check: the command, its exit code, the output. Failures too. |
| `doubt` | You are unsure, skipped something, or could not verify something. Reviewers read these first. |
| `note` | Anything else a reviewer should know. |
### An entry
| Field | Value |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `kind` | One of the kinds above. |
| `body` | Markdown, a few sentences: what and why. At most 32 KB. |
| `anchors` | The files and lines the entry is about: `[{ "path": "src/db.ts", "start_line": 40, "end_line": 48 }]`. Lines are optional. |
| `needs_code` | `true` only when a reader has to see the code at the anchor to understand the entry. Defaults to `true` when a line is given. |
| `evidence` | For `evidence`: `command`, `exit_code`, `output` (an excerpt; past 16 KB its start and end are kept), `ci_run_id` or `url`. |
```json
{
"repository": "acme/infra",
"branch": "feature/rate-limits",
"entries": [
{ "kind": "ask", "body": "Limit sign-in attempts to five a minute per address." },
{
"kind": "decision",
"body": "Counted in Postgres, not in memory: the API runs on several instances.",
"anchors": [{ "path": "src/auth/limits.ts", "start_line": 12, "end_line": 30 }],
"needs_code": false
},
{
"kind": "evidence",
"body": "The new tests pass.",
"evidence": {
"command": "pnpm test src/auth",
"exit_code": 0,
"output": "Tests 14 passed (14)"
}
},
{
"kind": "doubt",
"body": "Addresses behind one proxy share a limit. I did not change how the address is read."
}
]
}
```
### How it reaches the page
- Entries wait on the branch and are attached to the version the branch's **next push** makes. Record first, push after. Entries recorded after a push belong to the next one.
- A branch holds at most 1,000 entries waiting for a push, and entries nobody pushes after are dropped after 30 days.
- A note shows the lines it is about under its text when `needs_code` is true. Most decisions and doubts stand on their own: leave it `false` for those, even when they have an anchor. Every entry with an anchor hangs on its lines in the file's diff either way.
- Recording needs write access to the repository.
### Secrets
Every entry is masked before it is stored: known token formats, private key blocks, passwords in URLs, `Authorization` and `Cookie` headers, values given to names such as `TOKEN` or `PASSWORD`. That catches mistakes; it cannot know a secret that has no shape and no name. Do not paste a command's output without reading it, and never record a secret on purpose.
### Instructions
`list_instructions` lists what is still to do (`queued` and `delivered`). An instruction is a review comment, a finding or a reviewer's own words, written out as it was when sent. For each one: `mark_instruction_delivered` when you take it on, then do the work, record it, and call `mark_instruction_answered` just before you push (leave `version` out and it is tied to the version that push makes). A `must_fix` finding on a branch you are named as the agent of arrives as an instruction on its own, whether a reviewer or a CI job raised it.
Signs in through your browser on first connect (OAuth), with tools for resources, costs, workflows, CI, SQL, SSH, and more.
Skills
Infrawrench CLIInspect accounts, resources, metrics and costs from the terminal with the infrawrench CLI.
AGENTS.md (append)
# infrawrench CLI
The Infrawrench desktop app doubles as the `infrawrench` CLI: same local
accounts, same cloud session, same organizations. Enable the shell command
once from the desktop app's sidebar footer, or run `infrawrench cli install`.
For scripting, always pass `--json` — every listing/data command supports it.
Text mode (the default) renders ANSI tables and charts for humans.
## Commands
- `infrawrench` / `infrawrench tui` — interactive dashboard (needs a TTY)
- `login` / `logout` / `whoami` — cloud session (browser PKCE)
- `orgs` — list organizations
- `accounts` — list accounts (local + every org by default)
- `resources --account <id|name> [--type <typeId>]` — list an account's resources
- `resource <id>` — one resource's fields & outputs
- `metrics <id> [--last 6h] [--series cpu] [--local]` — metric charts
- `costs [--last 30d] [--group-by provider|account|service|region|resource]` — org cost graphs
- `costs push --source <name> [--file rows.json]` — push your own cost rows (stdin when no file)
- `page <message> --source <name> [--key k] [--title t] [--cooldown min] [--voice]` — alert on-call
- `page clear --source <name> [--key k]` — drop a page key's cooldown after recovery
- `cli install|uninstall|status` — manage the shell command
## Flags
- `--org <id|name>` or `--local` — scope to one org / the local desktop workspace (mutually exclusive)
- `-a, --account <id|name>` — account for resource commands
- `--json` / `--text` — output mode (mutually exclusive; default text)
- `--last 30m|6h|7d|2w` or `--from` / `--to` — time range for metrics & costs
- `--no-color`, `-v/--version`, `-h/--help`
Exit codes: `0` ok, `1` runtime error, `2` usage error. Errors print as a
single line on stderr.
## Examples
```sh
infrawrench resources --account prod-aws --json | jq '.[].name'
infrawrench metrics res_abc123 --last 6h --series cpu
infrawrench costs --org acme --last 30d --group-by service
echo '[{"amount": 12.5, "service": "ci"}]' | infrawrench costs push --source ci
infrawrench page "db replica lagging" --source poller --key db-lag --cooldown 30
```
## Behavior to know
- While the desktop app is open, the CLI runs read-only against the shared
database, and `login`/`logout` hand off to the app.
- Cloud `resources` listings sync the account first so rows reflect the
provider now; on sync failure the CLI warns on stderr and serves cached rows.
- Bare `infrawrench` without a TTY prints help instead of launching the TUI.
`NO_COLOR` or a non-TTY stdout disables ANSI colors.
Environment files (.infraenv)Writes and fixes a repository's .infraenv, the committed file that says where every environment variable comes from, without ever putting a secret in it.
AGENTS.md (append)
# Environment files (.infraenv)
A project that uses Infrawrench commits `.infraenv` instead of `.env`. It lists every environment variable and says where its value comes from, so it is reviewed and versioned like code, and it never holds a secret value. `infraenv pull` (the `@infrawrench/infraenv` npm package) or `infrawrench env pull` (the desktop app's CLI) resolves it into a normal `.env` that starts with `# Auto-generated by Infrawrench. Do not edit.` The user-facing guide is https://infrawrench.com/docs/features/env-files. Read the "The .infraenv format" section below before writing anything beyond a simple variable, and the "Converting an existing .env" section below when converting an existing `.env`.
## Rules
- **Never write a secret value into `.infraenv`**, and never copy one out of `.env` into it, a commit message or chat. A secret becomes a `secret("NAME")` reference (an organization secret the user creates in Infrawrench) or a `resource(...)` reference to where it already lives.
- **Never edit the generated `.env`.** Change `.infraenv` and pull again. A `.env` without the generated header is hand-written: do not overwrite it unless the user says so (`--force`).
- **Prefer references by name** (`resource("<plugin>/<type>", "<display name>", "<output>")`). They resolve in whichever organization pulls the file. Pin by id (`resource("<id>", "<output>")`) only when the user wants one exact resource or a name is ambiguous.
- **Do not add `[infrawrench] org`** unless the user asks to pin the file to one organization.
- Keep `.env` (the output) in `.gitignore`.
## Process
1. **Find the file.** `.infraenv` at the repository root (or the one the user names). If there is none, create it with `infraenv check` passing afterwards (see the "Converting an existing .env" section below when a `.env` exists).
2. **Find the values' sources.** With the Infrawrench MCP server connected, `list_env_sources` searches the organization's resources and lists each one's outputs with a suggested variable name; `describe_env_file` checks a draft. Without it, ask the user which resource or secret each variable should come from; do not guess ids.
3. **Write the variables.** Shared values go in `[env]`; what differs per environment goes in `[env.<name>]`, or better, in a substitution: `[vars]` / `[vars.<name>]` plus `${name}` inside the reference, so one line serves every environment. Put a `# <Plugin>: <resource name> (<output>)` comment above each reference.
4. **Check.** Run `infraenv check` (or `infrawrench env check`, or the `describe_env_file` tool). It reports syntax errors with line numbers, references that match nothing or several resources, outputs a type does not have, secrets that do not exist or have no value, and substitutions with no value. Fix every problem; report any that need the user (a secret to create, an account to connect).
5. **For Infrawrench CI**, a job loads the file with `env-file:`; `check_ci_env_file` (MCP) says what each variable would give a job on a given branch and what to grant first. In CI, `secret()` reads the repository's CI secrets, not the organization's.
6. **Pull only if asked.** `infraenv pull [--env <name>]` writes `.env` with the real values. Do not print the values; the commands never do in text mode.
## Commands
| npm package (`npx infraenv` or `node_modules/.bin/infraenv`) | Desktop CLI | What it does |
| ------------------------------------------------------------ | ---------------------------------- | -------------------------------------------------------------------- |
| `infraenv check [--var k=v]` | `infrawrench env check` | What each reference points at, and every problem. Exit 1 on any. |
| `infraenv pull [--env <name>] [--var k=v] [--stdout]` | `infrawrench env pull` | Resolve and write `.env` (mode 0600). Exit 1 if a variable failed. |
| `infraenv install` / `uninstall` / `status` | `infrawrench env hooks install` | Git hooks that pull again when a commit changes `.infraenv`. |
| | `infrawrench env init --from .env` | A new `.infraenv` with one `secret("KEY")` line per `.env` key. |
| `await config()` from `@infrawrench/infraenv` (in code) | | Load `.infraenv` into `process.env` at startup; keeps set variables. |
The npm package reads `INFRAWRENCH_API_KEY` (an `iwk_` key) when it is set, else the key `infraenv login` stored; the desktop CLI uses the desktop app's sign-in. In a third-party CI, set `INFRAWRENCH_API_KEY` and run `npx @infrawrench/infraenv pull --env <name>`; in Infrawrench CI, a job's `env-file:` key loads the file without a key.
## Example
```ini
[vars]
stage = dev
[env]
NODE_ENV = development
# Neon: storefront / dev (Connection string)
DATABASE_URL = resource("neon/neon-branch", "storefront / ${stage}", "connectionString")
STRIPE_SECRET_KEY = secret("STRIPE_SECRET_KEY_${stage}")
[vars.production]
stage = main
[env.production]
NODE_ENV = production
```
## The .infraenv format
A dotenv file with INI sections. Lines before any section belong to `[env]`, so a `.env` of plain values is already a valid `.infraenv`. `#` starts a comment line.
### Sections
| Section | Holds |
| --------------- | ----------------------------------------------------------------------------------------------------------------- |
| `[infrawrench]` | Optional settings: `output = .env` (where pull writes, relative to the file), `org = <id>` (pins the org; avoid). |
| `[vars]` | Substitutions for every environment: `name = value`. Never environment variables themselves. |
| `[env]` | Variables every environment gets. |
| `[vars.<name>]` | Substitutions for one environment, over `[vars]`. |
| `[env.<name>]` | Variables for one environment, over `[env]`. Variables it does not mention are inherited. |
Environment names use letters, digits, `-` and `_`. Variable and substitution names use letters, digits and `_`, not starting with a digit.
### Values
| Written as | Meaning |
| ------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| `development`, `"two words"`, `'raw $text'` | A literal. Quote it if it has spaces or `#`. A quoted value is always a literal, even `"secret(\"x\")"`. |
| `resource("<plugin>/<type>", "<name>", "<output>")` | An output of the synced resource with that plugin id, resource type id and display name, in the pulling organization. |
| `resource("<plugin>/<type>@<account>", "<name>", "<output>")` | The same, in the account with that display name. Use when two accounts have a resource of that name. |
| `resource("<id>", "<output>")` | An output of one resource by its id (`plugin:account:external-id`). Only resolves in the organization that owns it. |
| `secret("<NAME>")` | The organization secret with that name (the same store Infrawrench workflows use). |
Arguments are double-quoted strings with `\"` and `\\` escapes. Plugin ids, type ids and output keys come from `list_env_sources` (or the Infrawrench app's picker); never invent them.
### Substitutions
`${name}` inside the arguments of `resource()` and `secret()` is replaced before lookup. Values, lowest first: `[vars]`, the built-in `environment` (the environment being pulled), `[vars.<environment>]`, then `--var name=value`. A name with no value is a problem on that variable. Substitution never applies to literals: `HINT = ${HOME}` stays as written. `$${` is a literal `${` inside a reference.
### Resolution
- Pulling `--env production` gives `[env]` with `[env.production]` laid over it; no `--env` gives `[env]` alone.
- A variable whose source fails (no match, several matches, no value, a provider error) is reported with its line and left out of `.env`; the rest are written.
- In Infrawrench CI, a job's `env-file:` key loads the file, but only resources the repository is granted and the repository's CI secrets resolve there.
## Converting an existing .env
The goal is a committed `.infraenv` with the same keys and no secret values.
1. **Read the keys, not the values aloud.** List the keys in `.env` (and `.env.example`, `.env.production` and the like, if present). You may look at a value only to classify it; never repeat it.
2. **Classify each key:**
- **Not secret** (ports, feature flags, public URLs, `NODE_ENV`): keep it as a literal.
- **Comes from infrastructure** (database URLs, cache URLs, bucket names, endpoints, API keys a provider issues): find the resource with `list_env_sources` and write a by-name `resource()` reference with the output the key needs.
- **A secret with no resource behind it** (a third-party API key): write `secret("KEY")` and tell the user to create the organization secret `KEY` in Infrawrench (Environment files, or Settings) with the value from their `.env`. Do not create it for them with the value from the file unless they ask.
3. **Split environments.** Values that differ between the user's `.env.<stage>` files become `[env.<stage>]` overrides, or a `[vars]` substitution when only part of a name changes.
4. **Write `.infraenv`, then check it** with `infraenv check` (or `infrawrench env check`) and fix every problem.
5. **Leave the old `.env` alone.** The first pull refuses to overwrite a `.env` without the generated header; the user decides when to pass `--force`. Make sure `.env` is gitignored, and suggest `infraenv install` (or `infrawrench env hooks install`) so it regenerates when `.infraenv` changes.
`infrawrench env init --from .env` does steps 1 and 2 crudely (every key becomes `secret("KEY")`); use it as a start, then replace each line with the right kind.
Migrate from GitHub ActionsConverts a repository's GitHub Actions workflows into Infrawrench CI pipelines, job by job, and reports what could not move.
AGENTS.md (append)
# Migrate GitHub Actions to Infrawrench CI
Infrawrench CI runs the pipelines in a repository's `.infrawrench/ci/` folder on every push and pull request. Each job is one script (or one tool) that runs in its own WebAssembly sandbox over an in-memory snapshot of the commit, with the dependencies already installed from the lockfile. There are no steps, no marketplace actions and no runner images: most of a GitHub Actions job's steps either disappear or become lines of one script.
The reference for every key is the runner's README, `ci-runner/README.md` in the Infrawrench repository, and the user-facing guide is https://infrawrench.com/docs/features/ci. Read the sections below when the step below says so; they are written to be read one at a time.
## Process
1. **Inventory.** Read every file in `.github/workflows/`. For each workflow, list its triggers, its jobs, what each job runs on (`runs-on`), the actions it uses, its services, the secrets and variables it reads, and which jobs depend on which. Note reusable workflows (`workflow_call`) and composite actions (`.github/actions/`), which are inlined, not called.
2. **Classify each job** into one of three groups, and tell the user the result before writing files:
- **Runs on the runner**: bash, Node, Python, Go, PHP, TypeScript type checks, formatters, Postgres or ClickHouse tests, deployment CLIs. Most jobs.
- **Becomes a cloud job** (`cloud:`): anything that needs Docker, a native binary with no WebAssembly build, a GPU, or a real Linux machine. Rust is not one of these: it compiles with `tools: [builtin:[email protected]]` (see the "What changes, and what does not move" section below). It runs on one of the organization's connected cloud accounts, which an admin has to opt in to CI first.
- **Stays on GitHub Actions**: macOS and Windows jobs, and anything relying on an event Infrawrench CI does not have (see the "What changes, and what does not move" section below).
3. **Write one pipeline per workflow**, `.infrawrench/ci/<same-name>.yml`, starting with the schema comment so editors validate it:
```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/Infrawrench/Infrawrench/main/ci-runner/schema/ci.schema.json
```
Translate the triggers, jobs, expressions and environment variables with the "GitHub Actions to Infrawrench CI: key by key" section below, and replace each action with the "Replacing actions" section below.
4. **Move dependency installs to the workspace.** Delete `actions/setup-*`, `actions/checkout` and `npm ci` / `pnpm install` / `pip install -r` steps, and list the package managers under `workspace.deps` instead. Dependencies are installed once per commit and checked against the lockfile; install scripts do not run, so a `postinstall` that generates code (Prisma, protobuf) becomes an explicit line in the jobs that need it.
5. **Split big jobs.** A job that runs a whole monorepo's tests or type checks (`turbo run test`, `nx affected`, `pnpm -r test`) becomes a `packages:` job, one job per workspace package, with the task cache. Read the "Monorepos: from a few big jobs to a job per package" section below. This is usually the largest speed-up of the migration.
6. **Check the limits.** Read the "What changes, and what does not move" section below and fix anything it flags: the 10-minute default timeout, the 2 GiB default memory, pipes in scripts, and the checkout having no `.git`.
7. **List what the user has to do in Infrawrench**, since an agent cannot do it:
- Add every secret and variable the pipelines read under **CI → Secrets and variables** (names only: never write a secret's value into a file).
- Turn on what jobs borrow under **CI → CI access**: connections that run cloud jobs, connections lent with `connections:`, SSH keys lent with `ssh-keys:`.
- Tick **Run CI** for the repository's GitHub account if it is not on yet.
8. **Validate.** Push to a branch and open a pull request. A pipeline file that does not parse fails at once with a job named **Pipeline file** whose output gives every error with its path in the file (`jobs.test.timeout: ...`). With the Infrawrench MCP server connected, `list_ci_runs` and `get_ci_job_log` read the results without leaving the editor.
9. **Run both side by side, then switch.** Keep the GitHub Actions workflows until the Infrawrench runs pass on the same commits. Then delete the migrated workflows (or the migrated jobs, for a workflow that keeps some), and change branch protection to require **Infrawrench CI / pull request**, the check that covers every job of the run.
## Rules that catch people out
- **A job is one script.** `run:` is bash with `set -euo pipefail`. Join a GitHub job's `run` steps into one `run: |` block in order. Use `if:` on a job, not on a line; inside the script, use shell conditionals.
- **Secrets only in `env:`.** `${{ secrets.NAME }}` works only as an `env:` value. Map it to a variable and read the variable in the script.
- **Pick an environment.** Every job without `cloud:` names `using:`: `env:bash@5`, `env:bash-node@24`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, `env:[email protected]`, or a tool such as `builtin:[email protected]`. Versions are pinned; a bare name is an error.
- **Jobs in `needs:` hand files on with `artifacts:`**, not with upload and download actions. Files for people to download from the run are `downloads:`.
- **Pull requests from forks** run only after a maintainer approves them, get no secrets, and never run cloud jobs. There is no `pull_request_target` equivalent.
## What to hand back
Finish with a short report: each workflow and job, where it went (runner, cloud job, stayed on GitHub Actions) and why, the secrets and variables to add, the CI access to turn on, and anything you were unsure of. Do not claim speed-ups you have not measured.
## Replacing actions
There are no actions. Each `uses:` step is dropped, becomes workspace or job configuration, or becomes a command in the job's script. When an action is not listed here, read what it runs (its `action.yml` and entry point) and do that in the script: most wrap a CLI that runs in `env:bash-node@24` with `npx` or a pinned global install. Pin every version.
### Setup and checkout
| Action | Replacement |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `actions/checkout` | Drop it. Every job starts in the commit's files at `/app`. There is no `.git`; see the "What changes, and what does not move" section for jobs that need history. |
| `actions/setup-node`, `pnpm/action-setup` | `using: env:bash-node@24` (Node 24, `npm`, `pnpm`, `npx`), and `workspace: { deps: [pnpm] }` (or `[npm]` for `package-lock.json`) instead of the install step. |
| `oven-sh/setup-bun` | `tools: [builtin:bun@1]` (Bun 1.4.4) on `using: env:bash@5`, and `bun install --frozen-lockfile` in the script, or `deps: [{ bun: { native: true } }]` when no install script matters; read the "What changes, and what does not move" section. |
| `actions/setup-python` | `using: env:[email protected]`, and `deps: [pip]` (reads `pylock.toml` or `requirements.txt`; `- pip: { file: requirements/ci.txt }` for another). |
| `actions/setup-go` | `using: env:[email protected]` (1.23 to 1.27), and `deps: [go]` for `go.sum`. |
| `shivammathur/setup-php` | `using: env:[email protected]` (8.1 to 8.5), and `deps: [composer]`. |
| `dtolnay/rust-toolchain`, `actions-rs/*` | `tools: [builtin:[email protected]]` in an `env:bash@5` job (rustfmt and clippy included), with `workspace: { deps: [cargo] }`; see the "What changes, and what does not move" section. A non-host `targets:` needs a cloud job. |
| `Swatinem/rust-cache` | Nothing: crates come from `deps: [cargo]`. To keep `target/` between runs, `cache: { key: ..., paths: [target] }`. |
| `ruby/setup-ruby` | `using: env:[email protected]` (or `@3.4`), and `deps: [bundler]` instead of `bundler-cache: true`; see the "What changes, and what does not move" section for Rails. |
| `actions/setup-java`, `setup-dotnet` | No environment for these yet. Make the job a cloud job with an `image:` that has the runtime. |
### Caches and files between jobs
| Action | Replacement |
| ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `actions/cache` for `node_modules`, `~/.npm`, `~/.cache/pip`, `~/go/pkg` | Drop it: `workspace.deps` installs are cached by the runners. Go's build cache is kept on its own. |
| `actions/cache` for anything else | `cache: { key, restore-keys, paths }` with `${{ hashFiles('...') }}` in the key. Saved only when the job passes. Pull requests save to a scope the default branch never reads. |
| `actions/cache` for `.turbo` or `.nx` | Drop it and use the task cache instead (`task-cache:`), which skips whole jobs. See the "Monorepos: from a few big jobs to a job per package" section. |
| `actions/upload-artifact` + `download-artifact` between jobs | `artifacts: [dist]` on the producing job; every job that `needs:` it starts with those files where they were left. |
| `actions/upload-artifact` for people | `downloads: [report.html]`, or `{ paths, retention: 7d, when: always }`. Text files are masked for secrets; binary files are not, so never put a secret in one. |
### GitHub itself
Every one of these needs `github-token:` with the permissions it used, and `tools: [builtin:[email protected]]` for the `gh` command. The token is for the run's own repository, lasts an hour from when the run starts, and is never given to a fork's pull request.
| Action | Replacement |
| ------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `softprops/action-gh-release`, `ncipollo/release-action` | `gh release create "$TAG" dist/* --notes-file NOTES.md` with `github-token: { contents: write }`. |
| `peter-evans/create-pull-request` | Clone the repository in the script (the checkout has no `.git`), commit, push a branch and `gh pr create`, with `github-token: { contents: write, pull-requests: write }`. |
| `actions/github-script` | `gh api ...` in the script, or a Node script reading `GITHUB_TOKEN`. |
| `stefanzweifel/git-auto-commit-action` (formatters, codegen) | Make the job a check instead: `changes: fail` fails it when the formatter changes a file. To commit back, clone the repository in the script with `github-token: { contents: write }`. |
| `actions/labeler`, `actions/stale`, issue automation | These react to events Infrawrench CI does not have. Keep them on GitHub Actions. |
### Clouds and deployments
Credentials are lent, not stored: an admin turns a connection on for CI under **CI access**, and the job names it. Do not move cloud keys into secrets when a connection can be lent.
| Action | Replacement |
| ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `aws-actions/configure-aws-credentials` | `using: env:[email protected]` and `connections: [<connection name>]`: the `aws` CLI is signed in with the lent session. |
| `google-github-actions/auth` + `setup-gcloud` | `using: env:gcloud@593` and `connections: [<name>]`: `gcloud` and `bq` use the lent access token. |
| `azure/login` | `using: env:[email protected]` and `connections: [<name>]`: `az` signs in with the lent service principal. |
| `azure/setup-kubectl`, `azure/k8s-*`, `deliverybot/helm` | `tools: [builtin:[email protected]]` and `connections: [<cluster connection>]`, which writes a kubeconfig and sets `KUBECONFIG`. Helm has no builtin: run it in a cloud job. |
| `webfactory/ssh-agent`, `appleboy/ssh-action`, `appleboy/scp-action` | `ssh-keys: [<key name>]` (the key's owner turns on **Use in CI jobs**) or a lent SSH host connection, and `tools: [builtin:[email protected]]` (add `builtin:[email protected]` for `scp`). |
| `amondnet/vercel-action` | `tools: [builtin:vercel@65]`, `VERCEL_TOKEN` from a secret in `env:`, then `vercel deploy --prod --yes`. |
| `cloudflare/wrangler-action` | `tools: [builtin:wrangler@4]`, `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in `env:`, then `wrangler deploy`. |
| `neondatabase/create-branch-action` | `tools: [builtin:neon@9]`, `NEON_API_KEY` in `env:`, then `neon branches create ...`. |
| `docker/login-action`, `docker/build-push-action`, `docker/setup-buildx-action` | A build job: `cloud: aws/build` (CodeBuild), `gcp/build` (Cloud Build), `azure/build` (ACR Tasks) or `docker/build` (your own Docker host), with `docker build` and `docker push` in `run:`. Write the image digest to an output for the deploy job. |
### Testing and reporting
| Action | Replacement |
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `codecov/codecov-action` | Upload with Codecov's CLI in the script (`npx`), `CODECOV_TOKEN` in `env:`. |
| `dorny/test-reporter`, `mikepenz/action-junit-report` | Keep the JUnit file with `downloads: { paths: [junit.xml], when: always }`. The run page and the GitHub check show each job's result. |
| `microsoft/playwright-github-action` | Browsers do not run in a job. Run end-to-end browser tests as a cloud job with an image that has the browsers. |
## What changes, and what does not move
Check each migrated job against this list before handing back.
### Defaults that differ
- **Timeout: 10 minutes**, not 6 hours. Set `timeout:` (`30m`, `2h`, at most `6h`) on any job that can run longer. A job that prints nothing and uses no CPU for 5 minutes is stopped as stuck.
- **Memory: 2 GiB** per job, up to `16GiB` with `memory:`. Large test suites and bundlers usually want `4GiB` or more; a job over its limit fails and its report says so.
- **CPU: a share of one vCPU** per job, not a machine of its own, and its programs are told 1 CPU (`nproc`, `os.cpu_count()`, `os.availableParallelism()`), so anything that sizes its workers from the CPU count (`pytest -n auto`, Vitest, Jest, `cargo`, `make -j$(nproc)`) runs one. A job that builds or tests in parallel (`make -j`, `go test -p`, `cargo`, a test runner's workers) gets `cpus:` (1 to 64), whether or not it ran on a larger runner, and is then told that many: `-n auto` and `nproc` follow it, and a hard-coded count becomes `$IWCI_CPUS`. Billing follows: a job with `cpus: 4` is charged four vCPUs for as long as it runs.
- **One environment per job.** There is no image with everything installed. Pick the `using:` environment for the job's language, and add other tools with `tools: [builtin:...]`.
### Scripts
- **Pipes do not fail the script.** A pipeline reports only its last command's status, even with `pipefail`: `npm test | tee log.txt` passes when the tests fail. Write `npm test > log.txt 2>&1` and print the file afterwards, or drop the pipe.
- **No terminal.** Standard input is empty and nothing is a TTY, so prompts fail and colour is usually off. Pass non-interactive flags (`--yes`, `-y`, `--ci`).
- **No `sudo` and no `apt-get`.** The job's file system is its own; install command-line tools with `npm i -g` or `pnpm add -g` (pinned) in `env:bash-node`, or `pip install` in `env:python`. A system package means a cloud job.
- **Hard links work within the job's own files** (`ln`, `fs.linkSync`, `os.link`): the names are one file, with one inode number and a link count. A link to or from another mount (`/usr/local/bin`, the run's scratch directory) fails with `EXDEV`, which programs that link fall back to copying on, and caches, artifacts and `changes:` keep each name as a file of its own. Symbolic links work.
### The checkout
- **No `.git`.** Jobs get the commit's files, not a repository: `git log`, `git describe`, `git diff origin/main` and tools that read history (changelog generators, semantic-release) fail. Clone in the script when history is needed, with `github-token: { contents: read }` for a private repository: `git clone --depth=50 "https://github.com/$GH_REPO.git" /tmp/repo`.
- **No submodules** and **no Git LFS content** (a file kept in LFS is its pointer). Fetch them in the script if a job needs them.
- What changed in the push is still known: use `paths:` on a job or `changed('glob')` in `if:` instead of `git diff`.
### Languages and native code
- **Node 24 only** on the runner (`env:bash-node@24`). A matrix over older Node versions becomes one job on 24, or cloud jobs for the others.
- **Native Node addons** load only when the package ships a WebAssembly (`wasm32-wasi`) build: Vite 8, Vitest, Rolldown, tsdown, oxc and the Astro compiler do. A dependency with only native binaries (some image, database and crypto libraries) needs a cloud job.
- **npm**: `deps: [npm]` installs from `package-lock.json` (lockfile version 2 or 3; a version 1 lockfile needs `npm install --lockfile-version 3` with npm 7 or later). Do not keep `npm ci` in a job: npm refuses packages whose `os` list leaves out the job's platform. `npm run` scripts find their dependencies' commands in `node_modules/.bin`, as on a developer's machine.
- **Yarn lockfiles** are not installed by `workspace.deps` (it supports pnpm, npm, Bun, Go, Cargo, pip, Composer and Bundler). Convert with `pnpm import` and commit `pnpm-lock.yaml`.
- **Bun** is `tools: [builtin:bun@1]` (Bun 1.4.4, whose newest build `@1`, `@1.4` and `@1.4.4` all pick; `@1.3` and other versions do not exist), the real Bun run natively in a sandbox. Use it with `using: env:bash@5`, which has no `node`, so Bun runs package scripts, `#!/usr/bin/env node` bins and install scripts itself, and install in the job with `bun install --frozen-lockfile`, which gets the Linux builds of turbo, oxlint, esbuild and the like. `deps: [{ bun: { native: true } }]` instead installs once per lockfile, cached and checked against its hashes, with `node_modules/.bin` and the Linux builds of turbo and oxlint, so `bunx turbo` and `bun run lint` work over it; it runs no install scripts, and esbuild, Rollup and Lightning CSS are their slower WebAssembly builds there. Without `native: true` it has no native packages, and Bun fails over it. In `env:bash-node@24`, `node` is a WebAssembly Node (`process.platform` is `wasi`), and Bun runs install scripts with it, so a `postinstall` that loads a native package fails there. In `env:bash@5`, a file run with `bun run ./script.mts` that spawns `node` finds no `node`: link one, `ln -s "$(command -v bun)" /tmp/bin/node`, with `/tmp/bin` first on `PATH`. `env:bash@5` has no `npm`; use `bunx npm@11`. `cache:` `/root/.bun/install/cache`, keyed on `hashFiles('bun.lock')`, saves the downloads.
- **Ruby** (`env:[email protected]`, `@4.0`): gems with C extensions install only through `deps: [bundler]`, which has builds of the ones a `rails new` app locks (nokogiri, sqlite3, puma, bootsnap and the rest) at those versions; another one, or another version, fails the install naming the versions that have a build, and `- bundler: { without-extensions: [name] }` installs a gem the jobs never load without it. A Rails app needs `gem "tzinfo-data"` on every platform (no zoneinfo here; drop `platforms:`, then `bundle lock`) and `gem "selenium-webdriver", require: false` (it refuses to load here). No `fork`: Rails tests run in one process (`PARALLEL_WORKERS=1` is set), and system tests need a browser, so a cloud job. `bundle exec ruby` loses the bundle's settings; use `bin/rails`, `bundle exec rake` or `ruby -rbundler/setup`.
- **Rust**: `using: env:bash@5` with `tools: [builtin:[email protected]]` (rustc, cargo, rustdoc, rustfmt, clippy, and GCC 13 with binutils for linking and for build scripts that compile C), and `workspace: { deps: [cargo] }` so crates come from `Cargo.lock` with no network. Give build and test jobs `memory: 4GiB` to `8GiB` (the `target/` directory counts). The builtin's version is the toolchain: `rust-toolchain.toml` is ignored and there is no `rustup`, so `rustup target add` and cross builds need a cloud job, as do crates that link a system library (OpenSSL without `vendored`) or need a C++ compiler. A built binary runs from the script as on Linux. It needs a runner with the native sandbox; a job on one without fails saying so.
- **Native binaries from npm packages** (Turborepo's `turbo`, sherif, and others that pick a per-platform optional dependency): `workspace: { deps: [{ pnpm: { native: true } }] }` (or `bun`) and `tools: [builtin:[email protected]]` on the `env:bash-node@24` job that runs them. Without both, the binary is missing or does not start. TypeScript 7 (`tsc` from `typescript@7`) works the same way. A tool that loads a native Node addon in-process with no WebAssembly build (oxlint) runs under Bun instead: `tools: [builtin:[email protected], builtin:[email protected]]` and `bun node_modules/oxlint/bin/oxlint`. A project that pins pnpm 12 (`packageManager` or `engines.pnpm`) switches to it in a job with `native: true` on its pnpm dep and `tools: [builtin:[email protected]]`.
- **Java, .NET, Swift**: no environment yet. Cloud jobs.
### Services and containers
- **Postgres** (`env:postgres@18`, PGlite: many connections, `pgcrypto`) and **ClickHouse** (`env:[email protected]`) run as `services:` inside the job. Postgres runs one transaction at a time and shares `SET`, advisory locks and `LISTEN` across connections, so tests that depend on concurrent transactions need a real Postgres in a cloud job.
- **Any other service image** (Redis, MySQL, Elasticsearch, a vendor emulator): start it in a cloud job (`cloud: { provider: docker, kind: container }` or a VM with Docker), or, when it is a Node or Python program, as a `services:` entry running that program.
- **No Docker on the runner.** `docker build`, `docker run` and `docker compose` go in a cloud job: `kind: build` for building and pushing images, `kind: vm` or `container` for running them.
- **No browsers.** Playwright, Cypress and Puppeteer tests run as cloud jobs.
### Events and features with no equivalent
Keep these on GitHub Actions, or say what the user could do instead:
- Triggers other than push, pull request, schedule and manual: tags, releases, `workflow_run`, `issues`, `issue_comment`, `pull_request_target`, `repository_dispatch`, `merge_group`.
- macOS and Windows runners.
- GitHub Pages deployment through `actions/deploy-pages` (deploying the built site with a CLI from a job works).
- Job-level `concurrency`, `continue-on-error`, `fail-fast`, matrix `include:`.
- `environment:` protection rules and required reviewers. CI access limits what each repository and branch may use, and a fork's pull request waits for a maintainer's approval.
- OIDC (`id-token: write`) to a cloud. Lend the cloud's connection instead (`connections:`), which needs no stored key either.
## GitHub Actions to Infrawrench CI: key by key
Unknown keys are an error, so leave out anything without a row here rather than carrying it over.
### Workflow level
| GitHub Actions | Infrawrench CI |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `name:` | `name:` (required) |
| `on: push` with `branches`, `paths` | `on: { push: { branches, paths } }` |
| `branches-ignore`, `paths-ignore` | The same list with each pattern quoted and prefixed with `!`: `paths: ["!docs/**"]` |
| `on: pull_request` with `branches`, `paths` | `on: { pull-request: { branches, paths } }`. `types:` has no equivalent; every opened or updated pull request runs. |
| `on: schedule` with `cron` | `on: { schedule: [{ cron: "0 3 * * *" }] }`, UTC, runs the default branch's head |
| `on: workflow_dispatch` with `inputs` | `on: { manual: { inputs } }`: types `string`, `boolean`, `choice` (with `options`), `number` |
| `on: push: tags`, `release`, `workflow_run`, and others | No equivalent: tag pushes start nothing. Keep the workflow on GitHub Actions, or start it by hand. |
| `env:` at the top | No top-level `env`. Repeat it on each job, or share it with a YAML anchor (`env: &env {...}`, then `env: *env`). |
| `concurrency:` | `concurrency:` at the top only, `{ group, cancel-in-progress }`. A job-level `concurrency` has no equivalent. |
| `permissions:` | Per job, `github-token: { contents: write, pull-requests: write }`. No token at all unless a job asks. |
| `defaults.run.working-directory` | `cwd:` on each job, absolute: `/app/<dir>` |
| `defaults.run.shell` | Always bash. A Python or Node step becomes `python - <<'EOF'` or `node -e` in the script, or a script file it runs. |
### Job level
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `runs-on: ubuntu-*` | Nothing: the job runs on the runners. Choose `using:` for the language instead. |
| `runs-on:` a larger runner (`ubuntu-latest-8-cores`, `ubuntu-24.04-16core`) | `cpus: N` (1 to 64), the runner's vCPU count, so the job holds whole vCPUs rather than a share of one. Its scripts read the number from `$IWCI_CPUS` (`-j"$IWCI_CPUS"`). Billed at those vCPUs. Size `memory:` separately. |
| `runs-on: self-hosted` or a label | `cloud:` on a connected account (`aws/vm`, `gcp/container`, `docker/container`, `kind: host` for an existing machine over SSH). |
| `steps:` | One `run: \|` script, the `run` steps joined in order. Each `uses:` step is replaced as in the "Replacing actions" section. |
| `needs:` | `needs:` |
| `if:` | `if:` on the job. Functions: `success()`, `failure()`, `always()`, `contains`, `startsWith`, `endsWith`, `changed('glob')`. No `cancelled()`, `format`, `toJSON`, `fromJSON` or `hashFiles` here. |
| step-level `if:` | A shell `if` in the script, or a separate job with its own `if:`. |
| `strategy.matrix` | `matrix: [a, b]` (read as `${{ matrix }}`) or named axes `{ node: [22, 24], os: [x] }` (read as `${{ matrix.node }}`), with `exclude:`. Up to 64 entries. No `include:`: write those as separate jobs. |
| `fail-fast`, `max-parallel` | Leave out. Every entry runs; the runner schedules them. |
| `continue-on-error` | Leave out. Let the dependents run anyway with `if: always()`, and read `${{ needs.<job>.result }}`. |
| `timeout-minutes: 30` | `timeout: 30m`. The default is 10 minutes (GitHub's is 6 hours), the most 6 hours. Set it on anything that can take longer than 10 minutes. |
| `env:` | `env:`. `${{ secrets.X }}` works only here. |
| `outputs:` + `$GITHUB_OUTPUT` | `outputs: [name]` and `echo "name=value" >> "$IWCI_OUTPUT"`. Writing an undeclared name fails the job. A matrix job cannot have outputs. |
| `services:` (Docker images) | `services:` with `env:postgres@18` (`run: pglite-server`) or `env:[email protected]`, reached as `postgres:5432`. Other images: see the "What changes, and what does not move" section. |
| `container:` | No equivalent on the runner. Choose the matching `using:` environment, or make it a cloud job with `image:`. |
| `environment:` | No equivalent. What a branch may use is set in **CI access** (connections, SSH keys and resources per repository and branch). |
| `uses: ./.github/workflows/x.yml` | Inline the called workflow's jobs into this pipeline. |
### Expressions
| GitHub Actions | Infrawrench CI |
| --------------------------------------------------- | --------------------------------------------------------------------- |
| `${{ github.sha }}` | `${{ commit.sha }}` (`${{ commit.short-sha }}` for the short form) |
| `${{ github.ref_name }}`, `github.head_ref` | `${{ commit.branch }}` |
| `${{ github.event_name }}` | `${{ event }}`: `push`, `pull-request`, `schedule` or `manual` |
| `${{ github.event.pull_request.number }}` | `${{ pull-request.number }}` (empty unless a pull request) |
| `${{ github.workflow }}` | `${{ pipeline.name }}` |
| `${{ github.repository }}` | `$GH_REPO` in a job with `github-token:`; otherwise write it out |
| `${{ inputs.x }}` / `${{ github.event.inputs.x }}` | `${{ inputs.x }}`, never inside `run:`: map it in `env:` and quote it |
| `${{ vars.X }}` | `${{ vars.X }}` |
| `${{ secrets.X }}` | `${{ secrets.X }}`, in `env:` values only |
| `${{ needs.a.outputs.b }}`, `${{ needs.a.result }}` | The same |
| `${{ matrix.x }}` | The same; a one-axis list is `${{ matrix }}` |
| `${{ env.X }}` | `$X` in the script |
| `${{ runner.os }}`, `${{ runner.temp }}` | Always Linux-like; use `/tmp` |
| `${{ hashFiles('x') }}` | Only in a `cache:` `key` or `restore-keys` |
### Environment variables in scripts
| GitHub Actions | Infrawrench CI |
| --------------------------- | ---------------------------------------------------------------------------------- |
| `GITHUB_SHA` | `IWCI_COMMIT` |
| `GITHUB_REF_NAME` | `IWCI_BRANCH` |
| `GITHUB_WORKSPACE` | `/app` (the clone, and every job's default working directory) |
| `GITHUB_OUTPUT` | `IWCI_OUTPUT` |
| `GITHUB_ENV`, `GITHUB_PATH` | Not needed: the job is one script, so `export` and `PATH=...` carry to later lines |
| `GITHUB_STEP_SUMMARY` | No equivalent; keep a report with `downloads:` |
| `GITHUB_TOKEN` | Set only in a job with `github-token:` (also `GH_TOKEN`) |
| `RUNNER_TEMP` | `/tmp`. Files shared by the run's jobs go in `/tmp/workflow` (`$IWCI_SCRATCH`) |
| `CI` | `CI=true` |
## Monorepos: from a few big jobs to a job per package
On GitHub Actions every job pays for its own machine, checkout and install, so monorepo workflows usually have a handful of jobs that each run one task across every package (`turbo run test`, `nx affected -t lint`, `pnpm -r typecheck`). In Infrawrench CI a job costs none of that, so write one job definition per task and let it expand to one job per workspace package. Each package's job is its own row and log in the run, and the task cache skips the ones a change cannot affect.
### The shape
```yaml
name: Test
on:
push:
branches: [main]
pull-request: {}
workspace:
deps: [pnpm]
jobs:
build:
packages: { has-script: [build] }
needs: ["^build"]
using: env:bash-node@24
run: pnpm run build
artifacts: [dist]
task-cache: true
typecheck:
packages: { has: [tsconfig.json] }
needs: ["^build"]
using: builtin:[email protected]
args: [--noEmit]
task-cache: true
test:
packages: { has-script: [test] }
needs: [build]
using: env:bash-node@24
run: pnpm test
task-cache: true
memory: 4GiB
```
- **`packages:`** expands a job over the workspace (`pnpm-workspace.yaml`, or `workspaces` in the root `package.json`). `true` is every package. Narrow it with `only:` (globs over directory or name, `!` excludes), `has:` (files the package has), `has-script:` (scripts it defines) or `scripts:` (a glob its script's command must match). Each job runs in its package's directory and reads `${{ package.name }}` and `${{ package.dir }}`.
- **`needs: ["^build"]`** waits for `build` in each package this one depends on, like Turborepo's `dependsOn: ["^build"]`. `needs: [build]` in a `packages:` job means the same package's `build`. A plain job that needs a `packages:` job waits for all of its packages.
- **`artifacts:`** in a `packages:` job are relative to the package, so each package's `dist/` reaches the jobs that depend on it.
- **One slow package** can be split further: give it its own job with `only:` and a `matrix:` of shards, and leave the rest alone.
### The task cache
`task-cache: true` skips a job when nothing it reads has changed since a run of it passed, and hands on that run's log, outputs and artifacts as if it had run. Use it on every deterministic job: builds, type checks, tests, linters, formatters.
```yaml
task-cache:
inputs: [src/**, tsconfig.json, "!src/**/*.md"] # relative to the package; default: every file in it
root-inputs: [tsconfig.base.json, .eslintrc.cjs] # relative to the repository root
artifacts: false # see below
```
- **The key** covers the job's definition, the exact version of every tool and environment it uses, the lockfiles, the files its inputs match, and the bytes of every artifact it is handed. A job downstream of a change reruns only when what it is handed actually changed.
- **Name every file outside the package that a job reads** in `root-inputs:` (shared tsconfig, lint and test config, fixtures). A file the key leaves out can change without rerunning the job.
- **`artifacts: false`** leaves handed-on artifacts out of the key, for a job that only passes them along (a bundler that keeps workspace dependencies external), so a change at the bottom of the graph does not rebuild everything above it. Only when the job's result does not depend on them.
- **Cannot be task-cached:** a job that reads a secret, is lent anything (`connections:`, `ssh-keys:`), has `github-token:`, keeps `downloads:` or runs on a cloud account. Keep those jobs small and put them after the cached ones.
- A cache hit is not billed, takes no slot or memory, and a run where every job hits never installs dependencies. Pull requests keep their own results: nothing a pull request saves is used on the default branch.
### Translating common commands
| GitHub Actions step | Infrawrench CI |
| --------------------------------------------- | ------------------------------------------------------------------------------------- |
| `turbo run build` / `nx run-many -t build` | A `build` job with `packages:`, `needs: ["^build"]`, `artifacts: [dist]` |
| `turbo run test --filter=...[origin/main]` | A `test` job with `packages:` and `task-cache: true`: the cache does the filtering |
| `nx affected -t lint` | A `lint` job with `packages: { has-script: [lint] }` and `task-cache: true` |
| `pnpm -r --parallel typecheck` | A `typecheck` job with `packages:` and `using: builtin:[email protected]` |
| `pnpm --filter web test` | A job with `packages: { only: [apps/web] }`, or a plain job with `cwd: /app/apps/web` |
| A `paths-filter` step choosing which jobs run | `paths:` on each job, or `if: changed('apps/web/**')` |
Keep `turbo` or `nx` out of the jobs once they are split: each job runs one package's script directly, and the task cache replaces their caches.
git.infrawrench.com and Infrawrench CIWorks in a repository on git.infrawrench.com the way its reviewers read it: records the work on each push, answers what they send back, and writes CI jobs that put notes on the branch's page.
AGENTS.md (append)
# git.infrawrench.com and Infrawrench CI
git.infrawrench.com is a Git forge where a branch is reviewed as a record of versions. Every push to a branch that is not the default branch makes a version, and the branch's page shows what there is to read about that version before its code: what the agent that wrote it recorded (its trace), what reviewers and CI jobs found (findings), and what reviewers sent back (instructions). There are no pull requests to open: a branch gets its page at its first push.
You are in such a repository when `git remote -v` names `git.infrawrench.com`. The user-facing guides are https://infrawrench.com/docs/features/git-branches and https://infrawrench.com/docs/features/git-agents-and-mcp. Read the sections below when a step below says so.
## Connect
The forge's MCP server is `https://git.infrawrench.com/mcp`, usually added under the name `infrawrench-git`. If its tools (`record_trace`, `get_branch`, ...) are not available, tell the user how to add it: the "Connecting the forge's MCP server" section below has the command for Claude Code, Codex and Cursor. Call `whoami` once when you are unsure whether you can write. Tools take a repository as `owner/name` and a branch by its name.
## When you write code on a branch
1. **Start.** Given a task with no branch yet, call `start_work` with the ask: it makes the branch and its page, as a draft. When the task is one of the repository's open issues, pass its number as `issue` instead: the page takes the issue's title and description and closes the issue when it is merged into the default branch. Then `git fetch origin && git switch <branch>`. If a branch already exists, check it out and call `get_branch` to see where it stands.
2. **Record as you work**, with `record_trace`, not only at the end. the "Recording a trace" section below has the kinds and their fields. In short: one `ask`, a `step` for each piece of work, a `decision` when you chose between alternatives, `evidence` whenever you ran a check (the command, its exit code, the lines of output that show the result, failures too), and a `doubt` for anything you are unsure of, skipped or could not verify. Reviewers read doubts first.
3. **Record before you push.** Entries wait on the branch and are attached to the version the next push makes. Then `git push`. A `secret_files_pending` failure kept nothing: send the same entries again in a minute.
4. **After a push**, call `get_branch` for the branch's state, `list_instructions` for what reviewers sent back and `list_findings` for what reviewers and CI found.
5. **Answer instructions.** For each one you take on: `mark_instruction_delivered`, do the work, record it, `mark_instruction_answered`, then push. If you decide not to do what was asked, record why (a `decision` or a `doubt`) and still mark it answered. An instruction whose `source` is `conflict` means the branch no longer merges cleanly into its base: fetch the base, rebase onto it (or merge it in), resolve every conflict it lists, run the checks again, and push (`git push --force-with-lease` after a rebase). The forge sends one by itself when a push leaves the branch conflicting, and marks it answered when a later push resolves it. An instruction whose `source` is `ci_failure` lists the checks that failed on the branch's newest commit, with a link to each run (`GET /api/repos/<owner>/<repo>/ci/runs/<run id>`, with the Git credential your machine has for the forge as a Bearer token, has every job's output; the branch token cannot read it). Read the output and decide: if the branch caused it, fix it, run the check, and push; if it did not (a flaky test, an outage, a failure the base has too), change nothing, record a `decision` saying why, and mark it answered. The forge sends one by itself once a commit's checks have settled with a failure, and marks it answered when a later push passes.
6. **Hand it over when it is done.** The branch's page is a draft until it is marked ready for review. After your last push, call `mark_ready_when_checks_pass`: the page leaves draft by itself the moment every check on its head has passed (and every check the base branch requires has reported), or now if they already have. A failing check keeps it a draft and the request waits for your fix. `enabled: false` withdraws it, and a person who marks the page by hand cancels it. It never merges.
7. **Fix what must be fixed.** An open `must_fix` finding holds the branch's merge until it is fixed, dismissed by a person, or overridden by an administrator. You cannot dismiss or override one: fix it and push, or record a `doubt` saying why you think it is wrong.
## When you review a branch
Read the change with `get_branch` and `get_version_diff`, then call `report_finding`: a `severity` (`must_fix` only for what must not merge, `should_fix`, `note`), a short `title`, a `body`, the `path` and lines, and `evidence`. Set `complete: true` when the list is everything you find on that version, so your earlier findings that are not in it are marked fixed. Report under a `reviewer` name of your own (`claude-review`).
## Images and videos
A trace entry, a finding and an ask are Markdown, and can show a screenshot or a short recording (a UI before and after a change, a failing test's screen). Call `upload_media` with the file as base64 (3 MB at most) and put the `markdown` it answers in what you write next. For a larger file or a video, post the bytes to the repository's upload address with the same token: `curl -fsS --data-binary @shot.png -H "Authorization: Bearer <token>" "https://git.infrawrench.com/<owner>/<name>/uploads?name=shot.png"` answers the same JSON. Images: PNG, JPEG, GIF, WebP, AVIF up to 10 MB; videos: MP4, WebM, QuickTime up to 90 MB. Never upload a screenshot that shows a secret.
## Infrawrench CI
A repository's pipelines are the YAML files in `.infrawrench/ci/`. They run on every push and on each branch page's new version, and their results are on the branch's **Checks** tab. A pipeline has `name:`, `on:` (`push`, `pull-request`, `schedule`, `manual`) and `jobs:`; a job is one script (`run:`) in an environment (`using: env:bash-node@24`) or on a Linux machine (`platform: linux`). Do not guess the rest: the guide is https://infrawrench.com/docs/features/ci and every key is in `ci-runner/README.md` of the Infrawrench repository.
A CI job can put notes on the branch's page by printing lines, with no token and no API call:
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
`::must-fix`, `::should-fix` and `::note` become findings; `::doubt`, `::decision`, `::step` and `::evidence` become trace entries. Read the "Notes from a CI job" section below before writing a job that prints them: it has the parameters, the escapes, the limits, what a passing job marks fixed, and a job that turns a linter's JSON report into notes. Use this when a check already runs in CI (a linter, a type checker, a test report); use `report_finding` when you are the reviewer yourself.
## Secret files
A repository may have secret files (`filter=iwsecret` in `.gitattributes`): what is committed is a pointer, or a YAML or JSON skeleton whose values are `"iwsecret:1:..."` tokens. `get_branch` and `start_work` list a branch's secret files in `secretFiles` with `secretRules`; `secretFilesPending` means the forge was still listing them, so call `get_branch` again in a few seconds. When there are any, run `infrawrench git secret install` after checking the repository out, so they are readable in your checkout (if the person you work for may read them) and uploaded when you push. A file that stays a pointer is one you cannot read: leave it as it is.
- You may read and edit these files in your checkout.
- Never put a value from them into a trace entry (asks, steps, decisions, evidence, doubts), a finding, an instruction answer, a commit message, a branch's title or description, or command output you record. Refer to a secret by its path and key name: "changed `database.password` in `config/prod.yaml`".
- Never print one in a command whose output you record as evidence.
- Never copy one into a file that is not secret. The forge refuses an agent's push that does.
- When reviewing, a pointer or a token is not a placeholder or a bug: it is how the file is committed.
- A CI job that needs one names it in `secret-files:` (paths written out, at most 32). It gets the file only on a branch the repository lends secret files to CI on; turning that on is an administrator's choice in the repository's settings, never yours.
## Never
- **Never put a secret in a trace entry, a finding or a CI note.** Tokens, keys and passwords are masked before anything is stored, but masking recognises shapes and names, not every secret, and everyone who can read the repository reads the notes. Leave them out, and do not print what a secret protects.
- **Never report as one of the forge's own reviewers.** `general`, `security`, `tests`, `terraform` and `intent` are refused, and so is any name that starts with `ci:`, which is how Infrawrench CI names a job's findings (`ci:<pipeline>/<job>`). An agent kind of `ci` is refused for a trace in the same way.
- **Never mark an instruction answered for work you did not do**, and never push to the default branch to get around a branch's page.
- **Do not invent pipeline keys or note parameters.** An unknown parameter makes a note command malformed: it is ignored, and the job's reason on the run's page says how many were.
## Notes from a CI job
A job of a repository on git.infrawrench.com leaves notes on the branch page of the commit it ran on by printing one line per note, to its output or its errors. Nothing else is needed: no token, no API call, no tool.
```
::must-fix file=src/db.ts,line=42,title=Unbounded query::This read has no LIMIT.
::doubt file=src/retry.ts,line=12::Is three attempts enough for a cold start?
```
The line starts at its first character with `::`, the command, a space and the parameters when there are any, `::`, then the message. An indented line, or a command in the middle of a line, is not read.
### Commands
| Command | Becomes |
| -------------- | ------------------------------------------------------------------ |
| `::must-fix` | A finding that must be fixed. While it is open it holds the merge. |
| `::should-fix` | A finding that should be fixed. |
| `::note` | A finding that is a note. |
| `::doubt` | A trace entry of kind `doubt`. |
| `::decision` | A trace entry of kind `decision`. |
| `::step` | A trace entry of kind `step`. |
| `::evidence` | A trace entry of kind `evidence`. |
There is no `::ask` and no trace `note`: `::note` is the finding. Other names after `::` (`::group::`, `::error`) are other tools' commands and are left alone, so a typo in a command's name is silently not a note.
### Parameters
| Parameter | Value |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `file` | A path from the repository's root (`src/db.ts`). Not absolute, no `..`. Left out, the note is about the whole change. |
| `line` | The line, from 1, in the file as it is at the run's commit. Needs `file`. |
| `end_line` | The last line of a range. Needs `line`, and is not before it. |
| `title` | A finding's title (up to 200 characters), or a bold first line on a trace entry. Without one, a finding's title is its message's first line. |
| `needs_code` | `true` or `false`: show the lines under the note's text. Left out, it is `true` when there is a `line`. |
Parameters are separated by commas, each given once, in any order. All are optional. A finding with a `title` may have an empty message; a trace entry needs a message.
### Escapes
| Write | For |
| ----- | ------------------------------------------ |
| `%25` | `%` |
| `%0A` | A line break (`%0D` for a carriage return) |
| `%3A` | `:` in a parameter's value |
| `%2C` | `,` in a parameter's value |
Escape `%` first, then the others, whenever the text comes from a tool's output. A message needs only `%25`, `%0A` and `%0D`; a parameter's value needs all of them.
### What happens to them
- **Where.** On the open branch page of the run's commit, on the version that commit's push made. A run on a branch with no open page (the default branch, a schedule) leaves nothing, and so does a run of a commit the branch has been force pushed past.
- **Findings** are reported by the reviewer `ci:<pipeline>/<job>`, with a link to the line of the job's log that printed them.
- **The same finding on the next push is the same finding.** It is told apart by job, `file` and title, never by line. So keep titles stable: use the rule's id (`no-explicit-any`), not a sentence with a line number or a count in it. A finding a person dismissed stays dismissed.
- **A passing job marks fixed** what it reported before and did not print this time. A failing job fixes nothing, so a job that reports and then fails keeps its findings open until a later run passes without them.
- **Trace entries** of a job are replaced when the job runs again on the same commit. A run of a branch proposed from a fork leaves findings only.
- **A must-fix** holds the merge like any must-fix, and is sent to the agent that writes the branch as an instruction.
### Limits
- 100 notes per job, 1,000 per run. Print the worst first when a tool can report more.
- A message is at most 8 KiB after its escapes are read; a `file` at most 1,024 characters.
- A command over a limit, or a malformed one (a parameter not in the table, a `line` that is not a number, a `file` outside the repository, no message), leaves no note. The job's reason on the run's page counts them: `2 note commands ignored (2 malformed).` Check it after the first run of a new job.
### Secrets
The commands are read from the run's log as it is stored, where the organization's secrets are already `***`, and each note is masked again by shape before it is kept. Everyone who can read the repository reads the notes, so never print a secret, and do not print what one protects (a customer's record, a private URL).
### A linter's JSON as notes
On a Linux machine (`platform: linux`), whose image has `jq`:
```yaml
name: lint
on:
pull-request: {}
jobs:
eslint:
platform: linux
run: |
npm ci
status=0
npx eslint . --format json --output-file eslint.json || status=$?
jq -r --arg root "$PWD" '
def esc: gsub("%"; "%25") | gsub("\r"; "%0D") | gsub("\n"; "%0A");
def param: esc | gsub(":"; "%3A") | gsub(","; "%2C");
.[]
| (.filePath | ltrimstr($root + "/")) as $file
| .messages[]
| (if .severity == 2 then "must-fix" else "should-fix" end) as $command
| (if .line then ",line=\(.line)" else "" end) as $line
| "::\($command) file=\($file | param)\($line),title=\(.ruleId // "eslint" | param)::\(.message | esc)"
' eslint.json
exit "$status"
```
In a sandboxed environment (`using: env:bash-node@24`), which has no `jq`, the same with Node:
```yaml
jobs:
eslint:
using: env:bash-node@24
run: |
status=0
pnpm exec eslint . --format json --output-file eslint.json || status=$?
node -e '
const esc = (s) => String(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
const param = (s) => esc(s).replace(/:/g, "%3A").replace(/,/g, "%2C");
const root = process.cwd() + "/";
for (const file of JSON.parse(require("fs").readFileSync("eslint.json", "utf8"))) {
const path = file.filePath.startsWith(root) ? file.filePath.slice(root.length) : file.filePath;
for (const m of file.messages) {
const command = m.severity === 2 ? "must-fix" : "should-fix";
const line = m.line ? `,line=${m.line}` : "";
console.log(`::${command} file=${param(path)}${line},title=${param(m.ruleId ?? "eslint")}::${esc(m.message)}`);
}
}
'
exit "$status"
```
Both print the notes whether or not the linter passed, then end with the linter's own status, so the job still fails when it should. Write the report to a file and read the file: in a sandboxed environment a pipe reports only its last command's status.
## Connecting the forge's MCP server
The server is one address, `https://git.infrawrench.com/mcp`, over Streamable HTTP. A client that supports OAuth needs only the address: the first call opens the user's browser on git.infrawrench.com to sign in and allow the application. Adding a server is the user's to do; give them the command for their client.
### Claude Code
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp
```
Then `/mcp` inside Claude Code, pick `infrawrench-git` and sign in.
### Codex
```sh
codex mcp add infrawrench-git --url https://git.infrawrench.com/mcp
codex mcp login infrawrench-git
```
### Cursor
In `~/.cursor/mcp.json`, or `.cursor/mcp.json` in the project:
```json
{
"mcpServers": {
"infrawrench-git": {
"url": "https://git.infrawrench.com/mcp"
}
}
}
```
### Without a browser
A client that cannot open a browser sends a personal access token (`iwg_...`, made under **Settings > Access tokens** on git.infrawrench.com, with the `repo:write` scope to record traces and report findings) in the `Authorization` header:
```sh
claude mcp add --transport http infrawrench-git https://git.infrawrench.com/mcp \
--header "Authorization: Bearer $IWG_TOKEN"
```
Read the token from the environment. Never write it into a file that is committed, a trace entry or a note.
### A token for one branch
An agent that works on one branch does not need a person's whole access. Ask the forge for a token for that branch, with any credential that can write the repository (a personal access token, an organisation's API key):
```sh
curl -fsS -X POST -H "Authorization: Bearer $IWG_TOKEN" \
https://git.infrawrench.com/api/repos/<owner>/<repository>/branches/<branch>/agent/token
```
`<branch>` is the branch's name as one URL segment (`work%2Fadd-rate-limits`). The answer is `{ "token", "expiresAt", "branch" }`. The token lasts six hours; ask again for another. Send it as the MCP server's `Authorization: Bearer` header, or to the API.
It records that branch's trace, lists its instructions and marks them delivered and answered, and lists and reports findings on it. It does nothing else: it cannot clone or push, reach another branch or repository, send or withdraw an instruction, or dismiss a finding. With it, `whoami` answers `kind: "agent"` and the `branch`, and `get_branch`, `get_version_diff`, `list_my_branches` and `start_work` are refused.
A thread git.infrawrench.com starts in T3 Code is told to ask for one with the machine's own Git credential and to keep it in a file in the worktree's Git directory. Never print the token, and never put it in a message, a commit or a trace.
### Calling a tool without a client
A session that has not loaded the server's tools can still call them: each call is one `POST` of a JSON-RPC request, and `tools/list` in place of `tools/call` describes every tool.
```sh
curl -fsS https://git.infrawrench.com/mcp \
-H "Authorization: Bearer $INFRAWRENCH_GIT_TOKEN" \
-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"record_trace","arguments":{"repository":"acme/infra","branch":"work/add-rate-limits","entries":[{"kind":"decision","body":"A token bucket, not a fixed window: bursts are fine here."}]}}}'
```
### What a connection may do
| Scope | Allows |
| ------------ | -------------------------------------------------------------------------------------- |
| `repo:read` | Read the repositories the user can read, with their branches, reviews and traces. |
| `repo:write` | Push, record traces, answer instructions, report findings and start work, as the user. |
A connection never does more than its user can, and never administers a repository. `whoami` says whose credential it is and whether it can write.
### The tools
| Tool | Use |
| ----------------------------- | --------------------------------------------------------------------------------------------------------- |
| `whoami` | Whose credential this is, whether it can write, and the branch of a branch token. |
| `list_my_branches` | Open branches that involve the user and have something new. |
| `get_branch` | A branch's page, state, versions, and how many instructions and findings are open. |
| `get_version_diff` | A version's diff: the whole change, that version alone, or since an earlier version. |
| `record_trace` | Record the ask, steps, decisions, evidence and doubts of the work on a branch. |
| `list_instructions` | What reviewers sent to the agent that writes the branch. |
| `mark_instruction_delivered` | Say an instruction has reached you. |
| `mark_instruction_answered` | Say which version answers an instruction. Left out, it is the next push. |
| `mark_ready_when_checks_pass` | Ask that the branch's draft page be marked ready for review once its checks pass. |
| `list_findings` | What reviewers and CI jobs found on a branch. |
| `report_finding` | Report a reviewer's findings on a version. |
| `start_work` | Create a branch and its page, as a draft, from an ask or an open issue (`issue`), before any code exists. |
## Recording a trace
`record_trace` takes `repository` (`owner/name`), `branch` (not the default branch) and one or more `entries`, in the order they happened. Send several in one call. The branch does not have to exist yet.
### Kinds
| Kind | Record it when |
| ---------- | ---------------------------------------------------------------------------------------------------- |
| `ask` | Once, at the start: what you were asked to do, in the person's words. |
| `step` | After each meaningful piece of work: what you changed and why, with `anchors` to the files. |
| `decision` | You chose between alternatives: what you chose, what you rejected and why. |
| `evidence` | You ran tests, a build, a linter or any check: the command, its exit code, the output. Failures too. |
| `doubt` | You are unsure, skipped something, or could not verify something. Reviewers read these first. |
| `note` | Anything else a reviewer should know. |
### An entry
| Field | Value |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| `kind` | One of the kinds above. |
| `body` | Markdown, a few sentences: what and why. At most 32 KB. |
| `anchors` | The files and lines the entry is about: `[{ "path": "src/db.ts", "start_line": 40, "end_line": 48 }]`. Lines are optional. |
| `needs_code` | `true` only when a reader has to see the code at the anchor to understand the entry. Defaults to `true` when a line is given. |
| `evidence` | For `evidence`: `command`, `exit_code`, `output` (an excerpt; past 16 KB its start and end are kept), `ci_run_id` or `url`. |
```json
{
"repository": "acme/infra",
"branch": "feature/rate-limits",
"entries": [
{ "kind": "ask", "body": "Limit sign-in attempts to five a minute per address." },
{
"kind": "decision",
"body": "Counted in Postgres, not in memory: the API runs on several instances.",
"anchors": [{ "path": "src/auth/limits.ts", "start_line": 12, "end_line": 30 }],
"needs_code": false
},
{
"kind": "evidence",
"body": "The new tests pass.",
"evidence": {
"command": "pnpm test src/auth",
"exit_code": 0,
"output": "Tests 14 passed (14)"
}
},
{
"kind": "doubt",
"body": "Addresses behind one proxy share a limit. I did not change how the address is read."
}
]
}
```
### How it reaches the page
- Entries wait on the branch and are attached to the version the branch's **next push** makes. Record first, push after. Entries recorded after a push belong to the next one.
- A branch holds at most 1,000 entries waiting for a push, and entries nobody pushes after are dropped after 30 days.
- A note shows the lines it is about under its text when `needs_code` is true. Most decisions and doubts stand on their own: leave it `false` for those, even when they have an anchor. Every entry with an anchor hangs on its lines in the file's diff either way.
- Recording needs write access to the repository.
### Secrets
Every entry is masked before it is stored: known token formats, private key blocks, passwords in URLs, `Authorization` and `Cookie` headers, values given to names such as `TOKEN` or `PASSWORD`. That catches mistakes; it cannot know a secret that has no shape and no name. Do not paste a command's output without reading it, and never record a secret on purpose.
### Instructions
`list_instructions` lists what is still to do (`queued` and `delivered`). An instruction is a review comment, a finding or a reviewer's own words, written out as it was when sent. For each one: `mark_instruction_delivered` when you take it on, then do the work, record it, and call `mark_instruction_answered` just before you push (leave `version` out and it is tied to the version that push makes). A `must_fix` finding on a branch you are named as the agent of arrives as an instruction on its own, whether a reviewer or a CI job raised it.
May we use cookies and similar technologies to understand how this site is used and to measure our marketing? This turns on analytics, session replays with form inputs masked, and purchase measurement that can be shared with advertising platforms.Privacy policy