Loading...
Flagsmith's Python client uses `has_feature` and `get_value` methods that map cleanly to Python's conditional patterns. But when those checks are embedded in decorators, Django middleware, and template tags, you need AST analysis to find them all.
FlagShark generates a PR that removes the dead branch and keeps only the winning code path
from flagsmith import Flagsmith
flagsmith = Flagsmith(environment_key="YOUR_KEY")
def get_recommendations(user_id: str):
flags = flagsmith.get_environment_flags()
if flags.is_feature_enabled("personalized-recs"):
threshold = flags.get_feature_value("personalized-recs")
return generate_personalized(user_id, float(threshold))
return generate_default_recs(user_id)def get_recommendations(user_id: str):
return generate_personalized(user_id, 0.75)FlagShark uses Python AST module for static analysis of SDK imports and calls to find every call to has_feature(), get_value(), get_trait()across your Django, FastAPI, Flask codebase.
Each detected flag key is matched against your Flagsmith 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.
Flagsmith returns flag values as strings that Python code often casts to float or int — when inlining the value during cleanup, you need to preserve the type cast or use the correctly-typed literal to avoid subtle bugs.
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.
has_feature()get_value()get_trait()Plus custom patterns you define in .flagshark.yaml
FlagShark parses your Python source with the `ast` module and traces calls to `is_feature_enabled()`, `get_feature_value()`, and `has_feature()` on the Flagsmith client. It also detects the environment flags pattern with `get_environment_flags()`.
FlagShark detects Flagsmith checks in Django template tags and view context processors. It generates diffs that cover both the Python view code and the associated template logic.
FlagShark identifies `get_trait` calls and trait-based targeting logic. When a flag is removed, it checks whether the trait data was only used for that flag and marks it for cleanup.
Connect your repo, see stale flags in minutes, and get cleanup PRs automatically.
Free tier available • No credit card required • 5-minute setup
Step-by-step process for identifying and removing dead LaunchDarkly flags in Django, FastAPI, and Flask applications.
Find and clean up stale Split.io feature flag treatments in Django, FastAPI, and Flask projects.
Identify and safely remove stale Unleash toggles from Django, FastAPI, and Flask Python applications.
Find and remove dead PostHog flags from Django and FastAPI Python backends.
Find and remove stale ConfigCat flags from Django, FastAPI, and Flask Python applications.