paperclipai/paperclip · warning
Current checkout is the primary repo worktree. Pass --branch
Error message
Current checkout is the primary repo worktree. Pass --branch to create or repair a linked worktree.
What it means
`paperclipai worktree repair` resolves its target via ensureRepairTargetWorktree({ selector: opts.branch }). With no --branch and the current checkout already being the repository's primary worktree, there is no linked worktree to repair, so the command warns and exits ('No worktree repaired.') without touching anything. Repair is deliberately scoped to linked worktrees so the primary checkout's instance is never reseeded by accident.
Source
Thrown at cli/src/commands/worktree.ts:4404
await runWorktreeReseed(opts);
}
export async function worktreeRepairCommand(opts: WorktreeRepairOptions): Promise<void> {
printPaperclipCliBanner();
p.intro(pc.bgCyan(pc.black(" paperclipai worktree repair ")));
const seedMode = opts.seedMode ?? "minimal";
if (!isWorktreeSeedMode(seedMode)) {
throw new Error(`Unsupported seed mode "${seedMode}". Expected one of: minimal, full.`);
}
const target = await ensureRepairTargetWorktree({
selector: nonEmpty(opts.branch) ?? undefined,
seedMode,
opts,
});
if (!target) {
p.log.warn("Current checkout is the primary repo worktree. Pass --branch to create or repair a linked worktree.");
p.outro(pc.yellow("No worktree repaired."));
return;
}
const source = resolveWorktreeRepairSource(opts);
if (!existsSync(source.configPath)) {
throw new Error(`Source config not found at ${source.configPath}.`);
}
if (path.resolve(source.configPath) === path.resolve(target.configPath)) {
throw new Error("Source and target Paperclip configs are the same. Use --from-config/--from-instance to point repair at a different source.");
}
const targetConfig = existsSync(target.configPath) ? readConfig(target.configPath) : null;
const targetEnvEntries = readPaperclipEnvEntries(resolvePaperclipEnvFile(target.configPath));
const targetHasWorktreeEnv = Boolean(
nonEmpty(targetEnvEntries.PAPERCLIP_HOME) && nonEmpty(targetEnvEntries.PAPERCLIP_INSTANCE_ID),
);
View on GitHub (pinned to a7e689b3c3)
Solutions
- Pass --branch <name> so repair creates or repairs a linked worktree for that branch.
- Or cd into the linked worktree you want repaired and re-run the command there.
Example fix
# before $ paperclipai worktree repair # run from primary checkout ! Current checkout is the primary repo worktree. Pass --branch ... # after $ paperclipai worktree repair --branch feature-x
Defensive patterns
Strategy: validation
Validate before calling
import { execSync } from "node:child_process";
const commonDir = execSync("git rev-parse --git-common-dir").toString().trim();
const gitDir = execSync("git rev-parse --git-dir").toString().trim();
const isPrimaryWorktree = gitDir === commonDir;
if (isPrimaryWorktree && !branchFlag) {
console.error("Run from a linked worktree or pass --branch");
} Prevention
- Always pass --branch <name> when scripting worktree repair.
- Run repair from inside the linked worktree when repairing an existing one.
- Never expect repair to operate on the primary checkout — the guard is intentional.
When it happens
Trigger: Running `paperclipai worktree repair` from the main repo checkout with no --branch flag.
Common situations: Running repair from the repo root by habit; CI checkout which is always the primary worktree; forgetting that repair targets a linked worktree.
Related errors
- Import cancelled.
- Reseed cancelled.
- Managed worktree repair requires an embedded PostgreSQL targ
- Import cancelled.
- Could not open your browser automatically. Open this URL man
AI-assisted analysis of paperclipai/paperclip@a7e689b3c3 (2026-08-18).
Data as JSON: /api/errors/c2c9de6365a07d26.
Report an issue: GitHub.