{"record":{"id":"fe93d47c51662256","repo":"coleam00/Archon","slug":"workflow-slug-already-exists-at-destworkflo","errorCode":null,"errorMessage":"Workflow '${slug}' already exists at ${destWorkflow}.\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":5234,"sourceCode":"  const items = await fetchGitHubDirectory(owner, repo, path, entry.sha);\n\n  // Identify the main workflow YAML (named <slug>.yaml or the only .yaml in root)\n  const yamlFiles = items.filter(f => f.type === 'file' && f.name.endsWith('.yaml'));\n  const mainYaml =\n    yamlFiles.find(f => f.name === `${slug}.yaml`) ??\n    (yamlFiles.length === 1 ? yamlFiles[0] : undefined);\n\n  if (!mainYaml) {\n    throw new Error(\n      `Cannot identify main workflow YAML in directory. Expected '${slug}.yaml' or a single .yaml file.`\n    );\n  }\n\n  const workflowsDir = join(archonDir, 'workflows');\n  const destWorkflow = join(workflowsDir, `${slug}.yaml`);\n\n  if (existsSync(destWorkflow) && !force) {\n    throw new Error(\n      `Workflow '${slug}' already exists at ${destWorkflow}.\\nUse --force to overwrite.`\n    );\n  }\n\n  // Install the main workflow YAML\n  const mainContent = await downloadRawFile(owner, repo, mainYaml.path, entry.sha);\n  mkdirSync(workflowsDir, { recursive: true });\n  writeFileSync(destWorkflow, mainContent);\n  console.log(`  Workflow: ${destWorkflow}`);\n\n  // Install supporting files by convention\n  const subdirs = items.filter(f => f.type === 'dir');\n  let installedCount = 1;\n\n  for (const subdir of subdirs) {\n    if (!isSafePathComponent(subdir.name)) {\n      console.log(`  Skipped (unsafe directory name): ${subdir.name}`);\n      continue;","sourceCodeStart":5216,"sourceCodeEnd":5252,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/cli/src/commands/workflow.ts#L5216-L5252","documentation":"The Archon CLI workflow installer refuses to overwrite an existing workflow YAML file unless the caller explicitly passes --force. existsSync(destWorkflow) detects a file at the target path and throws this error to protect an existing workflow from silent clobbering. It is an intentional safety gate, not a failure of the install itself.","triggerScenarios":"Running the workflow install command (which downloads a workflow into <archonDir>/workflows/<slug>.yaml) when that slug's YAML already exists on disk and the --force flag was not supplied.","commonSituations":"Re-running an install of a workflow pack that was previously installed; installing a different workflow that happens to use the same slug; leftover files in .archon/workflows from an old checkout or manual copy.","solutions":["Delete or rename the existing workflow file at the printed destination path if it is no longer wanted.","Re-run the install command with --force to intentionally overwrite the existing workflow.","Pick a different slug/name for the workflow being installed so it does not collide."],"exampleFix":"// before\narchon workflow install owner/repo\n// Error: Workflow 'code-review' already exists...\n// after\narchon workflow install owner/repo --force","handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nconst dest = join(archonDir, 'workflows', `${slug}.yaml`);\nif (existsSync(dest) && process.argv.includes('--force') === false) {\n  console.warn(`Skipping install: ${dest} exists. Re-run with --force or remove the file.`);\n  process.exit(0);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await installWorkflow(slug, { force });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('already exists') && err.message.includes('--force')) {\n    // prompt the user or rerun with force\n  } else throw err;\n}","preventionTips":["Check for the destination file before invoking install in scripts.","Use --force deliberately only when you intend to overwrite.","Keep workflows under version control so overwrites are recoverable."],"tags":["cli","filesystem","workflow-install"],"backgroundTag":"file-already-exists","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}