[MISC] Add worktree setup script for automated env file copying#1756
[MISC] Add worktree setup script for automated env file copying#1756chandrasekharan-zipstack wants to merge 4 commits intomainfrom
Conversation
- Add scripts/worktree-setup.sh to automate copying .env files when creating new worktrees for the unstract repo - Update .gitignore to exclude worktree directories from tracking This helps developers quickly set up isolated development environments with all necessary configuration files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughThe changes introduce a new Git Worktree skill that automates creation of isolated git worktrees for parallel development. This includes documentation describing the workflow, a Bash script for automating configuration file copying during worktree setup, and updated .gitignore entries to track the skill files. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Add .claude/skills/worktree/SKILL.md with instructions for creating git worktrees with automatic env file copying - Update .gitignore to allow .claude/skills/ to be tracked This skill helps developers create isolated worktrees for parallel development with automatic configuration file setup. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move worktree-setup.sh into skill folder - Add gitignored backend settings copy - Streamline skill to end after worktree creation - Output copyable claude command and docker build/watch commands - Detect services from user request keywords Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In @.claude/skills/worktree/SKILL.md:
- Around line 38-74: Update the Markdown to satisfy markdownlint: add spaces
around table pipes in the Keywords → Services table so each cell is separated
like " | " (fix header and rows), and mark the example summary fenced code block
as language "text" by changing the opening fence to ```text and ensuring the
closing ``` remains; specifically edit the "Match keywords in user's request to
services" table and the "Print summary with commands" fenced block to apply
these changes.
🧹 Nitpick comments (2)
.claude/skills/worktree/worktree-setup.sh (2)
25-39: Add a guard to ensure the target is a git worktree.Without a check, a typo can copy secrets into an unintended directory. Consider failing fast if the target isn’t a worktree.
🔒 Suggested guard
TARGET_PATH="$1" SOURCE_PATH="${2:-$(cd "$(dirname "$0")/../../.." && pwd)}" if [ -z "$TARGET_PATH" ]; then show_usage 1 fi @@ SOURCE_PATH=$(cd "$SOURCE_PATH" && pwd) + +# Ensure target is a git worktree before copying secrets +if [ ! -d "$TARGET_PATH" ] || ! git -C "$TARGET_PATH" rev-parse --is-inside-work-tree > /dev/null 2>&1; then + echo "Error: target path is not a git worktree: $TARGET_PATH" >&2 + exit 1 +fi
63-150: Separate “updated” from “copied” in the summaries.Right now updates are counted as copies, which makes the final counts misleading.
♻️ Suggested counter split
-copied=0 +copied=0 +updated=0 skipped=0 missing=0 @@ if ! diff -q "$src" "$dest" > /dev/null 2>&1; then cp "$src" "$dest" echo " [updated] $file" - copied=$((copied + 1)) + updated=$((updated + 1)) else echo " [skipped] $file (unchanged)" skipped=$((skipped + 1)) fi @@ -echo "Env files: Copied=$copied, Skipped=$skipped, Missing=$missing" +echo "Env files: Copied=$copied, Updated=$updated, Skipped=$skipped, Missing=$missing" @@ -settings_copied=0 +settings_copied=0 +settings_updated=0 settings_skipped=0 @@ if [ -f "$dest" ]; then if ! diff -q "$file" "$dest" > /dev/null 2>&1; then cp "$file" "$dest" echo " [updated] $filename" - settings_copied=$((settings_copied + 1)) + settings_updated=$((settings_updated + 1)) else echo " [skipped] $filename (unchanged)" settings_skipped=$((settings_skipped + 1)) fi @@ -echo "Settings: Copied=$settings_copied, Skipped=$settings_skipped" +echo "Settings: Copied=$settings_copied, Updated=$settings_updated, Skipped=$settings_skipped"
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|
|



What
scripts/worktree-setup.shscript to automate copying .env files when creating new worktrees.claude/skills/worktree/SKILL.md- a Claude Code skill for creating git worktrees.gitignoreto exclude worktree directories and allow.claude/skills/to be trackedWhy
How
Setup Script (
scripts/worktree-setup.sh):Copies necessary configuration files from the source repository to a new worktree:
backend/.envplatform-service/.envprompt-service/.envx2text-service/.envdocker/essentials.envworkers/.envUsage:
scripts/worktree-setup.sh <worktree_path> <source_repo_path>Worktree Skill (
.claude/skills/worktree/SKILL.md):A Claude Code skill that provides instructions for:
fix/,feat/,misc/prefixes)Can this PR break any existing features?
No, this adds new utility scripts and a skill. No existing functionality is affected.
Database Migrations
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
git worktree add -b test/branch ../test-worktree origin/mainscripts/worktree-setup.sh ../test-worktree ./worktreeskill in Claude Code (requires Claude Code CLI)Screenshots
🤖 Generated with Claude Code