Skip to content

Commit 0076d3d

Browse files
committed
feat: default claude with codex switches
1 parent 8b4d362 commit 0076d3d

File tree

4 files changed

+49
-26
lines changed

4 files changed

+49
-26
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Worktree Task Plugin
22

3-
Manage large coding tasks using git worktrees and background Claude Code sessions.
3+
Manage large coding tasks using git worktrees and background agent sessions(默认启动 Claude Code `claude --dangerously-skip-permissions`,可用 `--codex` 快速切换 Codex CLI,或 `--agent-cmd` 指定任意命令,如 `codex --yolo -m gpt-5.1-codex-max -c model_reasoning_effort="high"`)。
44

55
## Features
66

7-
- **Launch**: Spawn autonomous Claude Code instances in separate git worktrees
7+
- **Launch**: Spawn autonomous agent instances (默认 Claude Code,可选 `--codex`/`--agent-cmd`) in separate git worktrees
88
- **Status**: Monitor running tasks and their progress
99
- **Resume**: Recover interrupted tasks (rate limits, API errors, timeouts)
1010
- **Cleanup**: Remove completed tasks and worktrees
@@ -81,7 +81,7 @@ worktree-task/
8181

8282
## How It Works
8383

84-
1. **Launch**: Creates a git worktree, starts a tmux session, runs Claude Code with the task prompt
84+
1. **Launch**: Creates a git worktree, starts a tmux session, runs Claude Code(或通过 `--codex`/`--agent-cmd` 指定的命令)with the task prompt
8585
2. **Monitor**: Polls tmux panes to detect completion, errors, or rate limits
8686
3. **Alert**: Sends macOS notifications via `osascript`
8787
4. **Resume**: Detects interrupted state and restarts with context

commands/launch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ allowed-tools: Bash
55

66
# Launch Worktree Task
77

8-
Launch a background Claude Code session in a separate git worktree to execute a large task autonomously.
8+
默认启动 Claude Code (`claude --dangerously-skip-permissions`),可选参数:`--codex` 快速切换到 Codex CLI,或用 `--agent-cmd "codex --yolo -m gpt-5.1-codex-max -c model_reasoning_effort=\"high\""` 自定义命令;在单独的 git worktree 中自主执行大任务。
99

1010
## Usage
1111

scripts/launch.py

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
"""
3-
Launch a background Claude Code session in a git worktree.
3+
Launch a background agent session (Codex CLI) in a git worktree.
44
55
Usage: launch.py <branch-name> "<task-description>"
66
"""
@@ -11,6 +11,11 @@
1111
import time
1212
from pathlib import Path
1313

14+
# Default agent command (Claude Code)
15+
DEFAULT_AGENT_CMD = 'claude --dangerously-skip-permissions'
16+
# Codex agent command (optional)
17+
CODEX_AGENT_CMD = 'codex --yolo -m gpt-5.1-codex-max -c model_reasoning_effort="high"'
18+
1419

1520
def run(cmd: str, check: bool = True, capture: bool = False) -> subprocess.CompletedProcess:
1621
"""Run a shell command."""
@@ -35,13 +40,13 @@ def session_exists(name: str) -> bool:
3540
return result.returncode == 0
3641

3742

38-
def wait_for_claude_ready(session_name: str, timeout: int = 30) -> bool:
43+
def wait_for_agent_ready(session_name: str, timeout: int = 30) -> bool:
3944
"""
40-
Wait for Claude Code to be ready by detecting the prompt.
45+
Wait for the CLI agent to be ready by detecting the prompt.
4146
42-
Returns True if Claude is ready, False if timeout.
47+
Returns True if the agent is ready, False if timeout.
4348
"""
44-
print(f" Waiting for Claude Code to initialize (timeout: {timeout}s)...")
49+
print(f" Waiting for agent to initialize (timeout: {timeout}s)...")
4550

4651
for i in range(timeout):
4752
result = run(f"tmux capture-pane -t {session_name} -p", capture=True)
@@ -51,11 +56,11 @@ def wait_for_claude_ready(session_name: str, timeout: int = 30) -> bool:
5156
lines = output.strip().split('\n')
5257
last_lines = lines[-5:] if len(lines) >= 5 else lines
5358

54-
# Check for Claude Code ready indicators
59+
# Check for agent ready indicators
5560
for line in last_lines:
5661
# Look for the prompt (>) or bypass permissions message
5762
if '>' in line or 'bypass permissions' in line.lower():
58-
print(f" ✓ Claude Code ready (took {i+1}s)")
63+
print(f" ✓ Agent ready (took {i+1}s)")
5964
return True
6065

6166
# Show progress every 5 seconds
@@ -64,7 +69,7 @@ def wait_for_claude_ready(session_name: str, timeout: int = 30) -> bool:
6469

6570
time.sleep(1)
6671

67-
print(f" ⚠ Warning: Claude Code may not be fully ready after {timeout}s")
72+
print(f" ⚠ Warning: Agent may not be fully ready after {timeout}s")
6873
return False
6974

7075

@@ -95,17 +100,20 @@ def load_task_template(script_dir: Path, task_desc: str, worktree_dir: str) -> s
95100

96101
def main():
97102
if len(sys.argv) < 3:
98-
print("Usage: launch.py <branch-name> \"<task-description>\" [--env KEY=VALUE ...]")
103+
print("Usage: launch.py <branch-name> \"<task-description>\" [--env KEY=VALUE ...] [--agent-cmd \"<agent command>\"] [--claude] [--codex]")
99104
print("Example: launch.py feature/my-task \"Implement the new feature\"")
100105
print("Example: launch.py feature/my-task \"Task\" --env ANTHROPIC_BASE_URL=http://api.codex.markets")
106+
print("Example: launch.py feature/my-task \"Task\" --agent-cmd \"codex --yolo -m gpt-5.1-codex-max -c model_reasoning_effort=\\\"high\\\"\"")
107+
print("Example: launch.py feature/my-task \"Task\" --codex")
101108
sys.exit(1)
102109

103110
branch_name = sys.argv[1]
104111
task_desc = sys.argv[2]
105112
script_dir = Path(__file__).parent.resolve()
106113

107-
# Parse custom environment variables
114+
# Parse custom environment variables and agent command override
108115
custom_env = {}
116+
agent_cmd_override = None
109117
i = 3
110118
while i < len(sys.argv):
111119
if sys.argv[i] == "--env" and i + 1 < len(sys.argv):
@@ -114,6 +122,15 @@ def main():
114122
key, value = env_pair.split("=", 1)
115123
custom_env[key] = value
116124
i += 2
125+
elif sys.argv[i] == "--agent-cmd" and i + 1 < len(sys.argv):
126+
agent_cmd_override = sys.argv[i + 1]
127+
i += 2
128+
elif sys.argv[i] == "--codex":
129+
agent_cmd_override = CODEX_AGENT_CMD
130+
i += 1
131+
elif sys.argv[i] == "--claude":
132+
agent_cmd_override = DEFAULT_AGENT_CMD
133+
i += 1
117134
else:
118135
i += 1
119136

@@ -173,28 +190,34 @@ def main():
173190
# Wait for shell to initialize
174191
time.sleep(1)
175192

176-
# Launch Claude Code
177-
print("Launching Claude Code...")
193+
# Launch agent
194+
print("Launching agent...")
178195

179196
# Build command with custom environment variables
197+
agent_cmd_base = agent_cmd_override if agent_cmd_override else DEFAULT_AGENT_CMD
180198
if custom_env:
181199
env_exports = " && ".join([f"export {k}='{v}'" for k, v in custom_env.items()])
182-
claude_cmd = f"{env_exports} && claude --dangerously-skip-permissions"
200+
agent_cmd = f"{env_exports} && {agent_cmd_base}"
183201
print(f" Using custom environment variables: {', '.join(custom_env.keys())}")
184202
else:
185-
claude_cmd = "claude --dangerously-skip-permissions"
203+
agent_cmd = agent_cmd_base
204+
205+
if agent_cmd_override:
206+
print(f" Agent command override: {agent_cmd_base}")
207+
else:
208+
print(f" Agent command (default): {agent_cmd_base}")
186209

187-
run(f"tmux send-keys -t {session_name} '{claude_cmd}' Enter")
210+
run(f"tmux send-keys -t {session_name} '{agent_cmd}' Enter")
188211

189-
# Wait for Claude Code to be ready (with timeout protection)
190-
if not wait_for_claude_ready(session_name, timeout=30):
212+
# Wait for agent to be ready (with timeout protection)
213+
if not wait_for_agent_ready(session_name, timeout=30):
191214
print(" Proceeding anyway, but task may not start correctly...")
192215

193216
# Extra buffer time to ensure input is ready
194217
time.sleep(1)
195218

196219
# Load and send task prompt
197-
print("Sending task to Claude...")
220+
print("Sending task to agent...")
198221
task_prompt = load_task_template(script_dir, task_desc, str(worktree_dir))
199222

200223
# Use a temp file to avoid shell escaping issues

skills/worktree-task/SKILL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
name: worktree-task
3-
description: Manage large coding tasks using git worktrees and background Claude Code sessions. Use this when users want to execute large, complex tasks (like implementing a new service, major refactoring, or multi-step features) in isolation without blocking the current session. Spawns autonomous Claude Code instances via tmux.
3+
description: 使用 git worktree + 背景代理会话管理大型任务(默认启动 Claude Code;可用 --codex 快速切到 Codex CLI,或通过 --agent-cmd 指定任意命令)。适合用户希望在不阻塞当前会话的情况下执行大型或多步骤任务。
44
---
55

66
# Worktree Task Manager
77

8-
This skill manages large coding tasks by spawning autonomous Claude Code instances in separate git worktrees via tmux sessions.
8+
This skill manages large coding tasks by spawning autonomous agent instances (默认 Claude Code,可选 `--codex`/`--agent-cmd`) in separate git worktrees via tmux sessions.
99

1010
## When to Use
1111

@@ -42,7 +42,7 @@ The script will:
4242
1. Verify git status is clean (or prompt to commit/stash)
4343
2. Create a git worktree with the specified branch
4444
3. Create a tmux session
45-
4. Launch Claude Code with `--dangerously-skip-permissions`
45+
4. Launch Claude Code by default (use `--codex` for default Codex command or `--agent-cmd` to switch, e.g., `codex --yolo -m gpt-5.1-codex-max -c model_reasoning_effort="high"`)
4646
5. Send the task with instructions to use Task tool for each phase
4747

4848
### 2. Monitor Progress
@@ -82,7 +82,7 @@ Configure alerts in `hooks/hooks.json`.
8282

8383
## Critical Instructions for Spawned Claude
8484

85-
The spawned Claude Code instance receives these critical instructions:
85+
The spawned agent receives these critical instructions:
8686

8787
1. **MUST use Task tool** - Each major phase must be executed via `Task` tool to prevent context overflow
8888
2. **Silent mode** - No confirmations needed, user has pre-approved all operations

0 commit comments

Comments
 (0)