ClauseGuard
AI-Powered Contract Risk Analyzer
The problem ClauseGuard solves
The Contract Review Crisis
Every business — from seed-stage startups to large enterprises — signs contracts that expose them to significant financial and legal risk.
The real problem is not the existence of risk, but the inability to detect it quickly and affordably.
Who Suffers, The Problem, and The Cost
| Who Suffers | The Problem | The Cost |
|---|---|---|
| Startups & Founders | Sign vendor/investor contracts without legal review | Locked into unfair terms, unlimited liability clauses |
| SMEs | Can't afford in-house lawyers for every contract | Missed penalty clauses, auto-renewal traps |
| Enterprise Legal Teams | Manual review of hundreds of contracts per month | 72 hours average review time per contract |
| Freelancers | No access to legal expertise at all | One-sided NDAs, IP ownership loss |
| Contract Managers | No visibility across contract portfolio | Duplicate risk exposure across vendors |
Challenges we ran into
Challenges We Ran Into
1. Gemini API Response Consistency
Getting Gemini API to return strictly valid JSON for every clause was tricky.
Long or ambiguous clauses caused the model to occasionally wrap responses in
markdown code blocks or add extra explanation text, breaking our JSON parser.
Fix: We added a strict system prompt instruction ("Return ONLY raw JSON, no
markdown, no preamble") and wrapped all API calls in a try/catch with a regex
fallback to strip code fences before parsing.
2. spaCy Clause Segmentation on Legal Text
Legal contracts don't follow normal sentence boundaries — they use numbered
sections, sub-clauses like (a)(i)(ii), and run-on sentences spanning entire
paragraphs. spaCy's default sentence boundary detection split clauses in the
wrong places.
Fix: We wrote a custom regex-based segmenter that splits on clause numbering
patterns (1., 1.1, (a), Article X) before passing text to spaCy, significantly
improving clause boundary accuracy.
3. API Rate Limits Under Parallel Batching
When we sent all 20+ clauses to Gemini API in parallel, we hit rate limits and
received 429 errors mid-analysis, causing partial results.
Fix: We implemented a batch queue with a concurrency limit of 5 simultaneous
requests and exponential backoff on retries. Full contract analysis now completes
reliably within 12 seconds.
4. PyMuPDF Layout Extraction on Scanned PDFs
Some test contracts were scanned PDFs with no embedded text layer. PyMuPDF
returned empty strings, silently breaking the entire pipeline.
Fix: We added a text-length check after extraction — if under 100 characters,
we fall back to pytesseract OCR on the rendered PDF pages.
5. React State Sync Between Clause List and Dashboard
The radar chart scores and the clause list were driven by separate state slices,
causing them to briefly show mismatched data during loading.
Fix: We lifted all analysis state to a single top-level context provider,
ensuring the dashboard and clause list always render from the same source of truth.
Tracks Applied (1)
