Skip to content

Repository files navigation

terms-ai

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.

What It Does

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

Review Modes

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

Drafting Principles

Every review is grounded in these rules:

  1. No legalese — use plain language; avoid "hereinafter," "notwithstanding," "whereas"
  2. Active voice — "The Customer will pay" not "Payment shall be made by the Customer"
  3. Short sentences — one idea per sentence
  4. Defined terms only when necessary — don't define terms used once
  5. Risk clarity — every provision should make clear who bears the risk
  6. Mutual where possible — prefer mutual obligations over one-sided terms

Getting Started

Prerequisites

  • Node.js 18+
  • An API key for at least one LLM provider (OpenAI or Anthropic)

Setup

# 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 dev

Open http://localhost:3000 in your browser.

Environment Variables

# 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=openai

File Upload Support

terms-ai accepts contracts in multiple formats:

  • .txt — plain text
  • .md — Markdown
  • .docx — Microsoft Word documents
  • .pdf — PDF documents

Customizing for Your Organization

The knowledge/ directory is the customization layer. To tailor terms-ai for your own contract stack:

  1. Fork this repo (make it private if adding proprietary content)
  2. Add your contract templates to knowledge/
  3. Add provision examples to src/lib/contracts/provision-examples/
  4. Update drafting principles in src/lib/drafting-principles.ts

See knowledge/README.md for detailed instructions.

Saved Reviews

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.

Project Structure

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

Tech Stack

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)

Deployment

Deploy to Vercel with one click:

Deploy with Vercel

Or deploy anywhere that supports Node.js:

npm run build
npm start

Disclaimer

terms-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.

License

MIT

Contributing

Contributions are welcome! Please open an issue or pull request.


Built by Ngandu Kasuku — Principal Product Counsel at GitHub.

About

AI-powered contract review tool — plain-language analysis, risk assessment, and redline suggestions

Resources

Stars

8 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages