Cxc Worktree Guardian logo

Cxc Worktree Guardian

Community
lidge-jun
cxc-worktree-guardian

Use for Codex-app worktrees. Triggers: worktree, rename worktree, detached HEAD, ~/.codex/worktrees, 워크트리, 워크트리 이름, 새 워크트리, 브랜치랑 워크트리.

Overview

Publisherlidge-jun
Repositorycodexclaw
Skill namecxc-worktree-guardian
Stars
51
Forks
10
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by lidge-jun on GitHub. Read the source before you install it.

Installation

Install the Cxc Worktree Guardian AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/lidge-jun/codexclaw/tree/main/plugins/codexclaw/skills/worktree-guardian
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/lidge-jun/codexclaw.git /tmp/codexclaw
mkdir -p .claude/skills
cp -r /tmp/codexclaw/plugins/codexclaw/skills/worktree-guardian .claude/skills/cxc-worktree-guardian
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Cxc Worktree Guardian in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Cxc Worktree Guardian on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Cxc Worktree Guardian is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Worktree Guardian — Codex-app managed worktrees

The Codex desktop app creates one worktree per thread under $CODEX_HOME/worktrees/ (hash or date-slug slot dirs, e.g. ~/.codex/worktrees/7627/opencodex), checked out from the selected base branch, usually detached HEAD. These sessions look like scratch directories but are not: the app binds the thread to that directory.

1. Three namespaces (WG-CONCEPT-01)

NamespaceWhat it isHow to rename
brancha git refgit branch -m <name> (or git switch -c <name> from detached HEAD), run inside the worktree
worktreea directory + its .git/worktrees/<id> admin entrygit worktree move <old> <new> — never for the ACTIVE one (WG-MOVE-01)
thread titlethe Codex app sidebar entrythe user renames it in the app; agents cannot

"워크트리 이름 붙여줘 / name the worktree" can mean any of these. Default: name the branch in place and tell the user to rename the thread in the app.

2. Managed-worktree facts (WG-FACTS-01)

  • Root: $CODEX_HOME/worktrees (default ~/.codex/worktrees); the app setting can move it (Settings → Worktrees) — codexclaw detection then needs CODEXCLAW_WORKTREE_ROOTS (WG-LIMIT-01).
  • Managed worktrees are per-chat disposable; the app retains the latest N (15 by default) and auto-deletes the worktree when the chat is archived (a snapshot is kept for restore). Commit early.
  • Source: developers.openai.com/codex/environments/git-worktrees; identity fragility is a known upstream area (openai/codex issues #10917, #10522, #14498, #34662; naming contract still a proposal, #12862).

One worktree per THREAD, not per agent (WG-FACTS-02). The per-chat worktree belongs to the Codex task. A subagent spawned with spawn_agent inherits this same directory: same path, same branch, same HEAD, and its writes appear in this worktree's git status. It never gets a worktree of its own, so spawning agents is not a way to parallelize branch work — that needs one task per lane, each with its own worktree. See Dispatch surfaces.

3. Never-list (WG-NEVER-01)

  • Never git worktree remove or rm -rf the session's OWN worktree, slot dir, or any ancestor of cwd — not even to "start clean". codexclaw's PreToolUse guard (WORKTREE-GUARD-03) denies it; do not try to bypass the deny.
  • Never copy the work elsewhere and delete the original — that loses the app binding and any uncommitted state you missed.
  • Never delete another slot under ~/.codex/worktrees without the user explicitly naming that path — another live session may be bound to it.

4. Safe procedures (WG-PROC-*)

Adopt-and-continue (DEFAULT for "이름 붙이고 새로 시작"):

  1. Stay in the worktree. git switch -c <name> (detached HEAD) or git branch -m <name>.
  2. Commit the work in progress (archive auto-deletes managed worktrees).
  3. Tell the user the thread title can be renamed in the app sidebar.

Move/repair — OTHER, inactive worktrees only (WG-MOVE-01): git worktree move <old> <new> (refuses the main worktree, locked worktrees, and worktrees containing submodules). After a manual directory move: git worktree repair <new-path>. Feature-detect with git worktree move -h / git worktree repair -h; do not version-gate. Moving the ACTIVE worktree kills the session's cwd (next command: ENOENT) and app rebinding is undocumented — don't.

Cleanup of other worktrees: verify clean (git status), merged (git merge-base --is-ancestor), no open PR head, not any session's cwd; then git worktree remove <path> — never rm -rf. A directory deleted without git worktree remove leaves admin state under .git/worktrees/; recover with git worktree prune (dry-run first). Automated or bulk cleanup of other worktrees follows cxc-dev-devops references/local-gc.md (DEVOPS-LOCAL-GC-01); the never-list above still wins.

5. Defense-in-depth limits (WG-LIMIT-01)

  • The PreToolUse guard matches literal paths. Pure variable/glob indirection that never mentions the slot path is out of scope — treat the deny as a seatbelt, not a sandbox.
  • Detection covers the default root + CODEX_HOME + CODEXCLAW_WORKTREE_ROOTS (path.delimiter-separated). A custom app-side root needs that env.

6. Hook interplay (WG-HOOK-01)

  • WORKTREE-GUARD-01 (SessionStart): identity block when cwd is managed.
  • WORKTREE-GUARD-02 (UserPromptSubmit): this guidance, once per session, on rename intent.
  • WORKTREE-GUARD-03 (PreToolUse, ^Bash$): deterministic deny of self-worktree deletion — applies to subagent turns too. The deny is intentional; follow §4 instead of routing around it.
  • WORKTREE-GUARD-04 (same PreToolUse hook): when the session bound a source worktree with cxc session source, git writes (commit, cherry-pick, merge, rebase, reset, checkout/switch, am, revert, push, pull, branch -D/-f/-m) whose repository is another worktree of the same repo are denied. Hooks receive only the command text, never exec_command's workdir, so write git -C <source> ... or cd <source> && .... --abort/--quit stay allowed.
  • SHELL-SUBST-01 (same hook): a backtick or $(...) that the shell will execute and that runs a git write or gh pr merge/close, gh issue close is denied with or without a binding; other backticks inside double quotes get an advisory. Pass generated text through apply_patch, files, or <<'EOF'.

7. AGENTS.md snippet (WG-AGENTS-01)

For repos where codexclaw hooks are not installed:

md
## Worktree safety
This session may run inside a Codex-app-managed worktree (~/.codex/worktrees/<slot>/<repo>).
Never delete or recreate that directory to "rename" it. Adopt in place:
`git switch -c <name>` / `git branch -m <name>`, commit early, and ask the user to
rename the thread in the app. `git worktree move` is for other, inactive worktrees only.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Cxc Worktree Guardian AI skill do?

Use for Codex-app worktrees. Triggers: worktree, rename worktree, detached HEAD, ~/.codex/worktrees, 워크트리, 워크트리 이름, 새 워크트리, 브랜치랑 워크트리.

Why use Cxc Worktree Guardian on TypingMind?

Because you install it once and use it with any model. Cxc Worktree Guardian is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Cxc Worktree Guardian in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/lidge-jun/codexclaw/tree/main/plugins/codexclaw/skills/worktree-guardian. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Cxc Worktree Guardian?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Cxc Worktree Guardian?

As many as you like. As long as a model supports skills, you can use Cxc Worktree Guardian with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Cxc Worktree Guardian AI skill free?

Yes. It is published on GitHub by lidge-jun under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇