AI software factory.
rix agent clones a target repo, runs a coding agent against it, and emits one git
bundle per proposed change. It is read-only — it never pushes or opens PRs itself, so the
agent run needs only a read token. A separate, trusted step turns the bundles into PRs.
Before the agent starts, rix configures the clone's git identity as
rix <rix@noreply.invalid>, so commits the agent creates carry a consistent author instead
of guessed metadata.
rix ships a reusable workflow (.github/workflows/agent.yml) that runs the agent and opens
the resulting PRs. Each repo drives it through a small caller workflow.
Run rix initialize --single-repo inside a checkout of the target repo to write both caller
workflows (.github/workflows/rix-agent.yml and .github/workflows/rix-on-ci-failure.yml;
existing files are overwritten). Releases up to v0.4 wrote the first one as rix.yml; delete that
file when you re-run it, or the repo ends up with two identical manual triggers. The templates are
baked into the rix binary, so this needs no network access.
Their uses: lines point at the floating major-version tag of the release this rix comes
from (@v0 for any 0.x build), so the caller workflows call the reusable workflows they were
released with. Then:
- Add the repo secret
RIX_READ_TOKEN, and addRIX_WRITE_TOKENto an environment namedrix(see Secrets). - Commit and push the two files.
The written workflows react to failures of the workflow named CI; pass --ci-workflow <name>
with the name: of yours if it is called something else. Pass --dir <path> to target a repo
other than the current directory, and --ref <git-ref> to pin the written workflows to a
different tag, branch, or commit SHA of this repo. The sections
below describe the files it writes and how to customize them further. To set up a factory repo
that serves several repos instead, run rix initialize factory in the factory repo, then onboard
each repo it serves, either through the factory's own agent or by running
rix initialize <owner/name> in it, naming the factory (see
Advanced: a central factory repo).
name: rix (agent)
on:
workflow_dispatch:
inputs:
prompt:
description: Task for the agent
required: true
jobs:
rix:
uses: Tim-Pohlmann/rix/.github/workflows/agent.yml@v0
with:
repo: ${{ github.repository }}
prompt: ${{ inputs.prompt }}
# agent: claude # optional; defaults to 'opencode'
secrets:
read-token: ${{ secrets.RIX_READ_TOKEN }}
write-token: ${{ secrets.RIX_WRITE_TOKEN }}Pick the coding agent with the optional agent input — opencode (default), claude, or
pi. All three install their CLI via npm at run time. With no model set, opencode picks
its own free default model, so the example above needs no agent-api-key at all.
The workflow posts a job summary to the run page after rix submit: the run's status, cost and
duration, plus the pull requests that were actually opened (with links). The run job posts an
early summary too, so a failed agent run still reports its outcome even when the PR-creation job is
skipped.
rix agent exposes a local API to the agent, described by an OpenAPI 3 document the agent fetches
from /openapi.json (the system prompt only points at it). Besides opening PRs (/pr), the agent
can push new commits onto a branch that already exists on the remote (/push, e.g. resuming a
previous run).
/push accepts nothing by default — an untrusted agent cannot touch any existing branch unless
you opt in with the allowed-push-branches input, a comma-separated list of branches the /push
endpoint accepts:
with:
repo: ${{ github.repository }}
prompt: ${{ inputs.prompt }}
allowed-push-branches: rix/continue-foo,rix/continue-barA push to any branch outside that list (or any push at all, if the input is omitted) is rejected
with a 403, and the agent is told the allow-list in its system prompt. The input forwards verbatim
as --allowed-push-branches (env RIX_ALLOWED_PUSH_BRANCHES); an entry can be any branch name
that already exists on the remote, not just rix/* — e.g. a human's own branch you want the agent
to resume.
The same list is given to rix submit, which checks it again before pushing. That repetition is
the point: rix agent writes what the agent asked for into result.json, the agent runs as an
ordinary process in the same workspace and can rewrite that file afterwards, and rix submit is
where the write token actually is. Only the second check decides what reaches the remote, so
submit takes the list from its own input and never from result.json. The agent.yml workflow
passes your allowed-push-branches to both jobs; if you drive the composite actions yourself,
give rix-submit the same value you gave rix-agent, or its pushes will all be refused.
Pending pull requests need no such input. A PR names a branch that cannot exist yet, and the
rix/* rule bounding it is carried by result.json's own type (RixBranchName), so it is
re-applied when rix submit parses the file.
The coding agent CLIs read configuration and context from the runner's user home (~/.config/...,
~/.claude/..., house style guides, MCP configs, and so on). Point rix at a second repo — a
"factory repo" — to copy files into that home directory before the agent starts. agent.yml and
on-ci-failure.yml both take the same two inputs:
with:
repo: ${{ github.repository }}
prompt: ${{ inputs.prompt }}
factory-repo: my-org/rix-factory
# agent-home-path: .rix/agent-home # optional; this is the default
secrets:
read-token: ${{ secrets.RIX_READ_TOKEN }}
write-token: ${{ secrets.RIX_WRITE_TOKEN }}When factory-repo is set, rix fetches one directory from it (a depth-1 blobless sparse checkout)
and copies that directory's contents into the runner's home. agent-home-path names the
directory inside the factory repo and defaults to .rix/agent-home. Collisions are resolved by
keeping the existing file — only paths not already present in home are written, and directories
are merged — so the factory bundle never clobbers what the runner image ships. Symlinks in the
bundle are recreated as symlinks, not followed.
The existing read-token is reused to clone the factory repo, so that PAT must also grant read
access to factory-repo. If the clone fails, agent-home-path is absent from the repo, or
the copy into home fails, the run stops with a setup failure and the agent never runs.
agent-home-path without factory-repo is rejected. The inputs forward as
--factory-repo / --agent-home-path (env RIX_FACTORY_REPO / RIX_AGENT_HOME_PATH).
opencode supports many model providers beyond the free default. Pick a model with the
model input, forwarded verbatim as --model (rix does not interpret it), and set
agent-api-key/agent-api-key-env to the credential that provider expects:
with:
repo: ${{ github.repository }}
prompt: ${{ inputs.prompt }}
agent: opencode
model: openai/gpt-4o
agent-api-key-env: OPENAI_API_KEY
secrets:
read-token: ${{ secrets.RIX_READ_TOKEN }}
write-token: ${{ secrets.RIX_WRITE_TOKEN }}
agent-api-key: ${{ secrets.OPENAI_API_KEY }}claude (Anthropic's Claude Code CLI) only talks to Anthropic's own models; for that agent,
model (if set) just picks among Claude's models, and agent-api-key-env defaults to
ANTHROPIC_API_KEY automatically (no need to set it unless using a non-default env var name).
pi (the open-source Pi coding agent CLI) is multi-provider like opencode — pick a model
with model, forwarded verbatim as --model (e.g. openai/gpt-4o). Unlike opencode, pi has
no free default provider, so agent-api-key-env must always be set explicitly when
agent-api-key is provided; there is no per-agent default to fall back on.
Set the optional effort input to change how hard the agent reasons. rix forwards it verbatim
to the agent CLI's own flag, so the accepted levels are that CLI's: --effort for claude (low,
medium, high, xhigh, max), --variant for opencode (provider-specific, e.g. high,
max, minimal), and --thinking for pi (off, minimal, low, medium, high, xhigh,
max). Leave it unset to keep the agent's default. The input forwards as --effort (env
RIX_EFFORT).
Local/self-hosted backends (e.g. Ollama, LM Studio) aren't supported yet — opencode and pi reach those through a generated config file rather than a model string + API key, which is a separate mechanism this workflow doesn't build today.
@v0 is the floating major-version tag: it moves to each new 0.x release, so callers pick up
fixes without re-pinning, and the workflow keeps fetching the binary belonging to that release.
Pin an exact tag (e.g. ...agent.yml@v0.5.0) or a commit SHA for byte-for-byte reproducible,
supply-chain-safe runs. @main is not recommended: between a version bump and the release it
names, it asks for a binary that isn't published yet.
| Secret | Purpose |
|---|---|
read-token |
Required. PAT with read access to the target repo; used to clone it during the agent run. |
write-token |
Required. PAT with contents:write + pull-requests:write on the target repo; used to push branches and open PRs. Belongs in an environment — see below. |
agent-api-key |
Optional. API key for the selected agent's model provider, exported as the env var named by agent-api-key-env (default OPENCODE_API_KEY for opencode, ANTHROPIC_API_KEY for claude; for pi, agent-api-key-env must be set explicitly whenever agent-api-key is provided, since pi has no per-agent default). Not needed when leaving model unset, since opencode then picks its own free default model. |
The read/write split keeps the agent run (which executes untrusted, model-generated work) on a read-only token; only the final, deterministic PR-creation step holds write access.
That PR-creation job runs in a GitHub
Environment
belonging to the calling repo, named by the optional environment input (default rix).
Create it under Settings → Environments, add RIX_WRITE_TOKEN to it as an environment secret,
and restrict its deployment branches to the branches the caller workflow runs on — "protected
branches only", with main protected, is the usual choice. GitHub then refuses to hand the
token to a run on any other branch. That is the bound that still holds if the token is ever
widened enough to push workflow files, which rix's own allowed-push-branches check cannot
promise on its own: that check runs inside rix, on the same side of the fence as the inputs it
reads. Callers pass the secret exactly as the examples here show — an environment secret can be
passed by name even though it exists nowhere else.
An environment name that does not exist in the calling repo is created on first use, with no protection rules: the run succeeds and nothing is enforced. So a caller holding the write token as a plain repo secret keeps working unchanged, just without this bound.
The workflow downloads the rix release binary belonging to the workflow ref you pinned in
uses: — not whatever was published most recently — and verifies it against that release's
published SHA-256 checksum before running it, so the workflow and the binary it drives always
come from the same release. Override with the optional rix-version input (an exact tag, or
latest) only if you specifically want them to differ.
Both jobs run on ubuntu-latest by default. Pass the optional runner input to run them
on a different runner (e.g. a self-hosted label). The workflow detects the runner's OS and
architecture and downloads the matching release binary: Linux and macOS on x64 or arm64,
and Windows on x64.
with:
repo: ${{ github.repository }}
prompt: ${{ inputs.prompt }}
runner: self-hostedrix also ships .github/workflows/on-ci-failure.yml, a reusable workflow that takes a
specific run, checks whether it actually failed, builds a prompt from the failure (PR number,
run URL, failing step logs), and runs the agent against it. It's the building block for both
patterns below — write the "turn a failure into a prompt" logic once, reuse it either way.
It runs as three jobs, one composite action each: detect-ci-failure decides whether to act and
writes the prompt, rix-agent runs the agent against it, and rix-submit pushes the result
and opens the PRs. They are separate jobs rather than steps because only the middle one executes
code from the failing branch — see What the agent's machine is trusted
with.
A caller triggered by workflow_run instead of workflow_dispatch — this is the
rix-on-ci-failure.yml that rix initialize writes, with the
watched workflow named by --ci-workflow:
name: rix (on CI failure)
on:
workflow_run:
workflows: ["CI"] # must match the `name:` of the workflow to watch
types: [completed]
jobs:
rix:
# Cheap short-circuit; on-ci-failure.yml re-checks both conditions via the API regardless.
if: >-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.head_repository.full_name == github.repository
# One rix run per branch at a time: when CI fails again while rix is still working on the
# previous failure, the second run waits instead of starting a second agent from the same tip.
# On the job rather than the workflow, so only runs that get past the `if` above contend:
# GitHub keeps a single pending entry per group and cancels whatever a newcomer displaces
# (`cancel-in-progress` governs the running entry, not the queued one), so at workflow scope
# every completion on the branch - a later successful rerun included - would join the group
# and could drop a queued answer to a real failure. The branch names the group on its own
# because the head_repository check above has already pinned which repo's branch it is.
concurrency:
group: rix-on-ci-failure-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: false
uses: Tim-Pohlmann/rix/.github/workflows/on-ci-failure.yml@v0
with:
# repo defaults to the calling repo — no need to set it here.
run-id: ${{ github.event.workflow_run.id }}
secrets:
read-token: ${{ secrets.RIX_READ_TOKEN }}
write-token: ${{ secrets.RIX_WRITE_TOKEN }}read-token needs Actions:read in addition to read access to contents, since
on-ci-failure.yml uses it to fetch the failing run's logs, not just to clone.
Fork PRs: workflow_run always executes with the base repo's secrets, even when the CI run
it's reacting to came from a fork PR. Since on-ci-failure.yml feeds that run's log output
straight into the agent's prompt, an untrusted fork PR could otherwise smuggle prompt-injection
text into a failing test's output and have it interpreted as instructions by an agent holding
write-token — and pushing to a fork takes no permission on your repo at all.
Rix therefore refuses these runs itself: rix ci-failure compares the run's head repo against the
target repo and stops with an untrustedRun result — reported as a notice, not a failure — before
fetching any logs. Getting a branch into the repo requires write access to it, so that one
comparison is the permission check; a maintainer's own fork PR is turned away by it too, but rix
could not have pushed a fix onto that branch anyway. The head_repository condition in the if:
above is the same rule applied a step earlier, so a fork's failure costs no runner minutes.
The agent runs the failing branch's own code — its tests, its build scripts, its dependencies —
so the machine it runs on must be assumed to belong to whoever can push to that branch. That is
why on-ci-failure.yml is three jobs and not one:
detectholds no write token and runs before the agent exists. It decides whether to act and names the one branch the answer may be pushed to. Both travel to the later jobs as job outputs, which a later job cannot rewrite — unlike a file, a step output, or anything else the agent's own job produces.runholds no write token. Everything it produces —result.json, the git bundles, its step outputs — is attacker-controlled by construction. Nothing downstream treats any of it as a permission.create-prholds the write token and never shares a machine with the agent. The one thing it enforces is that each push goes to the branchdetectnamed.
Two consequences worth stating outright:
- The contents of rix's commits are attacker-controlled. The boundary above governs where
a push may land, not what is in it — a prompt-injected agent writes whatever it likes into the
branch it was already allowed to fix. So the branches rix pushes to must never run privileged
CI: no workflow triggered by them may hold secrets,
contents: write, or a deployment environment. Review them like any other pull request from an untrusted author. read-tokenmust stay read-only. It is the one credential handed to the agent's machine, and the job split is worth exactly as much as that token is limited. A fine-grained PAT withcontents:read+actions:readon the target repo is the whole requirement; granting itcontents:writeoractions:write, or scoping it across other repos, extends the compromise to everything it reaches.
Useful when several project repos should share one set of read-token/write-token/
agent-api-key secrets instead of each holding its own. workflow_run can't cross repos, so
each project repo still needs a small local trigger — but it only notifies the factory repo
instead of running rix itself, using a PAT scoped just to dispatch to that one repo. Run
rix initialize <owner/name> in each project repo to write it, with the factory
repo's name filled in (and the watched workflow's, from --ci-workflow as above):
# In each project repo: .github/workflows/rix-notify-factory.yml
name: rix (notify factory)
on:
workflow_run:
workflows: ["CI"] # the name: of the workflow rix reacts to
types: [completed]
jobs:
notify:
# The factory re-checks both conditions against the API, so this only saves the round trip. The
# head_repository check keeps runs from forks' pull requests out: anyone can push to a fork.
if: >-
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.head_repository.full_name == github.repository
runs-on: ubuntu-latest
# The dispatch goes through RIX_FACTORY_DISPATCH_TOKEN; this job needs no GITHUB_TOKEN access.
permissions: {}
steps:
- name: Dispatch to the factory repo
# Every value reaches the script through env, never through ${{ }} inside `run:` - an
# expression there is pasted into the script before bash sees it. A fork PR's branch name
# is chosen by its author and git allows `$(...)` and backticks in one, so interpolating
# it would run the author's command in this step, which holds the dispatch token.
env:
GH_TOKEN: ${{ secrets.RIX_FACTORY_DISPATCH_TOKEN }}
FACTORY_REPO: my-org/rix-factory
PROJECT_REPO: ${{ github.repository }}
RUN_ID: ${{ github.event.workflow_run.id }}
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
run: |
gh api "repos/$FACTORY_REPO/dispatches" \
-f event_type=rix-ci-failure \
-f "client_payload[repo]=$PROJECT_REPO" \
-f "client_payload[run_id]=$RUN_ID" \
-f "client_payload[branch]=$HEAD_BRANCH"RIX_FACTORY_DISPATCH_TOKEN needs contents:write on the factory repo (required by the
dispatches API) and nothing else — it never touches RIX's own credentials. That grant is more
than a dispatch, though: contents:write can also push to the factory, and every project repo
holds the token. Changing a workflow file takes the separate Workflows permission, which the token
lacks, but everything else in the factory is open to it, including an agent home rix copies into
the runner (factory-repo above). So protect the factory's default branch with a ruleset that
requires a pull request (Settings → Rules → Rulesets), and keep the token's owner off its bypass
list: a PAT acts as its owner, so a bypass the owner has is one every project repo has. Other
branches don't matter, since the factory's workflows answer dispatches on the default branch and
the rix environment releases the write token only there. Don't trade the token for
workflow_dispatch either: its actions:write would let every project repo start the factory's
rix-agent.yml with a prompt of its own.
Run rix initialize factory in a checkout of the factory repo to write its two workflows and its
agent home, .rix/agent-home. Both workflows name the factory as their own factory-repo (see
Supplying agent home files from a factory repo),
so whatever you commit there reaches the agent on every run. It starts out holding a README and
the onboarding skill (see Onboarding a repo), and a run fails while it is
missing. The first workflow answers
the dispatched failures:
# In the factory repo: .github/workflows/rix-on-ci-failure.yml
name: rix (on CI failure)
# Answers the CI failures that the repos this factory serves dispatch here, each from its own
# rix-notify-factory.yml. Nothing in a repository_dispatch says who sent it, so on-ci-failure.yml
# re-checks the payload against the API: the run must exist, have failed, and have run on a branch
# of the repo the payload names.
on:
repository_dispatch:
types: [rix-ci-failure]
jobs:
rix:
# One rix run per branch at a time, as in a single repo's rix-on-ci-failure.yml. A
# repository_dispatch carries neither repo nor branch of its own, so the key comes from the
# payload, and a repo holding the dispatch token can name another one's branch and cancel the
# run it had queued.
concurrency:
group: rix-on-ci-failure-${{ github.event.client_payload.repo }}-${{ github.event.client_payload.branch }}
cancel-in-progress: false
uses: Tim-Pohlmann/rix/.github/workflows/on-ci-failure.yml@v0
with:
repo: ${{ github.event.client_payload.repo }}
run-id: ${{ github.event.client_payload.run_id }}
factory-repo: ${{ github.repository }}
secrets:
read-token: ${{ secrets.RIX_READ_TOKEN }}
write-token: ${{ secrets.RIX_WRITE_TOKEN }}The second is the factory's rix-agent.yml, a manual run like the simple pattern's, with a repo input
naming the repo to work on:
# In the factory repo: .github/workflows/rix-agent.yml
name: rix (agent)
on:
workflow_dispatch:
inputs:
prompt:
description: Task for the agent
required: true
repo:
description: "Target repo (owner/name); defaults to this repo"
required: false
jobs:
rix:
uses: Tim-Pohlmann/rix/.github/workflows/agent.yml@v0
with:
# Any repo read-token reaches; the PR only opens where write-token can push.
repo: ${{ inputs.repo || github.repository }}
prompt: ${{ inputs.prompt }}
factory-repo: ${{ github.repository }}
# agent: claude # optional; defaults to 'opencode'
secrets:
read-token: ${{ secrets.RIX_READ_TOKEN }}
write-token: ${{ secrets.RIX_WRITE_TOKEN }}The factory repo's read-token/write-token need access across every project repo it serves,
and read-token to the factory itself as well, for its agent home (e.g. a GitHub App installation token), which is the trade-off of centralizing: one PAT with a
much bigger blast radius than the per-repo tokens in the simple pattern.
To onboard a project repo, run the factory's rix (agent) workflow with repo set to the
project's owner/name and a prompt such as Onboard this repo to the factory. The agent picks up
the rix-onboard skill from the factory's agent home: it finds the project's CI workflow, writes
rix-notify-factory.yml with rix init, naming the factory, and opens a PR. The PR body lists
what is left to a human: the project's RIX_FACTORY_DISPATCH_TOKEN secret, and adding the project
to the factory's tokens.
That PR adds a workflow file, so write-token needs the Workflows permission on the project
repos. The rix environment is what keeps that permission from reaching a run on any branch but
the factory's default branch (see Secrets). Without the permission, run
rix initialize <factory owner/name> in a checkout of the project repo yourself.
The skill is written to the agent home twice, under .agents/skills/ and .claude/skills/, since
Claude Code reads only the latter; pi reads only the former, and opencode reads both.
The tokens bound the factory, not the payload: RIX_FACTORY_DISPATCH_TOKEN reaches
only the factory repo, but the repo/run_id/branch values inside client_payload are
unauthenticated free text — any repo holding that token can ask the factory to act on any repo
and run, not just its own. The factory does not check the payload against a list of onboarded
repos; what limits it is what its own tokens reach. A PR can only land where write-token can
push, so scope that token to exactly the repos the factory serves. Outside that set a request gets
as far as read-token reaches, and a fine-grained PAT can read every public repo: a payload naming
a real failing run in someone else's public repo starts the agent there, and the run fails only
when it tries to open the PR. That costs agent spend and writes nothing — the trade for not keeping
a list of onboarded repos in step with the tokens that already define it.
Onboarding a repo is mutual trust: nothing in a repository_dispatch says who asked. All
project repos share one RIX_FACTORY_DISPATCH_TOKEN, so an onboarded repo can name any other
onboarded repo in client_payload[repo] along with a real failing run ID from it, and every check
downstream passes — the run exists, it failed, and its head repo matches. rix then spends the
factory's cross-repo write token on that other repo. What an attacker gets is the trigger, not the
content: rix still answers a genuine CI failure and still opens an ordinary rix/* PR. But the
timing and the target are theirs to pick, and the reachable set is exactly the repos worth
reaching. The same holds in the other direction: client_payload also supplies the concurrency
key, so an onboarded repo can name another's repo/branch and cancel a response that repo had
queued.
Two things that don't close this, despite looking like they should: github.event.sender
names the account or App that called the dispatch API, not the repo it was called from, so with
one shared token every project looks identical; and a per-project event_type is just more
payload — the same token can send any of them.
So either run one factory per trust domain, keeping the onboarded set small enough that its
members may as well trust each other (usually what an org reaching for a factory wants anyway),
or, when the set spans trust boundaries, make each project prove who it is: have it send an
HMAC of repo/run_id under a per-project secret, and have the factory recompute it using the
secret it holds for the repo the payload claims to be. That lookup is what the payload alone
cannot give — claiming to be another repo then requires that repo's secret. The cost is that the
factory now stores one secret per project, which is most of the per-repo key management
centralizing was meant to avoid; that trade is the reason to prefer the first option when the
trust domain allows it.
rix pushes commits, those commits run CI, and a failing one triggers this workflow again — so left alone, rix answering its own failures is a loop with nothing to stop it. Two things bound it, and both apply to either pattern above:
- The loop guard. Before doing any work,
on-ci-failure.ymlcounts how many commits at the tip of the failing branch rix authored itself, and leaves the failure alone once that reachesmax-rix-commits(default 5, max 100). The count stops at the first commit rix didn't write, so anyone pushing to the branch re-enables rix on it; a guarded run logs a notice, succeeds, and creates nothing. The default is 5 rather than 1 because rix fixing up its own previous attempt is the normal case — the first attempt failing is exactly why there is a second. Note it bounds commits, not attempts: one agent run can produce more than one commit, so the effective number of attempts is at most this. It is a bound on cost and noise, not a security control — the streak is counted from commit authorship, which whoever wrote those commits chose. - The
concurrencygroup, keyed on the failing branch and the repository that branch lives in, so a branch that fails twice in quick succession queues the second run rather than starting a second agent from the same tip.cancel-in-progress: falsebecause a run already talking to the agent has work worth finishing. It sits on the job rather than on the workflow, which matters more than it looks: GitHub keeps one pending entry per group and cancels whatever a newcomer displaces, andcancel-in-progressgoverns the running entry, not the queued one. At workflow scope the group is taken before anyifis looked at, so an event that does no work — a later successful rerun of the same branch — could quietly drop a queued answer to a real failure. The branch alone is enough to name the group because theif:above it has already pinned the repository. Both callers above carry a group; the factory keys its on the dispatch payload'srepoandbranchrather than onworkflow_run, since arepository_dispatchknows neither on its own.
with:
run-id: ${{ github.event.workflow_run.id }}
max-rix-commits: 3