{"record":{"id":"660cc78833caa9a3","repo":"EveryInc/compound-engineering-plugin","slug":"could-not-verify-local-codex-development-mode-rep","errorCode":null,"errorMessage":"Could not verify local Codex development mode (reported ${status.mode})","messagePattern":"Could not verify local Codex development mode \\(reported (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/dev/codex-dev.ts","lineNumber":569,"sourceCode":"  )\n}\n\nexport async function switchToLocal(\n  context: CodexDevContext,\n  runner: CommandRunner = new BunCommandRunner(),\n): Promise<CodexDevStatus> {\n  const previous = await inspectLocalCollection(context)\n  if (previous.kind !== \"absent\" && previous.kind !== \"valid\") {\n    throw new Error(`Cannot switch to local mode while the local collection is ${previous.kind}`)\n  }\n  const activatedTarget = await fs.realpath(context.skillsRoot)\n  await activateLocalCollection(context)\n  try {\n    const plugins = await listCompoundEngineeringPlugins(context, runner)\n    await removeLocalPluginConflicts(context, runner, plugins)\n    const status = await inspectCodexDevStatus(context, runner)\n    if (status.mode !== \"local\") {\n      throw new Error(`Could not verify local Codex development mode (reported ${status.mode})`)\n    }\n    return status\n  } catch (error) {\n    await restoreLocalCollection(context, previous, activatedTarget)\n    throw error\n  }\n}\n\nasync function listMarketplaces(context: CodexDevContext, runner: CommandRunner): Promise<Marketplace[]> {\n  const result = await runCodex(context, runner, [\"plugin\", \"marketplace\", \"list\", \"--json\"])\n  return parseJson<{ marketplaces?: Marketplace[] }>(result, \"codex plugin marketplace list\").marketplaces ?? []\n}\n\nasync function ensureOfficialMarketplace(context: CodexDevContext, runner: CommandRunner): Promise<void> {\n  const marketplaces = await listMarketplaces(context, runner)\n  const existing = marketplaces.find((marketplace) => marketplace.name === OFFICIAL_MARKETPLACE)\n  if (!existing) {\n    await runCodex(context, runner, [","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/EveryInc/compound-engineering-plugin/blob/c9c10f8c75412c7232cb2bd663e5fd1cea98d84e/src/dev/codex-dev.ts#L551-L587","documentation":"`switchToLocal()` links your skills directory into Codex and then re-runs `inspectCodexDevStatus` to prove the switch actually took. If the post-switch status reports any mode other than `\"local\"` (e.g. `\"mixed\"`, `\"drifted\"`, `\"remote\"`, `\"absent\"`), the switch failed and this error is thrown; the previously active collection is restored before rethrowing.","triggerScenarios":"Calling `switchToLocal(context, runner)` when the activated local symlink leaves residual plugin state that keeps `inspectCodexDevStatus` from reporting `\"local\"` — e.g. an official marketplace-backed plugin was not fully removed by `removeLocalPluginConflicts`, or `activateLocalCollection` produced a link that `inspectLocalCollection` later classifies as `broken`/`unrelated`.","commonSituations":"Running `bun run codex:dev -- local` in a checkout whose `$CODEX_HOME` already contains a partially-installed official plugin; a stale `~/.codex` state from an older codex-dev run; switching to local while a previous run's cleanup was interrupted.","solutions":["Inspect `codex:dev -- status` to see the reported mode and installed plugins","Run `bun run codex:dev -- remove` to wipe stale plugin state, then retry `codex:dev -- local`","Manually check `$CODEX_HOME/config.toml` for leftover `compound-engineering` plugin entries and remove them","Start a new Codex session after switching modes (per the repo docs) so the state is re-read"],"exampleFix":"// before: switching with stale state\nawait runCodexDev([\"local\"])\n// after: clean state first\nawait runCodexDev([\"remove\"])\nawait runCodexDev([\"local\"])","handlingStrategy":"validation","validationCode":"const status = await inspectCodexDevStatus(context)\nif (status.mode !== \"absent\" && status.mode !== \"remote\") {\n  await removeCodexDevInstallation(context)\n}\nawait switchToLocal(context)","typeGuard":"function isLocalMode(status: CodexDevStatus): boolean { return status.mode === \"local\" }","tryCatchPattern":"try {\n  await switchToLocal(context)\n} catch (error) {\n  console.error(\"Switch to local failed; prior state was restored:\", error)\n  const status = await inspectCodexDevStatus(context)\n  console.log(\"Current mode:\", status.mode)\n}","preventionTips":["Run `codex:dev -- status` before switching and clean up with `codex:dev -- remove` if not absent/remote","Avoid interrupting a codex:dev run mid-switch","Start a new Codex session after every mode switch"],"tags":["codex","dev-mode","state-verification"],"backgroundTag":"codex-dev-mode-mismatch","analyzedSha":"c9c10f8c75412c7232cb2bd663e5fd1cea98d84e","analyzedAt":"2026-08-31T15:18:07.959Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}