nexus-cli
The native Rust CLI for managing Nexus workspaces locally.
nexus-cli handles project scaffolding, authentication, agentic file import, workspace management, environment preflight checks, and configuration management for multi-agent engineering workflows.
Installation
One-liner (recommended)
curl -fsSL https://nexus.gatewarden.eu/install.sh | bash
The installer detects your platform (macOS / Linux, x86_64 / aarch64), downloads the pre-built binary from GitHub Releases, and verifies its SHA-256 checksum. If no binary exists for your platform it falls back to cargo install --git.
From source
cargo install --git https://github.com/gwnexus/nexus-cli.git nexusctl
Requires Rust >= 1.85.
Pin a version
NEXUS_VERSION=v0.6.12 curl -fsSL https://nexus.gatewarden.eu/install.sh | bash
Quick start
nexus login # Authenticate with the Nexus platform
nexus init # Initialize a Nexus project workspace
nexus preflight # Verify environment readiness
nexus pull # Sync skills and agent files from the platform
Commands
| Command | Description |
|---|---|
nexus init [path] | Initialize a Nexus project workspace |
nexus login | Authenticate with the Nexus platform |
nexus logout | Remove stored credentials |
nexus status | Show auth, project, and workspace status |
nexus link [--project-id <id>] | Bind a project to the current workspace |
nexus unlink | Remove project binding from the workspace |
nexus pull [--project-id <id>] | Pull skills and config from the Nexus platform |
nexus import | Scan workspace for existing agentic files and import into linked project |
nexus skills export [--project-id <id>] | Export enabled skills as JSON |
nexus preflight | Run environment readiness checks |
nexus deinit [--force] | Remove all AI scaffold files from the workspace |
nexus config show | Display configuration |
nexus config set K=V | Update a configuration value |
nexus config path | Show the config file path |
nexus upgrade | Upgrade CLI to latest release version |
nexus run [--tool <t>] | Inject plugin env vars and launch OpenCode (or another tool) |
Global flags
| Flag | Short | Description |
|---|---|---|
--yes | -y | Non-interactive mode (auto-confirm all prompts) |
--verbose | -v | Enable verbose output |
--help | -h | Show help |
--version | -V | Show version |
nexus run
nexus run is the recommended way to launch OpenCode outside of a devbox
environment. It reads platform-managed plugin configuration from .nexus/env
and project secrets from .env.nexus.local, injects the resolved vars into
the child process environment, and exec-replaces itself with the target tool.
nexus run # inject env vars + exec opencode
nexus run --dry-run # show resolved env without launching
nexus run --show-env # print env block then launch
nexus run --no-db # skip af_export, use .nexus/env only
nexus run --tool cursor # launch a different tool
nexus run -- --model anthropic/claude-opus-4 # pass args through
Options
| Option | Default | Description |
|---|---|---|
--tool <tool> | opencode | Tool binary to launch |
--dry-run | false | Print resolved env block, do not exec |
--show-env | false | Print env block then exec |
--no-db | false | Skip af_export API call; read .nexus/env from disk only |
-- <args...> | — | Forwarded verbatim to the launched tool |
The default tool is opencode. To change it globally, set run.default_tool
in ~/.config/nexus/config.toml:
[run]
default_tool = "opencode"
Dry-run output
>> nexus run --dry-run
Project: NEXUS-APP (fdc7a78c)
Tool: opencode
Resolved env-vars (7 injected, 0 skipped — already in shell):
HEADROOM_MODE = transform [.nexus/env]
HEADROOM_DEBUG = false [.nexus/env]
HEADROOM_REQUIRE_PREFLIGHT = true [.nexus/env]
HEADROOM_ALLOW_FULL_RETRIEVAL = false [.nexus/env]
HEADROOM_RETRIEVAL_MAX_LINES = 200 [.nexus/env]
HEADROOM_RETRIEVAL_MAX_CHARS = 24000 [.nexus/env]
ANTHROPIC_API_KEY = sk-... [.env.nexus.local]
Dry run — would exec: opencode
Env resolution order
.nexus/env (1) platform plugin vars — lowest priority
.env.nexus.local (2) project secrets — overrides (1)
shell / process.env (3) already-set vars — never overwritten
Plugin environment
Nexus plugins (like nexus-headroom-intercept) run inside the OpenCode main
process and read configuration from process.env. The opencode.json MCP
server environment block only reaches MCP subprocesses — not plugins. This is
why plugin vars need a separate delivery path.
.nexus/env — platform-managed plugin vars
nexus pull and nexus init write .nexus/env from the project's
plugin_env field in the af_export API response. This field is derived from
the project agent's plugin configuration stored in the Nexus platform.
# .nexus/env — Platform-managed plugin environment variables
# Generated by: nexus pull
# DO NOT edit manually — overwritten by nexus pull / nexus init
HEADROOM_MODE=transform
HEADROOM_DEBUG=false
HEADROOM_REQUIRE_PREFLIGHT=true
HEADROOM_ALLOW_FULL_RETRIEVAL=false
HEADROOM_RETRIEVAL_MAX_LINES=200
HEADROOM_RETRIEVAL_MAX_CHARS=24000
The file is git-ignored (.nexus/.gitignore contains env). It contains
only non-sensitive, platform-configured values — never secrets.
Delivery paths by environment
| Environment | How plugin vars reach OpenCode |
|---|---|
nexus run | Injected directly into child process before exec |
| devbox shell | dbx_init.sh sources .nexus/env on devbox shell start |
| Manual | source .nexus/env in shell profile or before invoking opencode |
Updating plugin configuration
Plugin settings are managed in the Nexus dashboard under
Project > Agent Setup > Plugins. After saving changes, run nexus pull
to regenerate .nexus/env and then restart OpenCode (or use nexus run).
When to use nexus run vs devbox
| Scenario | Recommended approach |
|---|---|
| Daily development with a full Nexus workspace | devbox shell — init hook sources .nexus/env automatically |
| CI / scripted environments without Devbox | nexus run — zero dependencies beyond the CLI binary |
| Quickly launching OpenCode outside devbox | nexus run — single command, no shell restart needed |
| Running a different tool (Cursor, Claude Code, ...) | nexus run --tool cursor |
| Debugging which env vars will be injected | nexus run --dry-run |
| Laptop with no network access (offline) | nexus run --no-db — reads .nexus/env from disk, skips af_export |
Offline mode
When .nexus/env already exists on disk (written by a previous nexus pull),
nexus run --no-db works without any network connection. The af_export API
call is skipped and the cached env file is used as-is:
nexus run --no-db # use .nexus/env from disk, skip platform API
This is safe for short offline periods. Run nexus pull the next time you have
connectivity to refresh plugin configuration.
.nexus/env vs .env.nexus.local
Users familiar with dotenv conventions sometimes confuse these two files:
| File | Owner | Content | Git-tracked |
|---|---|---|---|
.nexus/env | Platform — written by nexus pull | Non-sensitive plugin config (HEADROOM_*, etc.) | No (env in .nexus/.gitignore) |
.env.nexus.local | Developer — maintained manually | Project secrets (ANTHROPIC_API_KEY, etc.) | No (.env.nexus.local in .gitignore) |
Rule of thumb: never put secrets in .nexus/env and never put plugin
config in .env.nexus.local. The files serve different purposes and have
different owners.
Troubleshooting
Plugin runs in observe mode instead of transform
The plugin defaults to observe when the preflight check fails or
HEADROOM_MODE is not set. Diagnose with:
nexus run --dry-run # check HEADROOM_MODE value and source
If HEADROOM_MODE shows observe in the dry-run output, run nexus pull to
refresh .nexus/env from the platform. If the variable is missing entirely,
check Project > Agent Setup > Plugins in the dashboard and confirm Headroom
is enabled.
If HEADROOM_MODE shows transform in the dry-run but observe in practice,
check the plugin log:
HEADROOM_DEBUG=true nexus run # writes .nexus/headroom-intercept.jsonl
nexus run exits with "tool not found"
The tool binary (opencode by default) must be on $PATH. Install OpenCode
globally or specify the full path:
nexus run --tool /usr/local/bin/opencode
Preflight checks
nexus preflight validates the local environment is ready for Nexus:
| Check | What it verifies |
|---|---|
| Git | git is installed and accessible |
| Node.js | node >= 18 available |
| npm | npm available |
| npx | npx available |
| Config | Nexus config file exists (~/.config/nexus/) |
| Credentials | Valid nxs_pat_* token stored |
| API | Nexus API reachable and token valid |
| Workspace | .nexus/ workspace marker present |
| MCP | Agent MCP configurations reference nexus-mcp |
Import workflow
nexus import scans the current workspace for pre-existing agentic configuration files and imports them into the linked Nexus project. This is the recommended way to onboard existing projects alongside the platform-managed workflow.
Detected files: CLAUDE.md, AGENTS.md, .cursorrules, copilot-instructions.md, .windsurf/rules/*.md, GEMINI.md
What happens:
- Detected agentic files are ingested as unclassified items for review and promotion
- Directive-like sections (rules, guidelines, conventions) are extracted and created as disabled project directives
- Markdown links to local documents (e.g.
docs/*.md) are resolved and ingested as referenced documents - Exported agent files (
.nexus/CLAUDE.md,.nexus/AGENTS.md) automatically include a cross-reference block pointing to the original customer files
During nexus init, the CLI automatically detects existing agentic files and offers to run the import.
Workspace cache
The CLI creates a .nexus/ directory in your project root to store workspace metadata, project bindings, and cached configuration. This directory is automatically excluded from Git via .git/info/exclude (not .gitignore) to avoid polluting the shared ignore file. The nexus deinit command cleans up both the cache directory and the exclude entries.
Local agent file changes are overwritten by nexus pull. Files managed by the Nexus platform (AGENTS.md, CLAUDE.md, .cursorrules, plugin configs, etc.) are pulled from the server and will overwrite local modifications. Edit agent files in the Nexus dashboard and run nexus pull to sync.
Cost control tools
nexus pull automatically configures two token-saving tools when enabled for a project:
RTK — Runtime Token Killer
Filters and compresses CLI output before it reaches the agent context (60-90% savings on build/test/lint output).
# Install the RTK binary
# See: https://www.rtk-ai.app/#install
# Install the OpenCode plugin (once per machine)
rtk init -g --opencode
# After nexus pull, trust project filters
rtk trust
The .rtk/filters.toml file is auto-generated from the project's codebase character presets (configured in the Nexus dashboard under Project > Plugins) and synced on every nexus pull.
Headroom — Context Compression Plugin
Policy-based context compression via the nexus-headroom-intercept OpenCode
plugin and the Headroom MCP server. Reduces token consumption by 60–95% on
large tool responses.
pip install "headroom-ai[mcp]"
headroom --version # verify install
After nexus pull:
opencode.jsonis updated with thenexus-headroomMCP server block.nexus/envis written with the project'sHEADROOM_*configuration
Use nexus run to launch OpenCode with the plugin vars in scope, or let
devbox shell source them automatically via dbx_init.sh.
See Plugins — nexus-headroom-intercept for the full plugin reference including env vars, compression profiles, and retrieval semantics.