What Is Trunk-Based Development?
Trunk-based development (TBD) is a source-control practice where all developers integrate their work into a single shared branch — called main or trunk — multiple times per day. There are no long-lived feature branches. There is no develop branch accumulating changes for weeks before a release. Just one branch, continuously integrated, continuously deployed.
Google, Meta, and Netflix all use trunk-based development at massive scale. The research in the *Accelerate* book identifies it as one of the highest-impact engineering practices for software delivery performance.
Why Long-Lived Branches Are Painful
When developers work in isolation for days or weeks, merging becomes an event — a stressful, conflict-heavy exercise in reconciling diverging histories. The longer the branch lives, the worse the merge. Teams call this merge hell, and it is the primary bottleneck in slow-moving delivery pipelines.
# The "merge hell" experience with long-lived branches
git checkout feature/big-redesign # branched 3 weeks ago
git merge main # 847 conflicts
# ... hours of manual conflict resolution
git push origin feature/big-redesignTrunk-based development eliminates this by keeping integration continuous. Conflicts surface within hours of being introduced, when they are trivial to resolve.
The Core Workflow
The TBD workflow is simple:
# Start from a fresh trunk
git checkout main
git pull origin main
# Make a small, focused change
# (complete a task in hours, not days)
# Run tests locally before pushing
npm test
# Push directly to main (or via a short-lived PR)
git add .
git commit -m "feat: add user avatar upload endpoint"
git push origin mainSome teams push directly to main; others use very short-lived pull requests (open, reviewed, and merged within a day) for code review. Both are valid forms of TBD.
Feature Flags: The Key Enabler
Trunk-based development requires that every commit to main is deployable. But incomplete features cannot be deployed to users. The solution is feature flags — toggle new code on and off at runtime without a deployment.
# Feature flags in environment configuration
features:
new_checkout_flow: false # off in production
redesigned_dashboard: true # on everywhere
beta_ai_suggestions: false # off until readyIncomplete features land in main hidden behind a flag. When the feature is ready, flip the flag — no deployment needed, no merge required.
PandaStack makes this easy: environment variables are managed per-deployment in the dashboard at [dashboard.pandastack.io](https://dashboard.pandastack.io), so you can toggle flags without touching code.
Branch Policies for Trunk-Based Development
Even with direct pushes to main, you should enforce quality gates via CI:
# .github/workflows/trunk-ci.yml
name: Trunk CI
on:
push:
branches: [main]
jobs:
quality-gate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- run: npm ci
- run: npm run lint
- run: npm test -- --passWithNoTests
- run: npm run buildIf any step fails, the deployment to PandaStack is blocked — the pipeline is the safety net that makes direct-to-trunk commits safe.
Continuous Deployment with PandaStack
Trunk-based development and PandaStack are a natural pair. PandaStack watches your main branch and auto-deploys every passing commit:
npm install -g @pandastack/cli
panda login
panda deploy --repo your-org/your-app --branch mainEvery commit that passes CI lands in production within minutes. This tight feedback loop means bugs are caught quickly, features reach users fast, and the team builds a sustainable rhythm of small, safe changes.
Making the Transition
If your team currently uses long-lived branches, transitioning to TBD is incremental:
- 1Shrink branch lifetime — set a team norm that no branch lives longer than two days.
- 2Invest in fast CI — if tests take 20 minutes, developers avoid running them. Target under 5 minutes.
- 3Add feature flags — introduce a simple flag system before removing long-lived branches.
- 4Automate deployment — connect your repository to PandaStack so merging to
mainautomatically deploys.
Within a few sprints most teams find they ship faster, merge less painfully, and spend far less time in integration meetings. That is the promise of trunk-based development.