{"record":{"id":"7380d4e6a510c9e8","repo":"ruvnet/ruflo","slug":"ruflo-init-existing-claude-md-backed-up-to-pat","errorCode":null,"errorMessage":"[ruflo init] Existing CLAUDE.md backed up to ${path.basename(backupPath)} before overwrite","messagePattern":"\\[ruflo init\\] Existing CLAUDE\\.md backed up to (.+?) before overwrite","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/init/executor.ts","lineNumber":2217,"sourceCode":"  options: InitOptions,\n  result: InitResult\n): Promise<void> {\n  const claudeMdPath = path.join(targetDir, 'CLAUDE.md');\n\n  if (fs.existsSync(claudeMdPath) && !options.force) {\n    result.skipped.push('CLAUDE.md');\n  } else {\n    // #2208: if overwriting an existing CLAUDE.md (force mode), back it up first so\n    // users don't silently lose curated project context.\n    if (fs.existsSync(claudeMdPath)) {\n      const backupBase = `${claudeMdPath}.pre-ruflo`;\n      // Don't clobber an existing backup — append a timestamp if one already exists.\n      const backupPath = fs.existsSync(backupBase)\n        ? `${backupBase}.${Date.now()}`\n        : backupBase;\n      fs.copyFileSync(claudeMdPath, backupPath);\n      result.created.files.push(path.basename(backupPath));\n      console.warn(`[ruflo init] Existing CLAUDE.md backed up to ${path.basename(backupPath)} before overwrite`);\n    }\n    // Determine template: explicit option > infer from components > 'standard'\n    const inferredTemplate = (!options.components.commands && !options.components.agents) ? 'minimal' : undefined;\n    const content = generateClaudeMd(options, inferredTemplate);\n\n    fs.writeFileSync(claudeMdPath, content, 'utf-8');\n    result.created.files.push('CLAUDE.md');\n  }\n\n  // Also write/append global ~/.claude/CLAUDE.md so ruflo tools are used automatically (#1497).\n  // Opt-out via --no-global / options.skipGlobalClaudeMd (#1744 — keeps global rules file pristine\n  // for users who don't want a per-machine pointer block).\n  const homeDir = process.env.HOME || process.env.USERPROFILE || '';\n  if (homeDir && !options.skipGlobalClaudeMd) {\n    const globalClaudeDir = path.join(homeDir, '.claude');\n    const globalClaudeMd = path.join(globalClaudeDir, 'CLAUDE.md');\n    const rufloBlock = [\n      '',","sourceCodeStart":2199,"sourceCodeEnd":2235,"githubUrl":"https://github.com/ruvnet/ruflo/blob/5234333c3462640ab348363ba4a142945fd2bc47/v3/@claude-flow/cli/src/init/executor.ts#L2199-L2235","documentation":"Data-protection notice in the ruflo init executor: force mode is overwriting an existing CLAUDE.md, so the file is first copied to a .pre-ruflo backup (timestamped if one exists) to preserve curated project context. Informational; the overwrite proceeds.","triggerScenarios":"Thrown at v3/@claude-flow/cli/src/init/executor.ts:2186 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["No action needed; the previous CLAUDE.md was backed up. Restore from the named backup if the overwrite was unwanted."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5234333c3462640ab348363ba4a142945fd2bc47","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}