---
description: Generate a retroactive specification from implementation artifacts
  (PRs, commits, diffs) for an issue that was already implemented.
handoffs: []
scripts: {}
---

# Retro-Spec Command

## User Input

```text
$ARGUMENTS
```

You **MUST** consider the user input before proceeding (if not empty).

## Outline

Generate a retroactive specification for an already-implemented issue by
analyzing its implementation artifacts (merged PRs, commit messages, diffs,
issue body, and comments).

### Usage

```bash
agdt-speckit-retro-spec --issue <NUMBER> [--dry-run] [--output PATH] [--commit]
```

### Arguments

| Flag | Required | Description |
|------|----------|-------------|
| `--issue N` | Yes | The issue number to generate a spec for |
| `--dry-run` | No | Preview the generated spec without writing files |
| `--output PATH` | No | Write spec to a custom path (skips hierarchy placement) |
| `--commit` | No | Create a git commit after writing the spec |

### Behavior

1. Resolves the GitHub repository from the current git remote
2. Fetches the issue body, comments, labels, and milestone
3. Discovers related merged PRs (closing keywords + conventional commit scope)
4. Retrieves PR diffs with per-file and cumulative budget management
5. Synthesizes a retroactive spec via LLM (or falls back to template extraction)
6. Places the spec in the correct hierarchy location (or flat path for standalone)
7. Optionally commits the generated spec

### Output

The generated spec includes:

- A `generated: retroactive` YAML frontmatter marker
- A visible "Retroactive Spec" warning banner
- User stories derived from implementation artifacts
- Functional requirements inferred from code changes
- PR references and key technical details
