Skip to content

November 13, 2025

Optimizing deployments using trunk-based development

Illustration of devops

Most companies with a development team eventually get to the point where shipping software is a bottleneck. It’s very hard to stay consistently fast when business needs frequently change, the software stack evolves, and teams grow. New processes are introduced to manage risk, deployments needs to go through multiple environments and the general feeling is that shipping a feature becomes a complex operation.

This is a very common problem in the industry, and one that we fixed in most companies we’ve worked with by combining trunk-based development (TBD) with good CI/CD pipelines. When your team have fully confidence in their deployment process, where breaking things is very hard and even if they happen, they are safely contained, shipping software becomes a non-event.

This article will explore how trunk-based development, CI/CD best practices and feature flags can be combined to create a deployment process that is fast, safe and auditable.

Why trunk-based development actually speeds teams up

TBD is a source-control branching model that developers collaborate in a single branch called main (or trunk). The main idea is that everyone integrates small changes frequently, which reduces merge conflicts and keeps the codebase healthy. The merge branches are short-lived and typically last only a few days. On every pull request (PR), an automated pipeline runs tests, linters, security checks, and other validations to ensure that the code is of high quality before it is merged into main. The PR is carefully reviewed by other developers and is merged as soon as it is approved and passes all checks. In sequence, every merge to main triggers an automated deployment to production or staging environments.

Mitigating risk while moving fast

At first glance, seems dangerous to have everyone merging to main all the time. However, with great power comes great responsibility. Trunk-based development relies on automated pipelines and feature flags to keep risk low while allowing teams to move fast. So whenever you want to introduce TBD in your organization, you need to make sure that you have the following guardrails in place:

  • Automated testing and validation. Every PR must go through automated pipeline that runs tests, linters, security checks, and other validations to ensure that the code is of high quality before it is merged into main.
  • Code reviews. Every PR must be reviewed by other developers to ensure that the code is of high quality and follows best practices. Every merge that happens is the team’s collective responsibility.
  • Feature flags. It’s a good practice to use feature flags to control the rollout of new features. This allows teams to deploy code to production without exposing it to users until it’s ready. If something goes wrong, the feature can be quickly disabled at runtime without requiring a new deployment.

How to test the code before it ships?

This is a common question on every team that hears about trunk-based development for the first time. It’s a very good question because it touches the core of risky deployments. If the main branch is the source of truth for production, and developers are frequently merging code and deploying it, how can we ensure that the code is safe to ship?

In addition to the automated testing, reviews, and feature flags above, critical systems should layer on these practices:

  • Let CI/CD pipelines fail fast. Pipelines run on every push and PR, and a red build blocks the merge. No exceptions.
  • Lean on PR previews. Use platforms like Cloudflare Pages, Vercel, or Netlify to spin up review deploys for every branch so product, QA, and ops can explore the exact artifact that will hit production.
  • Mirror prod data safely. Use synthetic datasets and contract tests to catch schema or integration drift before users do by keeping staging environments close to production.

With PR previews, you can test the exact artifact that will hit production before merging to main. This allows product, QA, and ops to explore the changes in a safe environment and catch any issues before they reach users.

Trunk-based development is actually safer!

If you ship infrequently, every deployment is a high-stakes event. The larger the change set, the more likely something will go wrong. When things go wrong, it’s harder to pinpoint the root cause because multiple changes were introduced at once. This increases the risk of prolonged outages and complex rollbacks. Trunk-based development may look risky because of the frequent merges to main, but in reality, it reduces risk by keeping change sets small and manageable. A rollback is as simple as reverting a single PR, and the smaller change sets make it easier to identify and fix issues quickly.

Deploying continuously without burning out the team

Trunk + automation optimizes for flow and keeps stress low:

  • Daily production releases. Every merge to main cuts a deploy, so value lands quickly and rollback windows stay tiny.
  • Automated change notes. Your CI/CD platform can post summaries to Slack, Linear, or Jira so stakeholders stay current without another status call.
  • Measured incident response. git revert plus a redeploy resolves most mistakes in minutes because only a few slices shipped.

Bringing it into your organization

  1. Start small. Pick a single team or service to pilot trunk-based development. Learn from the experience and iterate on the process.
  2. Invest in automation. Ensure that your CI/CD pipelines are robust and can handle the increased frequency of deployments.
  3. Educate the team. Trunk-based development requires a cultural change. Developers need to understand the importance of small, frequent merges and the use of feature flags.
  4. Monitor and measure. Track key metrics such as deployment frequency, lead time for changes, and mean time to recovery (MTTR) to assess the impact of trunk-based development on your team’s performance.

Trunk-based development keeps deployments predictable, fast, and fully auditable—the exact posture we need when we are running high-trust platforms. In follow-up posts we will dig deeper into how we run PR previews and feature flags so these habits scale across every client repo.

Further reading

For a deeper dive into the practices described here, start with trunkbaseddevelopment.com.