Skip to content

Commit 3997275

Browse files
JacobCoffeeclaude
andcommitted
fix: make worktree target subagent-friendly with NAME parameter
Previously, `make worktree` used an interactive `read` prompt that failed for subagents (resulting in invalid branch name `feature/`). Now supports: - Non-interactive: `make worktree NAME=my-feature` (for subagents) - Interactive: `make worktree` (prompts for name, backward compatible) - Validation: Fails gracefully if name is empty with helpful error message This allows subagents to create worktrees without manual intervention while maintaining the interactive experience for human developers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 8617c06 commit 3997275

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,18 @@ infra-down: ## Stop PostgreSQL infrastructure
265265

266266
##@ Git Worktrees
267267

268-
worktree: ## Create a new git worktree for feature branch
268+
worktree: ## Create a new git worktree for feature branch (Usage: make worktree NAME=my-feature)
269269
@echo "=> Creating git worktree"
270-
@read -p "Feature name: " name; \
270+
@if [ -z "$(NAME)" ]; then \
271+
read -p "Feature name: " name; \
272+
else \
273+
name="$(NAME)"; \
274+
fi; \
275+
if [ -z "$$name" ]; then \
276+
echo "ERROR: Feature name cannot be empty"; \
277+
echo "Usage: make worktree NAME=my-feature"; \
278+
exit 1; \
279+
fi; \
271280
git checkout main && git pull && \
272281
git worktree add worktrees/$$name -b feature/$$name && \
273282
mkdir -p worktrees/$$name/.claude && \

0 commit comments

Comments
 (0)