بنقرة واحدة
execute-merge
Merges completed task worktree to main branch. Handles sequential merge queue to prevent conflicts.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Merges completed task worktree to main branch. Handles sequential merge queue to prevent conflicts.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
Break down a PRD or CRD into self-contained implementation tasks for LLM execution. Use when you have a PRD/CRD file and want to generate executable task files for autonomous implementation.
Incremental PROJECT.md update using git diff. Only re-analyzes changed areas for efficient context maintenance.
Analyze the impact of a proposed change on an existing codebase. Identifies affected files, features, and potential breaking changes.
Deep codebase investigation to generate PROJECT.md context. Analyzes architecture, patterns, features, APIs, and schemas.
Orchestrates Change Request Document workflow. Manages context, captures changes, analyzes impact, and generates CRD files.
Handles one batch of tasks. Spawns task agents in parallel using git worktrees, waits for completion, and updates state.
استنادا إلى تصنيف SOC المهني
| name | execute-merge |
| description | Merges completed task worktree to main branch. Handles sequential merge queue to prevent conflicts. |
| context | fork |
| allowed-tools | Read Write Bash Glob |
| model | claude-sonnet-4-5 |
You merge a completed task's worktree branch into the main branch. Tasks complete in parallel but merge sequentially to avoid conflicts.
Parse these from the prompt:
| Argument | Required | Description |
|---|---|---|
--task-id <id> | Yes | Task ID to merge (e.g., "L1-001") |
--project-path <path> | Yes | Main project directory |
--worktree-path <path> | Yes | Path to task's worktree |
--task-file <path> | Yes | Task XML for commit context |
--tasks-path <path> | Yes | Tasks directory for state update |
Read task file for commit message context:
cat {task_file}
Extract:
<meta><id>: Task ID<meta><name>: Task name<meta><layer>: Layer name<requirements>: For commit message summaryCheck worktree is ready for merge:
cd {worktree_path}
# Check we're on the right branch
git branch --show-current
# Expected: worktree-{task_id}
# Check for uncommitted changes
git status --porcelain
# Expected: empty (all changes committed)
# Get commit count
git rev-list --count main..HEAD
# Expected: >= 1
If there are uncommitted changes (shouldn't happen normally):
cd {worktree_path}
git add .
git commit -m "$(cat <<'EOF'
[{task_id}] Uncommitted changes before merge
Auto-committed by merge agent.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
EOF
)"
cd {project_path}
# Ensure we're on main
git checkout main
# Pull latest (in case of external changes)
git fetch origin main
git merge origin/main --ff-only 2>/dev/null || true
Use --no-ff to preserve merge history:
cd {project_path}
git merge --no-ff worktree-{task_id} -m "$(cat <<'EOF'
Merge worktree-{task_id}: {task_name}
Layer: {layer}
Task: {task_id}
Commits: {commit_count}
Implements:
- {requirement_1_summary}
- {requirement_2_summary}
Verification: Passed
EOF
)"
If merge succeeds:
If merge fails (conflict):
git merge --abortAfter successful merge:
cd {project_path}
# Remove worktree
git worktree remove {worktree_path}
# Delete the branch
git branch -d worktree-{task_id}
If removal fails:
git worktree remove --force {worktree_path}
git branch -D worktree-{task_id}
Update execute-state.json:
state["tasks"][task_id]["status"] = "completed"
state["tasks"][task_id]["merged_at"] = now()
state["tasks"][task_id]["worktree_path"] = None
state["tasks"][task_id]["branch"] = None
# Update merge queue
for item in state["merge_queue"]:
if item["task_id"] == task_id:
item["status"] = "merged"
# Add to completed list
state["completed"].append(task_id)
# Remove from worktrees
del state["worktrees"][task_id]
# Update metrics
state["metrics"]["tasks_completed"] += 1
state["metrics"]["tasks_remaining"] -= 1
Success:
{
"task_id": "L1-001",
"status": "merged",
"merge_commit": "abc1234567890",
"commits_merged": 2,
"worktree_cleaned": true,
"branch_deleted": true
}
Conflict (should not happen):
{
"task_id": "L1-001",
"status": "conflict",
"conflict_files": ["app/models/__init__.py"],
"conflict_type": "both_modified",
"worktree_preserved": true,
"resolution_needed": true,
"suggested_action": "Manually resolve conflict in worktree, then re-run merge"
}
Merge worktree-L1-001: Create enums and constants
Layer: 1-foundation
Task: L1-001
Commits: 2
Implements:
- ProjectStatus enum (draft, in_progress, complete)
- PersonaType enum (developer, designer, pm)
Verification: Passed
The layer agent ensures merges happen in priority order:
Merge Queue:
Priority 1: L1-001 (status: ready) ← Merge this first
Priority 2: L1-002 (status: ready) ← Wait
Priority 3: L1-006 (status: pending) ← Still implementing
Each task waits for lower-priority tasks to merge before proceeding.
This ensures:
On merge failure:
git merge worktree-{task_id}
# fatal: worktree-L1-001 - not something we can merge
Action: Check if branch exists, report error if not.
git worktree remove {worktree_path}
# fatal: '{worktree_path}' is not a working tree
Action: Already removed (maybe manual cleanup). Continue.
git checkout main
# error: Your local changes would be overwritten
Action: Error - main should always be clean. Report and stop.
git merge --no-ff worktree-{task_id}
# CONFLICT (content): Merge conflict in app/models/__init__.py
# Automatic merge failed; fix conflicts and then commit.
Action:
git merge --abort[MERGE] L1-001 → main (abc1234)
MERGE_RESULT:
{json object}
| Command | Purpose |
|---|---|
git merge --no-ff branch | Merge preserving history |
git merge --abort | Cancel conflicting merge |
git worktree remove path | Remove worktree |
git worktree remove --force path | Force remove |
git branch -d branch | Delete merged branch |
git branch -D branch | Force delete branch |
git rev-parse HEAD | Get current commit hash |
git rev-list --count main..HEAD | Count commits since main |