feat: multi dev branches (#4023)

Closes this feature request:
[https://triggerdev.featurebase.app/p/isolated-dev-sessions-for-multiple-local-trigger-dev-instances](https://triggerdev.featurebase.app/p/isolated-dev-sessions-for-multiple-local-trigger-dev-instances)

### Feature notes:
- CLI `trigger dev` works as before
- `trigger dev --branch my-branch` to create a new branch and run
against it.
- `trigger dev archive --branch my-branch` to archive (or in webapp).
- New webapp page to manage and archive dev branches, currently feature
flagged.

### Implementation details:
- No changes to data model, no backfill. `isBranchableEnvironment`
column is ignored for dev branches, we use `parentEnvironmentId IS NULL`
instead.
- `x-trigger-branch` overloaded for preview and dev branches
- New `TRIGGER_DEV_BRANCH` env var available locally.
`TRIGGER_PREVIEW_BRANCH` overloaded for child runs.
- Lots of new glue code to sanitise the branch checks.

### Rollout
- Deploy webapp/API changes (all backwards compatible)
- Manual tests on some orgs
- Deploy docs, release CLI, flip feature flag for webapp feature

### NB
- `api.v1.projects.$projectRef.environments.ts` will return
`isBranchableEnvironment: true` for all dev environments.

### Prerequisites
- [x] Typecheck will not pass until we make a new release of
`@trigger.dev/platform` and bump it here
This commit is contained in:
Chris Arderne
2026-06-26 09:01:37 +01:00
committed by GitHub
parent bc605eedaf
commit df78ef96d9
74 changed files with 2589 additions and 454 deletions
+92
View File
@@ -0,0 +1,92 @@
---
title: "Development branches"
sidebarTitle: "Dev branches"
description: "Run multiple local dev sessions in isolation by giving each one its own development branch. Use branches to keep parallel work (in separate worktrees, directories, or agents) from clashing."
---
Every project starts with a single development environment called `default`. A **dev branch** is an isolated environment that lives under development, with its own runs, schedules, and concurrency.
Branches are useful when you run more than one local dev session at a time. Give each session its own branch so their runs don't collide:
- Run several [git worktrees](https://git-scm.com/docs/git-worktree) or copies of your project in parallel, one branch each.
- Let multiple coding agents each work in their own branch without stepping on one another.
When you're done with a branch, you can archive it to free up a slot or just re-use it.
## Run a dev session on a branch
Log in with the CLI first:
<CodeGroup>
```bash npm
npx trigger.dev@latest login
```
```bash pnpm
pnpm dlx trigger.dev@latest login
```
```bash bun
bunx trigger.dev@latest login
```
</CodeGroup>
Then start a dev session on a branch with the `--branch` flag. If the branch doesn't exist yet, it's created:
<CodeGroup>
```bash npm
npx trigger.dev@latest dev --branch my-feature
```
```bash pnpm
pnpm dlx trigger.dev@latest dev --branch my-feature
```
```bash bun
bunx trigger.dev@latest dev --branch my-feature
```
</CodeGroup>
Without `--branch`, the session runs on the `default` branch.
<Tip>
You can also set the branch with the `TRIGGER_DEV_BRANCH` environment variable instead of the flag.
</Tip>
## Archive a branch
Archive a branch from the CLI when you no longer need it. The CLI detects your local git branch, or you can name one with `--branch`:
<CodeGroup>
```bash npm
npx trigger.dev@latest dev archive --branch my-feature
```
```bash pnpm
pnpm dlx trigger.dev@latest dev archive --branch my-feature
```
```bash bun
bunx trigger.dev@latest dev archive --branch my-feature
```
</CodeGroup>
You can also create and archive branches from the **Dev branches** page in the dashboard.
## Limits on active branches
Each branch has its own concurrency, so we limit how many can be active per project. Archive a branch at any time to unlock another slot.
| Plan | Active dev branches |
| ----- | ------------------- |
| Free | 25 |
| Hobby | 25 |
| Pro | 25 |
Need more? [Get in touch](https://trigger.dev/contact) and we'll raise the limit.
+1
View File
@@ -199,6 +199,7 @@
"deploy-environment-variables",
"github-actions",
"deployment/preview-branches",
"deployment/dev-branches",
"deployment/atomic-deployment",
{
"group": "Deployment integrations",
+3 -3
View File
@@ -119,7 +119,7 @@ await envvars.update("proj_1234", "preview", "DATABASE_URL", {
</Tab>
<Tab title="cURL">
To target a specific preview branch, include the `x-trigger-branch` header in your API requests with the branch name as the value:
To target a specific preview or development branch, include the `x-trigger-branch` header in your API requests with the branch name as the value:
```bash
curl --request PUT \
@@ -137,8 +137,8 @@ curl --request PUT \
This will set the `DATABASE_URL` environment variable specifically for the `feature-xyz` preview branch.
<Note>
The `x-trigger-branch` header is only relevant when working with the `preview` environment (`{env}
` parameter set to `preview`). It has no effect when working with `dev`, `staging`, or `prod`
The `x-trigger-branch` header is only relevant when working with the `preview` or `dev` environments (`{env}
` parameter set to `preview` or `development`). It has no effect when working with `staging`, or `prod`
environments.
</Note>