Skip to content

Feat/territory based parallel worktree split#14

Open
rafaelpapastamatiou-afya wants to merge 7 commits into
iclinic:masterfrom
allanbrunoafya:feat/territory-based-parallel-worktree-split
Open

Feat/territory based parallel worktree split#14
rafaelpapastamatiou-afya wants to merge 7 commits into
iclinic:masterfrom
allanbrunoafya:feat/territory-based-parallel-worktree-split

Conversation

@rafaelpapastamatiou-afya

Copy link
Copy Markdown
Collaborator

No description provided.

allanbrunoafya and others added 6 commits April 9, 2026 13:22
…k groups

Add opt-in parallel execution during plan→implement transition. When the
plan contains disconnected task groups (no shared dependencies or files),
the user is offered a choice: sequential (default) or parallel worktrees
with territory-based file isolation.

New skill: parallel-split
- Builds territory map per task group (ownedFiles, forbidden, shared)
- Creates git worktrees with afyapowers state pre-populated at implement phase
- Generates PROMPT.md with territory protocol per worktree
- Supports Warp, tmux, and manual terminal launch
- Writes territory_map.json for merge orchestration

Modified: next command (Step 5A)
- Parses plan dependency graph to detect disconnected components
- Presents choice only when 2+ independent groups exist
- Falls through to normal flow when plan is fully connected

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address all 4 review findings:

1. CRITICAL — Parent state path: Revert next.md to original. Worktrees
   now run ONLY implement phase, merge back into parent branch, and the
   parent continues with review→complete seeing the consolidated diff.

2. IMPORTANT — Partial review/complete: Removed review and complete from
   worktree PROMPT.md. Worktrees create WORKTREE_COMPLETE.md and stop.
   Parent handles unified review and completion after merge.

3. IMPORTANT — Chain architecture: Moved split choice from next command
   into implementing skill (between plan validation and SDD invocation).
   This respects the implementing→SDD chain without bypassing it.

4. IMPORTANT — history.yaml format: Fixed to append under `events:` root
   key matching the framework convention from new.md.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Worktrees now copy and update the canonical plan.md at
  .afyapowers/features/<slug>/artifacts/plan.md so checkbox
  changes merge back cleanly into the parent branch
- TASK_SCOPE.md is now a read-only scope summary, not the
  source of truth for task progress
- Removed claude CLI coupling from parallel-split — MCP setup
  is optional and host-specific, not hardcoded
- implementing skill clarifies post-merge path: if all [x]
  run /afyapowers:next, otherwise stay in implement

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace hardcoded `claude` CLI in Warp launch config with
  <agent-launch-command> placeholder for host-agnostic distribution
- Document plan.md merge conflict resolution: preserve all valid
  [x] checkboxes from both sides when merging worktree branches
- Clarify _deferred/ as temporary merge aid, not final product
  code — consolidate during parent merge then remove

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rafaelpapastamatiou-afya rafaelpapastamatiou-afya marked this pull request as ready for review April 9, 2026 20:47

@gitstream-cm gitstream-cm Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✨ PR Review

This PR introduces a sophisticated parallel worktree feature with territory-based file isolation. The approach is well-structured, but there are several critical shell command issues and missing error handling that need attention before deployment.

5 issues detected:

🐞 Bug - rm without -r cannot remove directories, leaving orphaned files after cleanup 🛠️

Details: _The cleanup command will fail to remove the deferred directory because rm requires the -r flag for directories.

File: dist/claude/skills/parallel-split/SKILL.md (342-342)
🛠️ A suggested code correction is included in the review comments.

🐞 Bug - Using literal template syntax in a grep pattern that expects actual values causes cleanup to fail silently 🛠️

Details: The grep pattern uses literal angle brackets "<feature_short>" that won't match actual worktree paths after variable substitution.

File: dist/claude/skills/parallel-split/SKILL.md (341-341)
🛠️ A suggested code correction is included in the review comments.

🧹 Maintainability - Critical git operations without error handling can leave the system in an inconsistent state with partial worktree setup

Details: The git worktree add command has no error handling instructions. If the branch already exists or the path conflicts, the script continues without detection.
File: dist/claude/skills/parallel-split/SKILL.md (84-84)

🐞 Bug - Unquoted shell variables break when paths contain spaces or special characters

Details: Shell variables in worktree paths are not quoted, which will cause failures if PROJECT_NAME or FEATURE_SHORT contain spaces or special characters.
File: dist/claude/skills/parallel-split/SKILL.md (78-84)

🧾 Readability - Ambiguous placeholder replacement instructions can lead to inconsistent PROMPT.md generation across worktrees

Details: Step 3D instructs to replace placeholders in territory-protocol.md but doesn't specify the output format for the territory data (e.g., whether OWNED_FILES should be a markdown list, JSON array, or plain text list).
File: dist/claude/skills/parallel-split/SKILL.md (124-124)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Review using Guidelines Learn how


5. Clean up:
git worktree list | grep "<feature_short>.*wt" | awk '{print $1}' | xargs -I {} git worktree remove {}
rm territory_map.json _deferred/ 2>/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐞 Bug - Broken Cleanup: Change rm territory_map.json _deferred/ 2>/dev/null to rm -f territory_map.json; [ -d _deferred ] && rm -rf _deferred

Suggested change
rm territory_map.json _deferred/ 2>/dev/null
rm -f territory_map.json; [ -d _deferred ] && rm -rf _deferred
Is this review accurate? Use 👍 or 👎 to rate it

If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over

If some tasks are still [ ], stay in implement and continue from there

5. Clean up:
git worktree list | grep "<feature_short>.*wt" | awk '{print $1}' | xargs -I {} git worktree remove {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐞 Bug - Literal Template: Replace the literal string "<feature_short>" with proper variable reference or provide clear instructions that this placeholder must be replaced with the actual feature_short value before execution.

Suggested change
git worktree list | grep "<feature_short>.*wt" | awk '{print $1}' | xargs -I {} git worktree remove {}
git worktree list | grep "${FEATURE_SHORT}.*wt" | awk '{print $1}' | xargs -I {} git worktree remove {}
Is this review accurate? Use 👍 or 👎 to rate it

If you want to tell us more, use /gs feedback e.g. /gs feedback this review doesn't make sense, I disagree, and it keeps repeating over and over

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8d5085e5-ba75-4818-adc7-e7d25b2f9239

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants