# CLI reference

> Every `forkrail` command, grouped by what it’s for. Run `forkrail help COMMAND` for a command’s full options.

- Category: Reference
- URL: https://www.forkrail.com/docs/cli

## Install the CLI

**macOS and Linux**

```bash
curl -fsSL https://forkrail.com/install | sh
```

**Windows**

```bash
irm https://forkrail.com/install.ps1 | iex
```

Check it with `forkrail --version`. The CLI is one file with no dependencies, for macOS, Linux and Windows on x64 and Arm.

## Options every command takes

| Option | Does |
| --- | --- |
| `--profile NAME` | The AWS profile to use. Defaults to `AWS_PROFILE`, then the one `forkrail link` saved, then the AWS SDK’s default. |
| `--region REGION` | The install’s home region. Defaults to `FORKRAIL_HOME_REGION`, then the saved one, then `us-east-1`. |
| `--aws` | Use this machine’s AWS credentials even though the terminal is signed in. `FORKRAIL_AWS=1` does the same. |
| `-h`, `--help` | Show a command’s options. |
| `-V`, `--version` | Show the CLI’s version. |

A terminal works in one of two ways: **signed in** (`forkrail login`), acting as a team member with their role, or with the install’s **AWS credentials**, as its administrator. Signed-in commands go through the dashboard and need no AWS access.

## Deploy and manage deployments

| Command | Does |
| --- | --- |
| `forkrail [DIR]`, `forkrail deploy [DIR]` | Deploy a preview of the folder (the current one by default). `--prod` for production. With no command, forkrail deploys, as `vercel` does. |
| `forkrail ls [PROJECT]` | List projects, or a project’s deployments. |
| `forkrail inspect ID` | Show a deployment’s record. `--logs` for its build log. |
| `forkrail promote ID` | Make a deployment production. `--allow-preview-env` promotes a preview whose env vars differ from production’s. |
| `forkrail rollback [PROJECT]` | Point production back at the previous production deployment, or `--to ID`. |
| `forkrail redeploy ID` | Make a deployment again with today’s env vars and settings. `--prod`, `--skip-domain`, `--no-cache`. |
| `forkrail cancel ID` | Stop a build. |
| `forkrail rm ID` | Remove a deployment that isn’t production. `rm --project NAME` deletes a whole project. |
| `forkrail retention` | How long deployments are kept: `show`, `set`, `sweep`. |
| `forkrail restore ID` | Bring a deleted deployment back, within 30 days. |
| `forkrail build DIR --out OUT`, `forkrail publish OUT` | Build without publishing, then publish that build. |
| `forkrail curl URL -- ARGS` | curl a protected deployment as a team member. |

### deploy options

| Option | Does |
| --- | --- |
| `--prod` | Deploy to production. |
| `--project NAME` | The project. Defaults to the folder’s name. |
| `--memory MB` | Memory for this deployment only (128 to 10,240). |
| `--concurrent true|false` | Concurrent compute for this deployment only. |
| `--skip-domain` | With `--prod`: build production but leave your domains on the current deployment (a staged release). |
| `--no-cache` | Build without the build cache. |
| `--local` | Build on this machine instead of the install’s builder (needs AWS credentials). |
| `--prebuilt` | Deploy a framework’s existing build output. |

## Projects and functions

| Command | Does |
| --- | --- |
| `forkrail project NAME` | Show a project’s settings, or change them with the options below. |
| `forkrail limits NAME` | Show or set `--max-workers N` (1 to 1,000, or `default`). Applies within seconds. |
| `forkrail regions` | Router regions and where functions run: `ls`, `add`, `rm`, `setup`, `copy`. |
| `forkrail link` | Check the account has an install, and save the profile and region for later commands. |

### project options

| Option | Does |
| --- | --- |
| `--memory MB`, `--max-duration S` | Function memory and timeout. `default` clears one. |
| `--concurrent true|false` | Concurrent compute (alias `--fluid`). |
| `--max-inflight N` | Max requests per instance: how many requests share one worker, 2 to 50. Not a limit on the project: workers still scale out. |
| `--keep-warm N|auto` | Environments kept warm per region (0 to 20). |
| `--regions LIST` | Function regions, comma-separated. |
| `--role ROLE` | The IAM role functions run as, by name or ARN; `default` for the shared one. |
| `--framework NAME` | The framework preset. |
| `--auto-assign-domains on|off` | Whether production deploys move your domains (off for staged releases). |
| `--skew-protection on|off` | Skew protection, with `--skew-max-age`, `--skew-threshold`, `--skew-allowed-domains`. |
| `--analytics on|off` | Web Analytics. |
| `--rename NEW` | Rename the project. |

## Env vars, domains, schedules and hooks

| Command | Does |
| --- | --- |
| `forkrail env ls PROJECT`, `env add|rm PROJECT KEY` | List, add or remove env vars. `-e production|preview|development`, `--git-branch BRANCH`. Values come from stdin or a prompt, never the command line. |
| `forkrail env pull [FILE]` | Write Development’s variables to `.env.local` (or FILE). |
| `forkrail env run -- CMD` | Run a command with Development’s variables, writing no file: `forkrail env run -- next dev`. |
| `forkrail domains add DOMAIN PROJECT` | Add a custom domain. `--redirect OTHER --status 308`, or `--branch BRANCH` to follow a branch. |
| `forkrail domains ls|inspect|check|update|rm` | List, inspect, check DNS, change or remove domains. |
| `forkrail schedules ls|run|enable|disable|sync` | A project’s cron schedules (alias `crons`). |
| `forkrail deploy-hooks ls|create|rm` | Secret URLs that build a branch. `create --branch BRANCH`. |
| `forkrail git setup|status|repos|connect|disconnect|deploy` | The install’s GitHub App, and connecting a project to a repository. |

## Routing and cache

| Command | Does |
| --- | --- |
| `forkrail redirects ls|add|rm|import|export|test` | Bulk redirects. `add SRC DEST --permanent`, `import FILE --replace`. |
| `forkrail redirects publish|discard|versions|restore` | Publish staged redirects, or go back to a version. |
| `forkrail routes ls|add|update|rm|move|enable|disable|test` | Routing rules. `add NAME --src --src-syntax --action --dest --status --has --missing`. |
| `forkrail routes publish|discard|versions|restore|import|export` | Publish staged rules, or go back to a version. |
| `forkrail cache invalidate|dangerously-delete -p PROJECT --tag TAGS` | Purge by tag. `--target production|preview`, `--revalidation-deadline-seconds`. |
| `forkrail cache purge -p PROJECT` | Invalidate everything the project cached. |
| `forkrail cache ls PROJECT` | The latest purges. |

## Security, team and spend

| Command | Does |
| --- | --- |
| `forkrail firewall show|test|diff|publish|discard|versions|rollback PROJECT` | Look at, test and publish a project’s firewall. `--install` for the install’s own. |
| `forkrail firewall rule add|rm|on|off|move` | Custom rules: `--if`, `--and`, `--or`, `--then`, `--for`, rate limit options. |
| `forkrail firewall ip add|rm` | IP blocks. |
| `forkrail firewall attack-mode PROJECT --for 1h|6h|24h` | Challenge every visitor. `--off` to stop. |
| `forkrail firewall system-bypass add|rm`, `mitigations`, `limits`, `pause`, `resume` | DDoS mitigations and their exceptions. |
| `forkrail firewall enable|disable`, `import FILE` | Turn custom rules on or off, or import a Vercel firewall configuration. |
| `forkrail protection show|set PROJECT` | Deployment protection: `--scope`, `--members`, `--trusted-ips`, `--exceptions`, `--options-paths`, `--sign-out`. |
| `forkrail protection bypass add|rm PROJECT` | Bypass secrets for automation. `--env` also sets `FORKRAIL_AUTOMATION_BYPASS_SECRET`. |
| `forkrail protection default SCOPE` | The default scope for every project (owners). |
| `forkrail spend show|budget|no-budget|exempt|pause|resume` | Budgets and paused projects. |
| `forkrail owners ls|add|rm` | The install’s owners (needs AWS credentials). |
| `forkrail login [URL]`, `logout`, `whoami` | Sign a terminal in or out, and see who it is. |

## Monitor

| Command | Does |
| --- | --- |
| `forkrail logs PROJECT` | Requests, newest last. `--since`, `--status`, `--path`, `--host`, `-f`, `--request ID`, `--app`. |
| `forkrail stats PROJECT` | Status, latency, workers, cold starts and busiest paths. `--since 24h` by default. |
| `forkrail usage [PROJECT]` | Requests, function time, transfer and cost on AWS. `--since 30d`, `--daily`. |
| `forkrail routers` | Each router’s CPU, memory, disk, network and requests. |

## Install and administer

| Command | Does |
| --- | --- |
| `forkrail install` | Install forkrail in an AWS account. `--domain`, `--email`, `--check` (checks only), `--yes`, `--terminal`. Run it again to continue where it stopped. |
| `forkrail uninstall` | Delete everything `install` made. Asks you to type the domain unless `--yes`. |
| `forkrail dashboard [URL]` | Show or set the dashboard’s address. |
| `forkrail sweep` | List stored files no deployment uses; `--yes` deletes them. |
| `forkrail state status|mode|migrate|check` | Where project records are kept. |

## Environment variables the CLI reads

| Variable | Does |
| --- | --- |
| `FORKRAIL_TOKEN`, `FORKRAIL_API` | Sign in without a login file, for CI: the token and the dashboard’s address. |
| `FORKRAIL_AWS=1` | Use AWS credentials even when signed in. |
| `FORKRAIL_HOME_REGION` | The install’s home region. |
| `AWS_PROFILE` | The AWS profile, as in the AWS CLI. |
| `FORKRAIL_DASHBOARD_URL` | The dashboard’s address, for one command. |
| `FORKRAIL_CLOUDFLARE_TOKEN` | For `install --yes`: the Cloudflare API token for your domain’s DNS. |
