How to find a Git worktree by task number without hardcoding paths. Use in hooks or scripts that need to locate a specific task's worktree.
71
86%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
Reference snippet for locating a task's Git worktree from its task number, without hardcoding paths.
/tmp/... worktree path.TASK_NUM="TASK-005"
WORKTREE=$(git worktree list --porcelain \
| grep "^worktree " \
| awk '{print $2}' \
| grep -i "${TASK_NUM}" \
| head -1)
if [ -z "$WORKTREE" ] || [ ! -d "$WORKTREE" ]; then
echo "No worktree found for ${TASK_NUM} — skipping"
exit 0
figit worktree list reads from Git's internal registry — it knows every worktree regardless of where it was created. No assumptions about directory structure or machine-specific paths.
TASK_NUM=$(echo "$TASK_OWNER $TASK_SUBJECT" | grep -oP 'TASK-\d+' | head -1)Works whether the task number appears in the owner field or the subject line.
/tmp/... worktree path instead of querying git worktree list.exit 0).git worktree list --porcelain, never a hardcoded path.64e2163
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.