Loading...
PostHog's Go SDK provides straightforward flag evaluation, but in production services those checks spread across handler functions, middleware, and gRPC interceptors. FlagShark's AST walker finds every one.
FlagShark generates a PR that removes the dead branch and keeps only the winning code path
func handleExport(w http.ResponseWriter, r *http.Request) {
userID := auth.UserIDFrom(r.Context())
isBatchEnabled, _ := posthogClient.IsFeatureEnabled(
posthog.FeatureFlagPayload{
Key: "batch-export",
DistinctId: userID,
},
)
if isBatchEnabled {
startBatchExport(w, r)
} else {
startStreamExport(w, r)
}
}func handleExport(w http.ResponseWriter, r *http.Request) {
startBatchExport(w, r)
}FlagShark uses go/ast package for type-safe detection of SDK usage patterns to find every call to isFeatureEnabled(), getFeatureFlag(), getAllFlags()across your Gin, Echo, standard library 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 Go SDK uses struct-based flag payloads (`FeatureFlagPayload`) rather than positional arguments — when cleaning up, you need to remove the struct literal too, which can be several lines of code that a naive diff might miss.
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 walks your Go AST to find `IsFeatureEnabled` and `GetFeatureFlag` calls on the PostHog client. It parses `FeatureFlagPayload` struct literals to extract flag keys.
Yes. FlagShark detects `GetFeatureFlag` calls that return variant strings and maps each switch/case branch to a variant. It preserves the winning variant and removes the rest.
FlagShark identifies `posthogClient.Enqueue(posthog.Capture{...})` calls adjacent to flag checks and marks them for review. Analytics events may need to persist even after the flag is cleaned up.
Connect your repo, see stale flags in minutes, and get cleanup PRs automatically.
Free tier available • No credit card required • 5-minute setup
How to find, evaluate, and remove unused LaunchDarkly feature flags from Go microservices and CLI tools.
Identify and safely remove stale Split.io treatments from Go services using AST-based analysis.
Systematically identify and remove stale Unleash toggles from Go services and CLI applications.
Find and remove dead Flagsmith feature flags from Go web services and CLI applications.