thread-project-linker
Reassign Codex threads to the correct project/workspace by updating both thread DB cwd metadata and rollout session metadata together. Use when a user asks to move one thread, bulk migrate active thre
SKILL.mdSKILL.md
GitHubThread Project Linker
Migrate Codex thread-to-project mappings safely and repeatably.
Use the bundled script to keep both metadata stores in sync:
~/.codex/state_5.sqlite(threads.cwd)- thread rollout JSONL first line (
session_meta.payload.cwd)
Quick Start
Run from the skill folder:
cd "${CODEX_HOME:-$HOME/.codex}/skills/thread-project-linker"
Single thread to new project:
python3 scripts/reassign_thread.py \
--thread codex://threads/<thread-id> \
--project /absolute/path/to/new-project
Bulk migrate all threads from old project path:
python3 scripts/reassign_thread.py \
--from /absolute/path/to/old-project \
--to /absolute/path/to/new-project
Bulk migrate by previous folder name:
python3 scripts/reassign_thread.py \
--from-name old-folder-name \
--to /absolute/path/to/new-project
Bulk migrate only selected deeplink IDs:
python3 scripts/reassign_thread.py \
--from-name old-folder-name \
--to /absolute/path/to/new-project \
--deeplink codex://threads/<thread-a> \
--deeplink codex://threads/<thread-b>
Include archived threads too:
python3 scripts/reassign_thread.py \
--from-name old-folder-name \
--to /absolute/path/to/new-project \
--include-archived
Dry run (no writes):
python3 scripts/reassign_thread.py \
--from /absolute/path/to/old-project \
--to /absolute/path/to/new-project \
--dry-run
Workflow
- Parse thread IDs from
--threadand--deeplink. - Resolve migration scope:
- explicit IDs +
--project - all threads from
--fromor--from-name+--to - active-only by default, unless
--include-archivedis provided - optional filtering by specified IDs in bulk mode
- explicit IDs +
- Validate each target thread and rollout file before writing.
- Backup each rollout file.
- Update rollout
session_meta.payload.cwd. - Update DB
threads.cwdin a transaction. - Verify DB + rollout values.
- On failure, restore backups and restore DB cwd values.
Guardrails
- Prefer
--dry-runfirst on large bulk migrations. - Use absolute paths for
--project,--from, and--to. - Archived threads are excluded unless
--include-archivedis passed. - Keep generated backup files until you confirm the migration in Codex UI.