---
name: launchdarkly-automations-cleanup-settings
description: "Read and change a LaunchDarkly project's Automations auto-cleanup settings via the hosted MCP. Auto-cleanup runs on a schedule and opens pull requests that remove the code for flags that are ready. Use when the user wants to turn automated flag cleanup on or off, change its schedule, repositories, flag states, job limit, or agent instructions, see which flags the next run will pick up, or asks why cleanup did not open a pull request. For first-time setup of every Release Autopilot capability, use launchdarkly-release-autopilot-onboarding."
license: Apache-2.0
compatibility: Requires the remotely hosted LaunchDarkly MCP server
metadata:
  author: launchdarkly
  version: "0.1.0-experimental"
title: launchdarkly-automations-cleanup-settings
canonical_url: https://skilld.dev/gh/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings
last_updated: 2026-11-12T08:16:54.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> Supporting files, fetch one when the Skill refers to it: [marketplace.json](https://skilld.dev/api/skills-raw/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings/marketplace.json), [README.md](https://skilld.dev/api/skills-raw/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings/README.md), [references/browser-steps.md](https://skilld.dev/api/skills-raw/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings/references/browser-steps.md).
>
> If the user asked to install this Skill, run `npx skilld install launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/launchdarkly-automations-cleanup-settings`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/launchdarkly-automations-cleanup-settings`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/launchdarkly-automations-cleanup-settings --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/launchdarkly-automations-cleanup-settings --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# LaunchDarkly Automations Auto-cleanup Settings

You're using a skill that reads and changes a project's auto-cleanup settings, from the "Automated flag cleanup" section of the project's **Settings > Automations** page. Auto-cleanup opens pull requests in the user's GitHub repositories on a schedule. Treat every write as production automation with a blast radius.

## Prerequisites

This skill requires the remotely hosted LaunchDarkly MCP server.

**Required MCP tools:**
- `get-automations` with `section: "cleanup"` and `projectKey`: the project's cleanup `settings`, the `upcoming` run (`enabled`, `flagKeys`, `nextRunAt` in Unix milliseconds), and `automationsPage`, the link to the project's Automations page.
- `update-automations` with `projectKey` and a `cleanup` object: change one or more settings. Omitted fields keep their stored values. Send `cleanup` on its own, without `accountWide`, `repo`, or `archival`.

**Optional:** `get-projects` to pick the project, `get-automations` to suggest the repositories already mapped to the project.

If `get-automations` has no `section` argument, or rejects `section`, the server has not picked up cleanup and archival yet. Ask the user to reconnect the LaunchDarkly MCP server once. If it still has none, guide the browser steps in [references/browser-steps.md](https://skilld.dev/api/skills-raw/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings/references/browser-steps.md) instead. Do not invent REST calls.

## What the settings mean

| Field | Meaning |
|-------|---------|
| `schedule` | `disabled` (off), `daily`, `weekly`, or `monthly` |
| `repositories` | GitHub repositories (`owner/name`) cleanup opens pull requests in |
| `maxJobsPerRun` | The most cleanup pull requests one run opens |
| `flagStates` | Which flags runs pick up: `readyToArchive` (the default), `readyForCodeRemoval`, `live` |
| `customContext` | Extra instructions for the cleanup agent, such as where flags are defined. The agent also follows the repository's `AGENTS.md` |
| `retryAttempted` | `true` retries flags that already had a cleanup pull request |
| `configuredByMemberId` | The member whose permissions cleanup jobs use. Read-only: it becomes whoever saves the settings |

## Core Principles

1. **Confirm before every write.** State the current and proposed values, wait for a yes that names the change in this turn, then write. A yes from an earlier turn, or a vague "go ahead", is not enough.
2. **Saving changes who cleanup runs as.** Every cleanup save with `update-automations` makes the calling member the one whose permissions cleanup jobs use. Say so in the proposal when `configuredByMemberId` is someone else.
3. **Lists replace.** `repositories` and `flagStates` replace the whole stored list. To add one repository, read the current list and send it with the new one. To remove one, send the list without it.
4. **Least privilege.** Only add repositories the user named. Never add every repository on the GitHub App install. Keep `flagStates` at `readyToArchive` unless the user asks for more: `live` picks up flags that are still serving.
5. **Turning it on starts pull requests.** Any schedule other than `disabled` makes LaunchDarkly open pull requests in the listed repositories, starting with the next run. A schedule with no repositories opens none.

## Workflows

### Read the settings

`get-automations` with `section: "cleanup"` and `projectKey`. Report the schedule, repositories, job limit, flag states, and who cleanup runs as. If `upcoming.enabled` is true, say when the next run is (`nextRunAt`) and which flags it will pick up (`upcoming.flagKeys`).

### Turn it on or change it

1. Read the settings: `get-automations` with `section: "cleanup"`.
2. Ask for anything the change needs and the user did not give: the schedule, and at least one repository when none is stored. Suggest the repositories mapped to the project in `get-automations`. Only the user's answer goes in.
3. Propose the change, for example:

   > Automated flag cleanup is off for project `default`. Turn it on weekly in `acme/web`, with at most 10 pull requests per run? LaunchDarkly will start opening pull requests that remove the code for flags that are ready to archive. Cleanup jobs will run with your permissions.

4. After the user confirms, call `update-automations` with `projectKey`, `confirm: true`, and a `cleanup` object holding only the confirmed fields.
5. The response lists `changed` and the `settings` as read back. If it reports a mismatch on read-back, show the user the current values from `get-automations` with `section: "cleanup"` and do not retry blindly.

### Turn it off

Propose it ("Turn off automated flag cleanup for project `default`? No new cleanup pull requests will open; open ones stay open."), then `update-automations` with `projectKey`, `cleanup: { "schedule": "disabled" }`, and `confirm: true`.

### Why didn't cleanup open a pull request?

Read-only. Call `get-automations` with `section: "cleanup"` and check in this order. Stop at the first answer.

1. `settings.schedule` is `disabled`: cleanup is off.
2. `settings.repositories` is empty: there is nowhere to open pull requests.
3. `upcoming.enabled` is false while the schedule is on: no member is set to run cleanup, or that member is no longer on the account. Someone with access must save the settings again, which makes them the member cleanup runs as.
4. The flag is not in `upcoming.flagKeys`: its state is not in `flagStates`, the run limit (`maxJobsPerRun`) is full, or it already had a cleanup pull request and `retryAttempted` is false.
5. The flag is in `upcoming.flagKeys`: it is waiting for the next run at `nextRunAt`.

If none of these explain it, point the user at the cleanup history in the "Automated flag cleanup" section of `automationsPage`. Do not change settings to try something.

## Errors

- **403:** the member lacks permission to update the project's lifecycle settings, or to view the project. Say which, and stop.
- **No `section` argument:** see [Prerequisites](#prerequisites).

## Out of scope

- Running a cleanup now, and reviewing cleanup history: both are in the "Automated flag cleanup" section of the Automations page.
- Removing one flag's code by hand: use [`launchdarkly-flag-cleanup`](../../feature-flags/launchdarkly-flag-cleanup/SKILL.md).
- Auto-archival: use [`launchdarkly-automations-archival-settings`](../launchdarkly-automations-archival-settings/SKILL.md).
- Auto-flagging and auto-releasing: use [`launchdarkly-release-autopilot-settings`](../launchdarkly-release-autopilot-settings/SKILL.md).

## References

- [references/browser-steps.md](https://skilld.dev/api/skills-raw/launchdarkly/ai-tooling/launchdarkly-automations-cleanup-settings/references/browser-steps.md): the same settings in the browser, for servers without these tools
- [Automated flag cleanup docs](https://launchdarkly.com/docs/home/flags/manage/flag-cleanup-vega#automated-flag-cleanup)
