Chapter 3

PRD and documentation-driven

Master the core ideas of document-driven development, learn to use AI to help write PRDs, build structured thinking methods, and make documents the compass for development.

Key insight: Documentation is context

In the era of AI programming,Documentation is not a burden, but context for AI to understand requirements. A good PRD enables AI to understand requirements accurately and generate code that meets expectations. After reviewing the VibeCoding workflow in the previous chapter, let’s now learn how to write AI-readable documentation.

Why PRDs are needed

In traditional development, PRD was a communication tool for the team. In the era of AI coding, PRD isAI understands the context of the requirements

Traditional development

  • • PRD is used for team communication
  • • Requirement understanding relies on human discussion
  • • Documentation and code can easily drift apart
  • • Changes need to be synchronized manually

The era of AI programming

  • PRD is the context for AI
  • • AI directly reads the PRD and generates code
  • • Documentation as code, version synchronization
  • • Changes automatically trigger code updates

Value driven by documentation

Reduce rework: Write the documentation first, then let the AI understand it before coding to avoid misunderstandings
Improve quality: Structured documents enable AI to generate more accurate code
Traceability: document version control, clear change history
Team collaboration: Documentation is the common language of the team and reduces communication costs

Structured thinking method: Sequential Thinking

Writing a PRD is not something that happens overnight; what is needed isStructured thinking. Use the Sequential Thinking method to break complex problems into manageable steps.

Sequential Thinking workflow

1

Problem decomposition

Break complex requirements into multiple sub-problems, each of which can be solved independently

2

Step-by-step thinking

Think step by step for each subproblem and record the thought process

3

Validate assumptions

Verify each hypothesis to ensure the logic is correct

4

Integrated solution

Integrate the solutions to each subproblem into a complete solution

5

Iterative optimization

Continuously optimize and improve the solution based on feedback

Practical example: user login feature

Thinking step 1: Break down the problem
• How does the user enter the account and password?
• How do you verify user identity?
• How do you maintain state after a successful login?
• How to handle login failure?
Thinking step 2: deepen progressively
• Frontend: form validation, error messages, loading states
• Backend: password encryption, token generation, session management
• Security: brute-force protection, CSRF protection
Thinking Step 3: Integrated Plan
Integrate frontend, backend, and security solutions into a complete login feature design

Use AI to assist structured thinking

Use the Sequential Thinking MCP tool or a similar thinking approach to help AI assist you with:

  • Break down complex problems: AI helps you identify key subproblems
  • Record the thinking process: every step of thinking is recorded and traceable
  • Validation logic: AI helps you check logical loopholes
  • Iterative optimization:Continuously improve the plan based on feedback

PRD writing guide

PRD (Product Requirements Document) is a complete description of product requirements. In the era of AI coding, PRDs need toStructured, actionable, AI-readable

Core PRD structure

1. Product Overview

Required

Product positioning, target users, core value, one-sentence goal

2. Functional requirements

Required

Feature list, user stories, priorities, acceptance criteria

3. Non-functional requirements

Required

Performance, security, availability, and scalability requirements

4. Interface definitions

Required

Input/output, data structures, error handling, API specifications

5. Constraints and assumptions

Required

Technical constraints, resource limitations, prerequisites, non-goals

6. Acceptance criteria

Required

Functional acceptance, performance acceptance, security acceptance, DoD checklist

AI-readable PRD principles

❌ Vague description
User login feature - Users can log in - After logging in, they can access the system
✅ Structured description
User login feature Goal: Users log in to the system with their account and password Input: username (string), password (string) Output: token (string), userInfo (object) Errors: 401 Incorrect password, 429 Too Many Requests Acceptance: Entering the correct password returns a token; entering the wrong password returns 401

Best practices for writing PRDs

  • Clear goals: Each feature should answer “why is it needed” and “one-sentence goal”
  • Define non-goals: clearly state what not to do to avoid scope creep
  • Structured description: use Markdown format with a clear hierarchical structure
  • Testability: requirements must be verifiable and testable, including acceptance criteria
  • Version control: PRDs should be version-controlled like code (Git)
  • Continuously updated: Update documentation promptly when requirements change, keeping documentation and code in sync

Spec-driven development

Spec-Driven Development emphasizesWrite the spec first, then write the code. Standards are context, enabling AI to better understand requirements and generate code that meets expectations.

Traditional development process

1Requirements discussion
2Direct coding
3Discover problems
4Rework and revisions

Spec-driven flow

1Write Spec
2Review confirmation
3Spec-based coding
4Accept according to the spec

Core elements of the Spec

1
Goals: What problem does this feature solve? What is the goal in one sentence?
2
Non-Goals: What does this feature not do? Clarify the boundaries
3
Interface definition: input/output, data structures, error handling, API specifications
4
Acceptance Criteria: What counts as done? Includes functional acceptance and performance acceptance

Generate a Spec using AI

Let AI generate a Spec from the requirements, and then you review and optimize it:

Prompt example:
Please help me generate a Spec for a user login feature, including: 1. Goals and non-goals 2. Interface definition (input/output, error handling) 3. Acceptance criteria 4. Technical constraints

WBS Work Breakdown Structure

WBS (Work Breakdown Structure) breaks complex projects down into manageable small tasks. In the era of AI programming,Task decomposition allows AI to execute step by stepto increase the success rate.

Decomposition principle

MECE principle
Mutually exclusive and collectively exhaustive (Mutually Exclusive, Collectively Exhaustive)
Moderate granularity
Each task can be completed in 1-3 days, making it suitable for AI step-by-step execution
Deliverable
Each task has a clear deliverable that can be verified
Clear dependencies
Clarify the dependencies between tasks and determine the execution order

Example: user login feature

WBS structure:
User login feature ├─ Frontend login page │ ├─ UI component development │ ├─ Form validation │ └─ Error messages ├─ Backend API development │ ├─ Login API │ ├─ Token generation │ └─ Session management └─ Testing ├─ Unit tests └─ Integration tests

Use AI to assist task decomposition

Let AI break down the PRD into an actionable task list:

Prompt example:
Please break down the following PRD into a WBS task list: [Paste PRD content] Requirements: 1. Each task should be moderately scoped (can be completed in 1–3 days) 2. Clearly define task dependencies 3. Each task should have clear acceptance criteria

DoD Definition of Done

DoD (Definition of Done) defines the acceptance criteria for task completion. In the era of AI programming,DoD can be checked automatically, ensuring consistent quality.

Standard DoD checklist

The code has passed all tests (unit tests, integration tests)
The code has passed code review (AI review + human review)
Documentation updated (PRD, API documentation, README)
Comply with coding standards (ESLint, Prettier, TypeScript)
Deployed to the test environment and verified successfully
Product manager approved (features comply with the PRD)

AI automated DoD checks

Use AI tools to automatically check the DoD checklist and improve efficiency:

Code review
Use AI code review tools (such as Cursor, GitHub Copilot) to automatically check code quality
Test generation
Use AI to generate test cases and ensure code coverage
document synchronization
Use AI to check consistency between documentation and code, and automatically update the documentation

The value of DoD

  • Quality Assurance: Ensure all tasks meet a consistent quality standard
  • Reduce rework: detect problems early and avoid later modifications
  • Team consensus: Everyone has a consistent understanding of what "done" means
  • Traceability: clearly record the completion status of each task
  • AI-friendly: Clear acceptance criteria let AI know when the task is complete

Docs as Code

In the era of AI programming,Documentation should be managed like code: version control, code review, automated checks, continuous integration.

Document version control

Manage documentation with Git
docs/prd/
├── user-login.md
├── user-profile.md
└── README.md
  • • Document changes are submitted via PR, code review
  • • Keep document versions and code versions in sync
  • • Clear and traceable change history

Automated document checks

CI/CD integration
  • • Check whether the PRD format complies with the standards
  • • Check consistency between documentation and code
  • • Automatically generate API documentation
  • • Check document completeness (required fields)

Documentation as context

Documents are not just records, but alsoAI understands the context of the requirements. Good documentation helps AI accurately understand requirements and generate code that meets expectations. Documentation and code should be updated in sync to maintain consistency.

Learning outcomes

After completing this chapter, you will:

  • 1Understand the core ideas of document-driven development and master the concept that documents are context
  • 2Master structured thinking methods (Sequential Thinking) and be able to break down complex problems
  • 3Can write AI-readable PRD documents that include complete product requirements
  • 4Master the Spec-driven development process and understand the idea that the spec is the context
  • 5Able to perform effective task breakdown (WBS) and manage project progress
  • 6Understand the importance of DoD and be able to define clear acceptance criteria
  • 7Master document-as-code management methods and establish a document version control process