{"record":{"id":"033e82c579f09b73","repo":"tobi/qmd","slug":"skill-already-exists-targetdir-use-force-to","errorCode":null,"errorMessage":"Skill already exists: ${targetDir} (use --force to replace it)","messagePattern":"Skill already exists: (.+?) \\(use --force to replace it\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/cli/qmd.ts","lineNumber":3366,"sourceCode":"Load the full, version-matched QMD instructions from the CLI:\n\n!\\`qmd skill show\\`\n\nIf your agent does not support bang-command expansion, run:\n\n\\`\\`\\`bash\nqmd skill show\n\\`\\`\\`\n\nThen follow those instructions. In short: search first, fetch full sources with\n\\`qmd get\\` or \\`qmd multi-get\\`, and answer from retrieved text rather than snippets.\n`;\n}\n\nfunction writeSkillInstall(targetDir: string, force: boolean): void {\n  if (pathExists(targetDir)) {\n    if (!force) {\n      throw new Error(`Skill already exists: ${targetDir} (use --force to replace it)`);\n    }\n    removePath(targetDir);\n  }\n\n  const skill = findSkill(\"qmd\");\n  if (!skill) {\n    throw new Error(\"QMD skill not found. Reinstall qmd or set QMD_SKILLS_DIR.\");\n  }\n\n  copyDirectoryContents(skill.dir, targetDir);\n  writeFileSync(resolve(targetDir, \"SKILL.md\"), installedSkillStubContent(), \"utf-8\");\n}\n\nfunction outputSkillsJson(payload: unknown): void {\n  console.log(JSON.stringify(payload));\n}\n\nfunction runSkillsCommand(args: string[], jsonMode: boolean, fullOption = false, allOption = false): void {","sourceCodeStart":3348,"sourceCodeEnd":3384,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L3348-L3384","documentation":"Thrown by skill installation (`qmd skills install`-style flow) when the target skill directory already exists on disk and --force was not passed. It refuses to overwrite an existing install to avoid destroying user modifications.","triggerScenarios":"Running the skill install command twice, or installing into a path (e.g. ~/.claude/skills/qmd) that already contains a directory, without --force.","commonSituations":"Re-running setup after a partial install; CI provisioning that runs install on every boot; switching machines with synced skill dirs.","solutions":["Re-run the install with --force to replace the existing directory","Or manually remove/rename the existing target directory first, then install"],"exampleFix":"# before\nqmd skills install\n# after\nqmd skills install --force","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nconst target = \"~/.claude/skills/qmd\"; // your install target\nif (existsSync(target)) { /* pass --force or skip */ }","typeGuard":"null","tryCatchPattern":"try { install(); } catch (e) { if ((e as Error).message.includes(\"--force\")) install({ force: true }); else throw e; }","preventionTips":["Make install scripts idempotent: skip if the target already exists","Pass --force in provisioning scripts that must re-create skill dirs"],"tags":["skills","install","filesystem","idempotency"],"backgroundTag":"file-already-exists","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}