{"record":{"id":"6f0d78eb5fc70cca","repo":"JuliusBrussee/caveman","slug":"project-name-must-contain-a-letter-or-number","errorCode":null,"errorMessage":"project name must contain a letter or number","messagePattern":"project name must contain a letter or number","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-caveman-agent/src/index.ts","lineNumber":307,"sourceCode":"`,\n  };\n}\n\nfunction credentialName(provider: Provider): string {\n  if (provider === \"anthropic\") return \"ANTHROPIC_API_KEY\";\n  if (provider === \"openai\") return \"OPENAI_API_KEY\";\n  return \"GEMINI_API_KEY (or GOOGLE_API_KEY)\";\n}\n\nfunction parseProvider(value: string): Provider {\n  const normalized = value.trim().toLowerCase();\n  if (normalized === \"anthropic\" || normalized === \"openai\" || normalized === \"google\") return normalized;\n  throw new Error(`unsupported provider ${JSON.stringify(value)}`);\n}\n\nfunction safeName(value: string): string {\n  const normalized = value.toLowerCase().replace(/[^a-z0-9_-]+/g, \"-\").replace(/^-+|-+$/g, \"\");\n  if (!normalized) throw new Error(\"project name must contain a letter or number\");\n  return normalized.slice(0, 96);\n}\n\nasync function assertAbsent(path: string): Promise<void> {\n  try {\n    await stat(path);\n    throw new Error(`target already exists: ${path}`);\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n  }\n}\n\nmain().catch((error) => {\n  const message = error instanceof Error ? error.message : String(error);\n  process.stderr.write(`create-caveman-agent: ${message}\\n`);\n  process.exitCode = 1;\n});\n","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/create-caveman-agent/src/index.ts#L289-L325","documentation":"safeName sanitizes the project name (lowercase, non [a-z0-9_-] collapsed to hyphens, trimmed hyphens). If nothing alphanumeric survives — e.g. the name was all punctuation or only hyphens — it throws because the package/dir name would be unusable.","triggerScenarios":"Passing a positional project name consisting solely of symbols/hyphens (e.g. `---`, `!!!`, `@@@`), or characters that all get stripped so the normalized result is empty.","commonSituations":"Shell quoting mistakes leaving an empty/odd argument; trying to name a project with emojis or punctuation only; a variable expanding to a symbol-only string.","solutions":["Provide a project name containing at least one letter or digit, e.g. `my-app`","Avoid symbol-only names; let safeName normalize valid mixed names","Quote names with spaces and ensure they include alphanumeric characters"],"exampleFix":"// before\nnpm create @caveman-ai/agent@latest '!!!' --\n// after\nnpm create @caveman-ai/agent@latest my-app --","handlingStrategy":"validation","validationCode":"const normalized = projectName.toLowerCase().replace(/[^a-z0-9_-]+/g, \"-\").replace(/^-+|-+$/g, \"\");\nif (!normalized) throw new Error(\"project name must contain a letter or number\");","typeGuard":"function isValidProjectName(name: string): boolean {\n  return /[a-z0-9]/i.test(name);\n}","tryCatchPattern":"try {\n  const opts = parseArgs(argv);\n} catch (error) {\n  if (error instanceof Error && error.message.includes(\"project name must contain\")) {\n    console.error(\"Choose a project name with at least one letter or digit\");\n    process.exitCode = 1;\n  } else throw error;\n}","preventionTips":["Pick plain alphanumeric names like my-app up front","Check shell quoting when names include special characters","Sanitize user-supplied names in scripts before passing them"],"tags":["cli","naming","validation"],"backgroundTag":"invalid-identifier-format","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}