Skip to main content

X4 CLI Command Reference

The x4 CLI is implemented in src/cli.ts. The current top-level commands are:

CommandPurpose
x4 doctorValidate local, host, devbox, worker, control, and agent prerequisites.
x4 registryGenerate starter registry files and validate registry files.
x4 bootstrapCompatibility alias for workspace bootstrap.
x4 statusShow workspace status.
x4 cleanupClean generated worktrees, branches, and artifacts.
x4 testRun registry test commands per repo.
x4 envValidate and install env bundle contracts.
x4 codexCodex integration aliases.
x4 workspaceWorkspace bootstrap, status, test, commit, cleanup.
x4 agentsAgent integration helpers.
x4 branchMulti-repo branch helpers.
x4 featureFeature naming and branch rename helpers.
x4 learnLearning log helpers.
x4 aiAI provider checks, sandbox planning prompts, and reviewed sandbox profile generation.
x4 sandboxSandbox startup, wait, status, logs, down, destroy, and host-level clear.
x4 previewTailnet-only preview preparation and serve routes.
x4 prPR plan/create/comment/check-run helpers.
x4 workflowEnd-to-end PR and smoke workflows.
x4 issueLinked issue creation and evidence comments.
x4 infraInfrastructure plan output.
x4 remoteRemote execution plan and direct remote tests.
x4 controlControl-plane leases, workers, submissions, GC, and tests.
x4 githubGitHub App validation, poller, and /x4 command execution.
x4 changelogDeployed changelog registry, artifact, backfill, review, polish, and workflow helpers.
x4 orchestrationRepo-local orchestration policy helpers.

Help​

Every command supports --help:

x4 --help
x4 workspace --help
x4 control submit test --help

Common Options​

OptionUsed byMeaning
--entry <path>Most workspace commandsWorkspace entry repo path.
--registry <path>Registry/workspace commandsOverride registry file.
--repo-set <id>Bootstrap/poller commandsSelect a repo set.
--install <mode>Bootstrap/remote/control commandseager or skip.
--git-auth <mode>Bootstrap/remote commandsnone or app.
--github-app-env <path>GitHub commandsGitHub App credential env file.
--dry-runMutating workflowsPrint intended actions without applying.
--executeRemote/GitHub workflowsPerform the planned mutation.

Registry Generation​

Generate a starter registry from local Git checkouts:

x4 registry init \
--repo ~/dev/repos/app \
--repo ~/dev/repos/api \
--repo-set current-work \
--output ~/dev/x4/current-work.registry.yaml \
--install skip

The generated file is a reviewable starting point. It infers repo ids, remotes, default branches, package-manager setup commands, basic test commands, env allowlists, an env bundle placeholder, and a metadata-only sandbox profile.

Safety Defaults​

  • Mutating GitHub and remote-control commands usually default to dry-run or planning mode.
  • Preview comments refuse local-only URLs.
  • Cleanup dry-run is recommended before force cleanup.
  • Env commands validate key names without printing secret values.
  • x4 sandbox clear requires --all and either --dry-run or --force; it only targets X4-labeled sandbox resources.
  • x4 sandbox status reconciles saved service-sandbox state against X4-labeled Docker containers before showing preview links as live.
  • x4 sandbox run "<goal>" is the preferred interactive sandbox path: it writes a harness goal under .x4/ai/runs/, asks the selected AI engine to propose a sandbox profile for the current workspace goal, validates the profile, and only then runs deterministic sandbox startup. If startup fails, it retries with AI repair feedback up to --ai-attempts times, defaulting to 3.
  • x4 sandbox up --ai is the lower-level experimental shortcut when a script already knows the exact profile to prepare before startup.
  • Use AI only where discovery is the hard part, such as inferring sandbox service commands, ports, routes, and health paths. Keep workspace creation, registry validation, env filtering, cleanup, and PR operations deterministic.