tobi/qmd · warning · Error

Skill already exists: ${targetDir} (use --force to replace i

Error message

Skill already exists: ${targetDir} (use --force to replace it)

What it means

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.

Source

Thrown at src/cli/qmd.ts:3366

Load the full, version-matched QMD instructions from the CLI:

!\`qmd skill show\`

If your agent does not support bang-command expansion, run:

\`\`\`bash
qmd skill show
\`\`\`

Then follow those instructions. In short: search first, fetch full sources with
\`qmd get\` or \`qmd multi-get\`, and answer from retrieved text rather than snippets.
`;
}

function writeSkillInstall(targetDir: string, force: boolean): void {
  if (pathExists(targetDir)) {
    if (!force) {
      throw new Error(`Skill already exists: ${targetDir} (use --force to replace it)`);
    }
    removePath(targetDir);
  }

  const skill = findSkill("qmd");
  if (!skill) {
    throw new Error("QMD skill not found. Reinstall qmd or set QMD_SKILLS_DIR.");
  }

  copyDirectoryContents(skill.dir, targetDir);
  writeFileSync(resolve(targetDir, "SKILL.md"), installedSkillStubContent(), "utf-8");
}

function outputSkillsJson(payload: unknown): void {
  console.log(JSON.stringify(payload));
}

function runSkillsCommand(args: string[], jsonMode: boolean, fullOption = false, allOption = false): void {

View on GitHub (pinned to dbfd0b4736)

Solutions

  1. Re-run the install with --force to replace the existing directory
  2. Or manually remove/rename the existing target directory first, then install

Example fix

# before
qmd skills install
# after
qmd skills install --force
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "node:fs";
const target = "~/.claude/skills/qmd"; // your install target
if (existsSync(target)) { /* pass --force or skip */ }

Type guard

null

Try / catch

try { install(); } catch (e) { if ((e as Error).message.includes("--force")) install({ force: true }); else throw e; }

Prevention

When it happens

Trigger: Running the skill install command twice, or installing into a path (e.g. ~/.claude/skills/qmd) that already contains a directory, without --force.

Common situations: Re-running setup after a partial install; CI provisioning that runs install on every boot; switching machines with synced skill dirs.

Related errors


AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28). Data as JSON: /api/errors/033e82c579f09b73. Report an issue: GitHub.