Skip to content

CLI

The perafly command (short name pf): publish folders, manage versions and projects, and reach every project feature from a terminal or CI.

On this page

Install

The CLI needs Node.js 22 or later.

Terminal
npm install -g perafly
perafly --help

Every command prints readable text by default and a JSON envelope with --json. Running perafly with no command shows the same as perafly status.

Sign-in and setup

CommandWhat it does
perafly loginSign in with a device code in the browser. --access full|agent|read asks for a profile, --no-browser only prints the address, --token-stdin reads an API key from stdin, --handoff reads a handoff link from stdin.
perafly logoutRevoke the CLI key and remove it from this computer. Keys made in the dashboard aren't touched.
perafly whoamiShow the signed-in identity, team, role and permissions.
perafly teams lsList the teams you're signed in to.
perafly profilesList named profiles.
perafly switch [team]Make the profile for this team the default.
perafly initWrite perafly.jsonc with its $schema. --create also creates a project and links the folder (-n, --name).
perafly link [project]Link this folder to a project (writes .perafly/project.json).
perafly unlinkRemove this folder's project link.
perafly statusSign-in, linked project and live version.
perafly openOpen the live address; --version <vN> opens a version's address.

Publishing and versions

CommandWhat it does
perafly publish [dir]Publish a folder, a single HTML file or a .zip / .tar.gz archive (default: the current folder). Flags below.
perafly versions lsList versions (--state, --limit, --cursor).
perafly versions get <version>Show a version (v7 or ver_…).
perafly versions rm <version>Delete a version that isn't live (asks to confirm).
perafly promote <version>Make a ready version live. Nothing is rebuilt. With an agent sign-in it waits for approval (--no-wait, --wait-timeout).
perafly rollback <version>Move live back to an earlier version (asks to confirm).
perafly operations get <id>Show a long-running operation (opr_…).
perafly operations wait <id>Wait until an operation finishes.
perafly operations resume <id>Get the result of an action a teammate approved (exe_…); waits for the decision unless --no-wait.
perafly logs buildBuild log of a version from the hosting provider (--version).

perafly publish flags

FlagDefaultMeaning
-n, --name <name>generatedName (address) of a new project; only when a project is created.
-m, --message <text>last commit messageVersion note.
--target live|previewlivepreview makes the version ready at its own address and leaves live alone. With a Git branch and no target, the project's branch rule decides.
--publish-mode snapshot|additivesnapshotsnapshot removes paths you didn't send; additive keeps them from the live version.
--branch <name>, --commit <sha>from CIGit branch and commit of this build. Detected in GitHub Actions, GitLab CI, Bitbucket Pipelines and CircleCI.
--prebuiltoffReady-made output: .gitignore rules aren't applied.
--dry-runoffShow the files, skipped files and target; upload nothing.
--no-waitwaitsReturn before the version is ready.
--wait-timeout <seconds>900Stop waiting after this long (exit code 50); the build continues on the server.

The CLI never runs your build. If you publish source, the hosting provider detects the framework and builds it; perafly.jsonc can override the commands (see perafly.jsonc).

Projects and keys

CommandWhat it does
perafly projects lsList projects (-q, --query, --limit, --cursor).
perafly projects get [project]Show a project.
perafly projects createCreate an empty project (-n, --name, --title, --link).
perafly projects update [project]Rename, retitle or change the publish rule (-n, --name, --title, --publish-rule auto|manual).
perafly projects rm [project]Delete a project and all its versions (asks to confirm; not with an agent sign-in).
perafly projects claimMove the project you published without an account into your team. --keep-publishing gives the publishing agent a key for this project only.
perafly api-keys lsList the team's API keys.
perafly api-keys create <name>Create an API key; the secret is shown once (--out <file> writes it to a file instead). Needs a full sign-in.
perafly api-keys revoke <key>Revoke an API key (key_…).
perafly usageThis period's plan, usage, overage, spend limit and agent credits.

Project features

These commands act on the linked project, or the one given with --project. Each has its own page with details.

CommandWhat it does
perafly domains ls|add|check|rmCustom domains and the DNS records to set. See Domains and sharing.
perafly shareWho can open the project; public, private, link [--revoke], password [--clear] (from stdin), add <email>, rm <email>.
perafly env ls|set|rmEnvironment variables; values come from stdin or a hidden prompt. See Environment variables.
perafly data …Collections, records, project keys and hook deliveries. See Data.
perafly storage ls|put|get|mv|rm|syncProject storage. See Storage and SFTP.
perafly sftp ls|add|rmSFTP accounts for project storage.
perafly git …, perafly branchesGitHub connection, direct push, builds and branch previews. See Git and CI.
perafly logs [kind], perafly metrics, perafly topLogs, traffic and runtime metrics. See Logs and analytics.
perafly agent …The built-in agent. See Built-in agent.
perafly setup agent, perafly mcp …Connect agent clients. See Agents and MCP.

Global flags and environment

FlagEnvironment variableMeaning
--json—Machine-readable output.
--project <project>PERAFLY_PROJECTProject id, name or live address.
--team <team>PERAFLY_TEAMTeam name or id.
--api-url <url>PERAFLY_API_URLAPI address; default https://api.perafly.com.
--profile <name>PERAFLY_PROFILENamed profile.
-y, --yesPERAFLY_YESConfirm destructive actions.
--cwd <path>—Run as if started in this folder.
—PERAFLY_TOKENAPI key (pfa_…); comes before a stored sign-in. The way to authenticate in CI.
—PERAFLY_CLAIM_TOKENKey of a project published without an account (pfc_…).
—PERAFLY_AGENT1, true or yes: agent mode (see below).
—PERAFLY_NON_INTERACTIVENever ask questions.
—PERAFLY_HOMEState folder; default ~/.perafly.
—PERAFLY_CREDENTIAL_STOREkeyring or plaintext to force where the key is stored.
—PERAFLY_DEBUGDiagnostics on stderr; secrets are never printed.

There is no --token flag on purpose: arguments end up in shell history and process lists. The CLI rejects arguments that look like a secret key.

Files the CLI uses

FileHolds
perafly.jsoncProject configuration; committed and published, never served. See perafly.jsonc.
.perafly/project.jsonWhich project the folder publishes to. Commit it; it holds no secret.
.perafly/state.jsonKey of a project published without an account. Never committed; the CLI adds it to .gitignore.
~/.perafly/config.jsonProfiles, default team and API address.

Agent mode and confirmations

With PERAFLY_AGENT=1 or in CI (CI set), the CLI turns on --json and never asks questions. Agent mode never means --yes: a destructive action such as rollback, versions rm or storage rm still needs an explicit --yes, or it stops with confirmation_required.

Separately, the server asks a teammate to approve risky actions that come from an agent sign-in, like changing what's live. See Approvals.

JSON output and exit codes

With --json, success goes to stdout as { "data": … } and errors go to stderr as { "error": { code, message, … } }. Server errors keep the API's code (see Errors); recovery suggests the next command when there is one.

Exit codeWhen
0Success.
1Unexpected error.
2Invalid flag or argument, HTTP 400, 413 or 422, or a missing confirmation.
10HTTP 401 or 403; missing or expired credentials.
20HTTP 404 or 410.
30HTTP 409, or a plan limit (HTTP 402).
40Network error or rate limit (HTTP 429); safe to retry.
50--wait-timeout passed; the work continues on the server.
130Cancelled (Ctrl-C or a declined question).
Signed in as an agent, a command that waits for a teammate's approval exits with approval_required (exit code 2) when you pass --no-wait.
  • Run perafly <command> --help for every flag of a command.