Skip to content

feat: add worktree init hook configuration#135

Merged
bborn merged 1 commit intomainfrom
task/261-add-worktree-init-hook-configuration
Jan 12, 2026
Merged

feat: add worktree init hook configuration#135
bborn merged 1 commit intomainfrom
task/261-add-worktree-init-hook-configuration

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 12, 2026

Summary

  • Add support for running a custom script after worktree creation
  • Enables project-specific initialization (e.g., symlinking Rails credential keys)
  • Configuration via .taskyou.yml or convention-based bin/worktree-setup

Configuration Options

Option 1: Configuration file

Create a .taskyou.yml (or .taskyou.yaml) file in your project root:

worktree:
  init_script: bin/worktree-setup

Option 2: Convention-based

If no config file exists, TaskYou will automatically run bin/worktree-setup if it exists and is executable.

Environment Variables

The init script receives these environment variables:

  • WORKTREE_TASK_ID: The task ID
  • WORKTREE_PORT: The allocated port for the task
  • WORKTREE_PATH: The path to the worktree

Example Use Case: Rails Credentials

#!/bin/bash
# bin/worktree-setup

MAIN_REPO=$(git worktree list | head -1 | awk '{print $1}')
ln -sf "$MAIN_REPO/config/master.key" config/master.key
ln -sf "$MAIN_REPO/config/credentials/development.key" config/credentials/development.key

Behavior

  • Script runs after worktree creation but before the app is started
  • Script runs with the worktree directory as cwd
  • Non-zero exit codes are logged as warnings but don't block worktree creation
  • Script output is captured and logged

Test plan

  • Unit tests for LoadProjectConfig function
  • Unit tests for GetWorktreeInitScript function
  • Tests verify config file precedence (.taskyou.yml > .taskyou.yaml)
  • Tests verify executable check for conventional script
  • All existing tests pass

🤖 Generated with Claude Code

Add support for running a custom script after worktree creation to
enable project-specific initialization (e.g., symlinking Rails
credential keys, copying config files).

Configuration options:
- .taskyou.yml with worktree.init_script setting
- Convention: bin/worktree-setup (if executable)

The script receives these environment variables:
- WORKTREE_TASK_ID: The task ID
- WORKTREE_PORT: The allocated port for the task
- WORKTREE_PATH: The path to the worktree

Script failures are logged as warnings but don't block worktree creation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bborn bborn merged commit 2cbd524 into main Jan 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant