DEV Community

一郎 支
一郎 支

Posted on

I Built an Offline Contract Risk Analyzer That Flags the Clauses That Cost You the Most

Last month a friend signed a 12-month SaaS contract without reading clause 14. It auto-renewed for another year and the early-termination fee was three months of subscription. She is not careless; the clause was just 40 words buried on page 6 of a 9-page agreement.

That is the problem ClauseGuard attacks: the clauses that cost ordinary people the most money are the ones written to be skimmed past.

What ClauseGuard does

ClauseGuard is an offline, zero-dependency contract risk analyzer written in pure Python standard library. You paste contract text in; it flags high-risk clauses, explains each one in plain language, and produces a risk score:

$ python -m clauseguard.cli examples/sample_contract.txt

[HIGH   ] Auto-Renewal Trap — contract renews automatically unless cancelled 30 days before expiry
           why it hurts: you pay for a full extra cycle if you miss a narrow cancellation window
           fix: negotiate a 60-day notice window and a calendar reminder on day 1

[HIGH   ] One-Sided Modification — provider may change terms at any time without notice
           why it hurts: every protection in this contract can be rewritten unilaterally
           fix: require written notice + a termination right if changes are material

[HIGH   ] Uncapped Indemnity — you cover all losses, including provider's own negligence
           why it hurts: your liability has no ceiling, theirs does
           fix: cap indemnity at fees paid in the prior 12 months

[CAUTION] Broad IP Assignment — anything you create on the platform belongs to them
[CAUTION] Personal Guarantee — you personally back the company's obligations
...

==> Risk score: 40/100 (HIGH) — 3 high-risk clauses, 7 cautions
Enter fullscreen mode Exit fullscreen mode

Why offline and zero-dependency?

Two deliberate design choices:

  1. Contracts are among the most sensitive documents you own — salaries, NDAs, leases, pre-nups. ClauseGuard runs 100% locally. Nothing is uploaded, nothing is logged, no API keys involved.
  2. A transparent rule engine beats a black box for legal risk. Every finding shows the matched pattern, the reasoning, and the mitigation. You can audit why it fired. A hallucinating LLM summarizer is the wrong tool when the stakes are a signed obligation.

The engine ships with 12 risk detectors covering auto-renewal, unilateral modification, liability caps, broad indemnity, IP assignment, personal guarantees, non-competes, arbitration venue, penalty clauses, and more — each with a plain-language explanation and a negotiation suggestion.

It also generates a self-contained HTML report you can attach to an email before a signing meeting.

Try it

git clone https://github.com/Zhiyilang/clauseguard
cd clauseguard
python -m clauseguard.cli examples/sample_contract.txt --html report.html
Enter fullscreen mode Exit fullscreen mode

No pip install. Python 3.8+. MIT licensed.

What's next

  • Multi-language clause patterns (the engine is pattern-table driven)
  • DOCX/PDF text extraction
  • A "compare two versions" mode that diffs risk scores between contract drafts

Built as part of my open-source AI series. Feedback and PRs welcome — especially more clause patterns from other jurisdictions.

Disclaimer: ClauseGuard is decision support, not legal advice. For anything material, talk to a lawyer.

Repo: https://github.com/Zhiyilang/clauseguard

Top comments (0)