Codex project chat migration
Skill iancaoo/agent-skills/skills/codex-project-chat-migration
Diagnose and recover missing Codex Projects/Chats after switching between ChatGPT/OpenAI account login, API key auth, custom OpenAI-compatible providers, or model providers. Use when local Codex project chats appear missing, only new chats show, chats briefly appear then disappear, or threads need safe migration between providers such as openai, custom, and a configured provider by updating Codex local thread metadata and rollout JSONL session metadata with backups.From its SKILL.md
npx -y skills add iancaoo/agent-skills --skill codex-project-chat-migrationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
4.2 KB, 804 tokens by cl100k_base, as published. Nobody here has run it
Codex Project Chat Migration
Overview
Use this skill to recover local Codex project chats hidden by provider/auth metadata changes. Treat the operation as metadata reassignment, not chat copying: the same local chats are made visible to the target provider identity.
Workflow
- Identify the active provider from
~/.codex/config.tomlor ask for an explicit target when the user is switching back to a prior provider. - Run a dry run first:
python3 ~/.codex/skills/codex-project-chat-migration/scripts/migrate_project_chats.py
- Review the reported database provider counts, rollout JSONL provider counts, mismatches, affected threads, missing rollout files, blocking provider migration guards, and proposed target provider.
- Apply only after the dry run looks correct:
python3 ~/.codex/skills/codex-project-chat-migration/scripts/migrate_project_chats.py --apply
- Restart Codex after applying so the app reloads local thread state. Do not force quit the app from the skill unless the user explicitly asks.
Script Usage
Use scripts/migrate_project_chats.py for deterministic diagnosis and migration.
Common options:
--codex-home PATH: override Codex home; defaults to$CODEX_HOMEor~/.codex.--target-provider PROVIDER: override the provider to migrate chats to; otherwise the script readsmodel_providerfromconfig.toml.--source-provider PROVIDER: repeat to migrate only specific source providers; when omitted, all non-target providers and missing rollout providers are candidates.--active-only: exclude archived threads.--state-db PATH: use a specific Codex state SQLite file; otherwise the script prefersstate_5.sqliteand falls back to the higheststate_*.sqlite.--apply: create backups and write changes. Without this flag the script never mutates files.
The dry run may report Blocking provider migration guards when old SQLite triggers would force the target provider back to a previous provider. This usually means a previous provider migration left a guard table such as <provider>_provider_migration_ids. On --apply, the script clears the affected thread IDs from those guard tables before updating threads.model_provider.
Examples:
python3 ~/.codex/skills/codex-project-chat-migration/scripts/migrate_project_chats.py --target-provider cctq
python3 ~/.codex/skills/codex-project-chat-migration/scripts/migrate_project_chats.py --target-provider openai --source-provider cctq --apply
Safety Rules
- Never print or inspect API keys, session tokens, or
auth.jsoncontents. - Always run dry-run before
--apply. - Always keep SQLite and rollout JSONL
session_meta.payload.model_providerin sync. Updating only SQLite can make chats appear at launch and disappear after the app reconciles rollout metadata. - Treat
Blocking provider migration guardsas a first-class safety signal. If present, confirm the guard's forced provider matches the intended source provider before applying. - Backups are required before mutation. The script writes them under
~/.codex/backups/. - Use an explicit
--target-providerwhen reversing a migration or when the active provider inconfig.tomlis not the provider the user wants. - If the user asks whether switching back will lose data, explain that this changes local ownership metadata; backups preserve rollback points, and the original chat files are not deleted by this migration.
Verification
After applying, run the script again without --apply. A healthy result shows no affected threads, no database/rollout provider mismatch for the migrated set, and no blocking provider migration guards. If the UI still omits chats, restart Codex and re-run the dry run before making additional changes.
What ships with it: 2 files
22.1 KB alongside SKILL.md, 1 of them executable
agents/
- openai.yaml252 B
scripts/
- migrate_project_chats.pyruns21.9 KB