# Trunk-based development

## What it is

Trunk-based development is a way of integrating software changes frequently on a shared mainline. Contributors make small changes that can be reviewed and combined quickly. They may work directly on the shared line under its controls or use short-lived branches before merging. The central idea is to keep the interval between building a change and checking it against the current shared product small enough that integration is routine.

The trunk is where contributions are brought together. It usually has agreed entry checks and a way to identify a coherent version of the code. A feature can be developed over several steps and remain unavailable to users until it is ready. A feature flag, configuration or other product boundary can separate integrating a safe implementation step from releasing the complete experience.

Shared integration still needs explicit release practices. A team may build an artefact from the trunk and promote that exact artefact through environments. Release tags or short-lived release branches can serve products that support more than one version. The meaningful question is how long independent development remains separated from the shared line and how quickly a change can be checked with everyone else's work.

## Why it matters

Long intervals between integrations can hide interactions. One team can change a representation while another team builds a feature against the earlier shape. Both branches may pass their own checks. When they finally meet, the two teams have to diagnose the change and its consequences at once. Smaller, frequent integrations give the teams feedback closer to the decision that caused it.

Smaller changes can also improve recovery. A release with a clear sequence of commits allows an operator to trace a defect to a decision and choose a bounded correction. The history needs meaningful descriptions and an artefact that can be traced back to it. Several small commits can still be hard to interpret if they leave intermediate states that make no sense outside a developer's own branch.

A team has to make routine integration easy enough to sustain. Slow or unreliable checks can encourage contributors to accumulate changes while waiting. Review work can also queue for people whose approval is normally required. Measure time spent waiting for integration, organise review ownership and make common checks reproducible. Frequent merging works when each change is small enough to evaluate and the shared line continues to carry a usable product.

## What it looks like in practice

Imagine a team adding a new report format. The first change introduces an internal representation that works with the current report. The second adds a renderer that can be exercised in tests. A later change exposes a control to selected readers. Each step can be reviewed and integrated while the existing route continues operating. The feature's visible release has an explicit check and can happen after its constituent changes are combined.

Set the shared checks around actual compatibility. Cover the old public signal during each transition, run representative tests against the candidate build, and record which artefact contains a change. A failing check should tell the contributor how to reproduce it. If a change must be separated before integration, establish the small part of the work it protects and integrate it once that condition is satisfied.

Engineer's repository history standards case study records common commit-message and documentation rules enforced by hooks across four repositories. That gives a concrete example of making a shared standard observable in tooling. A reviewable trunk can apply the same discipline to its entry controls and commit history. Contributors can see what changed, which prerequisite was checked and how to investigate a result.

Include a recovery drill. Pick a small change whose behaviour differs in the shared build and follow the revision through the release artifact. Decide how the team would restore the previous behaviour through a safe follow-up or the release process. A database change can require separate compatibility planning. Regular integration makes these choices visible sooner when it keeps changes small and supports actual recovery.

## Where it goes wrong

A short-lived branch can still contain a change too large to review or release safely. Choose a change with a clear purpose and an observable result that can be checked promptly. A useful step adds one observable behaviour or prepares a clearly described later step. Exercise the application between steps and make sure a delayed follow-up leaves an acceptable result.

The time to integrate a small change is a useful signal when it regularly exceeds the time to make it. Aggregate where it spends that time and review which checks found real disagreements. A check can protect a shared contract while still needing better fixtures or earlier feedback. A reproducible failure, a clear owner and a small repair can help a team retain both the control and the integration habit. Watch for repeated idle time spent waiting for the same dependency.

Feature flags can accumulate and turn temporary states into a complicated product. Give a flag an owner, a testing policy for the supported states and a condition for removing it. When two flags affect the same route, identify which combinations must work during rollout. An integration check can show an unintended interaction before the feature is broadly visible.

Finally, make the trunk's health visible beyond the merge button. Watch whether the source actually builds, how recently there was a good artefact and whether a new revision progresses through the relevant release checks. A team should be able to explain what a green result certifies. Frequency helps when each integration produces evidence people can act on and a shared version they can reliably move forward from.

## Further reading
* DORA on trunk-based development. Describes frequent small integrations and related delivery measures.
* Trunk-Based Development. Documents branch and release arrangements used with the practice.
* GitHub protected branches. Explains controls for a shared branch.

=> /portfolio/held-4-repositories-to-one-history-standard/ repository history standards case study
=> https://dora.dev/capabilities/trunk-based-development/ DORA on trunk-based development
=> https://trunkbaseddevelopment.com/ Trunk-Based Development
=> https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches GitHub protected branches

=> https://engineer.company/glossary/trunk-based-development/ This page on the web
