---
name: eck:next-feature
version: "0.7.4"
description: "Auto-select the next backlog feature chronologically without prompting. Non-interactive alternative to /eck:select-feature."
disable-model-invocation: false
---

# Next Feature

Automatically select the next backlog feature by chronological order (`created_at`) and activate it. No user prompting — picks the oldest never-started feature. If a feature is currently active, it is auto-parked first.

> **Note:** For interactive selection from the backlog, use `/eck:select-feature` instead.

---

## Visual Framework

Follow these conventions for all terminal output displayed to the user via the Bash tool.

### Output Mode Awareness

Before producing output, read the user's preferred output mode:

```bash
cat $ECK_HOME/user-preferences.json 2>/dev/null
```

Extract the `outputMode` field and adapt verbosity:

- **guided** — Add explanatory prose after key steps. Describe what is happening and why.
- **standard** (default) — Balanced. Show steps with brief context for non-obvious decisions.
- **concise** — Steps and summary box only. No prose, no explanations.

If the file is missing or `outputMode` is absent, use **standard**.

### ANSI Colors

Declare these variables at the top of **every** Bash tool call (shell state does not persist between calls):

```bash
source $ECK_HOME/colors.sh
```

Every color sequence **must** end with `${RESET}`. No exceptions.

### Stage Banners

Mark major stage transitions with a bold banner. One blank line before and after.

```bash
echo ""
printf '%b\n' "${ORANGE}${BOLD}STAGE NAME${RESET}"
echo ""
```

### Status Symbols

| Symbol | Meaning          | Color       |
| ------ | ---------------- | ----------- |
| `[*]`  | Active / running | `${CYAN}`   |
| `[x]`  | Completed        | `${GREEN}`  |
| `[!]`  | Error            | `${RED}`    |
| `[-]`  | Skipped          | `${DIM}`    |
| `[>]`  | In progress      | `${YELLOW}` |
| `[ ]`  | Pending          | `${DIM}`    |

No emoji in output. Use only these bracket symbols for status.

### Summary Boxes

Display at checkpoints and at the end of the skill. One blank line before and after.

### Error Format

```bash
printf '%b\n' "${RED}[!]${RESET} Error message here"
printf '%b\n' "    ${DIM}Recovery guidance here.${RESET}"
```

### Spacing Rules

- One blank line before and after stage banners and summary boxes.
- No blank lines within step lists.
- Maximum output line width: 70 characters.

---

## Task Registration

| Stage | Subject           | Active Form        | Statusline     |
| ----- | ----------------- | ------------------ | -------------- |
| 1     | Stage 1: Select   | Selecting next     | Select (1/2)   |
| 2     | Stage 2: Activate | Activating feature | Activate (2/2) |

### Statusline Stage Updates

At the **start** of each stage, update the statusline:

```bash
bash $ECK_HOME/update-stage.sh "{Statusline text from table}"
```

At **skill completion** (success or error), reset:

```bash
bash $ECK_HOME/update-stage.sh
```

---

## Usage

```
/eck:next-feature     # auto-select oldest backlog feature
```

---

## Stage 1: Select

### Inputs

- `$ECK_HOME/manage-features.js list --status backlog`

### Activities

1. If a feature is already active, auto-park it:

   ```bash
   ACTIVE=$(node $ECK_HOME/update-lifecycle.js read 2>/dev/null | node -e "const d=JSON.parse(require('fs').readFileSync(0,'utf-8'));if(d.active_feature)console.log(d.active_feature)" 2>/dev/null)
   if [ -n "$ACTIVE" ]; then
     node $ECK_HOME/update-lifecycle.js deactivate
   fi
   ```

   Display: `[x] Auto-parked: {active_feature_name}`

2. Get the backlog (never-started features only):

   ```bash
   node $ECK_HOME/manage-features.js list --status backlog
   ```

3. If backlog is empty, stop with error:

   ```
   [!] No features in backlog
       Create a feature with /eck:create-feature first.
       To resume a parked feature, use /eck:resume-feature.
   ```

   -> STOP (reset statusline first)

4. Sort backlog features by `created_at` ascending (oldest first).

5. Auto-select the first (oldest) feature. Look up its name from `features.json`:
   ```bash
   FEATURES_JSON="$CLAUDE_PROJECT_DIR/.claude/features.json"
   NAME=$(jq -r --arg id "$FEAT_ID" '.features[$id].display_name // "<unknown>"' "$FEATURES_JSON")
   if [ "$NAME" = "<unknown>" ]; then
     printf 'Warning: orphan registry entry: %s has no features.json entry\n' "$FEAT_ID" >&2
   fi
   ```
   ```
   [x] Auto-selected: {KEY}-XXX $NAME (oldest backlog feature)
   ```

### Outputs

- A <KEY>-XXX selected for activation (oldest by `created_at`)

### Exit Criteria

- Feature selected automatically
- No conflicting active feature (was auto-parked if needed)

---

## Stage 2: Activate

### Inputs

- Selected <KEY>-XXX from Stage 1

### Activities

1. Activate the selected feature:

   ```bash
   node $ECK_HOME/update-lifecycle.js activate "$FEAT_ID"
   ```

2. Look up the feature name from `features.json`:

   ```bash
   FEATURES_JSON="$CLAUDE_PROJECT_DIR/.claude/features.json"
   NAME=$(jq -r --arg id "$FEAT_ID" '.features[$id].display_name // "<unknown>"' "$FEATURES_JSON")
   if [ "$NAME" = "<unknown>" ]; then
     printf 'Warning: orphan registry entry: %s has no features.json entry\n' "$FEAT_ID" >&2
   fi
   ```

3. Display summary box:

   ```
   Feature Selected

   Feature         {KEY}-XXX $NAME
   Status          active (from backlog)
   Progress        [ ] S [ ] D [ ] D [ ] V [ ] D
   Next command    /eck:spec {KEY}-XXX

   Run: /eck:spec {KEY}-XXX
   ```

   Note: Next step is always `/eck:spec` since the feature has never been started.

4. Log activity:

   ```bash
   node $ECK_HOME/log-activity.js --skill "eck:next-feature" --outcome "success" --summary "Auto-selected {KEY}-XXX $NAME from backlog (oldest)"
   ```

5. Reset statusline:
   ```bash
   bash $ECK_HOME/update-stage.sh
   ```

### Outputs

- Feature is active in lifecycle.json (keyed by <KEY>-XXX)
- Statusline reflects active feature (reads lifecycle.json directly)
- User sees next command to run (`/eck:spec <KEY>-XXX`)

### Exit Criteria

- Feature activated and statusline reflects it
- User has clear guidance that next step is `/eck:spec`

---

## Error Handling

- If `activate` fails, show the error output and stop
- If no lifecycle.json exists, treat as empty backlog
- At completion (success or error), always reset statusline
