stacktape dev runs your app on your machine while it stays connected to AWS. Containers and local copies of your databases run in Docker. Frontends run on their own dev servers. Lambda functions are built on your machine and run in AWS, with their logs in your terminal. You edit code, save, and see the result without a deploy.
What you need
- A Stacktape configuration.
stacktape devreads the samestacktape.tsyou deploy.stacktape initcreates one. - Docker running. Containers and local databases need it. A config with only Lambda functions and no local databases works without Docker.
- AWS credentials for the account you develop in. The first run deploys a small dev stack there. A Stacktape account is not needed.
Start dev mode
Run it in the directory with your stacktape.ts:
A picker lists the resources dev mode can run, all of them selected. Deselect what you don't need and press Enter. To skip the picker, name the resources or pass all:
The first run deploys the dev stack: IAM roles, secrets and the routing local development needs. When deployed functions use local databases or join the VPC, it also creates the account's dev network. A first start that creates both takes about 5 minutes. Later starts reuse them.
Give every developer their own stage, such as --stage dev-alice and --stage dev-bob. Each stage gets its own dev stack and its own local data. Don't use a stage you deploy: dev mode refuses a stage that stacktape deploy created, and deploy refuses a dev stage.
Change code and see it
Edit a file and save. Then:
- With
--watch, dev mode rebuilds the changed workload by itself. Containers restart, and Lambda functions get the new code in AWS. - Without
--watch, press Ctrl+R to rebuild. With several workloads running, a picker opens: press a workload's number, orafor all. Ctrl+A rebuilds everything at once. - Frontends reload through the framework's own hot reload, with or without
--watch.
A rebuild deploys code only. After you change the configuration, such as a new resource, an environment variable or a connection, dev mode tells you to restart, and refuses rebuilds until you do. The restart updates the dev stack.
Stop dev mode
Press Ctrl+C. The dev stack stays in AWS for the next start, and your local database data stays in .stacktape/dev-data/<stage>/. A dev session started with --agent runs in the background: stop it with stacktape dev stop.
What runs where
| Resource | Where it runs | After a change |
|---|---|---|
| Containers: web service, worker service, private service and workloads of several containers | Docker on your machine | Rebuilt with --watch or Ctrl+R |
| Lambda functions | AWS, built on your machine | Code updated in AWS with --watch or Ctrl+R. Logs stream to your terminal. |
| SSR frontends: Next.js, Astro, Nuxt, SvelteKit, SolidStart, TanStack Start, Remix | Its own dev server | Its own hot reload |
Static hosting with a dev command | Your dev command | Your dev command's reload |
| Relational databases, Redis, DynamoDB, OpenSearch | Docker on your machine | Data persists in .stacktape/dev-data/<stage>/ |
| Batch jobs | AWS, in the dev stack. They cannot be selected or skipped | Restart dev mode to rebuild their images |
| Everything else, such as queues, topics, buckets and state machines | AWS, in the dev stack | Restart dev mode after you change its config |
Lambda functions in AWS reach the databases on your machine through the dev box, a small EC2 instance in your account's dev network. See Connecting to local databases. Local databases listen on 127.0.0.1 only, and nothing is exposed on the internet.
A container counts as running once its port accepts connections, so a test started when dev mode reports it ready reaches the app. All local DynamoDB tables run in one DynamoDB Local, and workloads, local scripts and frontends connected to them get AWS_ENDPOINT_URL_DYNAMODB, so unchanged AWS SDK code uses the local tables.
What happens when it starts
When you run stacktape dev, these steps run in order:
- Load credentials and configuration: Stacktape reads your AWS credentials and config file.
- Select resources: You choose which resources to run via the interactive picker, or Stacktape uses the
--resourcesand--skip-resourcesflags. - Check references: Before any AWS work, Stacktape checks every
$ResourceParamthat ends up in the dev stack, so a misspelled parameter or a reference to a local database fails within seconds. - Load AWS metadata: Stacktape fetches stack information from AWS.
- Ensure secrets and SSM parameters: Stacktape can generate supported missing database credentials. Other missing secrets and SSM parameters require user-supplied values: interactive runs prompt, while agent/noninteractive runs stop with creation instructions. Deleting a dev stage keeps the database secrets dev mode generated; delete one with
stacktape secret deletewhen no stage needs it. See secret ownership. - Prepare the dev network: When deployed functions use local databases or join the VPC, Stacktape creates the account's dev network on first use, once per account and region, and starts its dev box in the background. A new network's dev box exists after about 1 minute; the next step starts then, while CloudFormation finishes the network. A session that finds another session creating the network continues as soon as the dev box exists, too. A first start that creates the network and the dev stack takes about 5 minutes.
- Deploy dev stack: Create the stack if missing, or update it when cloud configuration, cloud images or required outputs change. Otherwise reuse it.
- Start local resources and workloads: Docker containers start for selected databases, dev mode connects to the dev box, then container workloads, frontends, and Lambda deploys run in parallel.
- Wait for new API stages: AWS answers some requests to a new HTTP or WebSocket API stage with 403 or 404 for about half a minute after CloudFormation creates it. A function behind such an API reports running only after its stage is 45 seconds old. For a WebSocket API, dev mode also opens a few test connections, which run your
$connectand$disconnecthandlers. Later starts reuse the stage and do not wait.
Unchanged starts skip the dev stack deployment step. Stacktape still loads AWS metadata, prepares local resources, and starts or deploys the selected workloads.
Run part of the stack
--resources picks what runs. --skip-resources runs everything except the resources you name, alone or together with --resources all:
A skipped Lambda function stays in the dev stack without its triggers, so it does not run on queue messages, schedules, stream records or HTTP requests during the session.
If a name is wrong, the error shows the available resource names.
Keep deployed functions away from local databases
Pass --no-tunnel to keep deployed Lambda functions away from your local databases for one session:
Local database emulation
Selected emulatable databases run locally unless listed in --remote-resources. When local resources are active, dev mode runs an environment injection step so workloads can use Stacktape-provided STP_* variables with local endpoints. Code that reads these variables uses the same lookup path in both dev mode and deployed stacks.
| Config resource type | Local Docker image |
|---|---|
| PostgreSQL / Aurora PostgreSQL | postgres |
| MySQL / Aurora MySQL | mysql or mariadb |
| Redis cache | redis |
| DynamoDB table | amazon/dynamodb-local |
| OpenSearch domain | opensearchproject/opensearch |
Local database data persists between dev mode sessions under .stacktape/dev-data/{stage}/, so you typically keep your data across restarts without re-seeding.
Start with a fresh database
Use --fresh-db to reset databases prepared during startup, including relay dependencies. DynamoDB Local tables share storage; see reset scope.
Use a database in AWS instead
When the local copy is not enough, for example to test an engine feature the Docker image lacks, --remote-resources deploys that database in AWS as part of the dev stack, instead of running it locally:
This creates a real database for the dev stage (or reuses the one an earlier session created). It takes several minutes the first time and costs what the database costs, until you delete the dev stage. It is not another stage's database: the dev stack never connects to the database of a deployed stage such as production. To work against an existing database, pass its connection details yourself, for example from a secret. To make the choice permanent, set dev.remote: true on the resource. Functions and local containers that list a remote resource in connectTo get the same permissions as in a full deployment.
Resources the dev stack needs deployed
The dev stack in AWS cannot use a database that runs on your machine, except through the dev box: deployed functions get a local database's address and credentials in their environment variables and through connectTo. Two cases need the deployed resource:
- DynamoDB stream triggers. A stream trigger reads the stream of the deployed table, which DynamoDB Local cannot provide. When a deployed function has a stream trigger on a table, dev mode deploys that table in the dev stack automatically and says so when it starts. Local containers and functions then use the deployed table too.
- Any other reference to a local resource in the dev stack, for example
iamRoleStatementswith$ResourceParam('mainTable', 'arn')on a function or container. Dev mode stops before it starts anything and names the resource and the config path. Add the resource to--remote-resourcesor setdev.remote: trueon it.
For more details on local database setup, supported engines, and troubleshooting, see Local databases.
Environment variables
Workloads connected to locally-emulated resources receive STP_* environment variables pointing to local endpoints instead of AWS endpoints. Dev mode uses the same variable names as deployed stacks: only the values change.
For a relational database resource named myDb connected to a workload via connectTo, the connection string, host, and port point at the local emulator. For example, a PostgreSQL database may produce variables like:
In most applications, reading the Stacktape-provided STP_* variables lets the same code path work in dev mode and deployed stacks without conditional logic or environment switching.
Local containers also get AWS_REGION and AWS_DEFAULT_REGION with the stage's region, as deployed containers do, so AWS SDKs that read either one (boto3 reads only AWS_DEFAULT_REGION) find it without a profile.
Code on your machine talks to the dev stack, and deployed functions talk to your local databases, across the distance to the stage's region. In a region far from you, every first connection takes noticeably longer (several hundred milliseconds per round trip), and a client with a short connect timeout can fail. Node.js, for example, gives up on each address after 250 ms by default; raise it with NODE_OPTIONS=--network-family-autoselection-attempt-timeout=2000, or run dev mode in a region close to you.
Keyboard shortcuts
| Key | Action |
|---|---|
| Ctrl+R | Rebuild. With several workloads, pick one by its number, a for all, or Esc to cancel |
| Ctrl+A | Rebuild all workloads |
| Tab | Switch between the overview and the logs |
| Ctrl+C | Stop dev mode |
With --watch, workloads rebuild by themselves when their files change. Rebuilding one workload leaves the others running.
A workload whose rebuild fails, for example because of a syntax error, shows the error and stays failed until a rebuild succeeds. A Lambda function keeps its previous code until then. A rebuild deploys code only: after a change to the configuration file, stop dev mode and start it again.
That start updates the dev stack only when the change reaches it. Changing how a local container is built or started (its packaging, including startCommand), a frontend's dev settings or a local script restarts only what runs on your machine. When the dev stack is updated, functions whose code did not change keep their deployed code.
Local EFS storage
Configured EFS mounts are not mounted or emulated on local containers. Use explicit local test storage and verify the deployed EFS configuration in a deployed stage.
Lifecycle hooks
Dev mode registers configured beforeDev script hooks and displays them in the dev TUI. See Hooks and scripts for configuration details, hook types, and the full execution model.
Dev stack isolation
Dev mode creates a dedicated dev stack and refuses to reuse any stack it did not create, regardless of name or status. Use a separate stage name such as dev, dev-local, or dev-jane. To connect selected databases or Redis resources to deployed AWS resources, keep the dedicated dev stage and pass --remote-resources.
Dev mode only updates a stack that stacktape dev created. It marks every dev stack with the stack tag stp:dev-stack, and refuses any other stack on the stage, whatever its name or status: use a different stage name, or delete that stack with stacktape delete --stage <stage> yourself. Dev mode never deletes a stack.
If the first start of a stage fails or is interrupted, CloudFormation rolls the dev stack back. The next stacktape dev recognizes the stack by its tag and updates it again. Only a dev stack whose very first create failed (status ROLLBACK_COMPLETE) can't be updated; dev mode then asks you to delete it with stacktape delete --stage <stage>.
Agent mode for coding agents
When started with --agent, Stacktape spawns a detached daemon process. The daemon starts the agent server, writes a lock file with process and connection details, and reports readiness back to the parent command, which then exits. See Agent mode in dev for the full guide.
Start dev mode as an agent:
When --agent-port is omitted, Stacktape starts at port 7331 and searches ports 7331–7430 if the default is in use. Use --agent-port to request a specific port. The agent listens on 127.0.0.1 only, and every request must carry the session token stored in ~/.stacktape/dev-agent-tokens/{port}.token (see Authentication). If Stacktape finds an already running dev agent, the command returns that agent's connection details instead of starting another one. A Lambda build or deploy failure can leave the session running with DEV_STARTED_WITH_FAILURES and ready: false; fix the code and rebuild. A failure that aborts startup is reported separately. Inspect the returned session and status before starting another agent.
While the agent starts, the command prints its progress as JSONL event lines: the agent's port first, then the dev network, the dev box, the dev stack deployment with CloudFormation resource counts, and each workload and database. A first start that creates the dev network and the dev stack takes several minutes, and a heartbeat line every 20 seconds names the step it waits for.
Stop the agent of the current project with stacktape dev stop (--stage chooses between several stages, --cwd names another project directory):
Flags
These are the flags you use most. stacktape dev lists every flag, and stacktape help dev prints them in the terminal.
| Flag | What it does |
|---|---|
--stage | Stage name for the dev stack |
--region | AWS region |
--resources | Resources to run (all or comma-separated names) |
--skip-resources | Resources to leave out |
--watch | Rebuild on file changes |
--remote-resources | Databases to use in AWS instead of a local copy |
--fresh-db | Start local databases from a fresh state |
--no-tunnel | Keep deployed Lambda functions away from local databases |
--agent | Run in the background with an HTTP API for coding agents |
--agent-port | Port for that HTTP API (default: 7331) |
Dev mode FAQ
How do Lambda functions connect to local databases in dev mode?
Through the dev box of your account's dev network. Functions connect to the box's private address, and the box forwards each connection to your machine over an encrypted AWS Systems Manager session that your machine opens. Nothing is published on the internet. Bulk transfers are limited to about 0.7 MB/s. See Connecting to local databases.
What is the difference between dev mode and deploying to a dev stage?
Dev mode (stacktape dev) runs workloads on your local machine with Docker and deploys a dev stack to your AWS account when one does not already exist. Deploying to a dev stage (stacktape deploy --stage dev) provisions the full AWS infrastructure for your config and runs everything in the cloud. Use dev mode for rapid daily iteration; use a deployed dev stage for integration testing against real AWS infrastructure.
Does dev mode cost anything on AWS?
Dev mode creates a minimal dev stack in AWS, so AWS charges can come from the AWS resources in that dev stack, Lambda invocations, and any deployed resources you choose to use through --remote-resources. The dev box costs about $0.01 per hour while a dev session runs; it stops itself 30 minutes after the last session and then costs about $0.75 per month for its disk and the SSM parameter that holds its relay. Container workloads and locally emulated databases run on your machine and don't generate AWS charges. Small development workloads may fall within AWS Lambda free-tier usage, depending on account eligibility and invocation volume.
Next steps
- Local databases: seed data, reset it, or use a deployed database.
- Debugging Lambda functions: how deployed functions reach your machine, and what it costs.
- Deploying stacks: deploy it to a stage when it works.