The Pattern Behind Every Enterprise Document AI Product
I built an AI contract analyzer that extracts risk flags, obligations, and negotiation leverage from any legal document. The interesting part isn't the AI — it's the output design. Why 'here's the bad clause' is less useful than 'here's what to ask for instead.'
I built an AI contract analyzer last night. Paste any legal document — employment agreement, NDA, SaaS terms, service contract — and get structured output: risk flags by severity, plain-English summary, key obligations by party, and specific negotiation leverage points.
The app is at contract-analyzer-five.vercel.app. The interesting part isn't the AI capabilities — it's the output design. Here's what building it revealed about enterprise document AI patterns.
The problem with most contract tools
Most AI contract tools summarize. They read the document and produce a paragraph explaining what it's about. This is marginally useful — you could skim the document yourself in the same time.
The valuable layer is risk extraction + actionability. Not “this contract has a liability clause” but “your liability is capped at $500 while theirs is unlimited — this is a high-severity issue, here's what to request instead.”
The output design question is: what does someone actually need before signing?
- A plain-English summary of what they're agreeing to
- The specific clauses that are unusual or risky
- Who owes what to whom
- What to push back on and how
That maps directly to four tabs: Overview, Risks, Obligations, Negotiate.
The architecture
The core is a single API call to Claude Haiku with a carefully designed system prompt that defines a 9-field JSON schema:
{
summary: string,
documentType: string,
parties: [{ name, role }],
keyDates: [{ label, date, description }],
keyObligations: [{ party, obligation, section }],
riskFlags: [{ severity, issue, clause, recommendation }],
plainEnglish: string[],
negotiationPoints: [{ point, importance, suggestion }],
overallRisk: "low" | "medium" | "high" | "very-high"
}The system prompt instructs the model to return only valid JSON matching this schema. No preamble, no explanation, just the object. This is the “structured output via system prompt” pattern — cheaper and faster than the structured output API for well-defined schemas, and equally reliable when the schema is clearly documented in the prompt.
Risk classification design
The most important design decision was making risk flags genuinely useful. The prompt explicitly lists what counts as a high-severity flag:
- Asymmetric liability (one party capped, other unlimited)
- Unilateral amendment rights (“we may update these terms at any time”)
- Auto-renewal clauses with short cancellation windows
- One-sided IP assignment (all work product to client, no retained license)
- Mandatory arbitration + class action waiver
- Extreme non-compete scope (24+ months, broad geography)
Without this specificity, the model flags everything as medium risk. With it, it distinguishes between genuinely dangerous clauses and standard boilerplate.
The negotiation intelligence layer
Here's what makes the Negotiate tab more valuable than the Risks tab: it generates specific alternative language to request, not just descriptions of what's wrong.
“The liability cap is asymmetric — you should push back” is unhelpful. Most people reading that know it's bad. What they don't know is what to ask for. “Request a mutual liability cap set at 12 months of fees paid under the contract” is immediately actionable.
This is where AI adds the most leverage: converting pattern-matching (this clause is bad) into domain knowledge (here's the standard alternative).
The enterprise generalization
The pattern this app demonstrates is more general than contract analysis. It's the core pattern behind most enterprise document AI products:
- Ingest unstructured text (contract, invoice, medical record, customer email)
- Extract structured data via LLM with a defined schema
- Classify by risk/urgency/category with severity levels
- Surface actionable recommendations per item
Clio uses this pattern for legal document review. Medical AI companies use it for clinical notes. Financial compliance tools use it for regulatory filings. The core architecture — system prompt + schema + structured extraction + severity classification + recommendations — is the same.
What I'd build next
A few things I deliberately left out of this demo that would be essential in production:
- Multi-document comparison — compare two versions of a contract and show what changed
- Citation grounding — each risk flag links to the exact paragraph it came from
- Vector retrieval for clause search — find all contracts with a specific clause type across a corpus
- Confidence scoring — the model should indicate uncertainty when a clause is ambiguous
The demo shows the pattern. Production adds retrieval, grounding, and scale.
Try it at contract-analyzer-five.vercel.app. Load the sample contract (deliberately terrible — one-sided service agreement with $500 liability cap, 24-month non-compete, and unilateral amendment rights) to see the risk flags fire.