Deploy from a coding agent
An agent that can run shell commands can deploy to Tori with the published Tori CLI. Open the agent in your project and make Node.js 20 or newer available in its shell.
Sign in
Section titled “Sign in”Install the published CLI from a trusted directory outside the project, using a dedicated prefix outside the project. For example, from your home directory on macOS or Linux:
npm install --global --prefix "$HOME/.local/tori-cli" --registry https://registry.npmjs.org tori.hostUse the absolute path to the installed executable for all Tori commands. In the example, replace /absolute/path/to/tori below with the expanded path to $HOME/.local/tori-cli/bin/tori. Give that path to the agent before it runs the prompt. Keep the project directory as the working directory where instructed. This keeps npm from selecting a project-local package when Tori credentials are available.
Before running whoami, login, or any other authenticated Tori command, confirm the API endpoint. In the shell that will run the command, the CLI uses a nonempty TORI_API_URL, then the saved apiUrl in ~/.config/tori/config.json, then https://api.tori.host. Read only the apiUrl field from that file. Use only a valid HTTPS endpoint without embedded credentials, a query string, or a fragment. Stop before making any request if it fails that check. Remove trailing slashes from the base URL before confirming it and comparing it with the default. Set TORI_API_URL to the confirmed URL for all commands below, including any sign-in you run in your own terminal. Confirm that the credential belongs to the approved endpoint before sending it. If the confirmed endpoint differs from https://api.tori.host, use an endpoint-specific token explicitly supplied through TORI_TOKEN. The CLI chooses the token independently of the endpoint and can otherwise reuse a saved login from another environment. A saved browser login for https://api.tori.host can be used there even if TORI_API_URL explicitly pins that URL. If you cannot confirm that a token belongs to the selected endpoint, stop and have the user configure the correct token securely before continuing.
For a custom API endpoint, use one of the token setups below with a credential issued by that endpoint. Use browser sign-in only for the public default endpoint in this workflow.
Choose the setup that matches your environment.
- Interactive sign-in on
https://api.tori.host. UnsetTORI_TOKENin the shell that runs the agent and in any terminal used for browser sign-in, so the CLI uses the saved browser login. Run/absolute/path/to/tori loginon the confirmed public endpoint and approve the request in your browser before running/absolute/path/to/tori whoamiin the agent’s environment. This replaces any saved login from a different endpoint before an authenticated command can reuse it. On a remote machine, use the link and code the CLI prints. - A deploy token for an existing app. Deploy once interactively, keep the resulting
tori.json, then set a deploy token for that app throughTORI_TOKEN. Skipwhoamiandloginin this environment. The token can deploy only the app intori.json. - A trusted sandbox that must create the app. Provide a whole-account token through
TORI_TOKENand check it with/absolute/path/to/tori whoami. If the API refuses a token, replace or unset it before using a saved sign-in.
Ask for a deploy
Section titled “Ask for a deploy”For a first static deploy, use a fresh project directory without a tori.json in the root or in site/. Put your public files, including index.html, in a site/ subdirectory. Open the project directory in your agent and paste:
Use the absolute path to the published Tori CLI I installed outside this project. Replace /absolute/path/to/tori with that path for all Tori commands, including any recovery commands printed by the CLI. If the path is unknown, ask me before proceeding.
Before making any Tori request, determine the API endpoint in the shell that will run the deploy: use nonempty TORI_API_URL, otherwise the apiUrl field in ~/.config/tori/config.json, otherwise https://api.tori.host. Read only the apiUrl field from the config and never print tokens. Stop without printing the value if it is not an HTTPS URL or it contains credentials, a query string, or a fragment. Remove trailing slashes from the base URL before comparing it with the default. Show me the resulting endpoint and wait for confirmation. Use that confirmed endpoint as TORI_API_URL for every Tori command in this workflow.
Before any authenticated request, confirm that the credential is intended for that endpoint. If the confirmed endpoint differs from https://api.tori.host, require a token specifically issued for that endpoint in TORI_TOKEN. Do not use an inherited token of unknown origin or fall back to a saved login for a non-default endpoint. A saved browser login for https://api.tori.host is valid there even when TORI_API_URL explicitly pins that same URL. If the correct credential is unavailable, stop and ask me to configure it securely without pasting it into the conversation.
Check for tori.json in the project root and in ./site. If either exists, parse every existing file as JSON and require a valid, nonempty string slug. If a file cannot be read or parsed or its binding is invalid, stop before deploying. Read the app slug and wait for my explicit confirmation of the target slug and API endpoint together before updating it. If the files disagree or the slug is missing, stop and explain. If neither file exists, run `/absolute/path/to/tori whoami`, show me the account email and API endpoint together, and wait for my confirmation before creating an app. If the account cannot be verified, stop and explain. Before creating an app, check that the CLI can write tori.json in the project root. If the check fails, stop before deploying. Check that ./site contains index.html and only files intended for public access. If it is missing or contains secrets, server source, or other private files, stop and explain.
For an update, choose an exact public file URL or a unique revision marker already present in the new output. Before deploying, record what the existing site serves at that URL. Use it as evidence only if the pre-deploy response is known to differ from the expected new response.
Then deploy with `/absolute/path/to/tori deploy --static ./site -v`. Keep the deploy ID from the verbose output. If monitoring is interrupted after Tori accepts the deploy, use the saved ID with deploy status or deploy watch from the app binding directory.
If upload acceptance is unclear and the CLI has no usable deploy ID, report the outcome as unknown even if it suggests a retry. This includes a lost connection, a gateway timeout, or an unreadable success response. Check the bound app’s deploy history on the confirmed control plane and do not retry until you establish whether this attempt was accepted. If you still cannot identify the attempt, leave its outcome unknown.
If the app-creation result is unknown on a first deploy, including when writing tori.json fails after creation or when creation fails before upload without a binding or deploy ID, do not retry. Follow https://docs.tori.host/guides/deploys/#recovering-a-first-deploy on the confirmed endpoint. If the app was created, restore its slug in the correct tori.json before resuming. If the outcome remains unknown, stop.
If the CLI stops waiting while the deploy is still in progress, report it as pending. Use the printed deploy watch or deploy status command from the directory containing the tori.json that the CLI used or created for this app (the output directory or project root) and read the state for the exact deploy ID. Use the reported state rather than the command exit code: keep a building or starting deploy pending, report cancellation as cancelled, and continue to the live check only once this attempt is live.
If the deploy fails, report the exact deploy error. If Tori reports that a newer deploy superseded this attempt, report that outcome and include the URL only if Tori printed one. Any check of that URL describes the currently served page, so do not mark this attempt verified even if the page matches. Otherwise, if the deploy succeeds, report the URL printed by Tori and separately report whether the live check passed.
Fetch the URL, require a successful HTTP status (2xx), and compare the response body with ./site/index.html. For an update, also fetch the exact file or marker checked before the deploy, require a 2xx response, and compare its body with the new output and the recorded pre-deploy response. Use an exact file URL with an extension, such as /index.html or /version.txt, so a missing file cannot be masked by the SPA fallback. If the URL is unreachable, any checked response is outside the 2xx range, or an expected response differs, report that the live check failed and explain what you observed.
After the live HTTP checks, run deploy status with the saved deploy ID from the directory holding the app binding. Only report this attempt as verified if it is still live and the expected content matched. If the status cannot be checked or the attempt is no longer live, report the observed content and the separate deploy state without claiming this revision was verified. If there is no distinguishing content to check, report which content matched and say that the specific revision could not be confirmed.For a project with a build step, identify the configured output directory, such as ./dist, before building. Inspect both the project-root and output-directory tori.json files and confirm any existing target slug with the user before running a build that may clear the output. Keep a copy of any output-directory binding outside that directory. If the build removes it, restore the confirmed binding before deploying. If the output location or either binding changes unexpectedly, stop and ask the user to confirm the target again.
Run the build in an environment that cannot access either TORI_TOKEN or the saved Tori login. For example, use an isolated build environment with neither credential and copy out only the public build output. Provide credentials only to the Tori CLI commands.
After building, replace every occurrence of ./site in the prompt with the actual output directory. Recheck the bindings, inspect the public files, deploy that directory, and compare the live page with its index.html and verify a changed file or unique marker for updates.
For a server, follow the service deploy guide and ask the agent to identify the service source directory and check the tori.json in that directory. Use the same API endpoint check and keep the confirmed endpoint fixed for all Tori commands. Before uploading, inspect the source files the CLI would pack under What is uploaded. Stop if any included file contains secrets or private data, or if you cannot establish what will be uploaded. A .dockerignore does not exclude files from the upload. If the service has an enabled release command in tori.json, show the command without exposing any secrets and obtain explicit approval to run it. Explain that it runs in the app environment before the new revision takes traffic and can change persistent data even if the deploy later fails. Once the target, source, and any release command are confirmed, run /absolute/path/to/tori deploy --service -v with that same directory as the working directory. In a monorepo, for example, change into services/api before deploying that service. If the file exists, the agent must show the slug and API endpoint together and wait for your explicit confirmation before deploying. If the binding is invalid or names a different app than you intend to update, have the agent stop and explain. For an unbound service project, have the agent run /absolute/path/to/tori whoami from that same directory and wait for you to confirm the account email and API endpoint together before creating an app. If the account cannot be verified or the CLI cannot write tori.json in the service source directory, stop before deploying.
If the CLI asks to convert a static app to a service or suggests --convert, stop. Explain that conversion is permanent and obtain separate approval before proceeding. Confirming the app slug alone does not approve conversion.
After a service deploy, request a known endpoint on the URL Tori printed and compare the response status and content with what you expect from that service. Ask the user for the endpoint and expected response if they are unclear. Report the endpoint check separately from deployment status. For an update, record the expected endpoint or revision marker and its current response before deploying. After deployment, verify that the response matches the new revision and differs from the recorded pre-deploy response. If the endpoint is healthy but its response cannot distinguish the new revision from an older one, report the endpoint health and say the specific revision could not be confirmed. After the endpoint check, query the saved deploy ID again from the service directory. Only call the attempt verified if it is still live and the expected response matched. If status is unavailable or this attempt is no longer live, report the endpoint result separately without claiming this revision was verified.
Check the result
Section titled “Check the result”For service deploys, run both log commands below from the same service source directory you deployed from. The CLI reads that directory’s tori.json to select the app, including when you pass a deploy ID.
Keep the deploy ID from the verbose output. If upload acceptance is unclear and the CLI has no usable deploy ID, treat the outcome as unknown even if it suggests a retry. This includes a lost connection, a gateway timeout, or an unreadable success response. Check the bound app’s deploy history on the confirmed control plane and wait until you can establish whether the attempt was accepted before retrying. If monitoring fails after Tori accepts the deploy, use that ID with /absolute/path/to/tori deploy status <deploy-id> or /absolute/path/to/tori deploy watch <deploy-id> from the directory containing the binding used for that app. If the attempt cannot be identified, report its outcome as unknown and stop until it can be resolved. On a first deploy, including when the CLI cannot write the new binding, follow Recovering a first deploy. Wait until the app creation outcome is known and reuse the app if it was created.
The CLI normally waits for the deploy and prints the live URL or an error. If it stops waiting while the deploy is still in progress, report the attempt as pending and use the arguments from the printed watch or status command with the trusted CLI path from the directory containing the tori.json that the CLI used or created for this app. Read the reported state for the same deploy ID before reporting a final result. A zero exit code from watch or status does not establish that the deploy went live. Deploy status and recovery explains the states the agent may report. Keep tori.json so the next deploy updates the same app.
- A source build failed: ask the agent to run the
/absolute/path/to/tori deploy build-log <deploy-id>command printed with the error when a build log is available. The ID selects that failed attempt even if another deploy has started. A deploy token for the app can read its build log. - A service started but behaves unexpectedly: read its runtime logs in the signed-in console or ask the agent to run
/absolute/path/to/tori logsfrom the project with whole-account authentication. A deploy token cannot read runtime logs, nor the output of a failed release command, which runs with the app’s environment.
Can the agent use MCP?
Section titled “Can the agent use MCP?”Yes. Tori MCP is in Preview. The agent can connect to a local server over stdio when its host supports it. The CLI workflow above needs only a shell.