Reverse-engineer a codebase into a Product Requirements Document (PRD) scaffold. The toolchain scans routes, HTTP APIs, models, and structure, then emits JSON you can turn into human-readable docs.
# Analyze → JSON (default)
python3 scripts/codebase_analyzer.py /path/to/project -o analysis.json
# Human-readable summary
python3 scripts/codebase_analyzer.py /path/to/project -f markdown -o analysis.md
# Scaffold PRD directory from analysis
python3 scripts/prd_scaffolder.py analysis.json -o prd/ -n "My App"In Cursor, the code-to-prd skill (SKILL.md) drives the full PRD workflow; /code-to-prd /path/to/project is the intended slash-command entry point.
| Stack | Frameworks |
|---|---|
| Frontend | React, Vue, Angular, Svelte, Astro, Next.js, Nuxt, SvelteKit, Remix |
| Backend | NestJS, Express, Fastify, Django, DRF, FastAPI, Flask, Spring Boot (Maven / Gradle) |
| Fullstack | Next.js (pages + API routes), Nuxt (pages + server), Django (views + templates) |
Both scripts use only the Python standard library (no pip install).
The analyzer treats the project as Spring Boot when pom.xml or build.gradle / build.gradle.kts references Spring Boot (parent BOM, plugins, or spring-boot artifacts). It works for single-module and multi-module layouts (Maven <modules> / Gradle include).
What gets extracted
- REST routes — Classes annotated with
@RestControlleror@Controller. Paths combine the class-level@RequestMapping(or implicit prefix from stereotype annotations) with method-level@GetMapping,@PostMapping,@PutMapping,@DeleteMapping,@PatchMapping, or@RequestMapping(method=…). Each entry includes HTTP method and source file. - Domain models — JPA
@Entityclasses; DTO-style types named or matching*Dto,*Request,*Response,*Body(classes orrecordtypes). - Java / EE alignment —
java_version(major, from Maven/Gradle),spring_boot_version(from parent or plugin), andjava_ee_namespace(javax|jakarta|both|unknown) from imports (with inference from Spring Boot 2.x vs 3.x when needed). - Layout hints — Under
structure.spring_boot: Java source roots,application*.yml/.propertiespaths, inferred controller / entity / repository / DTO package directories, and alombokflag when Lombok appears in build files (useful when fields are generated).
Ignored paths — Build output such as Maven target/ is skipped so analysis stays on sources.
Backend-only PRDs — For a service with no frontend routes, inventory items correspond to API resource groups (controllers/modules) rather than UI pages.
Single controller — For documenting one class in isolation, use prompt-engineering.md together with Spring Boot Controller PRD Mode in SKILL.md.
prd/
├── README.md # System overview stub
├── pages/
│ ├── 01-user-mgmt-list.md # Per-page or per-endpoint stubs
│ └── ...
└── appendix/
├── enum-dictionary.md # Enums and constants from analysis
├── api-inventory.md # API / endpoint reference
└── page-relationships.md # Navigation and coupling notes
| Script | Purpose |
|---|---|
codebase_analyzer.py |
Walk the tree → routes, backend endpoints, client API usage, enums, models, stack metadata |
prd_scaffolder.py |
Build prd/ from analysis JSON |
CLI highlights for the analyzer: -o / --output, -f json|markdown (default json). Run --help on either script for full options.
references/framework-patterns.md— Conventions per framework (including Spring Boot)references/prd-quality-checklist.md— Completeness and accuracy checksSKILL.md— End-to-end PRD workflow and Spring Boot Controller PRD Mode
Inspired by code-to-prd by @lihanglogan.
Also inspired by the Product Team — Code → PRD skill in claude-skills by @alirezarezvani.
MIT