{"record":{"id":"744f24d8ef16c53d","repo":"Yeachan-Heo/oh-my-codex","slug":"usage-omx-auth-add-slot-device-auth-with-a","errorCode":null,"errorMessage":"Usage: omx auth add <slot> [--device-auth|--with-api-key|--with-access-token]","messagePattern":"Usage: omx auth add <slot> \\[--device-auth\\|--with-api-key\\|--with-access-token\\]","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/auth.ts","lineNumber":108,"sourceCode":"  let updated = upsertTopLevelTomlString(existing, \"model\", DEFAULT_SUBSCRIPTION_MODEL);\n  updated = upsertTopLevelTomlString(updated, \"model_provider\", DEFAULT_SUBSCRIPTION_MODEL_PROVIDER);\n  await mkdir(codexHome, { recursive: true });\n  await writeFile(configPath, updated);\n}\n\n\nexport async function authCommand(args: string[], env: NodeJS.ProcessEnv = process.env): Promise<void> {\n  const command = args[0];\n  const cwd = process.cwd();\n  const home = env.HOME;\n  if (!command || command === \"--help\" || command === \"-h\" || command === \"help\") {\n    console.log(AUTH_HELP.trim());\n    return;\n  }\n\n  if (command === \"add\") {\n    const slot = args[1];\n    if (!slot) throw new Error(\"Usage: omx auth add <slot> [--device-auth|--with-api-key|--with-access-token]\");\n    const loginArgs = args.slice(2);\n    const liveAuthPath = resolveLiveAuthPath(cwd, env, home);\n    const hadLiveAuth = await fileExists(liveAuthPath);\n    const tempCodexHome = await createIsolatedLoginCodexHome(home);\n    try {\n      runCodexLogin(cwd, { ...env, CODEX_HOME: tempCodexHome }, loginArgs);\n      const tempAuthPath = join(tempCodexHome, \"auth.json\");\n      const record = await addSlotFromAuthFile(slot, tempAuthPath, home);\n      await ensureSubscriptionCodexDefaults(dirname(liveAuthPath));\n      if (!hadLiveAuth) {\n        await useSlot(slot, liveAuthPath, home);\n      }\n      console.log(`Added auth slot ${record.slot}`);\n    } finally {\n      await rm(tempCodexHome, { recursive: true, force: true }).catch(() => undefined);\n    }\n    return;\n  }","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/auth.ts#L90-L126","documentation":"`omx auth add` requires a slot name as its first positional argument (a named credential slot to store the login under). If no slot is provided, the command aborts with a usage message showing the expected form and allowed flags.","triggerScenarios":"Running `omx auth add` with no arguments, or `omx auth add --device-auth` where the flag is consumed as the slot slot position incorrectly (missing positional).","commonSituations":"Users assuming interactive slot prompting that doesn't exist; copy-paste errors dropping the slot name; scripts with unquoted empty variables collapsing to nothing.","solutions":["Provide a slot name: `omx auth add <slot> [--device-auth|--with-api-key|--with-access-token]`","Quote script variables so empty values fail loudly instead of silently: `omx auth add \"$SLOT\"`","Use a meaningful slot like `work` or `personal` to keep multiple credentials organized"],"exampleFix":"# before\nomx auth add --device-auth\n# after\nomx auth add work --device-auth","handlingStrategy":"validation","validationCode":"const slot = process.argv[3];\nif (!slot || slot.startsWith('--')) {\n  console.error('Usage: omx auth add <slot> [--device-auth|--with-api-key|--with-access-token]');\n  process.exit(1);\n}","typeGuard":"const isNonEmptySlot = (s?: string): s is string => !!s && !s.startsWith('--');","tryCatchPattern":"catch (e) { if (/^Usage: omx auth add/.test(String(e))) { printAuthAddHelp(); } else throw e; }","preventionTips":["Always pass a named slot","Quote shell variables when scripting","Treat usage errors as programmer errors, not runtime failures"],"tags":["auth","cli","usage","missing-argument"],"backgroundTag":"missing-cli-argument","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}