Writing a PRD for an existing codebase: what changes when the app already exists
Writing a PRD for an existing codebase: what changes when the app already exists Most PRD guides assume a blank page: pick a stack, design the schema, name the tables. Real work rarely starts there. You are usually add
Writing a PRD for an existing codebase: what changes when the app already exists
Most PRD guides assume a blank page: pick a stack, design the schema, name the tables. Real work rarely starts there. You are usually adding a feature to an app that already has users, a database full of rows, and an agent that will happily "improve" code it was never asked to touch.
A PRD for an existing codebase is a different document. It is not just "what to build" — it is "what already exists, what must not break, and exactly where the new thing fits." Here is what changes, section by section.
1. Start with the current state, not the vision
A greenfield PRD opens with the product vision. A brownfield PRD opens with what is already true: the tables that exist, the endpoints that already serve traffic, the auth model in production.
For example, say your app already has a workspaces table and a workspace_members table tying users to workspaces. A new feature — sprint velocity forecasting — does not get to invent its own ownership model. It belongs to a workspace, full stop:
CREATE TABLE public.sprints (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
workspace_id UUID NOT NULL REFERENCES public.workspaces(id) ON DELETE CASCADE,
name TEXT NOT NULL,
start_date TIMESTAMPTZ NOT NULL,
end_date TIMESTAMPTZ NOT NULL,
target_points INTEGER DEFAULT 0 CHECK (target_points >= 0),
created_at TIMESTAMPTZ DEFAULT now()
);
That workspace_id foreign key is the whole point. The PRD names the existing tables the new table references, so the agent extends the model instead of building a parallel one. If your PRD never mentions the current schema, the agent will guess — and its guess will not match production.
2. Every migration is a requirement, not an afterthought
New tables are the easy part. The hard part is the data that is already there. A brownfield PRD has to answer, in writing:
- Does the migration backfill anything, or only add the new table?
- What happens to rows created before the feature existed?
- Can the migration run with zero downtime, or does it need a maintenance window?
If the answer is "add the table, no backfill, no breaking change," write that down too. An agent that sees an explicit "no data migration required" will not invent one. An agent that sees silence will decide for itself — usually by writing a migration that drops something you needed.
3. Name the code the agent must NOT touch
This is the rule greenfield PRDs never need. In a live codebase, the blast radius matters as much as the feature. The PRD should name the boundaries: which routes, which tables, which shared components are out of scope for this change.
The agent rules in the implementation file exist for exactly this:
- Never invent arbitrary dependencies or unapproved database tables.
- Every server action must validate input payloads using Zod schemas.
- Every database query must respect Supabase Row Level Security boundaries.
- Output complete, production-grade files. Do not use
// TODOor placeholder stubs.
Add a fifth line for brownfield work: do not refactor, rename, or "clean up" anything outside the feature's scope. Without that sentence, a well-meaning agent will "fix" your auth middleware while adding a sprint forecast — and you will find out from your users.
4. Security policies travel with the table
Existing apps already have an access model, and the new feature has to inherit it — not approximate it. If workspaces are isolated by Row Level Security, the new table gets the same policy on day one, in the same file as the table:
ALTER TABLE public.sprints ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Tenant Workspace Isolation" ON public.sprints
FOR ALL USING (
workspace_id IN (
SELECT workspace_id FROM public.workspace_members
WHERE user_id = auth.uid()
)
);
"Add RLS later" is how a new feature becomes a data leak in a mature app. The PRD must contain the policy, because the agent builds what the spec says — nothing more, nothing later.
5. Acceptance criteria must cover the old behaviour too
Greenfield criteria describe the new feature. Brownfield criteria describe the new feature and the old behaviour that must survive it:
GIVEN a team with at least 3 completed sprints, WHEN the lead creates a new sprint, THEN calculate and display the recommended story-point capacity with a 95% confidence interval.
That is the new behaviour. The brownfield half is the second criterion, the one people forget:
GIVEN existing sprints and completed work, WHEN the new sprint is created, THEN all existing sprint data, velocity history, and workspace memberships remain unchanged.
Without the second sentence, the agent has no test for "did I break the app." With it, the definition of done includes the thing your users actually care about — that yesterday still works.
The brownfield checklist
Before you hand the PRD to an agent, check six things: the current tables are named, the migration plan is written (even if it is "no migration"), the out-of-scope code is named, the new table inherits the existing access policy, the acceptance criteria cover old behaviour as well as new, and the agent has written rules about what not to touch. If one is missing, the agent will fill the gap with a guess — in a live codebase, guesses cost users, not just credits.
If you want the shape, the free template behind this format is on GitHub, no signup: https://github.com/web-dev-mehedi/ai-prd-template
And if you would rather generate the whole four-file suite from one paragraph — PRD, UI/UX spec, schema with RLS, and agent rules — the generator is here: https://webdevmehedi.com/ai-prd-generator — 50 free credits on signup, plans from ৳99/mo with bKash and Nagad.
A greenfield PRD describes a future. A brownfield PRD describes a future that has to fit inside a present — and names the present first.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.