-
Notifications
You must be signed in to change notification settings - Fork 578
[MISC] Add worktree setup script for automated env file copying #1756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chandrasekharan-zipstack Better to move this script and other related scripts to the skill too inside the same skill folder at .claude/skills/worktree/.
- 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>
|
Test ResultsSummary
Runner Tests - Full Report
SDK1 Tests - Full Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"
| Match keywords in user's request to services: | ||
|
|
||
| | Keywords | Services | | ||
| |----------|----------| | ||
| | frontend, UI, react, component | frontend | | ||
| | backend, API, django | backend | | ||
| | platform, adapter, LLM | platform-service | | ||
| | prompt, studio | prompt-service | | ||
| | worker, celery, task | backend (includes workers) | | ||
| | x2text, extraction | x2text-service | | ||
|
|
||
| Default if unclear: `backend frontend` | ||
|
|
||
| 6. **Print summary with commands** | ||
|
|
||
| ``` | ||
| Worktree created! | ||
|
|
||
| Branch: {branch} | ||
| Path: {worktree_path} | ||
|
|
||
| ───────────────────────────────────────────────────────── | ||
| Continue in new worktree and paste your prompt: | ||
|
|
||
| cd {worktree_path} && claude | ||
|
|
||
| {user_request_slightly_made_better_for_new_agent_to_understand} | ||
| ───────────────────────────────────────────────────────── | ||
| Build & run services: | ||
|
|
||
| cd {worktree_path}/docker && \ | ||
| VERSION={version} docker compose -f docker-compose.yaml -f compose.override.yaml build {services} && \ | ||
| VERSION={version} docker compose -f docker-compose.yaml -f compose.override.yaml watch {services} | ||
| ───────────────────────────────────────────────────────── | ||
|
|
||
| Cleanup later: git worktree remove {worktree_path} | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix markdownlint warnings (table spacing + fenced language).
Adds spaces around table pipes and specifies a language for the summary block.
📝 Suggested markdown fixes
- | Keywords | Services |
- |----------|----------|
- | frontend, UI, react, component | frontend |
- | backend, API, django | backend |
- | platform, adapter, LLM | platform-service |
- | prompt, studio | prompt-service |
- | worker, celery, task | backend (includes workers) |
- | x2text, extraction | x2text-service |
+ | Keywords | Services |
+ | --------------------------------- | -------- |
+ | frontend, UI, react, component | frontend |
+ | backend, API, django | backend |
+ | platform, adapter, LLM | platform-service |
+ | prompt, studio | prompt-service |
+ | worker, celery, task | backend (includes workers) |
+ | x2text, extraction | x2text-service |
@@
- ```
+ ```text
Worktree created!
@@
- ```
+ ```🧰 Tools
🪛 markdownlint-cli2 (0.20.0)
[warning] 41-41: Table column style
Table pipe is missing space to the right for style "compact"
(MD060, table-column-style)
[warning] 41-41: Table column style
Table pipe is missing space to the left for style "compact"
(MD060, table-column-style)
[warning] 41-41: Table column style
Table pipe is missing space to the right for style "compact"
(MD060, table-column-style)
[warning] 41-41: Table column style
Table pipe is missing space to the left for style "compact"
(MD060, table-column-style)
[warning] 53-53: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
In @.claude/skills/worktree/SKILL.md around lines 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.



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