name: worktree-sync description: Sync untracked .claude/ files (settings, hooks) to all active worktrees and report setup health. disable-model-invocation: false allowed-tools: Bash, Read
Boot
At session start, before running any of the steps below, source the project's pipeline.config so the PIPELINE_* variables are available for the rest of this skill, and self-resolve CLAUDE_PLUGIN_ROOT in case the env var is unset in the Bash subshell:
source "$(pwd)/pipeline.config" 2>/dev/null || source ./pipeline.config
# Self-resolve CLAUDE_PLUGIN_ROOT in case the env var is unset in the Bash subshell.
# Anchor via the plugin cache glob (var-independent — no chicken-and-egg dependence on
# CLAUDE_PLUGIN_ROOT to FIND the resolver). _cpr_dir is the dir prefix; literal source line.
_cpr_dir="${CLAUDE_PLUGIN_ROOT:+${CLAUDE_PLUGIN_ROOT}/}"
_cpr_dir="${_cpr_dir:-$(ls -d ${HOME}/.claude/plugins/cache/claude-pipeline-local/pipeline/*/ 2>/dev/null | sort -V | tail -1)}"
_cpr_dir="${_cpr_dir:-$(ls -d ${HOME}/.claude/plugins/cache/claude-pipeline/pipeline/*/ 2>/dev/null | sort -V | tail -1)}"
source "${_cpr_dir}scripts/_resolve-plugin-root.sh" 2>/dev/null || true
The bash code blocks below reference these variables via PIPELINE_REPO, PIPELINE_BASE_BRANCH, PIPELINE_TEST_CMD, PIPELINE_CONTEXT_FILES, etc. — they resolve from the sourced config, not from envsubst at install time. When prose refers to a config value by name (e.g., "the base branch is PIPELINE_BASE_BRANCH"), look it up in the sourced config.
Worktree Sync
prune orphaned branches → scan worktrees → diff .claude/ → copy missing/outdated → report
Run the sync script to check all active worktrees for missing or outdated files and fix them:
bash ${CLAUDE_PLUGIN_ROOT}/scripts/sync-worktrees.sh
Report the results to the user.