{"record":{"id":"ada48bfbb8c529a1","repo":"JuliusBrussee/caveman","slug":"provider-requires-a-value","errorCode":null,"errorMessage":"--provider requires a value","messagePattern":"--provider requires a value","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/create-caveman-agent/src/index.ts","lineNumber":67,"sourceCode":"    \"npm run dev\",\n    \"eval starts unapproved; inspect it, set approved: true, then npm run build\",\n    \"\",\n  ].join(\"\\n\"));\n}\n\nfunction parseArgs(args: string[]): {\n  target: string;\n  provider?: string;\n  install: boolean;\n} {\n  let provider: string | undefined;\n  let install = true;\n  const positional: string[] = [];\n  for (let index = 0; index < args.length; index++) {\n    const value = args[index]!;\n    if (value === \"--provider\") {\n      const candidate = args[++index];\n      if (!candidate || candidate.startsWith(\"--\")) throw new Error(\"--provider requires a value\");\n      provider = candidate;\n      continue;\n    }\n    if (value === \"--no-install\") {\n      install = false;\n      continue;\n    }\n    if (value.startsWith(\"--\")) throw new Error(`unknown option ${value}`);\n    positional.push(value);\n  }\n  if (positional.length !== 1) {\n    throw new Error(\n      USAGE,\n    );\n  }\n  return {\n    target: positional[0]!,\n    ...(provider === undefined ? {} : { provider }),","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/create-caveman-agent/src/index.ts#L49-L85","documentation":"The CLI's argument parser accepts --provider only when followed by a concrete value. When --provider is the last argument or is immediately followed by another --flag, there is no value to consume, so parseArgs throws this error before any scaffolding happens.","triggerScenarios":"Running the create command with '--provider' as the final argument (e.g. `npm create @caveman-ai/agent@latest my-app -- --provider`) or passing another flag right after it (e.g. `--provider --no-install`); parseArgs sees the next token is missing or starts with '--' and throws.","commonSituations":"Copy-pasting a documented command but dropping the value; shell snippets where the value was an unexpanded variable ($PROVIDER empty would still be a positional though — more commonly the flag is last); forgetting npm's `--` separator so npm eats the value itself and --provider ends up adjacent to another flag.","solutions":["Provide a value: `--provider anthropic|openai|google`","Reorder arguments so --provider and its value come before other flags","When using npm create, put CLI args after `--` so npm forwards them intact","Check shell history/script for an empty variable used as the provider value"],"exampleFix":"// before\nnpm create @caveman-ai/agent@latest my-app -- --provider\n// after\nnpm create @caveman-ai/agent@latest my-app -- --provider anthropic","handlingStrategy":"validation","validationCode":"const i = argv.indexOf(\"--provider\");\nif (i !== -1) {\n  const v = argv[i + 1];\n  if (!v || v.startsWith(\"--\")) throw new Error(\"--provider requires a value\");\n}","typeGuard":"function hasProviderValue(argv: string[]): boolean {\n  const i = argv.indexOf(\"--provider\");\n  return i !== -1 && i + 1 < argv.length && !argv[i + 1]!.startsWith(\"--\");\n}","tryCatchPattern":"try {\n  const opts = parseArgs(argv);\n} catch (error) {\n  if (error instanceof Error && error.message.includes(\"--provider\")) {\n    console.error(\"Usage: ... --provider anthropic|openai|google\");\n    process.exitCode = 1;\n  } else throw error;\n}","preventionTips":["Always place the value directly after --provider","Use `--` after npm create so all flags reach the CLI","Lint shell scripts for flags at end of command"],"tags":["cli","argument-parsing"],"backgroundTag":"missing-cli-argument","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"}