EveryInc/compound-engineering-plugin · error · Error

Unknown cleanup target: ${target}. Use one of: ${cleanupTarg

Error message

Unknown cleanup target: ${target}. Use one of: ${cleanupTargets.join(", ")}, all

What it means

`cleanup --target` accepts only the known cleanup targets — codex, opencode, pi, kiro, copilot, droid, qwen, windsurf — the literal "all", or a comma-separated list of those. `resolveCleanupTargets` splits the argument on commas and throws this error naming the first unrecognized entry, echoing the full list of valid values.

Source

Thrown at src/commands/cleanup.ts:650

  if (!(await isLegacyAgentArtifactOwned(artifactPath, legacyName, extension))) return 0
  await moveLegacyArtifactToBackup(managedDir, kind, artifactRoot, relativePath, label)
  return 1
}

function legacyAgentNameFromPath(relativePath: string, extension: string | null): string {
  const baseName = path.basename(relativePath)
  if (!extension) return baseName
  return baseName.endsWith(extension)
    ? baseName.slice(0, -extension.length)
    : path.basename(baseName, path.extname(baseName))
}

function resolveCleanupTargets(targetArg: string): CleanupTarget[] {
  if (targetArg === "all") return [...cleanupTargets]
  const targets = targetArg.split(",").map((entry) => entry.trim()).filter(Boolean)
  for (const target of targets) {
    if (!cleanupTargets.includes(target as CleanupTarget)) {
      throw new Error(`Unknown cleanup target: ${target}. Use one of: ${cleanupTargets.join(", ")}, all`)
    }
  }
  return targets as CleanupTarget[]
}

async function resolveCleanupPluginPath(input: string): Promise<string> {
  if (input.startsWith(".") || input.startsWith("/") || input.startsWith("~")) {
    const expanded = expandHome(input)
    const directPath = path.resolve(expanded)
    if (await pathExists(directPath)) return directPath
    throw new Error(`Local plugin path not found: ${directPath}`)
  }

  const repoRoot = fileURLToPath(new URL("../..", import.meta.url))
  const rootManifestPath = path.join(repoRoot, ".claude-plugin", "plugin.json")
  if (await pathExists(rootManifestPath)) {
    try {
      const raw = await fs.readFile(rootManifestPath, "utf8")

View on GitHub (pinned to c9c10f8c75)

Solutions

  1. Use only listed targets: codex, opencode, pi, kiro, copilot, droid, qwen, windsurf — or "all".
  2. Fix typos and casing in each comma-separated entry (matching is exact and case-sensitive).
  3. Run `cleanup --help` (or read src/commands/cleanup.ts:30) to confirm the current target list for your CLI version.

Example fix

// before
bun run src/index.ts cleanup --target claude,gemini
// Error: Unknown cleanup target: claude. Use one of: codex, opencode, pi, kiro, copilot, droid, qwen, windsurf, all

// after
bun run src/index.ts cleanup --target codex,opencode
Defensive patterns

Strategy: validation

Validate before calling

const CLEANUP_TARGETS = ["codex","opencode","pi","kiro","copilot","droid","qwen","windsurf"] as const
const requested = (process.argv.target ?? "all").split(",").map(s => s.trim()).filter(Boolean)
const bad = requested.filter(t => !(CLEANUP_TARGETS as readonly string[]).includes(t) && t !== "all")
if (bad.length) throw new Error(`Invalid cleanup target(s): ${bad.join(", ")}`)

Type guard

type CleanupTarget = typeof ["codex","opencode","pi","kiro","copilot","droid","qwen","windsurf"][number]
function isCleanupTarget(t: string): t is CleanupTarget {
  return (["codex","opencode","pi","kiro","copilot","droid","qwen","windsurf"] as const).includes(t as never)
}

Try / catch

try {
  await cleanup({ target })
} catch (e) {
  if (e instanceof Error && e.message.startsWith("Unknown cleanup target:")) {
    console.error(e.message) // lists valid targets
    process.exitCode = 2
  } else throw e
}

Prevention

When it happens

Trigger: Calling `cleanup --target claude` (typo or unsupported agent name), `--target "codex, claude-code"` where one comma entry is invalid, or shell-expansion artifacts like an empty-but-nonblank token. Note empty entries are filtered out, so trailing commas are fine.

Common situations: Guessing agent names not in the cleanup list (e.g. "gemini", "cursor", "claude"); copy-pasting a target list from an older version of the CLI that had different targets; case mistakes ("Codex" — matching is case-sensitive).

Understand the failure class

Background: "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained — this error's family across 19 libraries.

Related errors


AI-assisted analysis of EveryInc/compound-engineering-plugin@c9c10f8c75 (2026-08-31). Data as JSON: /api/errors/0b44c7c8d78c75fe. Report an issue: GitHub.