Agent Skill
2/7/2026

init-worktree

Initialize project environment after worktree creation. Detects project type from config files and CLAUDE.md, proposes setup commands with confirmation. Used by flow:start and flow:continue after new worktree creation.

N
nonameitem
0GitHub Stars
1Views
npx skills add NoNameItem/claude-tools

SKILL.md

Nameinit-worktree
DescriptionInitialize project environment after worktree creation. Detects project type from config files and CLAUDE.md, proposes setup commands with confirmation. Used by flow:start and flow:continue after new worktree creation.

name: init-worktree description: Initialize project environment after worktree creation. Detects project type from config files and CLAUDE.md, proposes setup commands with confirmation. Used by flow:start and flow:continue after new worktree creation.

Flow: Initialize Worktree

Overview

Core principle: Detect and confirm before running.

This skill initializes a newly created worktree's project environment. It detects the project type, proposes setup commands, and runs them only after user confirmation.

When invoked: After a new worktree is created by flow:start or flow:continue. NOT invoked for existing worktrees or regular checkouts.

Quick Reference

StepActionKey Point
1. Read docsCheck CLAUDE.md / README.mdDocs take priority
2. DetectInspect config filesFallback if no docs
3. ProposeShow commands to runAlways confirm first
4. ExecuteRun if user confirmsFailure is non-blocking

Algorithm

1. Read Project Documentation

Check for setup instructions in order:

  1. CLAUDE.md — project-specific instructions (highest priority)
  2. README.md — general project docs

Look for sections mentioning: "install", "setup", "getting started", "development", "dependencies".

If docs specify exact commands (e.g., "run uv sync"), use those commands.

2. Detect Project Type

If documentation doesn't provide clear commands, inspect config files at the current directory root:

FileProject TypeDefault Command
pyproject.tomlPython (uv)uv sync
package.json + pnpm-lock.yamlNode (pnpm)pnpm install
package.json + yarn.lockNode (yarn)yarn install
package.json + bun.lockbNode (bun)bun install
package.jsonNode (npm)npm install
Cargo.tomlRustcargo build
GemfileRubybundle install
go.modGogo mod download
docker-compose.ymlDockerdocker compose up -d

Priority: Documentation commands > lockfile-specific detection > default commands.

3. Propose Commands

If project type recognized, show what will run and ask:

Обнаружен Python-проект (pyproject.toml). Предлагаю выполнить инициализацию:
  → uv sync

Выполнить? (да/нет)

Multiple project types:

Обнаружены конфигурации проектов:
  → uv sync (pyproject.toml)
  → npm install (package.json)

Выполнить? (да/нет)

If nothing recognized — skip silently. Do NOT ask "no project detected, skip?"

4. Execute

If user confirms — run commands one by one. Show output.

If any command fails — show the error and continue. Init failure is non-blocking:

⚠️ Инициализация завершилась с ошибкой:
  uv sync → exit code 1: <error message>

Продолжаем работу. Вы можете запустить инициализацию вручную позже.

If user declines — skip silently and continue.

Scope Boundaries

This skill does NOT:

  • Create worktrees (caller's responsibility)
  • Decide whether to use worktree (caller's decision)
  • Check if worktree is new vs existing (caller filters this)
  • Run tests or lint
  • Modify project files

This skill DOES:

  • Read CLAUDE.md/README.md for setup instructions
  • Detect project type from config files
  • Propose initialization commands
  • Run commands after user confirmation

Red Flags

  • "I'll run uv sync without asking" → Always confirm first
  • "No need to check docs, I know the project type" → Docs take priority over guessing
  • "Init failed, I should stop the workflow" → Show error, continue. Non-blocking.
  • "I'll also run tests to make sure everything works" → Out of scope. Init only.
  • "The project has both pyproject.toml and package.json, I'll pick one" → Show both, let user decide

Common Rationalizations

ExcuseReality
"I'll run init without asking"Always confirm. User might not want it now.
"I know the project type, skip docs"Docs take priority. package.json could be npm, pnpm, yarn, or bun.
"Init failed, abort workflow"Show error, continue. Init failure is non-blocking.
"I'll also set up pre-commit hooks"Out of scope. Only run what was proposed and confirmed.
"Nothing to init, I'll tell the user"Skip silently if nothing recognized.
Skills Info
Original Name:init-worktreeAuthor:nonameitem