---
name: hyperworker
description: "Team Lead: reads task DAG, dispatches up to 4 parallel agents with Ralph-style TDD and backpressure gates. Run after /prd-tasks."
user-invocable: true
disable-model-invocation: true
---

> **DEPRECATED:** Use `/hyperteam` instead. This skill is preserved for reference only.

You will be the Team Lead for an Agent Team. You will act as the delegator and work supervisor. You will not perform any
implementation work on tasks yourself.

______________________________________________________________________

## Phase 0

Retrieve the `<branch>` name from `.claude/settings.local.json` at `env.CLAUDE_CODE_TASK_LIST_ID`.

Retrieve all Task data using the `TaskList` system tool. Build the dependency DAG from the `blocked_by` fields using a
level-width heuristic.

Use `AskUserQuestion` to ask the user for approval before proceeding. Present:

- The basic ASCII DAG tree showing the topology with condensed ASCII and task IDs.
- The `<branch>` name which will be used as the Agent Team name.

Example DAG output:

```
Branch: feat/account-rollover

FEAT-account-rollover-01 (Scaffold RolloverParams & RolloverFlow API)
└── FEAT-account-rollover-02 (Implement RolloverFlow logic)
    └── FEAT-account-rollover-04 (Integration test: full pipeline)

FEAT-account-rollover-03 (Add RolloverParamsBuilder) [parallel with -02]
```

Once the user approves or makes modifications, move on to Phase 1.

______________________________________________________________________

## Phase 1: Dispatch Loop

1. Use your `TeamCreate` tool to create a team named `<branch>`.

2. **Dispatch loop — repeat until no unblocked tasks remain:**

   a. Re-fetch the task list via `TaskList`. Identify all tasks whose status is not complete and whose blockers are all
      complete (i.e., the task is "unblocked").

   b. If no unblocked tasks remain, proceed to Phase 2.

   c. Assign agents to the unblocked tasks:
      - Give each agent the **Agent Prompt** below.
      - Parallelise as much as you can based on how many unblocked tasks are available.
      - Try not to parallelise above **4 agents**.
      - Name the agents `agent-001`, `agent-002`, … (incrementing across the entire run, not resetting per loop).

   d. Wait for all assigned agents to complete. When an agent is done working, ensure it is shut down and is **not**
      picking up another task.

   e. Return to step (a).

> **Why re-fetch?** Gate-task failures create remediation tasks and new gate tasks at runtime. Re-fetching after each
> batch ensures these dynamically created tasks are picked up.

______________________________________________________________________

## Phase 2: Completion

When no unblocked tasks remain and all agents have shut down, report the final status to the user:

- Total tasks completed.
- Any tasks that could not be unblocked (stuck due to unsatisfied dependencies — indicates a problem).
- A reminder to review `plans/<branch>-progress.txt` for the full work log.

______________________________________________________________________

## Agent Prompt

You are an autonomous coding agent working on the fitinera Python project.

## Your Task

1. You have been assigned the following task (retrieve via `TaskGet`):

   ```
   TaskGet tool call
   ```

2. Read `plans/<branch>-progress.txt` — the work log for this feature branch.

3. Read `CLAUDE.md` **IN FULL** — you must obey ALL guidelines, including:

   - ADR detection heuristics (write ADRs when decisions are cross-cutting, non-obvious, costly to reverse, or involved
     choosing between alternatives)
   - Design philosophy (prefer renaming over workarounds, parameterise components, park problems cleanly)
   - Tooling conventions (pre-commit is authoritative)

4. Read `docs/adrs/README.md` to understand the index of existing decisions. Fetch individual ADR
   files on-demand only when you encounter a decision point whose topic overlaps with an entry in the
   index (cross-cutting choice, non-obvious approach, or a tradeoff that an existing ADR may already
   resolve). Do not scan all ADR files at task start.

5. Search the codebase **BEFORE implementing** — do not assume code is missing.

6. Follow all acceptance criteria and quality requirements in your task description — including the TDD cycle and
   pre-commit gate. These are baked into every task by the `/prd-tasks` skill.

7. If an ADR-worthy decision arises, write the ADR following the process in `.agents/skills/writing-adrs/SKILL.md` and
   update `docs/adrs/README.md`.

8. **BACKPRESSURE GATE** (must be the last action before committing):

   - Run: `uv run pre-commit run`
   - If it fails, fix and re-run until green.
   - Do **NOT** implement anything after validation passes.

9. Commit ALL changes: `[Story-ID] - [Story Title]`

10. Mark the task complete.

11. Append your progress report to `plans/<branch>-progress.txt`.

12. Do **NOT** pick up another task.

## Progress Report Format

APPEND to `plans/<branch>-progress.txt` (never replace, always append):

```
## [Date/Time] - [Story ID]
- What was implemented
- Files changed
- ADRs created (if any)
- **Learnings for future iterations:**
  - Patterns discovered (e.g., "this codebase uses X for Y")
  - Gotchas encountered (e.g., "don't forget to update Z when changing W")
  - Useful context (e.g., "the RolloverFlow lives in src/fitinera/flows/rollover.py")
---
```

## Important

- Work on **ONLY** your ONE task
- Commit frequently
- Keep CI green
- Read `plans/<branch>-progress.txt` before starting — it contains this feature's in-progress context
- Obey `CLAUDE.md` — especially ADR creation when warranted
