{"record":{"id":"0559820de86ec8f8","repo":"coleam00/Archon","slug":"workflow-slug-already-exists-at-destpath","errorCode":null,"errorMessage":"Workflow '${slug}' already exists at ${destPath}.\nUse --force to overwrite.","messagePattern":"Workflow '(.+?)' already exists at (.+?)\\.\nUse --force to overwrite\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/commands/workflow.ts","lineNumber":5198,"sourceCode":"  slug: string,\n  archonDir: string,\n  force: boolean | undefined,\n  existsSync: (p: string) => boolean,\n  mkdirSync: (p: string, opts: { recursive: boolean }) => void,\n  writeFileSync: (p: string, data: string) => void\n): Promise<void> {\n  const { owner, repo, path } = parseGitHubUrl(entry.sourceUrl);\n  const content = await downloadRawFile(owner, repo, path, entry.sha);\n\n  if (!content.trim()) {\n    throw new Error(`Downloaded YAML is empty for '${slug}'`);\n  }\n\n  const workflowsDir = join(archonDir, 'workflows');\n  const destPath = join(workflowsDir, `${slug}.yaml`);\n\n  if (existsSync(destPath) && !force) {\n    throw new Error(`Workflow '${slug}' already exists at ${destPath}.\\nUse --force to overwrite.`);\n  }\n\n  mkdirSync(workflowsDir, { recursive: true });\n  writeFileSync(destPath, content);\n  console.log(`Installed '${entry.name}' to ${destPath}`);\n}\n\nasync function installDirectory(\n  entry: MarketplaceEntryJson,\n  slug: string,\n  archonDir: string,\n  force: boolean | undefined,\n  existsSync: (p: string) => boolean,\n  mkdirSync: (p: string, opts: { recursive: boolean }) => void,\n  writeFileSync: (p: string, data: string) => void\n): Promise<void> {\n  const { owner, repo, path } = parseGitHubUrl(entry.sourceUrl);\n  const items = await fetchGitHubDirectory(owner, repo, path, entry.sha);","sourceCodeStart":5180,"sourceCodeEnd":5216,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L5180-L5216","documentation":"Collision guard: installing would overwrite an existing workflow file at `.archon/workflows/<slug>.yaml` without explicit permission. The command refuses and tells the user to pass `--force`, protecting locally modified workflows from being silently clobbered by a marketplace re-install.","triggerScenarios":"`installSingleWorkflowFile` finds `existsSync(destPath)` true and `force` is false — i.e. re-running install for a slug already installed, or a different workflow whose slug maps to an existing filename.","commonSituations":"Re-running an install script that already succeeded once; installing a marketplace workflow over a locally customized one; two marketplace entries sharing a slug; leftover file from an uninstalled workflow.","solutions":["Re-run with `--force` if you are sure you want to overwrite: `archon workflow install <slug> --force`","Back up the existing `.archon/workflows/<slug>.yaml` first if you customized it","Pick a different local workflow name / remove the stale file","Skip the install if the existing workflow is already current"],"exampleFix":"// before\narchon workflow install code-review\n// after (intentional overwrite)\narchon workflow install code-review --force","handlingStrategy":"try-catch","validationCode":"import { existsSync } from 'node:fs';\nconst dest = join(repoRoot, '.archon', 'workflows', `${slug}.yaml`);\nif (existsSync(dest) && !process.argv.includes('--force')) {\n  console.error(`${dest} exists; re-run with --force to overwrite`);\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await workflowInstallCommand(slug);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('already exists')) {\n    // prompt user or re-invoke with force: true after backup\n  } else throw e;\n}","preventionTips":["Back up customized `.archon/workflows/<slug>.yaml` before reinstalling","Make install scripts idempotent by passing --force deliberately","Avoid two marketplace entries sharing a slug","Treat this error as a signal you may be overwriting local edits"],"tags":["cli","file-conflict","idempotency","marketplace"],"backgroundTag":"file-already-exists","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}