An open-source, AI-powered contract review tool that helps lawyers and legal teams analyze contracts, propose plain-language revisions, and generate structured legal analysis — all grounded in modern drafting principles.
Built as a demonstration of how lawyers can leverage AI to improve contract quality and efficiency.
Paste or upload a contract and get back:
- Executive Summary — overall assessment with risk level (🔴 High / 🟡 Medium / 🟢 Low)
- Clause-by-Clause Analysis — each provision analyzed for risk, with proposed revisions
- Drafting Quality Score — how well the contract follows plain-language principles (1–10)
- Actionable Recommendations — prioritized list of improvements
| Mode | Description |
|---|---|
| 📋 Full Review | Comprehensive analysis of the entire contract |
| 🔍 Clause-by-Clause | Deep dive into each individual provision |
| ✏️ Redline | Proposed revisions with before/after comparisons |
| 📝 Provision Drafter | Draft a new provision from a plain-language description |
Every review is grounded in these rules:
- No legalese — use plain language; avoid "hereinafter," "notwithstanding," "whereas"
- Active voice — "The Customer will pay" not "Payment shall be made by the Customer"
- Short sentences — one idea per sentence
- Defined terms only when necessary — don't define terms used once
- Risk clarity — every provision should make clear who bears the risk
- Mutual where possible — prefer mutual obligations over one-sided terms
- Node.js 18+
- An API key for at least one LLM provider (OpenAI or Anthropic)
# Clone the repo
git clone https://github.com/nkasuku/terms-ai.git
cd terms-ai
# Install dependencies
npm install
# Configure your API keys
cp .env.example .env.local
# Edit .env.local and add your API key(s)
# Start the development server
npm run devOpen http://localhost:3000 in your browser.
# Required: at least one API key
OPENAI_API_KEY=your-openai-api-key
ANTHROPIC_API_KEY=your-anthropic-api-key
# Optional: default provider (openai or anthropic)
DEFAULT_LLM_PROVIDER=openaiterms-ai accepts contracts in multiple formats:
.txt— plain text.md— Markdown.docx— Microsoft Word documents.pdf— PDF documents
The knowledge/ directory is the customization layer. To tailor terms-ai for your own contract stack:
- Fork this repo (make it private if adding proprietary content)
- Add your contract templates to
knowledge/ - Add provision examples to
src/lib/contracts/provision-examples/ - Update drafting principles in
src/lib/drafting-principles.ts
See knowledge/README.md for detailed instructions.
Contract reviews are saved to the reviews/ directory. In the public repo, this directory is gitignored. In your private fork, you can track it in git to build a searchable library of past reviews.
terms-ai/
├── src/
│ ├── app/ # Next.js pages and API routes
│ │ ├── api/review/ # Contract review endpoint
│ │ ├── api/reviews/ # Saved reviews endpoints
│ │ ├── reviews/ # Reviews history pages
│ │ └── page.tsx # Main application page
│ ├── components/ # React UI components
│ ├── lib/
│ │ ├── ai/ # LLM provider abstraction & prompts
│ │ ├── contracts/ # Knowledge base & provision examples
│ │ ├── storage/ # Review persistence
│ │ └── types.ts # TypeScript interfaces
├── knowledge/ # Grounding documents (customize here)
│ ├── drafting-guide.md # Plain-language drafting rules
│ └── provision-patterns/ # Common provision patterns
├── reviews/ # Saved contract reviews (gitignored)
└── .env.example # API key configuration template
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS v4 |
| LLM Providers | OpenAI, Anthropic (via Vercel AI SDK) |
| File Parsing | mammoth (docx), pdf-parse (pdf) |
Deploy to Vercel with one click:
Or deploy anywhere that supports Node.js:
npm run build
npm startterms-ai is a drafting and analysis aid. It does not provide legal advice. All output should be reviewed by a qualified attorney before use. The tool's analysis reflects the drafting principles and knowledge base it's grounded in — it is not a substitute for professional legal judgment.
Contributions are welcome! Please open an issue or pull request.
Built by Ngandu Kasuku — Principal Product Counsel at GitHub.