> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Clean Up Flags

> Learn how to run flag cleanup scans to find and remove stale flags.

export const HowToSchema = ({name, description, steps = []}) => {
  const schema = {
    "@context": "https://schema.org",
    "@type": "HowTo",
    name,
    description
  };
  if (steps.length > 0) {
    schema.step = steps.map((s, i) => ({
      "@type": "HowToStep",
      position: i + 1,
      name: typeof s === "string" ? s : s.name,
      text: typeof s === "string" ? s : s.text || s.name
    }));
  }
  return <script type="application/ld+json" dangerouslySetInnerHTML={{
    __html: JSON.stringify(schema)
  }} />;
};

<HowToSchema
  name="Clean Up Flags"
  description="Learn how to run flag cleanup scans to find and remove stale flags."
  steps={[
{
  name: "Go to Flag Cleanup",
  text: "Select Flags > Cleanup in the sidebar.",
},
{
  name: "Run a scan",
  text: "Click Run scan. The scan analyzes your flags and connected repositories for inactive flags, archived flags still referenced in code, and single variant flags.",
},
{
  name: "Review the results",
  text: "Each detected flag shows the signal type and any code references. Review the list and decide what to do with each flag.",
},
]}
/>

[Flag cleanup](../flags/flag-cleanup) scans your flags and connected repositories to find flags that are no longer in use. Each scan detects three kinds of stale flags—inactive flags, archived flags still referenced in code, and single variant flags—and can archive them or open cleanup pull requests automatically.

<Note>
  The Confidence home page also shows a **Clean up your workspace** card when
  any of your flags haven't been applied in over a week. It's a quick way to
  archive individual flags without running a full scan.
</Note>

## Run a Manual Scan

<Steps>
  <Step title="Go to Flag Cleanup">
    Select **Flags > Cleanup** in the sidebar.
  </Step>

  <Step title="Click Run scan">
    The scan analyzes your flags and any connected repositories. Results appear
    when the scan completes.
  </Step>

  <Step title="Review the results">
    Each row shows the flag name, the signal type (inactive, archived in code,
    or single variant), and any code references found.

    * For flags without code references, click **Archive** to archive the flag
      directly, or **Dismiss** to skip it.
    * For flags with code references, click **Open PR** to have a coding agent
      open a cleanup pull request in the affected repository.
  </Step>
</Steps>

## Set a Scan Schedule

<Steps>
  <Step title="Go to Flag Cleanup">
    Select **Flags > Cleanup** in the sidebar.
  </Step>

  <Step title="Open Schedule settings">
    Click **Schedule** in the top right.
  </Step>

  <Step title="Set the frequency">
    Choose how often the scan runs—daily, weekly, or monthly—and click
    **Save**.
  </Step>
</Steps>

Scheduled scans run automatically at the configured interval. You can still run a manual scan at any time.

## Enable Auto Archive

With auto archive enabled, Confidence automatically archives inactive flags that have no references in your connected repositories. You don't need to review and manually archive each one.

<Steps>
  <Step title="Go to Flag Cleanup">
    Select **Flags > Cleanup** in the sidebar.
  </Step>

  <Step title="Open settings">
    Click **Settings** in the top right.
  </Step>

  <Step title="Turn on auto archive">
    Enable **Auto archive inactive flags** and click **Save**.
  </Step>
</Steps>

<Note>
  Auto archive only applies to inactive flags with no code references. Flags
  that are still referenced in code are never archived automatically—they appear
  in scan results for you to review.
</Note>

## Related Resources

<CardGroup cols={2}>
  <Card title="Flag cleanup reference" href="/docs/flags/flag-cleanup">
    Signal types, automatic archive, and cleanup pull requests explained
  </Card>

  <Card title="Archive a flag" href="/docs/how-to-guides/archive-flag">
    Manually archive a flag that's no longer needed
  </Card>

  <Card title="Flags reference" href="/docs/flags/create-flags">
    Flag schemas, variants, and lifecycle
  </Card>
</CardGroup>
