cmdop mode
cmdop runs in one of two modes — prod (against the production cluster) or dev (against a developer cluster). Each mode has its own token file, its own active workspace, and its own endpoint base.
Show the current mode
cmdop modemode: prod
endpoint: api.cmdop.com
token: ~/.cmdop/token_prod.json
workspace: acme-prodSwitch mode
cmdop mode dev # explicit
cmdop mode prod
cmdop mode toggle # flip between the twoSwitching mode reloads the daemon — the local SDK socket stays up but the relay reconnects against the new endpoint with the new token.
Why per-mode tokens
| Mode | Token file | Endpoint base | Typical use |
|---|---|---|---|
prod | ~/.cmdop/token_prod.json | api.cmdop.com | Daily operations |
dev | ~/.cmdop/token_dev.json | api-dev.cmdop.com | Internal testing, dogfood builds |
Keeping tokens separate prevents accidentally hitting prod with dev credentials (or vice versa). Both tokens are workspace-scoped at issue time.
Switching mode does not re-prompt for OAuth if both tokens already exist. If only one exists, you’ll be prompted to log in for the other. Tokens auto-refresh in the background ~5 minutes before expiry.
Effects of a mode switch
When you flip mode:
- The daemon is asked to reload (
cmdop agent restarthappens implicitly). - The local SDK socket stays up — clients reconnect to the same socket, no client restart needed.
- The relay disconnects and reconnects against the new endpoint with the new token.
- The active workspace switches to whatever was last active in the destination mode.
cmdop machines,cmdop connect, and pickers now show machines from the destination workspace.
Inline override
For one-off commands without flipping global state:
cmdop --mode=dev machines
cmdop --mode=dev connect exec dev-vps-1 -- whoamiMode in scripts
Switching mode mid-script is reliable:
cmdop mode prod
cmdop connect exec prod-server -- ./deploy.sh
cmdop mode dev
cmdop connect exec dev-vps-1 -- ./smoke.shOr pass --mode=... per call to avoid touching shared state.
Troubleshooting
- “Token not found for mode dev” —
cmdop mode dev, thencmdop login. - Wrong workspace after switch — each mode tracks its own active workspace; use
cmdop connect workspace use <ws>after switching. - Endpoint unreachable in dev — confirm VPN / network access to
api-dev.cmdop.com.