---
name: eck:archive-feature
version: "0.7.4"
description: "Archive a feature, removing it from active tracking. Works on backlog, active, parked, or done features."
disable-model-invocation: false
---

# Archive Feature

Remove a feature from active consideration. Works on any non-archived feature (backlog, active, parked, or done). Archived features are excluded from queue, backlog, and statusline suggestions.

> Use `/eck:feature-status` to see archived features. Restore with manual lifecycle.json edit if needed.

---

## 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: Confirm | Confirming action | Confirm (1/2) |
| 2     | Stage 2: Archive | Archiving feature | Archive (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:archive-feature WA-042              # archive by {KEY}-XXX
/eck:archive-feature user-auth           # archive by slug (resolved)
/eck:archive-feature "User Auth"         # archive by name (resolved)
/eck:archive-feature                     # interactive selection
/eck:archive-feature WA-042 --close-issue            # archive + close tracker issue
/eck:archive-feature WA-042 --close-issue=not_planned  # archive + close as not planned
```

### Flags

| Flag                        | Purpose                                                          |
| --------------------------- | ---------------------------------------------------------------- |
| `--close-issue`             | Also close the feature's tracker issue (reason: `completed`)     |
| `--close-issue=not_planned` | Also close the feature's tracker issue with reason `not_planned` |

---

## Stage 1: Confirm

### Inputs

- `$ARGUMENTS` — <KEY>-XXX, feature slug, or name; optional `--close-issue` flag
- `$ECK_HOME/manage-features.js list` — full feature list for selection display
- `$ECK_HOME/manage-features.js resolve` — for slug/name lookup

### Activities

1. Parse `$ARGUMENTS` for the `--close-issue` flag:
   - `--close-issue` → set `CLOSE_ISSUE=true`, `CLOSE_REASON=completed`
   - `--close-issue=not_planned` → set `CLOSE_ISSUE=true`, `CLOSE_REASON=not_planned`
   - No flag → set `CLOSE_ISSUE=false`
   - Strip the flag from arguments before feature name matching.

2. **If no argument provided** (after stripping flags), get the non-archived feature list:

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

   Present non-archived features for selection:

   ```
   Features available to archive:

   1. [*] WA-042  User Authentication (active)
   2. [ ] WA-055  Email Templates (backlog)
   3. [>] WA-088  Billing API (parked)
   4. [x] WA-031  User Onboarding (done)
   ```

   Use AskUserQuestion to prompt for selection by number.

3. **If argument provided**, resolve it to a <KEY>-XXX:
   - If argument matches `<KEY>-XXX` format → use directly
   - Otherwise → `node $ECK_HOME/manage-features.js resolve "$ARGUMENT"`
   - If not found → show error and fall through to interactive selection

4. Read the resolved feature:

   ```bash
   node $ECK_HOME/manage-features.js read "$FEAT_ID"
   ```

5. Check if feature is already archived:
   - If `archived_at` is set → error: `[!] Feature already archived: <KEY>-XXX {display_name}`
   - → STOP

6. Determine current lifecycle status from `.claude/lifecycle.json` for the confirmation message.

7. **Confirmation gate** — stronger for active features:

   For active features:

   ```
   This feature is currently ACTIVE with in-progress work.
   Archiving will deactivate it and revert active steps to pending.

   Are you sure you want to archive "{KEY}-XXX {display_name}"? (yes/no)
   ```

   For other states:

   ```
   Archive "{KEY}-XXX {display_name}" ({status})? This removes it
   from active tracking. (yes/no)
   ```

   If user declines → STOP with: `[-] Archive cancelled`

### Outputs

- <KEY>-XXX confirmed for archiving
- User has confirmed the action

### Exit Criteria

- Feature exists and is not already archived
- User has confirmed (especially for active features)

---

## Stage 2: Archive

### Inputs

- Confirmed <KEY>-XXX from Stage 1

### Activities

1. Archive the feature in features.json:

   ```bash
   node $ECK_HOME/manage-features.js archive "$FEAT_ID"
   ```

2. Archive the feature in lifecycle.json:

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

   If was active: this clears `active_feature` and reverts active steps to pending.

3. If `CLOSE_ISSUE=true`: invoke `core/ops:close-feature-issue` primitive with:
   - `feature_id`: the confirmed <KEY>-XXX
   - `reason`: `$CLOSE_REASON` (`completed` or `not_planned`)
   - Non-blocking — log warning on failure, continue to summary.

4. Display summary box:

   ```
   Feature Archived

   Feature         {KEY}-XXX {display_name}
   Previous state  {previous_status}
   Archived at     {timestamp}
   Issue closed    {yes (reason) | no | skipped}

   View archived features with: /eck:feature-status
   ```

5. Log activity:

   ```bash
   node $ECK_HOME/log-activity.js --skill "eck:archive-feature" --outcome "success" --summary "Archived {KEY}-XXX {display_name}"
   ```

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

### Outputs

- Feature archived in features.json (`archived_at` set)
- Feature archived in lifecycle.json (`archived_at` set)
- If was active: `active_feature` cleared, active steps reverted to pending
- Feature tracker issue closed (if `--close-issue` flag was set)

### Exit Criteria

- Feature has `archived_at` set in both features.json and lifecycle.json
- User sees confirmation with guidance

---

## Error Handling

- If `archive` fails, show the error output and stop
- If feature is already archived, show error and stop
- If feature not found, show error and stop
- At completion (success or error), always reset statusline
