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
Section titled “Install”Install from your own server, which fills in its address. Profile → API tokens shows these commands ready to copy:
curl -fsSL https://<server>/install.sh | sh # Linuxirm https://<server>/install.ps1 | iex # Windows (PowerShell)Then sign in and set up your repository:
reflex login # approve a short code in your browserreflex init # project link, .gitignore entry, Lua type stubsreflex run flows/hello.luareflex doctor checks your setup and suggests repairs. reflex update updates the CLI to your server’s version.
Sign in
Section titled “Sign in”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:
REFLEX_SERVER=https://<server> REFLEX_TOKEN=rfx_pat_… reflex runs list --project acme/webshopLink a project
Section titled “Link a project”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.
Run a script
Section titled “Run a script”reflex validate # check scripts and reflex.yamlreflex run flows/orders.lua # on your local dev agentreflex run flows/orders.lua --job nightly-orders --data env=accreflex exec 'print(Dates.now())' # inline codereflex 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=valueor--data @values.jsonpasses values. - Remote (
--remote) uploads your working copy, honouring.gitignoreand.reflexignoreand never.reflex/secrets.local. Use it for systems only a project agent can reach.--detachreturns 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.
Look up functions
Section titled “Look up functions”reflex docs Xlsx # a libraryreflex docs Workbook.save # one function, with an examplereflex docs --search "send an email with attachment"Explore a page
Section titled “Explore a page”Use reflex browser to explore a page step by step, then turn what you learned into Lua:
reflex browser open https://example.comreflex browser summary -i -c # interactive elements with refs (@r1) and ranked selectorsreflex browser locate @r3 # durable locators for one elementreflex browser lua # Lua for the flow so farFailed run
Section titled “Failed run”Debug a failure with reflex run <file> --debug or reflex runs reproduce <id>. See Debug from the CLI or AI.
Use it from tools
Section titled “Use it from tools”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.