{"record":{"id":"782fdc6c326a3e81","repo":"paperclipai/paperclip","slug":"safety-checks-failed-resolve-the-issues-above-or","errorCode":null,"errorMessage":"Safety checks failed. Resolve the issues above or re-run with --force.","messagePattern":"Safety checks failed\\. Resolve the issues above or re-run with --force\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"cli/src/commands/worktree.ts","lineNumber":2102,"sourceCode":"    } else {\n      problems.push(\n        `Branch \"${name}\" has commits not found on any other branch or remote. ` +\n          `Deleting it will lose work. Push it first, or use --force.`,\n      );\n    }\n  }\n\n  if (hasTargetDir && worktreePathHasUncommittedChanges(targetPath)) {\n    problems.push(\n      `Worktree directory ${targetPath} has uncommitted changes. Commit or stash first, or use --force.`,\n    );\n  }\n\n  if (problems.length > 0 && !opts.force) {\n    for (const problem of problems) {\n      p.log.error(problem);\n    }\n    throw new Error(\"Safety checks failed. Resolve the issues above or re-run with --force.\");\n  }\n  if (problems.length > 0 && opts.force) {\n    for (const problem of problems) {\n      p.log.warning(`Overridden by --force: ${problem}`);\n    }\n  }\n\n  // ── 3. Clean up (idempotent steps) ──────────────────────────────────\n\n  // 3a. Remove the git worktree registration\n  if (linkedWorktree) {\n    const worktreeDirExists = existsSync(linkedWorktree.worktree);\n    const spinner = p.spinner();\n    if (worktreeDirExists) {\n      spinner.start(`Removing git worktree at ${linkedWorktree.worktree}...`);\n      try {\n        const removeArgs = [\"worktree\", \"remove\", linkedWorktree.worktree];\n        if (opts.force) removeArgs.push(\"--force\");","sourceCodeStart":2084,"sourceCodeEnd":2120,"githubUrl":"https://github.com/paperclipai/paperclip/blob/67001ec6eb96ae601aa27bc91d9b2415d665334a/cli/src/commands/worktree.ts#L2084-L2120","documentation":"Thrown by the worktree clean/remove command when one or more safety problems were detected AND --force was not passed. Problems are collected first and only enforced here: (a) the branch has unique local commits not present on any remote (would lose work), and (b) the worktree directory has uncommitted changes. Each problem is logged via p.log.error before the throw so the user sees specifics. With --force the same problems are downgraded to warnings and cleanup proceeds.","triggerScenarios":"Running `paperclipai worktree:clean <name>` where the branch has unpushed unique commits; cleaning a worktree that has modified/tracked files not yet committed; CI trying to auto-clean a worktree the developer left dirty.","commonSituations":"Developer did work in the worktree but never pushed; merge conflict resolution left uncommitted state; the branch was never pushed to origin before attempting cleanup.","solutions":["Read the logged problems above the error — each names the exact branch/dir and reason.","Push unique commits (`git push -u origin <name>`) or commit/stash uncommitted changes in the worktree.","If you are certain the work is disposable, re-run with `--force` to override (the problems become warnings).","Re-run clean after the data is safely preserved."],"exampleFix":"// before\npaperclipai worktree:clean feat-x   # uncommitted changes / unique commits\n// after (preserve first)\ncd /path/to/feat-x && git add -A && git commit -m \"wip\" && git push -u origin feat-x\npaperclipai worktree:clean feat-x\n# or intentional data loss\npaperclipai worktree:clean feat-x --force","handlingStrategy":"validation","validationCode":"function cleanSafetyOk(opts: { force?: boolean }, problems: string[]): boolean {\n  return problems.length === 0 || opts.force === true;\n}","typeGuard":"function hasUncommittedOrUniqueCommits(targetPath: string, branch: string): boolean {\n  return worktreePathHasUncommittedChanges(targetPath) || branchHasUniqueCommits(process.cwd(), branch);\n}","tryCatchPattern":"try { await worktreeCleanCommand(name, opts); }\ncatch (err) {\n  if (/Safety checks failed/.test(String((err as Error).message))) {\n    await worktreeCleanCommand(name, { ...opts, force: true }); // user-confirmed destructive\n  } else throw err;\n}","preventionTips":["Push unique branch commits to a remote before cleaning.","Commit or stash uncommitted worktree changes first.","Only use --force when you have confirmed the data is disposable."],"tags":["worktree","git","safety","cli"],"backgroundTag":null,"analyzedSha":"67001ec6eb96ae601aa27bc91d9b2415d665334a","analyzedAt":"2026-08-12T12:05:45.408Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}