Loading...
Loading...
Use when creating git worktrees for Maven projects - prevents SNAPSHOT artifact clashes and corporate plugin resolution failures through isolated local repositories
npx skill4agent add maxandersen/skills using-maven-worktrees~/.m2/repository/# Check in priority order
ls -d .worktrees 2>/dev/null # Preferred (hidden)
ls -d worktrees 2>/dev/null # Alternative.worktreesgrep -i "worktree.*director" CLAUDE.md 2>/dev/nullNo worktree directory found. Where should I create worktrees?
1. .worktrees/ (project-local, hidden)
2. ~/.config/superpowers/worktrees/<project-name>/ (global location)
Which would you prefer?# Check if directory is ignored
git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null# Determine full path (same as git worktrees)
project=$(basename "$(git rev-parse --show-toplevel)")
case $LOCATION in
.worktrees|worktrees)
path="$LOCATION/$BRANCH_NAME"
;;
~/.config/superpowers/worktrees/*)
path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME"
;;
esac
# Create worktree
git worktree add "$path" -b "$BRANCH_NAME"
cd "$path".mvn/maven.configmkdir -p .mvn
cat > .mvn/maven.config << 'EOF'
-Dmaven.repo.local=${session.executionRootDirectory}/.m2/repository
-Dmaven.repo.local.tail=${user.home}/.m2/repository
EOFmaven.repo.localmaven.repo.local.tail# Check maven.config exists and has both properties
cat .mvn/maven.config
# Expected output:
# -Dmaven.repo.local=${session.executionRootDirectory}/.m2/repository
# -Dmaven.repo.local.tail=${user.home}/.m2/repository# Check for wrapper
if [ -f ./mvnw ]; then
MVN_CMD="./mvnw"
elif [ -f ../mvnw ]; then
MVN_CMD="../mvnw"
else
MVN_CMD="mvn"
fimvn verifymvn install$MVN_CMD verifymvn installmvn verifymvn test.idea/*.iml.project.classpath.settings/.vscode/.idea/| Situation | Action |
|---|---|
| Use it (verify ignored) |
| Use it (verify ignored) |
| Both exist | Use |
| Neither exists | Check CLAUDE.md → Ask user |
| Directory not ignored | Add to .gitignore + commit |
| Tests fail during baseline | Report failures + ask |
| mvnw exists | Use |
| Baseline verification | Use |
| IDE files | Generate per worktree, don't share |
.mvn/maven.config-Dmaven.repo.local=${session.executionRootDirectory}/.m2/repository-Dmaven.repo.local.tail=${user.home}/.m2/repository~/.m2/repository.mvn/maven.configmvn installmvn verify| Excuse | Reality |
|---|---|
| "Default Maven config is fine" | Concurrent SNAPSHOT installs will clash without isolation |
| "maven.repo.local alone is enough" | Without tail, downloads everything fresh and plugins fail |
| "Shared repository is normal" | Normal for single workspace, broken for parallel worktrees |
| "No time for advanced setup" | Setup takes 30 seconds, debugging clashes takes hours |
| "This is complete isolation" | Complete = maven.repo.local + maven.repo.local.tail |
| "mvn install verifies properly" | mvn install pollutes repo, use mvn verify |
| "IDE files should be consistent" | IDE files reflect code structure, which varies by branch |
.mvn/maven.configmvn install.idea/mvn verifyYou: I'm using the using-maven-worktrees skill to set up an isolated Maven workspace.
[Check .worktrees/ - exists]
[Verify ignored - git check-ignore confirms]
[Create worktree: git worktree add .worktrees/feature-auth -b feature/auth]
[cd .worktrees/feature-auth]
[Create .mvn/maven.config with maven.repo.local + maven.repo.local.tail]
[Verify config exists and has both properties]
[Run ./mvnw verify - 127 tests passing]
Worktree ready at /Users/max/myproject/.worktrees/feature-auth
Maven isolation configured:
- maven.repo.local: .m2/repository (worktree-local)
- maven.repo.local.tail: ~/.m2/repository (shared cache)
Tests passing (127 tests, 0 failures)
Ready to implement authentication feature