StoicBuilder

HandbookX the PortusFeature flags

Xthe Portus, Ship it

Feature flags

1 min readUpdated 28 November

In plain words

A feature flag is a setting your code checks while it runs to decide whether to show a feature, so you can ship code switched off, turn it on for some users, and turn it off again in seconds.

Where you see it

Harbor's new file-sharing page merges to main behind a flag called file-sharing-v2, managed in a service such as LaunchDarkly, Unleash or PostHog. It goes on for the team first, then 5% of customers, then everyone, and when uploads start failing at 20%, someone switches it off without waiting for a deploy.

app/files/page.tsxserver
const sharingV2 = await flags.isEnabled("file-sharing-v2", { userId: user.id, teamId: user.teamId,}); return sharingV2 ? <SharingV2 /> : <Sharing />;
Both versions ship. The flag decides at request time which one each team sees.

What goes wrong

  1. Flags that never get removed

    A year later the code is full of flag checks nobody dares delete, and some combinations were never tested. Give each flag an owner and a removal date, and delete it once the feature is fully on.

  2. Hiding a feature only in the browser

    A flag checked only in the React component hides the button, but the API route still works for anyone who calls it. Check the flag on the server too.

  3. Deciding per request instead of per user

    If the flag rolls the dice on every request, a user sees the new page, then the old one, then the new. Bucket by user or team id so each one gets a steady answer.

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Put the new file-sharing page behind a server-side feature flag named file-sharing-v2, checked in both the page and its API routes and bucketed by team id. Keep the old path working while the flag is off, and add a comment naming the flag's owner and the date we plan to remove it.

Quick check

Sign in to earn +10 XP for it

Harbor's new billing page is behind a flag, switched on for 10% of teams. Errors spike. What's the fastest safe response?

Got a prompt that touches feature flags?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.