Command Reference
Every command, flag, and mode in the sudoji CLI.
@sudoji/cli (npm-installed). The macOS/Windows agent is a separate, smaller binary with a different command set — see Command differences for what it does and doesn't support.Agent modes
Every sudoji ask and sudoji do call runs in one of three modes, controlled by --mode. The mode determines what tools the AI can call and whether any commands are executed on your server.
diagnose to understand the problem, then switch to fix once you know what needs to change. The agent in fix mode will still diagnose first before touching anything.Commands
[options]Authenticate the CLI with a Sudoji API key. The key is stored in your OS keychain (macOS Keychain, GNOME Keyring) or in an encrypted file at ~/.sudoji/credentials on headless servers.
sudoji loginsudoji login --paste sudoji_sk_your_key_here
# Force file-based storage (no keychain)
SUDOJI_NO_KEYCHAIN=1 sudoji login[options]Remove stored credentials for a profile.
sudoji logout
sudoji logout --profile staging[options]Show which profile is currently logged in and a masked preview of the stored key. Useful for confirming which account a machine is authenticated as before running anything.
sudoji whoami profile default
token sudoji_sk_a1b2c3d4…Run a self-check: verifies API key is stored, loads settings, confirms agent.sudoji.io is reachable, and tests that secret redaction is active. Run this after install or after any credential change.
sudoji doctor ✓ API key stored sudoji_sk_a1b2c3…
✓ Settings loaded apiBaseUrl: https://agent.sudoji.io
✓ API reachable https://agent.sudoji.io/healthz → HTTP 200
✓ Redaction active "password=super$ecret…" → "password=[REDACTED]…"
All checks passed.<question> [options]Ask the agent a question about your server. The agent automatically gathers context (OS, Node version, git status, recent logs) and streams the answer to your terminal. The default mode is diagnose — read-only analysis with no command execution.
sudoji ask "why is nginx returning 502 after my last deploy?"sudoji ask --mode suggest "how do I free up disk space on this server?"sudoji ask --mode fix "restart nginx and verify it comes back healthy"sudoji ask --no-context "what does exit code 137 mean?"search the web for … (or "look this up online", "google it") and it will — this works in sudoji ask, sudoji chat, and portal-forwarded daemon sessions alike, not just the web chat.<instruction> [options]Shorthand for sudoji ask --mode fix. The agent reads your server state and executes approved commands to complete the task. Each run_command call shows the exact command and prompts [y/N] before running.
sudoji do "update all system packages"sudoji do "check disk space and find the top 5 largest directories"sudoji do "restart nginx and confirm it is serving traffic"sudoji do "find out why pm2 api is crashing and fix it"[options]Start a persistent, multi-turn conversation with the agent directly in your terminal. Unlike sudoji ask (which is one-shot), chat keeps full conversation history across turns — the agent remembers what it read and what it found earlier in the same session. Every session is automatically assigned a generated name (e.g. 'Brave Falcon') and saved as a thread in your Sudoji portal. You can rename threads from the portal by clicking the title.
sudoji chat
sudoji › I want to add swap space to this server, plan it out for me
[agent analyses memory, suggests steps…]
sudoji › how much swap do you recommend given 2 GB RAM?
› For a 2 GB server I'd recommend 2 GB swap. Here's what I'd run…
sudoji › exitsudoji chat --mode fix
sudoji › add 2 GB of swap
allow? run fallocate -l 2G /swapfile [y/N] y
✓ Done.sudoji chat session creates a conversation thread visible in your portal under Sessions → Chat tab. If the daemon is running on your server, you can also continue the conversation from the portal web UI — messages you send from the browser are forwarded to the agent on the server in real time.[options]Start the always-on daemon — a persistent WebSocket connection between your server and the Sudoji cloud hub. While the daemon is running, messages sent from the web portal are forwarded to the agent on your server and streamed back to the portal in real time. The daemon also keeps the server listed as online in the portal.
sudoji daemon# Install pm2 if not already installed
sudo npm install -g pm2
# --interpreter none matters — otherwise pm2 tries to run the file
# through Node itself instead of letting the shebang handle that
pm2 start $(which sudoji) --name sudoji-daemon --interpreter none -- daemon
pm2 save
# Register pm2 as a system service (run the printed command)
pm2 startup# /etc/systemd/system/sudoji-daemon.service
[Unit]
Description=Sudoji Daemon
After=network.target
[Service]
ExecStart=/usr/bin/sudoji daemon
Restart=always
RestartSec=5
User=ubuntu
Environment=SUDOJI_NO_KEYCHAIN=1
[Install]
WantedBy=multi-user.target[text] [options]View, set, or auto-build persistent server context. Whatever you set here is included in the system prompt of every sudoji ask and sudoji do request, so the agent always knows what kind of server it is talking to without you having to repeat it each time.
sudoji context --buildsudoji context "Ubuntu 22.04 LTS. nginx 1.24 + Node 20 + PM2. Production web server for api.example.com. No Docker."sudoji contextsudoji context --clearsudoji context --build once after installing on a new server — it auto-discovers OS, runtimes, and running services (including pm2 processes) with no typing required. Prefer to write it by hand if you want to add detail the auto-discovery can't see, like which environment (production/staging) or specific constraints.[options]Fetch recent log output from systemd, pm2, or a file, redact secrets, and send it to the agent for analysis. Equivalent to manually copying logs into sudoji ask but faster.
sudoji logs --source systemd --unit nginx
sudoji logs --source systemd --unit postgres --since "2 hours ago"sudoji logs --source pm2 --unit api --tail 200sudoji logs --source file --file /var/log/app/error.log --tail 50sudoji logs --source pm2 --unit api --ask "did this crash from an out-of-memory error?"<name> [options]Run a built-in Sudoji tool directly against this device, without writing out a natural-language request. This is the same underlying mechanism the portal's '+ run tool' chat menu uses — CLI, chat, and portal all funnel into the same tool call.
sudoji tool knowmesudoji tool exportconfigknowme is read-only and runs without a prompt. exportconfig writes a manifest file to disk on the server — installed packages, pm2/nginx/systemd config, cron, firewall rules, and .env variable names only, never values — so it requires a one-time [y/N] approval since it performs a write, unlike the read-only tools above. Copy the resulting file off the server (e.g. scp) before decommissioning it.<subcommand>Placeholder subcommands that point you to the dashboard for API key management — list, create, and revoke each print a link to https://sudoji.io/dashboard/settings and exit. Full key management from the CLI is planned for a future release; for now this isn't scriptable.
sudoji keys listsudoji keys createsudoji keys revoke <key-id>Tool execution loop
In fix mode (sudoji do), the agent runs a multi-round loop. Each round the AI decides which tool to call next, the CLI executes it locally, and the result is sent back to continue reasoning.
In the terminal, an approval prompt looks like this:
🦚 sudoji ────────────────────────────────────────
I'll check disk usage first, then identify the largest directories.
▶ run df -h
allow? [y/N] y
✓
│ Filesystem Size Used Avail Use% Mounted on
│ /dev/sda1 50G 43G 7.0G 86% /
▶ run du -sh /* 2>/dev/null | sort -rh | head -5
allow? [y/N] y
✓
│ 18G /var
│ 12G /usr
│ 8G /home
...
──────────────────────────────────────────────────Conversation threads
sudoji chat and the daemon both operate on conversation threads — persistent records of a multi-turn agent session. Each thread stores the full message history, which tools were called, and the total token cost. Threads are tied to a server and visible in your portal.
Permission policy
You can pre-approve or pre-deny specific commands so you don't get prompted every time. Policy rules live in ~/.sudoji/settings.json and use a Tool(matcher) syntax.
{
"permissions": {
"allow": [
"Bash(df:*)",
"Bash(du:*)",
"Bash(systemctl status:*)",
"Bash(journalctl:*)",
"Bash(npm install:*)"
],
"ask": [
"Bash(apt:*)",
"Bash(systemctl restart:*)"
],
"deny": [
"Bash(rm -rf /)",
"Bash(dd:*)"
]
}
}/etc/sudoji/managed.json) cannot be removed by user-level config.