Skip to content

Conversation

@conorbranagan
Copy link

Overview

Adds the ability to bootstrap a worktree with commands + copy over files that are explicitly ignored. This is useful for getting your worktree into a working state for claude to be able to test things locally.

Might do better as a per-repo config, but wanted to keep the changes limited to the existing config. You can workaround this, as shown in the example, to only run commands when specific files exist.

Changes

  • Added worktree_setup config section with:
    • copy_ignored: List of glob patterns for gitignored files to copy
    • run: List of commands to execute after worktree creation
  • Validates and skips absolute paths (starting with /)
  • Only copies files that are actually gitignored

Example config

{
  "worktree_setup": {
    "copy_ignored": [".env.local", "config/*.secret"], 
    "run": ["[ -f package.json ] && pnpm install || exit 0", "cp .env.example .env"]
  }
}

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@conorbranagan
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

@conorbranagan conorbranagan force-pushed the feat/worktree-setup-config branch from a50fbf4 to f8869ea Compare July 7, 2025 21:56
- Add worktree_setup configuration for bootstrapping new worktrees
- Capture command output to prevent TUI interference
@conorbranagan conorbranagan force-pushed the feat/worktree-setup-config branch from f8869ea to 1254989 Compare July 7, 2025 21:57
@mufeez-amjad
Copy link
Member

@conorbranagan I just came across this, looks like it's possible to add a hook that runs after creating a worktree: https://mskelton.dev/bytes/using-git-hooks-when-creating-worktrees

might be more better than handling it inside of cs, since it's a standard git feature

@conorbranagan
Copy link
Author

Ah, I had looked for this originally but guess I missed it. Agreed that going the hooks route is a better approach, thanks for the pointer. I'll close this one out.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants