{"record":{"id":"77cfd8afe88d1ac0","repo":"paperclipai/paperclip","slug":"worktree-config-already-exists-at-paths-configpa","errorCode":null,"errorMessage":"Worktree config already exists at ${paths.configPath} or instance data exists at ${paths.instanceRoot}. Re-run with --force to replace it.","messagePattern":"Worktree config already exists at (.+?) or instance data exists at (.+?)\\. Re-run with --force to replace it\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/worktree.ts","lineNumber":2424,"sourceCode":"  const seedMode = opts.seedMode ?? \"minimal\";\n  if (!isWorktreeSeedMode(seedMode)) {\n    throw new Error(`Unsupported seed mode \"${seedMode}\". Expected one of: minimal, full.`);\n  }\n  const instanceId = sanitizeWorktreeInstanceId(opts.instance ?? worktreeName);\n  const paths = resolveWorktreeLocalPaths({\n    cwd,\n    homeDir: resolveWorktreeHome(opts.home),\n    instanceId,\n  });\n  const branding = {\n    name: opts.name ?? worktreeName,\n    color: opts.color ?? generateWorktreeColor(),\n  };\n  const sourceConfigPath = resolveSourceConfigPath(opts);\n  const sourceConfig = existsSync(sourceConfigPath) ? readConfig(sourceConfigPath) : null;\n\n  if ((existsSync(paths.configPath) || existsSync(paths.instanceRoot)) && !opts.force) {\n    throw new Error(\n      `Worktree config already exists at ${paths.configPath} or instance data exists at ${paths.instanceRoot}. Re-run with --force to replace it.`,\n    );\n  }\n\n  if (opts.force) {\n    // Only remove the specific files we're about to rewrite, not the whole\n    // repoConfigDir — that directory can contain sibling state such as\n    // <repo>/.paperclip/worktrees/ holding every repo-managed worktree\n    // checkout, and a recursive rmSync here would nuke them all.\n    rmSync(paths.configPath, { force: true });\n    rmSync(paths.envPath, { force: true });\n    const seedMarkers = resolveWorktreeSeedMarkerPaths(paths.configPath);\n    rmSync(seedMarkers.pending, { force: true });\n    rmSync(seedMarkers.complete, { force: true });\n    rmSync(paths.instanceRoot, { recursive: true, force: true });\n  }\n\n  const { serverPort, databasePort, targetConfig } = await withWorktreePortRegistryLock(","sourceCodeStart":2406,"sourceCodeEnd":2442,"githubUrl":"https://github.com/paperclipai/paperclip/blob/01ad8584922b5d85292b1723cae71fa0d9b07a19/cli/src/commands/worktree.ts#L2406-L2442","documentation":"Idempotency guard in worktree init: a Paperclip config or instance data directory already exists at the computed paths, so initialization would clobber an existing instance unless the operator explicitly passes --force.","triggerScenarios":"Thrown at cli/src/commands/worktree.ts:1643 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run with --force to replace the existing worktree config and instance data.","Remove ${paths.configPath} and ${paths.instanceRoot} manually, then retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"01ad8584922b5d85292b1723cae71fa0d9b07a19","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}