Headless & CI
When a person runs the CLI, they use 4rged login on a laptop — browser sign-in, then commands
from a repo. When a pipeline runs the CLI, there is no browser: the job uses a User API key
stored as a CI secret, installs the CLI, runs the agent, and passes or fails the build from
the result.
That second pattern is headless — the same X4RGE agents and org rules as desktop, but built for GitHub Actions, GitLab CI, cron, and internal bots.
This page is for teams wiring the CLI into automation. For a first install on your machine, see Installation. For when to use the CLI at all, see CLI overview.
What this page is for
Automation uses your organization's model control and usage. Denied models and budget stops fail the job — same as for a developer on a laptop.
Who this page is for
You do not need to be an org admin to run headless on a single repo — you need a key, a secret, and access to the project.
Understand headless at a glance
First time wiring CI — typical order:
- Create API key (dashboard)
- Save as CI secret (never in git)
- Add job steps: install CLI (pinned) → whoami → agent run
- Optional wait step for long or cloud runs
- Fail the job on error; store JSON summary if useful
- Ask admin to link repo on the project if policy errors appear
Command flags change over time — 4rged.ai/cli/install has the current reference. This page explains concepts that stay stable.
Headless vs interactive login
API keys belong in GitHub Secrets, GitLab protected variables, or a vault — never in the repository, workflow files, or log output.
Headless vs cloud automations
Both can run agents without a person watching — choose by who owns the trigger:
Many teams use CLI in CI for PR checks and cloud automations for ongoing monitors — not either/or.
Choose local vs cloud in CI
Same CLI command — different where the work runs:
Why headless matters
How headless fits together
How automation works
One-line flow: install → verify key → agent run → (wait) → pass or fail.
Set up for CI
Create a User API key
Dashboard → Integrations → User API keys. If missing, an org admin enables keys in Settings.
Store as a CI secret
Name it clearly (e.g.
X4RGE_API_KEY). Map into the job environment. Never log the value.Install pinned CLI in the job
Same installer as Installation, with a fixed version — see Pin the CLI version.
Verify before heavy runs
Run
4rged whoami(or JSON variant) so bad keys fail in seconds, not after a long agent run.Run with project + clear prompt
Use your project slug when the org scopes repos. Write a prompt the job can repeat safely (review rules, doc sync scope, etc.).
A dedicated automation user (not a personal developer key) simplifies rotation and audit when someone leaves the team.
Typical pipeline flow
Same shape for GitHub Actions, GitLab, Jenkins, or other CI:
Checkout
Clone the repo the agent should read or modify.
Install CLI
Pinned version your platform team approved.
Authenticate
Inject secret; confirm org with
whoami.Run agent
Focused prompt; project + json output when scripts parse the result.
Wait (if needed)
Local runs may finish inline; cloud or long runs need poll/wait by run ID with a timeout.
Gate
Non-zero exit fails the pipeline; optional artifact or PR comment from JSON summary.
Full provider YAML samples live in hidden operator notes and on the install page — adapt steps above to your provider's syntax.
What success looks like
A healthy pipeline fails loudly on policy problems so bad merges do not slip through.
Pin the CLI version
Pick a version your org tested; bump it in one test pipeline before company-wide rollout. Version env details are on the install page and in operator notes below.
Rules that still apply
Check Dashboard → Usage for denial hints; confirm repos on the project.
For org admins
Before enabling CI for many teams:
In practice
Fix CI issues
Fails on first step (auth)
Wrong secret name, revoked key, or keys disabled in Settings — recreate and update CI.
whoami OK but agent denied
Model not allowed, budget stop, or missing project access for key user.
Repo / project error
Link repo on project; verify project slug matches GitHub integration.
Job hangs
Add timeout on wait; use cloud for long runs.
Flaky without code changes
Unpinned CLI upgraded — pin version and retest.
Key person left company
Rotate API key; update CI secret; revoke old key in Integrations.
Still stuck
Troubleshooting or org admin.