---
name: crew-new-task
description: Creates a crew task (TODO or CURRENT_TASKS) with its file and batch entry — written inline for a single task with a clear zone, through the manager persona for a multi-task breakdown or an ambiguous zone. Also triggers on — "/crew-new-task", "crée une tâche", "ajoute au backlog", "découpe ça en tâches", "create a task", "add to the backlog", "break this into tasks".
---

Standardizes task creation. The rules it needs are inlined below, so there is
no need to read `crew/CLAUDE_CONTEXT/LIFECYCLE.md`; open its § Task management /
§ Batching only for a case not covered here.

**Repo-root anchoring is mandatory**: every `crew/...` path resolves **from the
repo root**, never from the cwd — in a subfolder session a relative `crew/...`
would create a phantom `crew/` there.

## Rules (inlined from LIFECYCLE)

- A task = one `crew/<FOLDER>/<slug>.md`, never in two folders. Born in
  `crew/CURRENT_TASKS/` if it starts now, otherwise `crew/TODO/`.
- Content: title, short "why", the zone line, then concrete tickable `- [ ]`
  actions (not vague ones).
- Zone line: ``Zone : `path/`, `file.ext` `` — **every path in backticks**: the
  hook ignores the others, and a batch with no parsed zone is skipped by
  `count` / `next-task`.
- Every task gets an entry in `crew/CLAUDE_BATCH.md`: zone overlapping or
  depending on an existing batch → append `` N. `<slug>.md` `` to that batch's
  list; otherwise a new section `## Batch <slug> · <short title>` + zone line +
  `` 1. `<slug>.md` ``; zone unknown → the `## Unsorted` section (or the legacy
  `## À classer` if that is the header the file has).
- Invariant: one batch = one Claude, two **active** batches (a task in
  `CURRENT_TASKS/`) never share a zone. A new task whose zone overlaps an
  active batch → attach it to that batch, sequenced after its current task,
  **and** create it in `TODO/` — never in `CURRENT_TASKS/`.
- `INDEX.md` files are regenerated by the hook at the end of the turn — do not
  hand-edit them. Never touch a file outside `crew/`. Never write code.

## Steps

1. One Bash call for the state (duplicates, active zones, team mode):

   ```bash
   ROOT="$(git rev-parse --show-toplevel)"
   HOOK="${CLAUDE_PLUGIN_ROOT:+$CLAUDE_PLUGIN_ROOT/scripts}"; HOOK="${HOOK:-$ROOT/crew}/crew_hook.py"
   ls "$ROOT"/crew/{TODO,CURRENT_TASKS,PAUSED}/; CLAUDE_PROJECT_DIR="$ROOT" python "$HOOK" count
   grep -c "remote_claims : true" "$ROOT/crew/CLAUDE_CONTEXT/CREW_CONFIG.md" 2>/dev/null
   ```

   Existing task with the same intent → stop, no duplicate. Ambiguous product
   or scope call → `ceo` first.
2. **Remote claims** (only if the grep found `remote_claims : true`):
   `python "$HOOK" claims check-dup --title "<title>" --zone "<zones>"` before
   writing — non-empty `duplicates` → show them (title, holder, reason) and ask;
   after writing, `python "$HOOK" claims publish <slug>.md --title "<title>" --zone "<batch zones>" --body-file crew/<TODO|CURRENT_TASKS>/<slug>.md`.
   `offline` or failure → non-blocking, flag it.
3. Choose the path:
   - **Inline (default)** — a single task with a clear zone: write the task
     file, then the `CLAUDE_BATCH.md` entry (new batch → append the section;
     existing batch → `grep -n "^## "` and Read only that section before the
     Edit). No subagent.
   - **`manager`** — **≥2 tasks**, or zone / batch attachment ambiguous:
     dispatch **a single** `Agent({subagent_type: "manager"})` with the template
     below. No `manager` persona in this project → inline.
4. Report: path of the created file(s), summary of the actions, landing
   batch/section, and any external dependency (cross-repo, sequencing).

## Prompt template for the manager agent

```
New task(s) to add to the crew backlog.

<description of the feature/problem, context, why>

Known technical context:
<files/modules concerned if known, cross-repo dependencies if this project
has any, existing crew tasks to look at for a similar convention/infra>

Apply the standard lifecycle (already in your role): file(s) in
crew/TODO/ or crew/CURRENT_TASKS/, concrete tickable `- [ ]` actions,
CLAUDE_BATCH.md categorization (impact zone with every path in backticks,
existing or new batch, disjointness invariant), nothing outside crew/.

Report: path of the created file(s), summary of the tickable actions chosen,
and landing batch/section in CLAUDE_BATCH.md.
```
