← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Trunk-Based Development

DevOps Intermediate
debt(d7/e7/b7/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The detection_hints note automated detection is 'no' and the code_pattern is 'Long-lived feature branches >1 week; complex merge ceremonies; large merge conflicts from diverged branches.' Tools listed (git, github, launchdarkly) can surface branch age metrics but require deliberate inspection — no tool automatically flags TBD violations. A team drifts away from TBD gradually and only careful process review or CI pain reveals it.

e7 Effort Remediation debt — work required to fix once spotted

Closest to 'cross-cutting refactor across the codebase' (e7). The quick_fix describes a conceptually simple change (commit to main, use feature flags), but operationalizing TBD requires changing developer habits, branch policies, CI pipeline configuration, introducing feature flag infrastructure (e.g. LaunchDarkly), and updating team process across the entire organization. Common mistakes list multiple interrelated practices (feature flags, review culture, branch discipline) that all must change together — this is a cross-cutting, team-wide remediation.

b7 Burden Structural debt — long-term weight of choosing wrong

Closest to 'strong gravitational pull' (e7, mapped to b7). TBD applies to all web and CLI contexts per applies_to, and its tags span devops, git, ci-cd, and team-process — meaning every developer, every feature, every deployment is shaped by this choice. Abandoning or adopting TBD reshapes how PRs, CI pipelines, feature releases, and hotfixes are managed. It exerts gravitational pull on every change made to the codebase.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap — a documented gotcha most devs eventually learn' (t5). The misconception field explicitly states: 'Trunk-based development means committing untested code directly to main' — developers conflate TBD with cowboy coding or no-review workflows, when in fact it demands higher testing discipline and feature flags. This is a well-documented, common misunderstanding that misleads competent developers unfamiliar with the practice.

About DEBT scoring →

Also Known As

trunk-based development TBD main branch development

TL;DR

All developers integrate small, frequent commits directly into a single shared branch (trunk/main), avoiding long-lived feature branches.

Explanation

Trunk-Based Development (TBD) requires developers to commit to the main branch at least once per day, keeping branches short-lived (hours, not weeks). This forces continuous integration — conflicts surface immediately rather than at merge time. Incomplete features are hidden behind feature flags. TBD reduces merge conflicts, improves team visibility, and enables true continuous deployment. It requires a comprehensive automated test suite and discipline around feature flags. Google, Facebook, and Netflix use variants of TBD at scale. It contrasts with GitFlow, where feature branches can live for weeks.

Common Misconception

Trunk-based development means committing untested code directly to main. TBD requires short-lived feature branches (hours, not days) merged via CI with passing tests — feature flags hide incomplete work from users. It demands higher testing discipline than long-lived branches, not less.

Why It Matters

Trunk-based development keeps all developers on a single main branch with short-lived feature branches — eliminating merge conflicts from long-lived branches and enabling continuous integration.

Common Mistakes

  • Feature branches that live longer than 1-2 days — divergence makes merges painful.
  • Not using feature flags to hide incomplete work — trunk-based requires deploying incomplete features safely.
  • Skipping code review for small changes — small changes still need review; pair programming is an alternative.
  • Confusing trunk-based development with no branching — short-lived branches are fine; long-lived ones are not.

Code Examples

✗ Vulnerable
# Long-lived feature branch — anti-pattern:
git checkout -b feature/new-payment-system
# 6 weeks of development
# 847 files changed
# Merge conflict hell with main

# Trunk-based:
git checkout -b feature/payment-step-1  # 1 day max
# Small, releasable increment behind a feature flag
git merge main  # Easy — only 1 day of divergence
✓ Fixed
# Trunk-based: all devs commit to main (or short-lived branches <1 day)

# Feature in progress but not ready → hide behind a flag
# 1. Create branch, work, push small commits daily
git checkout -b feat/new-checkout
# 2. Merge to main within a day — feature flag hides incomplete work
git checkout main && git merge feat/new-checkout

# Feature flag keeps it off for users until complete
if ($this->flags->isEnabled('new_checkout', $user)) {
    return $this->newCheckout->handle($cart);
}
return $this->legacyCheckout->handle($cart);

# CI runs on every push to main — must stay green
# If you break main, fix forward or revert immediately

Added 15 Mar 2026
Edited 22 Mar 2026
Views 54
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 0 pings W 1 ping T 0 pings F 0 pings S 1 ping S 0 pings M 1 ping T 1 ping W 0 pings T 2 pings F 0 pings S 1 ping S 1 ping M 0 pings T 3 pings W 0 pings T 1 ping F 1 ping S 0 pings S 1 ping M 0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 1 ping S 1 ping M 1 ping T 0 pings W
No pings yet today
PetalBot 1
Scrapy 8 Amazonbot 6 Perplexity 6 ChatGPT 6 SEMrush 5 Google 4 Ahrefs 4 Claude 2 Bing 2 PetalBot 2 Meta AI 1
crawler 41 crawler_json 5
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: High
⚡ Quick Fix
Commit directly to main (or short-lived branches <2 days) and use feature flags to hide incomplete work — this eliminates merge conflicts and keeps CI green at all times
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Long-lived feature branches >1 week; complex merge ceremonies; large merge conflicts from diverged branches
Auto-detectable: ✗ No git github launchdarkly
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: Medium ✗ Manual fix Fix: High Context: File Tests: Update


✓ schema.org compliant