---
name: spec-remove
description: Remove spec entry by ID
argument-hint: "<entry-id> [--cascade]"
allowed-tools:
  - read_file
  - write_file
  - edit_file
  - shell
  - find_files
  - search
  - ask_user
---
<!-- Open-standard mirror generated by scripts/build-agents-standard.mjs — do not edit; re-run after editing .claude/ source. -->

<purpose>
Remove a `<spec-entry>` from a specs file. Symmetric with `/spec-add`.
Uses `maestro wiki remove-entry` for atomic removal with index auto-update.
</purpose>

<required_reading>
@~/.maestro/workflows/specs-remove.md
</required_reading>

<context>
$ARGUMENTS -- expects `<entry-id>` (e.g., `spec-learnings-003`, `spec-coding-conventions-001`)

**Entry ID format**: `spec-{file-stem}-{NNN}` — the sub-node ID assigned by WikiIndexer when indexing `<spec-entry>` blocks.

**Discovery**: Use `maestro wiki list --type spec --json` or `/spec-load --keyword <term>` to find entry IDs.

**Flags:**
- `--cascade` — When the target spec is a ref-type entry (created via `spec-add --ref` and linked to a knowhow document), also delete the referenced knowhow file. Without this flag, ref-type removal leaves an orphan knowhow file.
</context>

<execution>
Follow '~/.maestro/workflows/specs-remove.md' completely.
</execution>

<error_codes>
| Code | Severity | Description | Stage |
|------|----------|-------------|-------|
| E001 | fatal | Entry ID is required -- usage: `/spec-remove <entry-id>` | parse_input |
| E002 | fatal | `.workflow/specs/` not initialized -- run `/spec-setup` first | validate |
| E003 | fatal | Entry ID not found in wiki index | lookup |
| E004 | fatal | Entry is not a spec sub-node (wrong type) | validate |
</error_codes>

<success_criteria>
- [ ] Entry ID parsed and validated
- [ ] Entry found in wiki index (type=spec, is sub-node)
- [ ] User confirmed removal (unless -y flag)
- [ ] Entry removed from container file via `maestro wiki remove-entry`
- [ ] Wiki index auto-updated
- [ ] If `--cascade` and entry has a `ref` attribute: referenced knowhow file deleted, orphan avoided
- [ ] Confirmation displayed with removed entry details (and cascaded knowhow path if applicable)
</success_criteria>
