Anvil CLI commands

The Anvil CLI is currently in beta while we continue to make improvements.

Here you can find a list of the most useful Anvil CLI commands.

For the full list of commands and flags, run

Bash
anvil --help
anvil <command> --help

configure

Set up your default Anvil server, editor preferences, and login.

Bash
anvil configure

Use this when:

  • you are setting up the CLI for the first time
  • you want to run the guided setup again
  • you want the guided setup instead of configuring pieces manually

checkout

Checkout an Anvil app locally using the interactive picker, the app’s URL in Anvil, or the app ID.

Alias: anvil co

Bash
anvil checkout [input] [directory]
anvil co [input] [directory]

Key options:

  • -O, --open: open the app folder after checkout. If a preferredEditor is set, the app folder will open in that editor.
  • -b, --branch <BRANCH>: check out a specific branch
  • -Q, --query <QUERY>: prefill the interactive search
  • --git-url <GIT_URL>: use a separate Git server on an Enterprise installation

Examples:

Bash
anvil checkout https://anvil.works/build/apps/W36XUTXGNPDK6VEA my-app
anvil checkout W36XUTXGNPDK6VEA my-app --url anvil.works
anvil co -Q "dashboard"

Use this when:

  • you want a fresh local copy of an app
  • you want interactive app selection
  • you want to start from an app URL copied from Anvil

If you need to work across multiple accounts or Anvil installations, see Multiple accounts.

create

Create a blank Anvil app and check it out into a local folder.

Bash
anvil create "My App" ./my-app
anvil create "Sales Dashboard" ./sales-dashboard --tag internal sales --open
anvil create "My App" --no-checkout --tag internal

Run this from outside an existing Git repository. The destination must be empty or not yet exist. If you omit the name, the CLI prompts for one. If you omit the destination, it uses the app name to choose a folder name.

Key options:

  • -d, --directory <PATH>: choose the destination instead of supplying a second argument
  • --no-checkout: create the app in Anvil without a local folder, and print its ID and editor URL
  • --tag <TAG...>: add space-separated tags, or repeat the option for each tag
  • -u, --url <ANVIL_URL>: choose your Anvil installation
  • -U, --user <USERNAME>: choose your logged-in account
  • --git-url <GIT_URL>: use a separate Git server on an Enterprise installation
  • -O, --open: open the new folder in your preferred editor

Place --tag after the app name and destination. Tags are lowercased, trimmed, and deduplicated. You can supply up to 20 unique tags, each containing 1 to 50 letters, digits, hyphens, or underscores.

With --no-checkout, you can run the command from any folder. Destination checks are skipped, and no local files are created. Use it without a destination argument, --directory, --git-url, or --open; combining these options produces an error before login or app creation. With --json, the result includes the app ID, name, server, account, tags, and editorUrl, without checkout fields.

The new app uses Python 3. Its name is preserved after trimming surrounding whitespace. Once creation finishes, run anvil watch inside the new folder to start syncing changes.

For scripts, supply a name and use --url and --user if the server or account would otherwise be ambiguous. --json disables interactive prompts.

If the app is created but checkout fails, follow the recovery instructions in the error. Running create again would create another app. With --json, the error includes the existing app’s details in data.created.

watch

Keep your local app folder synced with Anvil while you work.

Bash
anvil watch [path]

Key options:

  • -A, --appid <APP_ID>: specify the app directly
  • -s, --staged-only: sync only staged files
  • -a, --auto: automatically handle some branch and sync transitions
  • -O, --open: open the watched path in your preferred editor

Use this when:

  • you want local edits to sync to Anvil
  • you want compatible Anvil changes to sync back to your local files
  • you are doing normal day-to-day local development

validate

Check that the specified .yaml file is formatted correctly and thus valid.

Bash
anvil validate <file>

You’ll need to specify the path to the file or run the command from the relevant directory and provide the file name.

If the file is valid, the command prints a success message and exits successfully. If the file is invalid, it prints the fields that need attention and exits with an error.

Supported files:

  • anvil.yaml
  • .yaml files under client_code/, including client_code/**/form_template.yaml

Key options:

  • --json: output from the command is structured as JSON. Useful for feeding the output to an agent

Examples:

Bash
anvil validate anvil.yaml
anvil validate client_code/Form1/form_template.yaml
anvil validate client_code/Form1.yaml

Other useful commands

Login and account fixes

  • anvil login to log in again, or to a specific installation such as anvil login anvil.company.com
  • anvil logout if the CLI is using the wrong account

Config commands

  • anvil config list to check which server URL and CLI settings are currently in effect
  • anvil config set <key> <value> to update a config value directly
  • anvil config get <key> to inspect one config value directly
  • anvil config reset to reset CLI configuration back to its defaults and clear saved logins

Troubleshooting and maintenance

  • anvil version when troubleshooting
  • anvil update if the CLI tells you a newer version is available
  • anvil help <command> or anvil <command> --help for full command details

Do you still have questions?

Our Community Forum is full of helpful information and Anvil experts.