linear-worktree
Creates a git worktree from main for a Linear issue. Use when the user pastes a Linear URL (https://linear.app/.../issue/ABC-58/...), a Linear "copy as prompt" string, or just an issue ID like "ABC-58". Handles URL parsing, branch name derivation, and worktree creation as a sibling directory. Also use when asked to "make a worktree for ABC-58", "set up a branch for this issue", or "create a worktree".
How do I install this agent skill?
npx skills add https://github.com/mblode/agent-skills --skill linear-worktreeIs this agent skill safe to install?
- Gen Agent Trust Hubpass
This skill facilitates the creation of git worktrees from Linear issues. It involves parsing Linear URLs or issue identifiers and executing standard git commands. The skill includes specific sanitization instructions to transform issue titles into safe branch names, effectively mitigating potential command injection risks from external data.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
linear-worktree
Creates a git worktree from main for a Linear issue as a sibling directory of the current repo.
Copy and track this checklist:
Worktree creation progress:
- [ ] Step 1: Resolve REPO_ROOT / REPO_NAME / REPOS_BASE
- [ ] Step 2: Parse input into ISSUE_ID and BRANCH
- [ ] Step 3: git fetch origin main
- [ ] Step 4: git worktree add at $REPOS_BASE/$REPO_NAME-$ISSUE_ID
- [ ] Step 5: Report worktree path, branch, and cd command with resolved paths
Setup
Resolve three variables:
- Inside a git repo (most common):
REPO_ROOT=git rev-parse --show-toplevel,REPO_NAME= its basename,REPOS_BASE= its parent directory. - Not inside a git repo but
config.jsonhasrepos_base: use that asREPOS_BASE. Ask the user which repo folder. - Neither: ask for the full repo path.
Inputs
The user provides one of:
- Linear URL:
https://linear.app/myteam/issue/ABC-58/add-dark-mode-toggle - Copy as prompt:
ABC-58 Add dark mode toggle to settings page - Issue ID only:
ABC-58
Parsing
All parsing produces two values: ISSUE_ID (lowercased) and BRANCH (id + slug).
From URL
- Extract issue ID from the path segment after
/issue/→ISSUE_ID=abc-58 - Last path segment becomes the slug →
BRANCH=abc-58-add-dark-mode-toggle
From copy as prompt
- First token is the issue ID →
ISSUE_ID=abc-58 - Slugify the rest: lowercase, spaces to
-, strip backticks/parentheses/.../quotes/#/@, collapse consecutive hyphens, trim leading/trailing hyphens BRANCH=abc-58-<slug>
Example: ABC-58 Add dark mode toggle (don't break "light" default)
→ abc-58-add-dark-mode-toggle-dont-break-light-default
From issue ID only
Lowercase the ID → ISSUE_ID = abc-58. Slugify any description the user provides for the branch, otherwise BRANCH = abc-58.
Worktree Creation
git -C $REPO_ROOT fetch origin main
git -C $REPO_ROOT worktree add \
-b $BRANCH \
$REPOS_BASE/$REPO_NAME-$ISSUE_ID \
main
This creates a worktree at $REPOS_BASE/$REPO_NAME-$ISSUE_ID (e.g. /Users/you/Code/myrepo-abc-58) — a sibling of the main repo, not inside it.
After Creation
Tell the user the worktree path, branch name, and cd command using actual resolved paths:
Worktree: /Users/you/Code/myrepo-abc-58
Branch: abc-58-add-dark-mode-toggle
Run: cd /Users/you/Code/myrepo-abc-58
Edge Cases and Gotchas
- Branch exists but not checked out: drop
-b— usegit worktree add $REPOS_BASE/$REPO_NAME-$ISSUE_ID $BRANCH. - Branch checked out in another worktree: do not
--force. Rungit worktree listand tell the user tocdto the existing worktree. - Directory already exists: confirm with user before removing — may be a forgotten worktree.
- Always fetch first:
git fetch origin mainbeforegit worktree add, or the worktree gets a stale base. - Sibling, not child: worktree path is next to
$REPO_ROOT, never inside it. - "Create a branch" means worktree: use
git worktree add, notgit checkout -b. - Always end with
cd: the worktree is useless if the user stays in the original repo.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/mblode/agent-skills/linear-worktree">View linear-worktree on skillZs</a>