Spawn Agent Skill
Create a git worktree and spawn a new Claude Code agent in a separate Zellij tab. This combines the /worktree and /zellij skills into a single workflow.
Arguments
- •
$ARGUMENTSshould contain:- •branch-name (required): Name for the new branch and worktree
- •prompt (required): The prompt to pass to Claude Code (should be quoted if it contains spaces)
Steps
- •
Validate environment: Check that we're inside a Zellij session (
$ZELLIJis set) - •
Parse arguments from
$ARGUMENTS:- •First argument is the branch name
- •Everything after the branch name is the prompt
- •
Create the worktree using the
/worktreeskill:code/worktree <branch-name>
This will create a worktree at
.worktrees/<branch-name>based on the current branch. - •
Create a Zellij tab using the
/zellijskill patterns:- •Create a tab named
<branch-name> - •Set the working directory to the worktree path
- •Run
echo '<prompt>' | claude --dangerously-skip-permissionsin the tab
Refer to the
/zellijskill for the KDL layout syntax and how to create tabs with commands. - •Create a tab named
- •
Report success:
- •Worktree path
- •Branch name
- •Tab name
- •The prompt that was passed
Example Usage
code
/spawn-agent feature-auth "Implement user authentication with JWT tokens" /spawn-agent fix-bug-123 "Fix the null pointer exception in UserService.java"
Error Handling
- •If not in a Zellij session, report error and exit
- •If the
/worktreeskill fails (e.g., branch exists), report the error and stop