# Trunk-Based Development

A source-control practice in which developers integrate small changes into one shared mainline frequently and avoid long-lived development branches.

- Type: practice
- Domain: Engineering & architecture
- Level: Advanced
- Last reviewed: 2026-09-22
- Original: [Soroush’s Product Wiki](<https://wiki.soroush.uk/topic/trunk-based-development/>)

## What it means

Trunk-based development is a branching and integration practice centered on a single shared branch, commonly called trunk or main. Developers either commit directly with suitable controls or use short-lived branches that are merged quickly. Incomplete capabilities are kept safe through small increments, abstractions, or feature flags rather than remaining isolated in long-running branches.

## Why it matters

Frequent integration reduces the distance between each developer's code and the current system. Smaller differences are generally easier to review, test, merge, and diagnose than large branch batches. The practice also gives continuous integration a truthful view of the software and supports release processes that do not depend on coordinating prolonged branch merges.

## When to use it

Use trunk-based development when a team can maintain fast automated checks, review small changes promptly, and restore a broken mainline quickly. It is especially useful for teams pursuing continuous delivery. Regulated or safety-critical environments can still use it, but may require explicit approvals, traceability, and release controls around the mainline.

## How it works

1. Maintain one authoritative, releasable mainline and define protections appropriate to the repository's risk.
2. Break work into small, backward-compatible changes that can be integrated at least daily.
3. Use direct commits or short-lived branches, keeping review queues brief and avoiding branch dependencies.
4. Run automated build and test checks for every proposed integration.
5. Hide incomplete user-facing behavior with safe techniques such as feature flags or branch by abstraction.
6. Fix or revert mainline failures immediately, then improve controls that failed to detect them.

## A practical example

A payments team replaces a fraud provider over several weeks. Instead of maintaining a replacement branch, it first introduces a provider interface, then adds the new adapter, shadow comparisons, and controlled routing in separate small changes. Every change reaches main after review while production continues using the established provider until validation is complete.

## Where it breaks

The practice exposes weak test suites, slow builds, oversized work items, and delayed reviews; adopting the branch rule alone does not solve those problems. Feature flags can accumulate complexity, and direct commits require disciplined safeguards. Teams maintaining several supported product versions may still need release branches for patches, even while current development stays on trunk.

## Common mistakes

- Calling branches short-lived while allowing them to remain open for many days.
- Merging incomplete changes without a safe way to keep behavior dormant.
- Permitting a failing mainline to remain broken while more changes accumulate.
- Measuring success by branch count instead of integration frequency and recoverability.

## Visualization

[View the visualization on the website](<https://wiki.soroush.uk/topic/trunk-based-development/#visualization-trunk-based-development>)

## Sources

1. [Trunk-Based Development](<https://dora.dev/capabilities/trunk-based-development/>) — DORA · Research-based capability guide
2. [Trunk Based Development](<https://trunkbaseddevelopment.com/>) — TrunkBasedDevelopment.com · Professional technical reference

## Related topics

- [Continuous Integration](<https://wiki.soroush.uk/topic/continuous-integration/>)
- [CI/CD Pipeline](<https://wiki.soroush.uk/topic/cicd-pipeline/>)
- [Code Review](<https://wiki.soroush.uk/topic/code-review/>)
