This skill should be used when the user asks to "reverse engineer requirements", "extract what the system actually does", "build a PRD from code", "document existing features", "trace user flows from code", or needs to understand the actual behavior of a brownfield codebase by analyzing code rather than trusting documentation.
From pm-architect-brownfieldnpx claudepluginhub nbkm8y5/claude-plugins --plugin pm-architect-brownfieldThis skill uses the workspace's default tool permissions.
Guides Next.js Cache Components and Partial Prerendering (PPR) with cacheComponents enabled. Implements 'use cache', cacheLife(), cacheTag(), revalidateTag(), static/dynamic optimization, and cache debugging.
Migrates code, prompts, and API calls from Claude Sonnet 4.0/4.5 or Opus 4.1 to Opus 4.5, updating model strings on Anthropic, AWS, GCP, Azure platforms.
Orchestrates subagents to execute phased plans: deploys for implementation, verification, anti-pattern checks, code quality review, and commits only after passing checks.
Extract a Product Requirements Document from what the codebase ACTUALLY does, not what documentation claims. This skill traces routes, handlers, models, and integrations to build an evidence-backed feature inventory, user flow map, data entity catalog, and integration manifest.
[AS_IS_SYSTEM_MODEL.md + Codebase] --> **REVERSE PRD** --> [REVERSE_PRD.md] --> Architecture Gap Analysis --> ...
Input: AS_IS_SYSTEM_MODEL.md, actual codebase (via Read/Glob/Grep)
Output: REVERSE_PRD.md written to artifacts directory
The output artifact follows the standard artifact template:
# [ARTIFACT TITLE]
## Summary
## Inputs
## Outputs
## Assumptions
## Open Questions
## Main Content
## Acceptance Criteria
AS_IS_SYSTEM_MODEL.md to understand:
Systematically find all entry points where the system accepts input.
HTTP Routes (Grep for framework-specific patterns):
app.get(, app.post(, router.get(, router.post(@app.get(, @app.post(, @router.get(path(, url(, urlpatternsget ', post ', resources :@GetMapping, @PostMapping, @RequestMappingr.GET(, r.POST(, http.HandleFunc([HttpGet], [HttpPost], MapGet(CLI Commands (Grep for command registration):
argparse, click.command, cobra.Command, clap::Commandbin/ directory scripts with shebang linesMessage Queue Consumers (Grep for subscription patterns):
subscribe(, consume(, on('message', @RabbitListener, @KafkaListenerScheduled Jobs (Grep for cron/scheduler patterns):
cron(, schedule(, @Scheduled, setInterval(File/Event Watchers:
watch(, on('change', inotify, FileSystemWatcherRecord each endpoint:
| Method | Path/Pattern | Handler | Component | Evidence |
|--------|-------------|---------|-----------|----------|
| GET | /api/users | UserController.list | COMP-0001 | [src/routes/users.ts:12] |
| POST | /api/users | UserController.create | COMP-0001 | [src/routes/users.ts:25] |
For each discovered endpoint/entry point, trace the handler logic to understand what the system does.
Feature format:
### REQ-0001: [Feature Title]
- **Type**: Functional | Non-Functional | Integration | Administrative
- **Description**: [What this feature does, derived from code behavior]
- **Entry Point**: [HTTP method + path | CLI command | Queue topic]
- **Handler Chain**: [handler -> service -> repository flow with citations]
> Request enters via POST /api/users [src/routes/users.ts:25]
> Validated by UserSchema [src/schemas/user.ts:8-22]
> Processed by UserService.create [src/services/user.ts:34-58]
> Persisted via UserRepository.save [src/repositories/user.ts:15]
- **Data Entities**: [Models/schemas touched]
- **Side Effects**: [Emails sent, events published, files written]
- **Error Handling**: [How errors are caught and reported]
- **Authentication**: [Required | Optional | None] with evidence
- **Authorization**: [Role/permission checks] with evidence
Trace end-to-end user journeys through the codebase.
#### FLOW-0001: [Flow Name]
```mermaid
sequenceDiagram
actor User
User->>API: POST /login [src/routes/auth.ts:10]
API->>AuthService: validate(credentials) [src/services/auth.ts:22]
AuthService->>DB: SELECT user [src/repositories/user.ts:8]
DB-->>AuthService: user record
AuthService->>AuthService: bcrypt.compare() [src/services/auth.ts:30]
AuthService-->>API: JWT token [src/services/auth.ts:35]
API-->>User: 200 + token
4. **Assign FLOW-NNNN IDs**: Sort alphabetically by flow name
### Step 5: Catalog Data Entities
Extract the data model from code, not documentation.
1. **Grep for model/schema definitions**:
- ORM models: `class.*Model`, `@Entity`, `Schema({`, `model(`, `#[derive(`, `type.*struct`
- Database schemas: migration files, SQL CREATE TABLE statements
- API schemas: Zod schemas, Joi validations, Pydantic models, JSON Schema files
- TypeScript interfaces/types in model directories
2. **For each entity, record**:
```markdown
#### ENT-0001: [Entity Name]
- **Source**: [ORM model | Migration | API schema | TypeScript interface]
- **File**: [file:line]
- **Fields**:
| Field | Type | Constraints | Evidence |
|-------|------|------------|----------|
| id | UUID | Primary Key | [src/models/user.ts:5] |
| email | string | Unique, Not Null | [src/models/user.ts:8] |
- **Relationships**:
- Has many: [Entity] via [foreign key] [file:line]
- Belongs to: [Entity] via [foreign key] [file:line]
- **Indexes**: [If discoverable from migrations]
```mermaid
erDiagram
USER ||--o{ ORDER : places
ORDER ||--|{ LINE_ITEM : contains
PRODUCT ||--o{ LINE_ITEM : "ordered in"
4. **Assign ENT-NNNN IDs**: Sort alphabetically by entity name
### Step 6: Identify Integration Points
Map all external system interactions.
1. **Database connections** (Grep for connection/client initialization):
- Connection strings, pool configurations, ORM setup
- Record: database type, connection method, evidence
2. **External API calls** (Grep for HTTP client usage):
- `fetch(`, `axios.`, `http.get(`, `requests.`, `HttpClient`, `reqwest::`
- Record: target URL/service, method, purpose, evidence
3. **Message queues** (Grep for publisher/subscriber setup):
- RabbitMQ, Kafka, SQS, Redis pub/sub, NATS
- Record: queue/topic names, message formats, evidence
4. **File I/O** (Grep for file system operations):
- `fs.readFile`, `open(`, `File::open`, `os.Open`
- Cloud storage: S3, GCS, Azure Blob
- Record: paths/buckets, read/write, evidence
5. **Email/Notification services**:
- SMTP, SendGrid, Twilio, push notification services
- Record: service, trigger conditions, evidence
6. **Integration inventory**:
```markdown
| INT-NNNN | Type | Target | Direction | Evidence |
|----------|------|--------|-----------|----------|
| INT-0001 | Database | PostgreSQL | Bidirectional | [src/db/connection.ts:5] |
| INT-0002 | API | Stripe | Outbound | [src/services/payment.ts:22] |
| INT-0003 | Queue | Redis | Bidirectional | [src/queue/setup.ts:8] |
Identify features that exist in code but may not be reachable.
Unreachable routes: Routes defined but commented out or behind always-false feature flags
Unused exports: Functions/classes exported but never imported elsewhere
Commented-out code blocks: Large sections of commented code indicating abandoned features
// TODO, /* deprecated */, # FIXME, # HACKDead feature flags: Feature flags that are always true or always false
Orphaned files: Source files not imported by any other file
Record findings:
#### DEAD-0001: [Description]
- **Type**: Unreachable Route | Unused Export | Commented Code | Dead Flag | Orphan File
- **Location**: [file:line]
- **Evidence**: [Why this is considered dead]
- **Risk**: [What breaks if removed]
Assemble all findings into the final artifact.
REVERSE_PRD.md following the template[file:line] citation# Reverse PRD: [Project Name]
## Summary
[3-5 sentence overview of what the system actually does based on code analysis]
## Inputs
- AS_IS_SYSTEM_MODEL.md
- Codebase at: [path]
## Outputs
- REVERSE_PRD.md (this document)
## Assumptions
- [ASM-NNNN]: [Assumption with rationale]
## Open Questions
- [OQ-NNNN]: [Question about ambiguous or unclear behavior]
## Main Content
### Feature Inventory
[REQ-NNNN entries with full detail]
### Feature Summary Table
| REQ ID | Title | Type | Entry Point | Component | Auth Required |
|--------|-------|------|------------|-----------|---------------|
### User Flows
[FLOW-NNNN entries with sequence diagrams]
### Data Entities
[ENT-NNNN entries with field tables]
#### Entity Relationship Diagram
```mermaid
[ER diagram]
[INT-NNNN entries]
[Integration diagram]
[DEAD-NNNN entries]
| REQ ID | Components | Entities | Integrations | Flows |
|---|---|---|---|---|
| [Cross-reference matrix] |
**Output path**: `artifacts/brownfield/<project_name>/REVERSE_PRD.md`
**Template**: `${CLAUDE_PLUGIN_ROOT}/reference/templates/REVERSE_PRD.template.md`
## Determinism Rules
These rules ensure reproducible output regardless of when or how many times the skill is invoked on the same inputs.
1. **REQ-NNNN IDs**: Sort all requirements alphabetically by feature title (case-insensitive), then assign sequential four-digit numbers starting at 0001
2. **FLOW-NNNN IDs**: Sort all flows alphabetically by flow name, then assign sequentially
3. **ENT-NNNN IDs**: Sort all entities alphabetically by entity name, then assign sequentially
4. **INT-NNNN IDs**: Sort all integrations alphabetically by target name, then assign sequentially
5. **DEAD-NNNN IDs**: Sort all dead code findings alphabetically by description, then assign sequentially
6. **Entity fields**: Sort by field name alphabetically within each entity
7. **Endpoint table rows**: Sort by Method, then by Path alphabetically
8. **Sections**: Always in template order, never reordered
9. **No timestamps**: Do not include generation timestamps in artifact body
10. **Handler chains**: List in call order (entry -> ... -> exit), not alphabetically
## Evidence Citation Rules
Every claim about system behavior MUST include evidence citations from actual code.
**Format**: `> Claim text [relative/path/to/file.ext:line_number]`
**Examples**:
```markdown
> User creation validates email uniqueness before insert [src/services/user.ts:42]
> Password is hashed with bcrypt, 12 salt rounds [src/auth/hash.ts:8]
> Order total calculation includes tax based on shipping state [src/services/order.ts:88-102]
> Webhook retry logic attempts 3 times with exponential backoff [src/integrations/webhook.ts:15-30]
Rules:
[file:line][file:start-end][file1:line] [file2:line]Before finalizing the artifact, verify:
[file:line] citationsType: Test/Debug in the REQ entry