Loading...
PostHog makes it easy to ship flags alongside your analytics — but that convenience leads to flag sprawl. FlagShark connects to your PostHog project to identify flags that have been fully rolled out, then generates clean TypeScript diffs.
FlagShark generates a PR that removes the dead branch and keeps only the winning code path
import { useFeatureFlagEnabled } from 'posthog-js/react';
function TrialBanner() {
const showNewBanner = useFeatureFlagEnabled('new-trial-banner');
if (showNewBanner) {
return <TrialBannerV2 />;
}
return <TrialBannerLegacy />;
}function TrialBanner() {
return <TrialBannerV2 />;
}FlagShark uses AST parsing with ts-morph for precise SDK call detection to find every call to isFeatureEnabled(), getFeatureFlag(), getAllFlags()across your React, Next.js, Node.js codebase.
Each detected flag key is matched against your PostHog project to check rollout status, last evaluation date, and whether the flag is archived or still active.
For each stale flag, FlagShark creates a pull request that removes the SDK call, eliminates the dead code branch, and preserves the winning path. Every PR includes a before/after diff you can review.
PostHog's feature flags and A/B experiments share the same API — make sure a flag isn't still being used to collect experiment data before removing it, or you'll lose statistical power mid-experiment.
Grep misses flags behind abstractions. AST-level scanning catches SDK calls that regex can't.
Every cleanup goes through code review. No surprises, no broken builds.
Only flags at 100% rollout for your configured threshold are suggested for removal.
New stale flags are detected automatically. Your codebase stays clean without manual audits.
isFeatureEnabled()getFeatureFlag()getAllFlags()Plus custom patterns you define in .flagshark.yaml
FlagShark traces imports from `posthog-js` and `posthog-js/react`, then finds every `useFeatureFlagEnabled()`, `posthog.isFeatureEnabled()`, and `posthog.getFeatureFlag()` call. It checks your PostHog project to determine flag status.
FlagShark checks whether a flag is actively running as an experiment in PostHog. If an experiment is still in progress, it warns you and prevents premature removal.
FlagShark detects `getFeatureFlagPayload()` calls and their associated type assertions. When cleaning up, it inlines the winning payload value and removes the type guard.
Connect your repo, see stale flags in minutes, and get cleanup PRs automatically.
Free tier available • No credit card required • 5-minute setup
A hands-on guide to finding and safely removing stale LaunchDarkly feature flags from TypeScript and React codebases.
Detect and remove abandoned Split.io treatments from your TypeScript frontend and Node.js backend.
Find and remove stale Unleash feature toggles from React, Next.js, and Node.js TypeScript projects.
Find and safely remove stale Flagsmith flags from React and Node.js TypeScript codebases.
Detect and remove stale ConfigCat feature flags from React and Node.js TypeScript projects.