lockstep
3 min readNaman Jain

Trunk-based development, with feature flags and AI agents

Trunk-based development explained: one main branch, short-lived feature branches, feature flags, vs GitFlow, and how to keep it working when AI agents open PRs.

A team's release branch has drifted from main for three weeks. Merging it back takes two days, breaks the build twice, and reintroduces a bug fixed on main last week. Everyone agrees never to do that again, and then does it again next quarter.

Trunk-based development avoids that by not having the long-lived branch in the first place. This guide follows trunkbaseddevelopment.com, checked on 16 November 2026.

The model

The site defines trunk-based development as a branching model where developers collaborate on one branch, trunk, now usually main, and resist creating other long-lived development branches by using documented techniques. The payoff: no merge hell, a build that doesn't break, and a codebase that's always releasable.

It's described as a key enabler of continuous integration: when everyone commits to trunk several times a day, it's easy to meet CI's core requirement that every team member commits to trunk at least once every 24 hours.

Two styles

StyleHowFits
Direct to trunkCommit and push to mainVery small teams
Short-lived feature branchesBranch, open a PR, review quickly, mergeMost teams

The site's rule for the second: branches must be short-lived and the product of a single developer's workstation, solo, paired, or mobbed. They count as trunk-based development only if merged after a prioritized code review, and time waiting for review counts toward the branch's life.

Before pushing, teams run a full pre-integration build locally: compile, unit tests, integration tests.

Shipping bigger changes

Work that can't finish in a day still merges daily, using:

  • Feature flags: merge incomplete code turned off.
  • Branch by abstraction: introduce the new implementation behind an interface while the old one keeps working, then switch over.
  • Don't break the build: every merge leaves main releasable.

Trunk-based vs GitFlow

Trunk-basedGitFlow
Long-lived branchesOne: mainSeveral: develop, release, and so on
Feature branchesHours to a day or twoCan live for weeks
IntegrationContinuousAt merge time
Unfinished workBehind flagsOn its branch

The trunk-based development site recommends it over GitFlow and other models with multiple long-running branches.

Trunk-based development with AI agents

Agents change the volume, not the rules.

  • Keep agent PRs small. An agent can produce a 2,000-line branch in an hour. Ask for one change at a time.
  • Same checks, before merge. Agent branches run the same pre-integration build and CI.
  • Review fast. The site counts review wait toward branch lifetime. A queue of agent PRs waiting for review is a queue of aging branches. See AI code review best practices.
  • Flags for agent-built features too. Merge behind a flag, turn on when verified.
  • Parallel agents, separate branches. Use worktrees so parallel sessions don't edit the same files.

What trunk doesn't carry

Main tells everyone what the code is. It doesn't say what the team decided last week about where the code is going. With many small merges from many people and agents, that gap shows up quickly.

Where Lockstep fits

Lockstep captures decisions from PRDs, Slack, and pull requests, routes each to its owner for approval, and briefs Claude Code sessions on the ones that apply, so each small change starts from the same decisions.

See how it works.

Sources checked 16 November 2026

For delivery metrics this improves, see DORA metrics. For repository layout, see monorepo vs polyrepo.

Frequently asked questions

What is trunk-based development?
A source control branching model where developers collaborate on one branch, called trunk or main, and avoid other long-lived development branches. The trunkbaseddevelopment.com site describes it as a key enabler of continuous integration and continuous delivery.
Can I use pull requests with trunk-based development?
Yes, as long as feature branches are short-lived and merged after a prioritized code review. The site notes that time spent waiting for review counts toward a branch's lifetime, so slow reviews undermine the model.
What is the difference between trunk-based development and GitFlow?
GitFlow uses several long-running branches, such as develop and release branches. Trunk-based development keeps one main branch and only short-lived feature branches. The trunk-based development site recommends it over GitFlow and other models with long-running branches.
How do you ship unfinished features with trunk-based development?
Behind feature flags, which let incomplete code merge to main turned off, or with branch by abstraction, which introduces a new implementation behind an interface while the old one keeps working. Both let work merge daily without exposing it to users.
Does trunk-based development work with AI coding agents?
It can, if agent-written branches stay small and short-lived like anyone else's, pass the same pre-merge checks, and get prompt review. Large agent-generated PRs that sit for days break the model the same way large human ones do.

Keep reading