Hyphen

Stale Feature Flag Cleanup

Learn how Hyphen Agent identifies and helps clean up stale feature flags to reduce release risk and code complexity, turning unused flags into reviewable removal work.

Hyphen Agent can identify stale Toggle feature flags and prepare cleanup pull requests for review. Stale feature flag cleanup reduces release risk and code complexity by turning unused or fully settled flags into reviewable removal work. Use it to reduce technical debt from flags that are no longer active or no longer changing behavior.

Table of Contents

Requirements

Stale feature flag cleanup needs:

  • Hyphen Toggle usage data.
  • Feature flags that are not marked perpetual.
  • A connected GitHub repository for the app when code cleanup pull requests are needed.
  • Permission to run or manage the applicable Agent task policy.

How It Works

Agent analyzes Toggle flag activity and identifies flags with no recent usage or unchanged return values over a 90-day window.

When Agent finds stale flags, it can:

  • Mark eligible flags as stale.
  • Exclude flags marked as perpetual.
  • Use connected repository context to find stale flag references in code.
  • Open a cleanup pull request for review.

Agent delivers code changes through pull requests. Your team reviews, tests, and merges those changes through your normal repository workflow.

Automatic and Manual Runs

Policy-driven stale feature flag cleanup tasks run automatically based on the Agent task policy set at the organization level. Admins can enable or disable the cleanup policy and choose one of these schedules:

  • Manual only.
  • Every day.
  • Every week.
  • Every month.
  • Every quarter.

If you have permission, ask Hyphen Agent to run stale feature flag cleanup manually. Teams can ask Agent to run cleanup manually even when the organization policy is set to manual only.

Results

Agent task and run views show the cleanup run, related feature flags, repository context, pull request status, and any required approvals.

Things to Know

  • The stale window is based on no recent usage or unchanged return values over 90 days.
  • Perpetual feature flags are excluded from stale flag cleanup.
  • Pull request cleanup requires a connected GitHub repository for the affected app.
  • Cleanup changes are reviewable and are not merged automatically.
  • Users without policy management access may be able to view the policy but cannot change it.