Files
2026-05-21 13:05:53 +00:00

38 lines
2.0 KiB
Markdown

---
name: codex-thread-cwd
description: Change a Codex thread working directory/cwd on the Codex side, not in downstream tool databases. Use when asked to change, move, fix, align, or sync a Codex thread workspace/cwd, especially for app-server threads or client integrations where dependent tools should sync from Codex afterward.
---
# Codex Thread CWD
Use this skill to change a Codex thread's stored working directory (`cwd`) in Codex state, then let clients such as a Telegram bot sync from Codex. Do not edit downstream client databases as the source of truth.
## Required Inputs
- Target absolute `cwd`. Derive it from the user's request, the current repo, or an explicit argument. Do not assume a machine-specific path.
- Target thread is normally the active Telegram/Codex thread unless the user specifies another one.
## Telegram Bot Directive
When working through this Telegram bot, emit exactly one hidden directive line in normal assistant output, outside code fences:
`<!-- codex-thread-cwd {"cwd":"<absolute-cwd>"} -->`
The bot strips the directive, updates Codex-side cwd state, and syncs its local workspace tracking from the new Codex cwd. Do not run the bundled script or other tool calls when this directive is available.
## Script Fallback
Use the bundled script only outside the Telegram bot directive path, or when repairing state manually:
```bash
python3 path/to/codex-thread-cwd/scripts/set_thread_cwd.py THREAD_ID /absolute/new/cwd
```
Use `--codex-home`, `--state-db`, or `CODEX_HOME` when the Codex state is not under the current user's default Codex home.
## Notes
- The app-server schema exposes `cwd` on `thread/resume`, `thread/fork`, and `turn/start`; `thread/metadata/update` does not patch `cwd`.
- The proven no-turn approach is to update Codex's own `state_*.sqlite` `threads.cwd` row and the first `session_meta.payload.cwd` line in the rollout JSONL. This is Codex-side state, not downstream client state.
- The bot implementation performs that no-turn update when configured with access to Codex state.