cleanup-feature-flags
Skill127 starsChanged 31 days agoApache-2.0View on GitHub
Remove a launched Harness FME feature flag from application code, keeping the treatment FME serves today, and open a pull request. Use when asked to remove a flag from code, hardcode the winning treatment after a rollout, or pay down flag debt for a specific flag. Do not use for finding stale flags (discover-feature-flags) or archiving and deleting flags in FME (manage-flag-lifecycle). Trigger phrases: remove flag from code, hardcode treatment, flag cleanup, flag debt, clean up feature flag.
In this repository76 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/harness.mdcCursor rule
- manage-rolesSkill
- manage-usersSkill
- create-agentSkill
- create-agent-templateSkill
- dbops-changesetSkill
- choose-metricSkill
- create-experimentSkill
- create-feature-flagSkill
- create-metricSkill
- discover-feature-flagsSkill
- explain-flagSkill
- feature-flag-onboardingSkill
- fme-pipelineSkill
- instrument-feature-flagSkill
- instrument-metricSkill
- manage-experimentsSkill
- manage-flag-lifecycleSkill
- manage-segmentsSkill
- review-experiment-resultsSkill
- update-flag-targetingSkill
- create-connectorSkill
- create-environmentSkill
- create-infrastructureSkill
- create-secretSkill
- create-serviceSkill
- ai-operationsSkill
- analyze-costsSkill
- audit-reportSkill
- chaos-code-risk-scanSkill
- chaos-dr-testSkill
- chaos-experimentSkill
- create-policySkill
- deployment-readinessSkill
- dora-metricsSkill
- gitops-statusSkill
- incident-responseSkill
- manage-idpSkill
- manage-slosSkill
- optimize-pipelineSkill
- pr-analysisSkill
- scorecard-reviewSkill
- security-reportSkill
- sei-analyticsSkill
- template-usageSkill
- create-pipelineSkill
- create-pipeline-v1Skill
- create-templateSkill
- create-triggerSkill
- debug-pipelineSkill
- manage-freeze-windowsSkill
- migrate-pipelineSkill
- run-pipelineSkill
- create-sbomSkill
- enforce-sbomSkill
- manage-artifactsSkill
- manage-cdeSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 7 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Remove one launched FME flag from application code and keep the branch FME serves today.
- Very specific: line 46
If the user named a flag, Get flag to confirm it exists and note its status and rolloutStatus.
- Distinctive: line 51
Run the experiment check with List experiments, covering every page of ACTIVE and PAUSED results before a verdict.
- Distinctive: line 54
Never infer the forward treatment from the code's default or fallback value.
- Very specific: line 60
If you find dynamic keys ("prefix-" + id,
flag-${id}), the verdict is blocked. - Distinctive: line 61
If you find no hits, the flag may live in another repo or only in a flag set.
- Very specific: line 71
If the forward treatment is control or a killed defaultTreatment, say plainly that the newer code path will be deleted.
- Distinctive: line 77
Search again for the key and for the batch and flag-set patterns.
- Distinctive: line 78
Run the repo's own build, lint and tests.
- Distinctive: line 106
Search the flag key first, then the batch and flag-set patterns.
- Distinctive: line 107
Keep the diff to the flag.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cleanup Feature Flags
Remove one launched FME flag from application code and keep the branch FME serves today. The work ends with a PR. FME is read-only here; archive happens later in manage-flag-lifecycle.
Related: discover-feature-flags finds candidates (stale audit); manage-flag-lifecycle archives after the change deploys.
Tools
Works through the Harness MCP server or the Harness CLI; names are from tool-map.md.
| Operation | MCP | CLI |
| List environments | harness_list · fme_environment · compact: false | harness list fme_environment --json |
| Get flag | harness_get · fme_feature_flag · params: { feature_flag_name } | harness get feature_flag <flag> --json |
| List flag definitions | harness_list · fme_feature_flag_definition · params: { feature_flag_name } · filters: { offset: 0, limit: 100 } · compact: false | harness list feature_flag:definition <flag> --json |
| List experiments | harness_list · fme_experiment · filters: { parent_type: "FEATURE_FLAG", parent_name, status: ["ACTIVE", "PAUSED"], offset: 0, limit: 100 } (apply pagination completeness checks) · compact: false | harness list experiment --parent-type FEATURE_FLAG --parent-name <flag> --status ACTIVE --json, then again with --status PAUSED |
Instructions
Load readiness.md before giving a verdict. Load sdk-patterns.md before searching code.
Phase 1: Establish scope
Follow scope-establishment.md. Fully paginate List environments per pagination before confirming the critical environments: by default those with isProduction, plus any the user adds. The critical set must be non-empty and explicitly confirmed back to the user before any later phase. If no environment is marked isProduction and the user hasn't named any, STOP and ask which environments are critical — do not treat an empty critical set as vacuously ready.
Phase 2: Pick the flag
If the user named a flag, Get flag to confirm it exists and note its status and rolloutStatus. If they want candidates instead, hand off to discover-feature-flags (stale audit) and come back with one flag.
Phase 3: Forward treatment and verdict
- Fully paginate List flag definitions for the flag with explicit MCP
filters.limit: 100and advancingfilters.offsetuntil a short page (sizeis ignored). Incomplete coverage stops code removal; it cannot establish a missing definition or the live forward treatment. Resolve the forward treatment for each critical environment per readiness.md. If any call site usesWithConfig, also resolve and compare each critical environment'sconfigurationsvalue for that treatment — identical treatment names with differing configs are blocked, not ready. - Run the experiment check with List experiments, covering every page of ACTIVE and PAUSED results before a verdict. An incomplete scan stops code removal. Here ACTIVE means blocked: code removal ends the experiment. PAUSED means caution.
- Give the verdict per readiness.md. Stop on blocked.
Never infer the forward treatment from the code's default or fallback value.
Phase 4: Find call sites
In the application repo, identify the SDK and search for the flag key, batch calls, flag sets, config-file entries and tests per sdk-patterns.md. For each hit, record file:line, which branch is the forward one, and any side effects (tracking, metrics, logging).
- If you find dynamic keys (
"prefix-" + id,`flag-${id}`), the verdict is blocked. Stop and ask the user how to proceed; automated removal can't be complete. - If you find no hits, the flag may live in another repo or only in a flag set. That is caution.
Phase 5: Present the plan and wait
Show:
- the forward treatment for each critical environment and why;
- each call site with the branch to keep and the code to delete;
- the verdict, with every caution reason;
- the last impression for each critical environment.
If the forward treatment is control or a killed defaultTreatment, say plainly that the newer code path will be deleted. Edit nothing until the user explicitly confirms this plan.
Phase 6: Edit and verify
- Work on a new branch in the application repo.
- At each call site, keep the forward branch and inline the config value if
WithConfigis used. Remove the dead branches, plus any flag-only constants, wrappers, imports, tests, fixtures, localhost or offline entries, and docs. Don't refactor unrelated code. - Search again for the key and for the batch and flag-set patterns. Any remaining hits must be explained: homonyms, other services, or fixtures the user wants to keep.
- Run the repo's own build, lint and tests. Fix any failures before moving on.
Phase 7: Open the PR
Confirm with the user before pushing or opening the PR. Use the repo's normal tooling and its own PR template and conventions (for example .github/pull_request_template.md or CONTRIBUTING). Don't impose a format. Whatever the template, the description must capture:
- the flag key and the treatment (or config value) that was kept;
- the FME evidence: org and project, critical environments checked, the forward treatment (and config value, if
WithConfigis used) in each, the verdict and any caution the user acknowledged, the experiment check result, and the last impression in each critical environment; - what was removed: branches, tests, config, imports;
- how it was verified: the clean search and the build and test run;
- which repo(s)/service(s) were searched — a clean search here does not prove the flag is unused elsewhere;
- the follow-up: archive the flag with
manage-flag-lifecycleonce this change is deployed everywhere the flag is evaluated, plus any other repos or services that may still reference it.
Phase 8: Hand off
Report the PR link and the follow-up: "After this deploys, use manage-flag-lifecycle to archive <flag>." Don't archive or delete here.
Examples
- "Remove
new-checkout-flowfrom this repo": verdict, plan, confirm, edit, verify, PR, then the archive hand-off. - "Hardcode the winning treatment for
dark-mode": resolve the forward treatment from the live definitions, not from the code. - "This flag is killed in prod, clean it up": the forward treatment is
defaultTreatment; warn that the new path is deleted. - "Which flags can we clean up?": hand off to
discover-feature-flags(stale audit). - "Archive the flag too": PR here first, then
manage-flag-lifecycleafter the deploy.
Performance Notes
- One complete paginated List flag definitions inventory covers the environments; it may require multiple calls. A page is not the whole inventory.
- Search the flag key first, then the batch and flag-set patterns. Wrappers often hide the literal key.
- Keep the diff to the flag. Unrelated refactors make the PR harder to review and revert.
Troubleshooting
| Issue | Action |
| Critical environments disagree | blocked. Ask the user to align targeting (update-flag-targeting) or narrow the critical set. |
| An environment has no definition | Its forward treatment is control, so the fallback branch is live there. Treat it as caution and confirm. |
| Flag is already archived but still in code | Allowed. The forward treatment is control; confirm the fallback branch is what users get today. |
| ACTIVE experiment on the flag | blocked. Finish it first (manage-experiments). |
Code uses WithConfig | Hardcode the treatment's config value from the definition, not just the name. If critical environments share the treatment name but have different config values, that's blocked, not ready — hardcoding would silently diverge environment behavior. |
| No explicit critical environment set | Stop and ask. Don't default to "ready" on an empty or unconfirmed critical set. |
| Only one repo searched | Record that scope in the PR and summary. Don't claim the flag is fully unused until other repos/services are confirmed or searched. |
| Dynamic flag keys | blocked. Stop and ask the user. |
| No call sites found | caution. Check other repos and flag sets before claiming the flag is unused. |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

