Skip to content

Command line

Use the reflex CLI to write, run and debug scripts from your terminal.

It is one binary for Linux and Windows (amd64 and arm64). It talks to your Reflex server and to a local dev agent on your machine, which the CLI downloads, starts and stops for you.

Install from your own server, which fills in its address. Profile → API tokens shows these commands ready to copy:

Terminal window
curl -fsSL https://<server>/install.sh | sh # Linux
irm https://<server>/install.ps1 | iex # Windows (PowerShell)

Then sign in and set up your repository:

Terminal window
reflex login # approve a short code in your browser
reflex init # project link, .gitignore entry, Lua type stubs
reflex run flows/hello.lua

reflex doctor checks your setup and suggests repairs. reflex update updates the CLI to your server’s version.

reflex login https://<server> works with whatever login your server uses (basic auth, OIDC, Azure AD). Tokens are kept in your OS keychain. reflex whoami shows your user, scopes and what works per project. Use reflex context list to switch between servers.

In CI, create a personal access token (rfx_pat_…) or a service-account token (rfx_sat_…) under API tokens and pass it in the environment:

Terminal window
REFLEX_SERVER=https://<server> REFLEX_TOKEN=rfx_pat_… reflex runs list --project acme/webshop

reflex init links the repository to a server project. To link without the rest of the setup, run reflex link, which matches your git remote to a project, or reflex link acme/webshop. The link is saved in .reflex/project.yaml; commit it.

Terminal window
reflex validate # check scripts and reflex.yaml
reflex run flows/orders.lua # on your local dev agent
reflex run flows/orders.lua --job nightly-orders --data env=acc
reflex exec 'print(Dates.now())' # inline code
reflex run flows/orders.lua --remote # on a project agent of the server
  • Local is the default. The script runs on your machine with your project files, like a job. --job <name> uses that job’s setup files, default data and agent labels. --data key=value or --data @values.json passes values.
  • Remote (--remote) uploads your working copy, honouring .gitignore and .reflexignore and never .reflex/secrets.local. Use it for systems only a project agent can reach. --detach returns the run id; reflex runs attach <id> reconnects.
  • Secrets for local runs come from REFLEX_SECRET_<NAME>, .reflex/secrets.local (gitignored), the OS keychain (reflex secret set <name> --local) or, if the project allows it, a short lease from the server. A missing secret fails before the run starts.
Terminal window
reflex docs Xlsx # a library
reflex docs Workbook.save # one function, with an example
reflex docs --search "send an email with attachment"

Use reflex browser to explore a page step by step, then turn what you learned into Lua:

Terminal window
reflex browser open https://example.com
reflex browser summary -i -c # interactive elements with refs (@r1) and ranked selectors
reflex browser locate @r3 # durable locators for one element
reflex browser lua # Lua for the flow so far

Debug a failure with reflex run <file> --debug or reflex runs reproduce <id>. See Debug from the CLI or AI.

Add --json to any command to get one JSON object (NDJSON for streams). Without a terminal the CLI never prompts, so destructive actions need --yes. To set up an AI coding tool, see Work with AI.

Every command and flag is in the CLI reference.