CLI Fundamentals
How base finds your workspace, your worker, and your environment, and how to see what it resolved.
Every base command answers three questions before it does anything: which workspace am I in, which worker am I operating on, and which environment am I targeting? Understanding those three resolutions is most of understanding the CLI.
Invoking
Three global options work on every command:
[worker]: most commands take the worker as a positional (base develop app);-w appis the equivalent flag form.-e, --environment: the target environment. Defaults toDevelopment.--workers-folder: override where workers live.
Worker resolution
When you don't name a worker, the CLI infers it from where you are:
- An explicit positional or
-walways wins. - If your current directory is a worker (it contains
settings.ts), that's the worker, socd workers/app && npx base developjust works. - Otherwise you'll be asked:
No worker specified. Pass -w <name> or run from inside a worker folder.
A worker is "a directory containing settings.ts" — that's also how --all-workers discovers the workspace's workers.
Workspace resolution
The workers folder resolves in precedence order:
--workers-folder <path>: explicit override.- Your current directory is a worker → its parent is the workers folder.
- The nearest
package.json(walking up) with a"base": { "workersFolder": "..." }block — the scaffold sets"./workers". - A
./workers/directory under the current directory. - The current directory itself.
The same package.json base block can set "persistTo" — the directory for wrangler's local state (D1/KV/R2/DO data). The scaffold sets "./.wrangler/state" at the workspace root so all workers share one local state root; base develop, orm migration:run --local, and orm db:reset all honor it (and a --persist-to flag overrides it per run — keep them consistent, or your migrations land in a different local database than your dev server reads).
Environments
-e selects a named environment: a [env.<Name>] section in wrangler.toml, a [<Name>] section in env.toml, and a key in environment-keyed settings like server. Two names carry built-in behavior:
Development(the default): skips the released-migrations deploy gate; local dev mode.Production: refuses to deploy a dirty git tree.
Anything else (Staging, Integration, …) is yours to define — the CLI treats custom names as first-class environments with no special gates beyond the standard checks.
When resolution surprises you
info prints the resolved workspace, worker, environment, and the exact resolution path that produced them — plus, with --with-settings, the worker's modules and databases. It's read-only and the first thing to reach for when a command seems to be operating on the wrong thing.
Next: the development loop, or the full command reference.