codex-open-worktree
Skill1 starsChanged 5 months agoApache-2.0View on GitHub
Open any existing Git-registered worktree as a workspace in the macOS Codex desktop app, including installations branded as ChatGPT. Use when the user asks to open, switch to, move to, or continue in an existing worktree from Codex; invokes `$codex-open-worktree`; supplies a branch name, worktree directory, or worktree path; or wants Codex to discover a repository's worktrees and ask which one to open. Works with worktrees created by Git, Claude, Codex, Supacode, or other tools at any path. Opens a workspace without creating, removing, checking out, or modifying a worktree or branch.
In this repository4 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- address-pr-commentsSkill
- generate-commit-messageSkill
The file
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
If the user supplied a branch, worktree name, or path, run:
- Distinctive: line 23
If the user supplied no selector, run:
- Distinctive: line 31
If selection is ambiguous or missing, show the script's candidates and ask the user for one branch or path.
- Distinctive: line 32
After a successful script result, report the opened branch and absolute worktree path.
- Distinctive: line 37
Never run Git commands that mutate worktrees, branches, the index, or files.
- Very specific: line 38
Never invoke codex app, an installer, a package manager, or a download.
- Distinctive: line 39
Do not claim the current conversation switched.
- Distinctive: line 40
Treat an explicit skill invocation with a unique selector as authorization to open that workspace.
- Distinctive: line 41
Treat locked worktrees like any other registered worktree.
- Very specific: line 45
Use --dry-run to verify resolution without opening the app:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Codex Open Worktree
Open a registered Git worktree in the macOS desktop app without changing Git state. Treat "switch" as "open the selected worktree in another Codex workspace" because the current task cannot be rebound to a different workspace.
Workflow
- Resolve the repository from the current directory unless the user supplied a repository or worktree path. If neither path is inside a Git repository, ask for one; do not search the filesystem broadly.
If the user supplied a branch, worktree name, or path, run:
python3 ./scripts/open_worktree.py --repo <repo> <selector>Resolve
./scripts/open_worktree.pyrelative to thisSKILL.md.Open immediately when the selector has one exact or unique match. An explicit invocation with a unique selector authorizes this external app action; do not ask for redundant confirmation.
If the user supplied no selector, run:
python3 ./scripts/open_worktree.py --repo <repo> --listPresent the registered worktrees and ask which one to open. Put a clearly implied candidate first and label it
(Recommended); if intent does not distinguish a candidate, ask neutrally instead of inventing a preference. Never choose silently, even when only one alternative exists.- If selection is ambiguous or missing, show the script's candidates and ask the user for one branch or path. Rerun with the exact selection after they answer.
- After a successful script result, report the opened branch and absolute worktree path. State that the app was asked to open that workspace and the current task remains attached to its original workspace. Stop; do not begin work in either workspace.
Safety Boundaries
- Open only an existing directory returned by
git worktree list --porcelainfor the selected repository. - Never run Git commands that mutate worktrees, branches, the index, or files. In particular, never run
git switch,git checkout,git worktree add,git worktree remove, orgit worktree prune. - Never invoke
codex app, an installer, a package manager, or a download. Use the bundled script, which calls macOSopenwith the installed app's stable bundle identifier only. - Do not claim the current conversation switched. The app opens or focuses a workspace for the selected folder; this task's workspace and branch indicator do not change.
- Treat an explicit skill invocation with a unique selector as authorization to open that workspace. With no selector, list and ask before opening anything.
- Treat locked worktrees like any other registered worktree. A Git worktree lock affects pruning, not whether its directory can be opened.
Script Interface
Use --dry-run to verify resolution without opening the app:
python3 ./scripts/open_worktree.py --repo <repo> --dry-run <selector>The selector accepts an exact branch name, absolute or repository-relative path, directory name, flattened branch name such as feat-example, or a unique case-insensitive substring. The script exits without opening anything when the selector is absent, ambiguous, unmatched, or resolves to a missing directory.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

