Skip to content
Latchkey

How to Manage Long-Running Feature Work With Flags

Feature flags let you merge incomplete work to main safely, replacing long-lived branches so integration and CI stay continuous.

Long-running features do not need a long-lived branch. Merge the code to main behind a flag that keeps it off in production. CI tests both flag states, and you flip the flag when the feature is ready. This is the trunk-based answer to big features.

Steps

  • Guard the new code path behind a flag that defaults off.
  • Merge small increments to main behind the flag.
  • Test both flag states in CI with a matrix.
  • Flip the flag on when the feature is complete, then remove it.

Test both flag states

.github/workflows/ci.yml
jobs:
  test:
    strategy:
      matrix:
        flag: ['off', 'on']
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: npm ci
      - run: npm test
        env:
          FEATURE_NEW_CHECKOUT: ${{ matrix.flag }}

Gotchas

  • Stale flags accumulate; schedule their removal once the feature is fully rolled out.
  • Untested off-by-default paths rot; keep both states in CI until you remove the flag.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →