Certainly! Here's a potential solution styled as you might see as a good answer on Laracasts, in response to the original post:
Great idea! Managing multiple isolated git worktrees for Laravel development is a real productivity booster, especially with Herd. Thanks for sharing your plugin and approach!
If anyone wants to achieve similar isolated environments manually or extend your workflow, here’s a rundown:
Manual Approach Summary
You want each worktree to have:
- Its own
.env - Unique database and DB credentials
- Herd (Valet) domain
- Clean
node_modules& dependencies, unique Vite port (for Hot Module Reloading)
1. Creating an Isolated Worktree
Suppose your main project is in ~/Sites/myapp:
# Add a new worktree for the feature branch
git worktree add ../myapp-feature-billing feature-billing
cd ../myapp-feature-billing
cp ../myapp/.env.example .env
Edit .env:
- Set a unique
DB_DATABASE,DB_USERNAME,DB_PASSWORD - Use a unique Vite port:
VITE_PORT=localhost:5174 - For Herd, use a unique
APP_URL(e.g.feature-billing.myapp.test)
2. Database Setup
# For MySQL
mysql -u root -p -e "CREATE DATABASE myapp_feature_billing;"
# Update .env
DB_DATABASE=myapp_feature_billing
Run migrations:
php artisan migrate
3. Herd Domain
If using Laravel Herd:
Open Herd and add the new worktree folder as a new site, with the unique domain matching your .env.
Or, for Valet (if not Herd):
valet link feature-billing-myapp
valet secure feature-billing-myapp
Update APP_URL=https://feature-billing-myapp.test in .env.
4. Dependencies and Vite
Determine your package manager, then install dependencies:
# Node dependencies
npm install
# or
yarn install
# or
pnpm install
Start Vite on a unique port:
npm run dev -- --port=5174
5. Automate With Scripts
What the claude-skills plugin/skill does is automate all this in one go, plus add nice setup/teardown hooks. You can roll your own as well, e.g.:
#!/bin/bash
BRANCH=$1
WORKDIR=../myapp-$BRANCH
git worktree add $WORKDIR $BRANCH
cd $WORKDIR
cp ../myapp/.env.example .env
# Here you'd use sed or envsubst to patch .env with new DB name, VITE port, APP_URL, etc.
# Create DB, link Herd domain, etc.
Reverse in the teardown script (drop DB, remove domain, remove worktree).
6. Conclusion
If you want it done for you, definitely try:
/plugin marketplace add gausejakub/claude-skills
/plugin install laravel-worktrees@gause-claude-skills
and follow the full setup guide.
If you want to suggest improvements:
- Add support for custom DB ports (sometimes people have multiple SQL servers)
- Auto-detect available ports more robustly
- Integrate with other local dev tools (e.g. Mailpit)
- Optional ENV var override prompts
Thanks for sharing! Would love to hear how it works on bigger multi-service apps or with Dusk tests.
Let me know if you want a ready-to-edit bash script template for manual setup.
References: