Menu

1 / 2

How I Built a Chrome Extension That Analyzes Contracts Using 1,700+ Real Statutes as RAG Grounding

DEV Community: ai·henry·5 months ago
#LzhZJXCJ
#dev#statutes#contract#clause#pactlens
Reading 0:00
15s threshold

Two months ago I signed a contract with an auto-renewal clause I didn't notice. When I tried to cancel, I owed another year. That $1,200

mistake turned into PactLens — a Chrome extension that reviews contracts before you sign.

The core problem: LLMs hallucinate. You can't just ask an AI "is this clause risky" — it'll confidently make up laws that don't exist. So I

needed real statutes as a source of truth.

The RAG Pipeline

Here's how it works:

User selects contract text on any page → right-clicks → "Review with PactLens"

The text hits our Cloudflare Worker backend, which extracts clause-level semantics

We run semantic search against 1,700+ pre-loaded statutes using keyword matching + TF-IDF similarity

The top N most relevant statutes are injected into the prompt as context

The AI generates analysis grounded in those actual statutes, not hallucinations

The key insight: ground first, generate second .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.