
codex-provider-sync-skill
Synchronize Codex session provider metadata across rollout files and SQLite state when switching providers
- Installs
- 256
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/reason-machines/codex-skills --skill codex-provider-sync-skill- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads codex-provider-sync-skill automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
codex-provider-sync
Skill by ara.so — Codex Skills collection.
What It Does
codex-provider-sync solves a specific Codex problem: when you switch model_provider (e.g., from OpenAI to Anthropic, or vice versa), historical sessions may become invisible in Codex Desktop or /resume — not because the session files are lost, but because provider/visibility metadata across rollout files, SQLite thread tables, and project path caches becomes inconsistent.
This tool synchronizes metadata in:
~/.codex/sessions(rollout files)~/.codex/archived_sessions~/.codex/state_5.sqlite(threads table).codex-global-state.json(project root path cache)
Important limitations:
- Does not modify session content, messages, or titles
- Does not handle authentication or
auth.json - Does not re-encrypt
encrypted_contentacross providers - Does not modify
updated_attimestamps to change session ordering - Sessions with
encrypted_contentmay only regain list visibility; continuing them may still error withinvalid_encrypted_content
Installation
Windows GUI (Recommended)
Download CodexProviderSync.exe from the Releases page:
- Extract the release ZIP
- Run
CodexProviderSync.exe - Click Refresh to scan current state
- Select target provider
- Click Execute to sync
CLI (macOS/Linux/Node.js)
Requires Node.js 24+ (due to node:sqlite dependency):
npm install -g git+https://github.com/Dailin521/codex-provider-sync.git
Or clone and run locally:
git clone https://github.com/Dailin521/codex-provider-sync.git
cd codex-provider-sync
npm install
npm link
Key Commands
Status Check (Dry Run)
Check current provider, rollout metadata, SQLite state, and project visibility without making changes:
codex-provider status
Sample output:
[INFO] Current provider: openai
[INFO] Rollout files: 127 (openai: 50, anthropic: 77)
[INFO] SQLite threads: 130
[INFO] Project visibility: 12/15 projects have visible sessions
[WARN] Project /home/user/my-project: first page 0/50, ranks 64-77 (Desktop likely won't show)
Sync Metadata (No Provider Switch)
Synchronize all historical session metadata to the current provider without changing config.toml:
codex-provider sync
This updates:
- Rollout files
model_providerfield - SQLite
threads.model_provider - Project root path caches in
.codex-global-state.json
Switch Provider & Sync
Change the root-level model_provider in config.toml and sync all metadata:
codex-provider switch anthropic
codex-provider switch openai
codex-provider switch apigather
This:
- Updates
~/.codex/config.tomlmodel_provider - Syncs all rollout/SQLite/project metadata to the new provider
Restore from Backup
Every sync/switch creates a timestamped backup in ~/.codex/backups_state/provider-sync/<timestamp>.
Restore all:
codex-provider restore ~/.codex/backups_state/provider-sync/2026-05-16T123045
Restore selectively:
# Restore only config.toml
codex-provider restore <backup-dir> --no-db --no-sessions
# Restore only SQLite
codex-provider restore <backup-dir> --no-config --no-sessions
# Restore only session rollouts
codex-provider restore <backup-dir> --no-config --no-db
Prune Old Backups
Keep only the last N backups created by this tool:
codex-provider prune-backups --keep 5
This only touches backups in ~/.codex/backups_state/provider-sync/, not other Codex backups.
Configuration
The tool reads from standard Codex config paths:
| File | Purpose |
|---|---|
~/.codex/config.toml | Root-level model_provider |
~/.codex/state_5.sqlite | Threads table with model_provider column |
~/.codex/sessions/*.rollout | Active session rollout files |
~/.codex/archived_sessions/ | Archived session rollout files |
.codex-global-state.json | Project root path cache (workspace metadata) |
No additional configuration needed. The tool auto-detects Codex home directory from:
CODEX_HOMEenvironment variable (if set)- Default:
~/.codex(macOS/Linux) or%USERPROFILE%\.codex(Windows)
Code Examples (Node.js/JavaScript)
Programmatic Status Check
import { checkStatus } from 'codex-provider-sync';
async function diagnose() {
const result = await checkStatus({
codexHome: process.env.CODEX_HOME || require('os').homedir() + '/.codex',
verbose: true
});
console.log('Current provider:', result.currentProvider);
console.log('Rollout files:', result.rolloutStats);
console.log('SQLite threads:', result.sqliteStats);
console.log('Project issues:', result.projectDiagnostics);
}
diagnose().catch(console.error);
Programmatic Sync
import { syncProvider } from 'codex-provider-sync';
async function syncToAnthropic() {
const backupPath = await syncProvider({
targetProvider: 'anthropic',
codexHome: process.env.CODEX_HOME,
createBackup: true,
verbose: true
});
console.log('Sync complete. Backup:', backupPath);
}
syncToAnthropic().catch(console.error);
Programmatic Provider Switch
import { switchProvider } from 'codex-provider-sync';
async function switchToOpenAI() {
const result = await switchProvider({
newProvider: 'openai',
codexHome: process.env.CODEX_HOME,
updateConfig: true, // Modify config.toml
syncMetadata: true // Sync all sessions
});
console.log('Switched to:', result.provider);
console.log('Sessions synced:', result.sessionsUpdated);
console.log('Backup:', result.backupPath);
}
switchToOpenAI().catch(console.error);
Restore from Backup
import { restoreBackup } from 'codex-provider-sync';
async function rollback() {
await restoreBackup({
backupDir: '/home/user/.codex/backups_state/provider-sync/2026-05-16T123045',
restoreConfig: true,
restoreDb: true,
restoreSessions: true
});
console.log('Restore complete');
}
rollback().catch(console.error);
Common Patterns
Before/After Major Provider Switch
# 1. Check current state
codex-provider status
# 2. Switch and auto-backup
codex-provider switch anthropic
# 3. Verify sessions visible in Desktop
# If issues persist, restore:
codex-provider restore ~/.codex/backups_state/provider-sync/<latest>
Manual Rollout File Inspection
Rollout files are newline-delimited JSON. Each session has metadata in the first line:
# Check first line of a rollout file
head -n 1 ~/.codex/sessions/<session-id>.rollout | jq .
Look for model_provider field:
{
"session_id": "abc123",
"model_provider": "openai",
"created_at": 1715900000000,
"project_root": "/home/user/my-project"
}
If this doesn't match your current provider, sessions won't appear in Desktop.
Sync Only Specific Provider (Not Implemented Yet)
Current tool syncs all sessions to the target provider. If you need selective sync (e.g., keep some sessions on OpenAI, others on Anthropic), you must manually edit rollout files or filter before sync.
Codex Desktop 50-Session Limit
Codex Desktop currently loads only the most recent 50 sessions on first page load. This is an upstream limitation.
Symptoms:
- CLI
/resumeshows sessions that Desktop doesn't - Project sidebar shows "No conversations" even after sync
codex-provider statusreportsranks 64-77(beyond first 50)
Workarounds:
- Use CLI
/resumeto access sessions beyond rank 50 - Wait for Codex Desktop to implement project-scoped pagination
- Don't modify
updated_atto force old sessions into top 50 (not supported by this tool)
Troubleshooting
"Database is locked" / "SQLITE_BUSY"
Cause: Codex Desktop, Codex App, or app-server has state_5.sqlite open.
Fix:
- Close all Codex applications
- Kill
app-serverprocess if running:# macOS/Linux pkill -f app-server # Windows taskkill /IM codex.exe /F - Re-run
codex-provider sync
"Malformed database" / "Unreadable SQLite"
Cause: state_5.sqlite is corrupted.
Fix:
- Check if a backup exists:
~/.codex/backups_state/ - Restore from backup:
codex-provider restore <backup-dir> --no-config --no-sessions - If no backup, SQLite recovery is beyond this tool's scope
Rollout File Locked (Session in Use)
Symptom: Tool skips certain .rollout files with "file locked" warning.
Cause: Active Codex session has the file open.
Fix:
- Close the specific session in Codex
- Re-run sync (tool will process previously skipped files)
GUI EXE Won't Start (Windows)
Symptoms:
- Double-clicking
CodexProviderSync.exedoes nothing - No window appears
Diagnostics:
- Check
%AppData%\codex-provider-sync\startup-error.log - Run from PowerShell to see console output:
cd C:\path\to\extracted\folder .\CodexProviderSync.exe - Verify all files were extracted (ZIP extraction issue)
- Check Windows SmartScreen didn't block execution
Sessions Still Invisible After Sync
Checklist:
- Run
codex-provider status— check provider matches config - Check session ranks — if beyond 50, Desktop won't show (see "50-Session Limit")
- Verify
state_5.sqlitethreads.model_providerupdated:sqlite3 ~/.codex/state_5.sqlite "SELECT model_provider, COUNT(*) FROM threads GROUP BY model_provider;" - Check project root path cache in
.codex-global-state.json - If session has
encrypted_content, it may not be continuable cross-provider
Node Version Error (node:sqlite)
Symptom: Cannot find module 'node:sqlite'
Cause: Node.js <24 doesn't have built-in SQLite.
Fix: Upgrade to Node.js 24+:
# Using nvm
nvm install 24
nvm use 24
# Or download from nodejs.org
Advanced: Manual Metadata Editing
If you need surgical changes (not recommended), rollout files are JSON-lines:
// Read rollout file
const fs = require('fs');
const lines = fs.readFileSync('~/.codex/sessions/abc123.rollout', 'utf-8').split('\n');
// Parse first line (metadata)
const meta = JSON.parse(lines[0]);
console.log('Current provider:', meta.model_provider);
// Change provider (manual edit)
meta.model_provider = 'anthropic';
lines[0] = JSON.stringify(meta);
// Write back
fs.writeFileSync('~/.codex/sessions/abc123.rollout', lines.join('\n'));
Warning: Always backup before manual edits. Use the official CLI when possible.
Safety & Backups
Every sync/switch automatically creates:
~/.codex/backups_state/provider-sync/<timestamp>/
├── config.toml
├── state_5.sqlite
├── sessions/
└── archived_sessions/
Backup retention:
- Default: unlimited (manually prune with
prune-backups) - Recommended:
codex-provider prune-backups --keep 10
Restore example:
# Full restore
codex-provider restore ~/.codex/backups_state/provider-sync/2026-05-16T123045
# Config only
codex-provider restore <backup> --no-db --no-sessions
Testing
# JavaScript tests
npm test
# C# GUI tests (if contributing to desktop app)
dotnet test desktop/CodexProviderSync.Core.Tests/CodexProviderSync.Core.Tests.csproj
License
MIT
FAQ
What does the codex-provider-sync-skill skill do?
Synchronize Codex session provider metadata across rollout files and SQLite state when switching providers
How do I install codex-provider-sync-skill?
Run npx skills add https://github.com/reason-machines/codex-skills --skill codex-provider-sync-skill in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/codex-provider-sync-skill/ (personal) or .claude/skills/codex-provider-sync-skill/ (project).
Which AI agents can use codex-provider-sync-skill?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is codex-provider-sync-skill safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains codex-provider-sync-skill?
It is published by reason-machines in reason-machines/codex-skills. It has 256 recorded installs.
More from reason-machines/codex-skills
academic-research-skills-codex
reason-machines/codex-skills
Open the skill to read its SKILL.md instructions.
codexplusplus-launcher
reason-machines/codex-skills
Open the skill to read its SKILL.md instructions.
codex-plugin-claude-code
reason-machines/codex-skills
Open the skill to read its SKILL.md instructions.
awesome-codex-skills-curator
reason-machines/codex-skills
Open the skill to read its SKILL.md instructions.
codex-plusplus-tweak-system
reason-machines/codex-skills
Open the skill to read its SKILL.md instructions.
awesome-codex-subagents
reason-machines/codex-skills
Open the skill to read its SKILL.md instructions.
Popular data & databases skills
supabase-postgres-best-practices
supabase/agent-skills
Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pgcron, pgmq), vector/semantic search (pgvector), and restoring dumps (pgrestore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query.
prisma-client-api
prisma/skills
Prisma Client API reference covering model queries, filters, operators, and client methods. Use when writing database queries, using CRUD operations, filtering data, or configuring Prisma Client. Triggers on "prisma query", "findMany", "create", "update", "delete", "$transaction".
prisma-database-setup
prisma/skills
Deprecated compatibility name for prisma-orm-setup. Use only when a user or existing integration explicitly invokes prisma-database-setup; otherwise select prisma-orm-setup.
prisma-cli
prisma/skills
Prisma ORM 7 CLI reference for existing Prisma 7 applications or explicitly selected Prisma 7 workflows. Covers prisma init, generate, migrate, db, dev, studio, and mcp. For setup, connection repair, or Prisma 8, use prisma-orm-setup; not the Prisma Platform CLI.
prisma-postgres
prisma/skills
Deprecated compatibility name for prisma-postgres-setup. Use only when a user or existing integration explicitly invokes prisma-postgres; otherwise select prisma-postgres-setup.
prisma-driver-adapter-implementation
prisma/skills
Required reference for Prisma ORM 7 SQL driver adapter work. Use when implementing or modifying adapters, adding database drivers, or touching SqlDriverAdapter, Transaction, savepoint, result mapping, or DriverAdapterError behavior. Covers current transaction lifecycle, optional savepoint hooks, original database-error preservation, and verification.