Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

Back to skills

Worktree

ASecurity

Create and manage git worktrees for isolated working directories. Use when starting a new task that needs its own branch and directory.

33 stars
0 votes
0 copies
0 views
Added 9/20/2026
developmentrustgobashnodegitfrontendbackend

Security Analysis

A96/100
mediumInstalls packages at runtime which could introduce malicious dependencies

Scanned 9/20/2026

Install to Claude Code

$npx -y skills add ayunis-core/ayunis-core --skill worktree --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Worktree?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Worktree
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ayunis-core-worktree/badge)](https://www.skillsdirectory.com/skills/ayunis-core-worktree)

More formats (shields.io, HTML) on the badges page.

Download Zip
Files
SKILL.md
---
name: worktree
description: Create and manage git worktrees for isolated working directories. Use when starting a new task that needs its own branch and directory.
---

# Git Worktree Management

## When to Use

At the start of a task, the user will tell you which environment to work in. This skill covers creating and removing worktrees — for starting the dev stack, see the `dev-environment` skill.

## Creating a Worktree

The user gives you a **task ID** and optionally a **branch name** (if the branch already exists).

```bash
TASK_ID="AYC-123"  # from user
REPO_ROOT="$(git rev-parse --show-toplevel)"
WORKTREE_DIR="$(dirname "$REPO_ROOT")/ayunis-core-wt-${TASK_ID,,}"

# New branch from HEAD:
git worktree add "$WORKTREE_DIR" -b "feat/${TASK_ID,,}/work" HEAD

# OR existing branch:
git worktree add "$WORKTREE_DIR" "$BRANCH"

# Track the new branch in Graphite — REQUIRED before any `gt create`.
# `git worktree add -b` produces a branch Graphite doesn't know about, so the
# first `gt create` fails with "Cannot perform this operation on untracked
# branch". Track it as a child of main:
cd "$WORKTREE_DIR" && gt track --parent main

# Symlink secret .env files (gitignored, not in the new worktree)
ln -sf "$REPO_ROOT/ayunis-core-backend/.env" "$WORKTREE_DIR/ayunis-core-backend/.env"
ln -sf "$REPO_ROOT/ayunis-core-frontend/.env" "$WORKTREE_DIR/ayunis-core-frontend/.env"

# Install dependencies — ayunis-core is a pnpm workspace
# (pnpm-workspace.yaml + pnpm-lock.yaml at repo root, packageManager pinned to pnpm).
# Never `npm install` inside a sub-project — that creates a stray package-lock.json
# and resolves the wrong tree.
cd "$WORKTREE_DIR" && pnpm install

# Build the workspace packages so @ayunis/* types resolve (see below).
cd "$WORKTREE_DIR" && pnpm run build:deps
```

## Build @ayunis/* deps before trusting a full typecheck

A fresh worktree has `node_modules` (after `pnpm install`) but **not** the built
`dist/index.d.ts` for the `@ayunis/*` workspace packages — those only exist after
the `tsup` build. Until you run `pnpm run build:deps`, a full `pnpm exec tsc --noEmit`
emits ~60 `TS2307 "Cannot find module '@ayunis/…'"` errors **on your branch AND on
clean HEAD**.

**Never wave those TS2307 errors off as "pre-existing on clean HEAD."** They are a
missing-build artifact, not a real baseline — and treating them that way hides genuine
type errors in your own new code behind the noise. In one session this masked a real
bug (a raw `'mistral'` string passed where an `EmbeddingsProvider` enum was required).

The pre-commit hook (`tsc-files`, staged-only) and `ts-jest` (transpile-only) both have
blind spots that only a full post-build typecheck covers. So, in any worktree, before
running or trusting `tsc --noEmit`:

```bash
cd "$WORKTREE_DIR" && pnpm run build:deps   # builds @ayunis/* dist/*.d.ts
pnpm exec tsc --noEmit                       # now TS2307 noise is gone; real errors surface
```

## Empty Base Branch Gotcha

The worktree branch `feat/<task>/work` is the **base** — Graphite stacks are
built on top of it (see the `git-workflow` skill). Following git-workflow,
the first commit goes on a `gt create` child branch, leaving the worktree
base intentionally empty.

That's fine until you push. `gt submit --stack` refuses to submit an empty
base branch:

```text
WARNING: This branch does not introduce any changes: ▸ feat/<task>/work
Nothing to submit!
```

Fix: re-parent the child directly onto `main` so the empty base drops out
of the stack:

```bash
gt track --parent main --force   # run on the CHILD branch, not the base
gt submit --stack --force --no-interactive
```

Alternative (single-PR tasks): skip the `gt create` and commit on the
worktree base branch directly with `gt modify --commit` so the base
isn't empty in the first place. Prefer this when the task is a single
self-contained change, not a stack.

## Scenario C — Use an existing worktree

The user points you to a **worktree that already exists**. Just `cd` into it and start working.

```bash
WORKTREE_DIR="/path/to/existing/worktree"  # from user
cd "$WORKTREE_DIR"
```

## Cleanup

Only tear down when the user asks you to, or when they explicitly say the task is complete. Worktrees persist across agent sessions.

```bash
# First stop the dev stack if running (see dev-environment skill)
cd "$WORKTREE_DIR" && ./dev down

# Remove the worktree (from the main repo)
cd "$REPO_ROOT"
git worktree remove "$WORKTREE_DIR"
```

## Branch Naming

Worktree branches follow the pattern `feat/${TASK_ID,,}/work` (e.g., `feat/ayc-123/work`). This is the base branch that Graphite stacks are built on top of — see the `git-workflow` skill.

Attribution

ayunis-coreayunis-core
View sourceMore from ayunis-core →
SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Your tool, in front of Claude Code builders.

3 founder slots · $299/mo · GSC-verified traffic · sponsors can never buy grades.

See placements

Related Skills

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

281612 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2132 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Tanstack Start

Build a full-stack TanStack Start app on Cloudflare Workers from scratch — SSR, file-based routing, server functions, D1+Drizzle, better-auth, Tailwind v4+shadcn/ui. Use whenever the user mentions TanStack Start, asks to scaffold a full-stack Cloudflare app with SSR, wants an SSR dashboard, or asks for a React 19 + Cloudflare Workers app with file-based routing and server functions — even if they don't name TanStack Start specifically. No template repo — Claude generates every file fresh per ...

9881 votes

Pentest

PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.

5491 votes
View all in development →