Legal Document Agent
Reviews, drafts, and advises on legal documents with a traced reasoning chain: clause, applicable principle, analysis, and recommendation. Extracts reusable precedent from every review. Not legal advice.
OVERVIEW
A legal document agent that operates in three modes: review, draft, and advise. It classifies documents by practice area (corporate, employment, IP, regulatory, commercial) and adjusts its analysis posture accordingly. Every finding follows a traced reasoning chain: the specific clause, the legal principle it engages, why it matters in context, and what to do about it. Precedent clauses extracted during review feed back into draft mode, creating a compound knowledge loop. All output is framed as legal analysis, not legal advice.
ARCHITECTURE
The agent runs through a Next.js API route that validates input, enforces rate limits, classifies the document by practice area and request mode (review, draft, or advise), constructs the appropriate prompt pipeline via OpenRouter, and streams structured output over SSE. Review mode chunks and analyses existing documents with practice-area-specific risk patterns. Draft mode assembles documents from deal parameters, document type, and accumulated precedent. Advise mode constructs a legal strategy brief from the stated position and context. Precedent extraction runs as a post-processing step after every review, feeding reusable clause patterns back into the precedent library.
FUNCTIONALITY
- Review: traces each finding through a 4-part chain: clause cited, legal principle engaged, contextual analysis, and actionable recommendation
- Review: classifies document by practice area (corporate, employment, IP, regulatory, commercial) and applies practice-specific risk patterns
- Review: identifies missing protections standard for the document type and practice area, including indemnification, limitation of liability, termination rights, and IP ownership
- Draft: generates contracts, SOWs, NDAs, and commercial agreements from deal terms, party details, and document type, drawing on precedent extracted from prior reviews
- Draft: follows standard market structure for the practice area and incorporates reusable clause patterns from the precedent library
- Advise: recommends legal strategy with a traced reasoning chain, covering risk quantification, negotiation sequencing, ideal and fallback positions, and escalation triggers
- Codify: extracts reusable precedent clauses from every review and feeds them into the draft precedent library, compounding quality over time
- All output positioned as legal analysis to surface what to take to your lawyer, not a legal opinion
HOW IT WORKS
The user selects a mode: review, draft, or advise. The agent first classifies the document or scenario by practice area to load the right risk patterns and precedent. In review mode, it analyses the document clause by clause, tracing each finding through the reasoning chain: clause, applicable principle, contextual analysis, and recommendation. After review, it extracts reusable precedent clauses and adds them to the precedent library. In draft mode, it generates a structured first draft from deal terms and document type, drawing on accumulated precedent for clause language. In advise mode, it returns a strategy brief with traced reasoning covering risk exposure, negotiation sequence, fallback positions, and when to escalate. Findings and output stream progressively across all modes.
OUTCOMES
- Surfaces what could hurt you in contracts with traced reasoning, not just severity labels
- Drafts agreements from deal terms and accumulated precedent, compounding quality with each review
- Provides legal strategy with negotiation sequencing, fallback positions, and escalation triggers
- Adapts analysis posture by practice area so employment agreements and MSAs get different treatment