Skip to content

Use with AI agents

Use a dry run first. It builds and inspects the output without uploading or requiring authentication. After it passes, a real deploy needs an authenticated account.

For Claude Desktop, Claude Code, Cursor, and other MCP clients, see Use LeafCloud from AI assistants (MCP).

Install the LeafCloud CLI with `curl -fsSL https://leafcloud.in/install.sh | sh` and verify it with `leaf --version`. In this project, run `leaf deploy --dry-run --json` and read the result. If it reports an error, fix the project using the LeafCloud docs at https://leafcloud.in/docs/llms.txt, then run the dry run again. When it passes, run `leaf deploy --json --yes` and report the live URL. Never print or expose LEAF_TOKEN.

The install-script URL is assumed; verify it before launch. On Windows, the documented install command is irm https://leafcloud.in/install.ps1 | iex.

Choose either path:

  1. The person runs leaf login once on the machine. The agent then uses that saved login.
  2. The person creates a deploy-only key for one site, sets it as LEAF_TOKEN in the agent environment, and does not paste the secret into project files or logs.
Terminal window
leaf keys create --name agent --can deploy --site <name> --expires 90d

Revoke the key when it is no longer needed:

Terminal window
leaf keys revoke <id>

Copy this block into the project’s AGENTS.md:

### LeafCloud deploy
- Run `leaf deploy --dry-run --json` before a deploy. Fix any reported error and repeat the dry run until it succeeds.
- After a passing dry run, deploy with `leaf deploy --json --yes`.
- Parse each stdout line as a JSON object. Check for an `error` property and confirm the command exit code is `0` before treating the operation as successful.
- Never print, log, commit, or include `LEAF_TOKEN` in a response. Read it only from the environment.
- Report the live URL returned by a successful deploy.

With --json, leaf writes newline-delimited JSON objects to stdout. Objects produced by the CLI include "schema": 1. A result can include type and data; list commands can write one object per row. Errors include an error field. Error text is also written to stderr, so parse stdout as JSON and use the process exit status as the success signal.

Exit status 0 means success. The CLI source uses failure statuses 1, 2, 3, and 4; any nonzero status is a failure. Do not infer success from a JSON object alone.

  • Run the dry run before any real deploy.
  • Use a deploy-only key scoped to one site, set an expiry, and revoke it when finished.
  • Keep LEAF_TOKEN in the agent’s secret environment. Never put it in prompts, source files, shell transcripts, or logs.
  • A real deploy uploads the selected output folder. Only run one when the person has asked for it.