Product Requirements Document (PRD)
In the previous section, we defined what we're building — a Text Comparer that diffs two pieces of text at line, word, and character granularity — and why it's useful. We outlined the key features (dual-panel input, real-time diffing, change navigation, file upload, export, and more) and the quality goals (instant diff for typical inputs, responsive UI, resizable panels, and reliable edge-case handling).
Now it's time to turn those ideas into a Product Requirements Document (PRD) — and we'll use Claude Code to write it. We will use Claude Code by default throughout this tutorial, but if you don't have Claude Code, you can also use Codex.
Why Write a PRD?#
You might wonder: if we already listed the features, why not just start coding? For a small personal project, you often can. But writing a short PRD before coding has real benefits, even for solo projects:
- Forces precision — Vague ideas like "change navigation" become concrete decisions: What does jumping to a change look like? What happens when you reach the last change? Writing it down exposes gaps in your thinking before they become bugs.
- Creates a shared reference — If you're working with others (or with an AI coding assistant), the PRD is the single source of truth. Everyone builds toward the same target.
- Guides AI code generation — When you ask Claude Code to implement a feature, a clear PRD gives it direction. Instead of "build a text comparer," you can point to specific requirements and constraints.
- Prevents scope creep — A PRD draws a clear boundary around what's in scope. Without one, it's easy to keep adding "one more thing" and never finish.
That said, keep your PRD short and concise. You won't get everything right upfront — new requirements always surface during development as you encounter edge cases and rethink interactions. A lean PRD that captures the core intent is more useful than an exhaustive one that tries to anticipate every detail. This is especially true when working with AI coding agents: a long, overly detailed PRD can actually hurt more than it helps, because too much context can mislead the AI or cause it to fixate on low-priority details instead of the things that matter most.
Setting Up the Project#
Before we write the PRD, let's create a Next.js project. Open your terminal and run:
npx create-next-app@latest text-compare --typescript --tailwind --eslint --app --import-alias "@/*"
This scaffolds a new Next.js project called text-compare with TypeScript, Tailwind CSS, ESLint, the App Router, and the @/* path alias — everything we'll need for the build.
Once the command finishes, navigate into the project root and create an empty file for our PRD:
cd text-compare
touch PRD.md
You can also open the project in VS Code:
code .
Alternatively, you can create PRD.md directly in VS Code — right-click in the file explorer on the left and select New File.
Having the PRD as a markdown file in the project root keeps the spec right next to the code — easy to reference, easy to update, and easy to feed back to Claude Code later when we're implementing features.
Write the PRD#
Rather than writing the PRD from scratch ourselves, we'll use Claude Code to draft it. If you're new to Claude Code, check out the Getting Started with Claude Code guide first.
This is a great use case for AI assistance — we have a clear vision of what we want (from the previous section), and we need Claude Code to organize it into a structured, detailed document.
Ask AI to generate a structured PRD based on our feature list.
Here's an example of what Claude Code might produce:
Revising the PRD#
Always review the generated PRD carefully and thoroughly. The PRD is the key guideline that AI agents will follow when building the solution — any vague requirement, missing detail, or unnecessary scope in the PRD will directly affect the quality of the generated code. Think of it as programming the AI: the more precise your spec, the better the output.
The generated PRD above is in good shape — it's well-structured, covers the major features, and reads like a real spec. However, we want to focus on the key features and keep the scope tight. Let's remove the unnecessary requirements so we can focus on building rather than specifying.
Here's what we'll remove:
- Keyboard shortcuts (
Alt+Up/Alt+Down) — Previous/Next buttons are enough for this version. - UI Layout section — Unnecessary detail; the design phase will handle layout decisions.
- Non-Goals (Out of Scope) section — Unnecessary since we're only building one version.
Let's ask Claude Code to make these changes:
Ask AI to trim the PRD to a more focused scope.
Here's the revised PRD:
Reviewing the PRD#
Now that we've revised the PRD, the next step is to let Claude Code review the PRD one more time. Even after our edits, there may be conflicting requirements, ambiguous wording, or gaps that could confuse the AI during implementation. A quick review pass catches these issues before they turn into bugs.
Ask AI to check for conflicts or unclear requirements.
Here's what Claude Code flagged:
We want to resolve the contradictions and ambiguities with these decisions:
- Diff view placement — Inline highlighting within the editors themselves, no third output panel.
- "Modified" color in line mode — Only green (added) and red (removed) in line mode; yellow only applies in word/char modes.
- Clear confirmation — A simple toast notification, no modal or confirm dialog.
- Synced scrolling — Aligned by diff chunks (not proportional or line-for-line).
- "Modified" vs. "Added + Removed" — In line mode, only count additions and removals (no "modified" category).
Let's ask Claude Code to apply these resolutions:
Ask AI to fix the flagged conflicts and ambiguities.
Here's the final PRD with all issues resolved:
You can repeat this review-and-resolve cycle as many times as needed — ask Claude Code to review again, fix what it finds, and review once more until no issues remain. A clean, unambiguous PRD means fewer surprises during implementation.
With the PRD finalized, we're ready to move on. In the next section, we'll use Claude Code to turn this PRD into a technical design — defining the component structure, data flow, and architecture before we write any code.