description = "Automates task orchestration via planning, bash scripting, and parallel execution."
prompt = '''
MANDATORY: READ the entire file @.claude/agents/orchestrator.md (or  @.agents/orchestrator.md) to fully understand the orchestration method. DO NOT START WORKING BEFORE YOU UNDERSTAND THE CONTEXT.

When the user issues the `/delegate` command, follow this strict 5-step process:

## 1. Unique Plan Identification
- Generate a unique plan name based on the current date and the task scope (e.g., `PLAN_20260109_CSS_FIX`).
- Use this name for ALL files related to this delegation.
- Create a dedicated script directory: `bash/<PLAN_NAME>/`.

## 2. Plan & Task Mapping
- Document the strategy in `<PLAN_NAME>.md` in the project root.
- Create `<PLAN_NAME>.json` to track execution state.
- Include all tasks with their associated agent path, detailed prompt, status ("pending"), and any dependencies.

## 3. Orchestrate & Review
- Create `bash/<PLAN_NAME>/execute.sh`.
- **CRITICAL: SHELL ESCAPING**: To avoid shell execution errors (like "Permission denied" or "command not found"), use a quoted heredoc (`<<'EOF'`) to capture the full prompt for each task.
- Example structure for `execute.sh`:
  ```bash
  #!/bin/bash
  # Task 1
  (
    PROMPT=$(cat <<'EOF'
  $(cat ~/.claude/agents/<agent-path>.md)
  <detailed_prompt>
  EOF
  )
    gemini --yolo "$PROMPT" 2>&1 | tee -a <PLAN_NAME>.log
    if [ ${PIPESTATUS[0]} -eq 0 ]; then
      python3 -c "import json; f=open('<PLAN_NAME>.json', 'r+'); d=json.load(f); next(t for t in d['tasks'] if t['id']==1)['status']='completed'; f.seek(0); json.dump(d, f, indent=2); f.truncate()"
    fi
  ) &

  wait
  ```
- **CRITICAL**: Before executing, you MUST present a clear list of all tasks to the user, showing:
    - **Agent:** The path to the expert agent.
    - **Prompt:** The exact detailed prompt being sent.
- Wait for the user to acknowledge the plan details.

## 4. Execute & Monitor
- After user acknowledgment, run `chmod +x bash/<PLAN_NAME>/execute.sh && ./bash/<PLAN_NAME>/execute.sh`.
- Monitor terminal output, `<PLAN_NAME>.log` and `<PLAN_NAME>.json`.

## 5. Summarize
- Once all tasks are marked "completed" in the JSON file, provide a comprehensive summary of changes and verified statuses.

USER REQUEST:
{{args}}
'''
