{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreigpyk2fpzclfznrwpjgyy7r6oflqdawhmtax32edoqhd5zrtv2ubq",
"uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mpijlpvofwz2"
},
"coverImage": {
"$type": "blob",
"ref": {
"$link": "bafkreigp7far622xzohtwow7fmkj4b45edsbh3xjm7mebmvd7jdvnnaxlq"
},
"mimeType": "image/webp",
"size": 73792
},
"path": "/vvbogdanov/preserving-context-when-moving-from-chatgpt-to-codex-cli-bpl",
"publishedAt": "2026-06-30T07:48:26.000Z",
"site": "https://dev.to",
"tags": [
"openai",
"npm",
"ai",
"cli",
"https://github.com/vv-bogdanov/chatgpt2codex",
"https://www.npmjs.com/package/chatgpt2codex"
],
"textContent": "A lot of useful technical work starts as a conversation.\n\nMaybe you are exploring an architecture decision in ChatGPT. Maybe you are debugging an idea before touching the codebase. Maybe you are asking broad questions first, then moving into a local development workflow once the direction is clear.\n\nThat handoff is often awkward.\n\nThe context starts in ChatGPT, but the implementation happens somewhere else: a terminal, an editor, a local agent, or a repo-specific workflow.\n\nFor me, that \"somewhere else\" is often Codex CLI.\n\nSo I built a small bridge:\n\n\n\n npx chatgpt2codex https://chatgpt.com/share/<id>\n\n\n`chatgpt2codex` imports a shared ChatGPT conversation into a local Codex CLI session attached to your current project directory.\n\nGitHub: https://github.com/vv-bogdanov/chatgpt2codex\n\nnpm: https://www.npmjs.com/package/chatgpt2codex\n\n## The workflow gap\n\nChatGPT share links are useful for handing context to another person, but they are not directly useful to local tooling.\n\nIf I have a long conversation that contains design notes, constraints, tradeoffs, and implementation ideas, I do not want to manually copy pieces of it into a new Codex thread.\n\nI want the local coding agent to resume from the conversation as if it had been part of the local workflow from the beginning.\n\nThat is what this tool tries to do.\n\n## What it does\n\nGiven a public ChatGPT share URL, `chatgpt2codex`:\n\n * reads the shared conversation\n * normalizes the messages\n * writes a Codex rollout JSONL session\n * attaches the session to a project directory\n * indexes the session so modern Codex builds can show it in resume flows\n\n\n\nBy default, it attaches the imported session to the current directory:\n\n\n\n npx chatgpt2codex https://chatgpt.com/share/<id>\n\n\nYou can target another project directory with:\n\n\n\n npx chatgpt2codex https://chatgpt.com/share/<id> -C /path/to/project\n\n\nAnd you can preview the import without writing anything:\n\n\n\n npx chatgpt2codex https://chatgpt.com/share/<id> --dry-run\n\n\n## A few practical details\n\nThe tool is intentionally conservative.\n\nIf a Codex session already exists for the target project directory, it exits with an error instead of overwriting anything:\n\n\n\n A Codex session already exists for /path/to/project.\n Use --force to replace it.\n\n\nIf you do want to replace the existing imported session, use:\n\n\n\n npx chatgpt2codex https://chatgpt.com/share/<id> --force\n\n\nThere are also options for overriding the imported title and Codex home directory:\n\n\n\n npx chatgpt2codex https://chatgpt.com/share/<id> \\\n --name \"Architecture discussion\" \\\n --codex-home ~/.codex\n\n\n## The slightly tricky part\n\nThe first version wrote a Codex session file, but that was not always enough for Codex to pick it up in the resume flow.\n\nModern Codex builds use both rollout JSONL files and local SQLite metadata. So the current release writes the session file and also indexes the thread in Codex's local `state_5.sqlite` database when that database exists.\n\nIt also uses Codex-visible session metadata, so the imported conversation appears as a normal CLI-originated thread rather than being filtered out.\n\nThat was the main lesson: for local agent tools, \"write the file\" is often only half the integration. The rest is making sure the surrounding state agrees with it.\n\n## Caveat\n\nChatGPT share pages and Codex local session files are not official public import APIs.\n\nBecause of that, I kept the implementation small and pragmatic, with tests around the parts most likely to break:\n\n * parsing shared ChatGPT conversations\n * writing Codex session metadata\n * detecting duplicate sessions for the same project directory\n * replacing an existing session with `--force`\n\n\n\nThe tool requires Node.js 22.13.0 or newer because Codex's local SQLite index is important for the current workflow.\n\n## Why I like this shape\n\nThis is not a big framework or a new platform.\n\nIt is just a small CLI tool that closes a specific gap:\n\n\n\n ChatGPT conversation -> shared URL -> local Codex session\n\n\nThat is enough to make the handoff from exploration to implementation feel much smoother.\n\nIf you use Codex CLI and sometimes start your thinking in ChatGPT, I would love to hear whether this fits your workflow.\n\nRepo: https://github.com/vv-bogdanov/chatgpt2codex",
"title": "Preserving Context When Moving from ChatGPT to Codex CLI"
}