steps to follow
Step 0: Check if worktree setup should be skipped
First, check if workspace setup is disabled via config files:
Read(.humanlayer/workspace.json)
Read(.humanlayer/workspace.local.json)
Output this final answer instead of proceeding:
First, check out the task branch for the user:
Bash(git checkout -b [BRANCHNAME])
Then output this final answer:
I've checked out branch [BRANCHNAME] for you. To start implementation, use the button below or create a new session with the following command:
/rpi:implement-outline
If you really do want to create a worktree anyway, let me know and I can still help with that.
To re-enable workspace setup, edit the file that sets disabled: true and change it to false, or add "disabled": false to .humanlayer/workspace.local.json to override the shared config.
Do NOT proceed to Step 1 unless the user explicitly confirms they want to create a worktree anyway.
Next, check if you're already in a git worktree:
Bash(git rev-parse --git-dir)
Output this final answer instead of proceeding:
To start implementation, use the button below or create a new session with the following command:
/rpi:implement-outline
If you really do want to create a new worktree from here, let me know and I can still help with that.
Do NOT proceed to Step 1 unless the user explicitly confirms they want to create a worktree anyway.
Step 1 Get required information
- Figure out what task you're working on - you should have the slug to .humanlayer/tasks/TASKSLUG already
1a. once you have a task dir, read ticket.md (or task.md) and outline.md if present:
Read(.humanlayer/tasks/TASKSLUG/ticket.md) # or task.md
Read(.humanlayer/tasks/TASKSLUG/...outline...md)
First, check for the legacy create_worktree.sh script to see if the user has existing preferences
Read(scripts/create_worktree.sh)
{
"disabled": false,
"pathTemplate": "~/.humanlayer/workspaces/{{ TASKSLUG }}/{{ REPOBASENAME }}",
"branchTemplate": "{{ TASKSLUG }}",
"repos": [
{
"localPath": ".",
"description": "Selected repository",
"sourceRef": "HEAD",
"setupCommand": "",
"copyGlobs": [
".env*",
".claude/settings.local.json",
"CLAUDE.local.md",
".humanlayer/workspace.local.json"
]
}
]
}
Note: For multi-repo setups, add additional entries to repos[] with relative paths like "localPath": "../other-repo". The localPath: "." entry is required and becomes the primary working directory.
If the user wants more control over the workspace configuration (custom paths, setup commands, multi-repo coordination), they can use the rpi:configure-workspaces skill to interactively set it up.
Create the worktree according to .humanlayer/workspace.json and .humanlayer/workspace.local.json, taking the workspace.local.json as overrides for the workspace.json config.
REPOBASENAME is the basename of the repository, e.g. ~/repos/humanlayer -> humanlayer
```
Bash(git worktree add -b {{ branchTemplate(TASKSLUG) }} {{ pathTemplate(TASKSLUG, REPOBASENAME) }} {{ sourceRef }})
```
```bash
ls -la [REPO_ROOT]/[glob-pattern]
```
For each matched file, preserve directory structure when copying:
```bash
mkdir -p [WORKTREE_FULL_PATH]/[parent-dir]
cp [matched-file] [WORKTREE_FULL_PATH]/[same-relative-path]
```
For example, `.claude/settings.local.json` → `[WORKTREE_FULL_PATH]/.claude/settings.local.json`
```
cd [WORKTREE_FULL_PATH] && [setup-command]
```
If there are any error messages or failures, report the error to the user and work with the user to complete the setup
don't proceed to step 4 until the worktrees are created and setup is complete
Only output this if the worktree(s) were successfully created.
If you encountered an error in Step 3, do NOT output this section.
use the rpi:implement-outline skill for task .humanlayer/tasks/{{ TASKSLUG }}
in the [WORKTREE_FULL_PATH] directory
You can modify worktree behavior by editing the .humanlayer/workspace.json (committed, shared config) and .humanlayer/workspace.local.json (local overrides, gitignored) files.