Naming resources
Every command that acts on something (a workflow, script, run, trigger, vault, server or key) takes either its name or its id.
- Names are matched without regard to case.
sagex show workflow deployfinds “Deploy”. - Script names include their extension:
deploy.sh,migrate.py. - Runs are usually named by id, and the first few characters are enough:
sagex show run 46a2. - If a name matches more than one thing, SageCode lists the matches with their ids so you can pick. For a server or key whose name exists in more than one vault, add
--vault.
Your workspace
SageCode keeps local files in one folder, your workspace. It's the current directory unless you choose one, and it's a good thing to keep in git.
| Folder | What's in it |
|---|---|
workflows/ | Workflow JSON, from new, copy or for push |
scripts/ | Script files, from new, copy or for push |
logs/script/<id>/ | Saved by run script |
logs/workflow/<run id>/ | Run metadata and logs: saved by run workflow, rerun, watch, trigger fire and trigger watch, and by copy run |
Commands that read a local file accept a path, or just a name inside the matching folder: sagex push script deploy finds scripts/deploy.sh. Relative paths always start from the workspace, never the folder you're in, so it doesn't matter where you run a command. Once you've set a workspace, the terminal app opens there too.
Output and exit codes
- Tables by default, JSON on request. Every
listand mostshowcommands take--json, ready forjq. - Script output on stdout, everything else on stderr. During a live run, SageCode's own progress lines go to stderr, so
sagex run script report.sh -s web-1 > report.txtcaptures only what the script printed. - Exit codes you can build on.
run scriptexits with the script's own exit code.run workflowexits 0 when the run succeeds, 1 when it fails, and 130 when you cancel it or detach.
During a live run, Ctrl+C stops it. Press it again to detach: the run carries on, and sagex show run <id> checks on it later.
Run a script on a server
Pick a script and a server from your vault. SageCode streams the output live, line by line, and saves a copy of the logs in your workspace.
- A script's inputs are its
{{NAME}}markers. Each value comes from--param, else the script's saved default, else a prompt. - Secret inputs are always asked for at a hidden prompt, never taken as a flag.
- SageCode connects with the key attached to the server. Use
--keyto pick a different key from the same vault. - Add
--no-logto skip saving the logs locally.
Build a workflow from files
Scaffold a workflow, fill it in with the snippets SageCode gives you, preview it, then push it to the server.
- The new file explains every field in a
_docblock, which is never sent to the server. - The first push creates the workflow and writes its id back into the file. Later pushes update it, after asking.
sagex syntaxprints snippets fortrigger,script,email,decision,edgeanddecision-edge.- If the file's id is stale (say, the workflow was deleted),
push workflow --newcreates a fresh one.
Scripts work the same way: sagex new script disk_check --lang shell, then sagex push script disk_check. When you update a script, SageCode shows a diff of the server copy against yours before asking.
Expose a webhook
An HTTP trigger gives a workflow a URL that other systems can call. SageCode creates it, shows you how to call it, and can call it exactly as an outside caller would.
The secret is shown once. Store it straight away, in your CI provider's secrets for example. Lost it? sagex trigger regenerate Deploy issues a new one at the same URL, and the old one stops working.
Every call needs two headers: X-Trigger-Secret and a unique Idempotency-Key. Repeating a key returns the run it started instead of starting another, so retries are safe. Parameter values go in inputs, keyed by parameter id (shown in sagex show workflow Deploy --json):
Schedule a job
- Cron expressions have five fields and run in UTC. After saving, SageCode shows the next runs in UTC and your local time.
- Scheduled runs have nobody to ask for input, so every parameter needs a saved value. SageCode warns you if one doesn't have one.
- A firing is skipped if the previous scheduled run of the same workflow is still going.
trigger watchtells you when that happens. sagex trigger disable Backuppauses a schedule without deleting it;enableresumes it.
Unlike classic cron, a day of the month and a day of the week in the same expression must both match: 0 9 1 * 5 runs only on a Friday that's also the 1st. SageCode words its description to match.
Run from CI
In a pipeline, give SageCode its key through SAGEX_API_KEY and run a workflow. The job's exit code follows the run, so a failed deploy fails the build. Here's a GitHub Actions step:
- A pipeline can't answer prompts, so every parameter needs a value, either saved in the workflow or passed with
--param. - Secret parameters must be saved in the workflow. SageCode won't take a secret as a flag, even in CI.
- Prefer not to install anything? Call the workflow's webhook with
curl, using your commit SHA as the Idempotency-Key.
Manage the vault
Vaults hold the servers your scripts run on and the keys that log in to them.
- Key types are
username_password,ssh_keyandcertificate. Passwords and passphrases are typed at hidden prompts; SSH keys and certificates come from a file you point to, or-to paste. - Servers connect over
ssh(port 22 by default) orwinrm(5985). sagex show key deploy-keykeeps the secret hidden. Add--revealto see it, after confirming.- Deleting a vault deletes everything in it, so SageCode asks you to type the vault's name first.
Runs: look back, follow, repeat
watch works for a run started anywhere (the web app, a trigger, Sage); Ctrl+C stops watching and leaves the run going. rerun asks again for any secrets the earlier run was given, since Autosage keeps them only masked. Run logs are kept for 90 days. copy run --since takes 1day, 7days, 1month or all.
The terminal app
Run sagex with no arguments to open the full-screen app. Your resources are on the left; the right side is a terminal-style transcript.
- Start a line with
!to run a command, such as!sagex run workflow Deployor!git status. Workflow runs draw a live graph as they go. - F3 switches the left panel between your server resources and your local workspace, where you can also change the workspace folder.
- F2 switches the shell your commands run in. On Windows it cycles PowerShell, cmd and WSL; elsewhere bash and sh.
- Esc stops the running command, ↑ ↓ recall earlier ones, F5 refreshes and Ctrl Q quits.
- Anything you type without
!goes to Sage.
Ask Sage
Sage is your Autosage assistant, built into the terminal app. Type a question without ! and the answer streams into the transcript. Esc stops it.
- Ask about what you just ran. Your next question carries the end of the last
!command's output (obvious secrets masked), so "why did that fail?" just works. - It looks things up itself. Sage runs read-only commands like
list,showandrender, and reads any command's help. Each call shows as a card with the exact command and its output; click a finished card to expand it. - It asks before changing anything. Runs, creates, updates, deletes and pushes show as an approval card: a one-line description and the exact command. Press y to run it once, a to allow that command on that resource for the rest of the session, or n to decline. Deletes always ask.
- Files and shell, with your approval. Sage reads, writes and edits files in your workspace (it shows the new file or a diff first) and runs shell commands in your current shell. It never touches files outside the workspace or ones that usually hold secrets, like
.env, keys or.ssh.
| Type | To |
|---|---|
/permissions | See what you've allowed for this session; /permissions revoke <n> or revoke all takes it back |
/sessions | List your saved conversations; /sessions <n> reopens one, /sessions delete <n> deletes it |
/new | Start a fresh conversation |
/model | List your models and switch: /model <n or name>, or /model free |
/usage | Requests and tokens today, over 7 days and all time, with models and devices |
Conversations are saved as you go, and your latest 100 are kept. Long tool output and file contents are trimmed before saving, so your files' contents aren't stored. The "Sage Today" block at the bottom of the left panel shows today's requests and tokens, the model in use and the free requests left.
Sage can never sign in, create or change vault keys or model keys, read a secret, or use --reveal. It can't type into prompts either: a run that needs a password typed at a hidden prompt is handed back to you to run with !.
Use your own model
Sage answers with Autosage's free models, which share a daily allowance with Autobot on the web. To use a model with your own provider API key instead, add it and select it:
- Providers:
gemini,groq,openrouter,anthropic,openai,azure_openai(add--api-version),nvidia_nimandcustom(any LiteLLM-compatible endpoint, with--base-url). - The API key is typed at a hidden prompt, or read from a file with
--key-file. Never as a flag. It's stored encrypted on Autosage and never shown again. Inside the terminal app, use--key-file, since!commands can't show a hidden prompt. sagex use model <name>switches, andsagex use model --freegoes back to the free models.list,show,update(--new-keyreplaces the key),renameanddelete modelmanage them.- These are the same models as Autobot's Customize panel on the web, and the choice applies to both.