DEV Community

Raj Jasani
Raj Jasani

Posted on

ContractGuard: Local-First Legal & Scope Creep Auditor for Freelancers (Powered by Google Gemma)

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission πŸ’Έ

This is a submission for Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle.

What I Built

ContractGuard is a sovereign, local-first legal auditor and scope creep defense engine built for freelancers, contract developers, designers, and agency solopreneurs. It is powered by Google Gemma open-weight models (gemma2:9b / gemma2:2b).

Every year, independent contractors lose thousands of dollars to predatory clauses buried deep inside client Master Services Agreements (MSAs) and Statements of Work (SOWs). A single clause can trap a freelancer in a Net-90 payment delay, force them to transfer their intellectual property before final payment clears, or expose them to unlimited personal indemnification liability.

ContractGuard solves this by auditing contracts against the Freelancer Fatal 7β„’ traps:

  1. Payment Terms & Cash Flow Traps: Detects Net-60/90 terms, "pay-when-paid" clauses, and missing upfront deposits.
  2. Premature IP Assignment: Ensures your copyright and IP only transfer after full payment has cleared your bank account.
  3. Infinite Revisions & Scope Squeeze: Flags subjective client satisfaction clauses and missing revision round caps.
  4. Restrictive Covenants & Non-Competes: Protects your freedom to take other clients in your specialty.
  5. Unilateral Indemnification & Unlimited Liability: Caps your liability at the contract fee paid, protecting your personal assets.
  6. Unilateral Termination & Missing Kill Fees: Guarantees you get paid for completed milestones plus an early termination fee.
  7. Unbounded Scope Control: Requires a mutually signed Change Order before starting any out-of-scope work.

Beyond just scoring the risk, ContractGuard provides ready-to-use Redline Counter-Clauses that freelancers can copy-paste straight into an email or contract redline document.

Additionally, the Scope Creep Defender turns out-of-scope client messages ("Can you also quickly build an admin dashboard before Monday?") into three polished responses:

  • Diplomatic & Upsell (Recommended): Validates the client's idea and quotes a paid addendum or Phase 2 sprint.
  • Firm & Structured: References agreed contract terms and requires a signed Change Order.
  • Quick Boundary: A polite postponement to protect the launch timeline.

Who Would Pay for It?

Solo developers, designers, video editors, and independent consultants worldwide.

When freelancers sign a new project, hiring a lawyer at $400–$600/hour to review a $4,000 SOW is financially impractical. Most freelancers simply cross their fingers and sign. When a dispute happens:

  • A late payment leaves them unable to pay rent for 90 days.
  • A client demands 12 rounds of "minor tweaks" for free.
  • A client cancels the project with 95% of the work done and pays $0.

A tool that costs $9/month or $5/audit that catches a single $3,000 trap pays for itself for decades. Unlike general chatbots where you have to manually prompt and risk hallucinations, ContractGuard evaluates the exact risk rubric, calculates an objective risk score (0-100), and provides industry-standard redline clauses.


Demo

Here is the ContractGuard interface in action:

  • Instant Sample Audits: Test with pre-loaded high-risk developer SOWs, design contracts, or a fair gold-standard contract with 1 click.
  • Risk Scorecard: Immediate visual verdict with critical and warning indicators.
  • Fatal 7 Breakdown: Problematic clause quote, plain-English legal risk explanation, and 1-click copy redline counter-clause.
  • Scope Creep Response Generator: 3 distinct tone variations to turn unbilled scope creep into paid revenue.
+-------------------------------------------------------------------------------+
|  ContractGuard AI                  Hacktoberfest 2026: Week 2 (Side Hustle)   |
+-------------------------------------------------------------------------------+
|  [Risk Score: 97/100 - CRITICAL RISK]   5 Fatal Traps Detected                |
|  Summary: High-risk contract. Contains terms that severely threaten cash flow.|
|                                                                               |
|  🚨 1. Payment Terms & Cash Flow Trap [CRITICAL]                              |
|     Clause: "Invoices submitted by Contractor subject to Net-90 terms..."     |
|     Risk: Forces you to act as an interest-free bank for 3 months.            |
|     Redline: "All invoices payable within Net-15 days. 50% deposit upfront..."|
|     [Copy Redline Counter-Clause]                                             |
|                                                                               |
|  🚨 2. Premature IP Assignment Trap [CRITICAL]                                |
|     Clause: "Assigns all rights unconditionally upon initial delivery..."     |
|     Risk: Strips away all leverage before final payment clears.               |
|     Redline: "IP rights transfer solely upon receipt of full payment..."      |
|     [Copy Redline Counter-Clause]                                             |
+-------------------------------------------------------------------------------+
Enter fullscreen mode Exit fullscreen mode

Code

The complete source code is open-source under the MIT License on GitHub:

ContractGuard AI πŸ›‘οΈ

Local-First Contract & Scope Creep Auditor for Freelancers & Solopreneurs
Built for Hacktoberfest 2026: Week 2 Open-Source AI Challenge (Side Hustle)
Category: Overall Submission & Best Use of Gemma

Hacktoberfest 2026 Model License: MIT Tests Privacy


πŸ’‘ Executive Summary

Every year, solo developers, designers, and consultants lose thousands of dollars to sneaky clauses hidden inside client Master Services Agreements (MSAs) and Statements of Work (SOWs). From Net-90 payment delays and premature IP assignment to unlimited revisions and unilateral indemnification, clients regularly shift massive business risk onto unprotected solopreneurs.

Freelancers cannot afford a $500/hour contract lawyer for a $5,000 project. But they also cannot paste confidential client contracts into proprietary closed cloud AI models without violating client NDAs.

ContractGuard AI is a sovereign, local-first legal auditor and scope creep defense system powered by Google Gemma open-weight models (gemma2:9b / gemma2:2b). It scans client contracts for the Freelancer Fatal 7β„’ traps, computes…

πŸ”— Repository Link: https://github.com/RajJasani/contractguard


How I Built It

  • Open-Weight Model: Google Gemma 2 (gemma2:9b and gemma2:2b) running via local Ollama or OpenAI-compatible inference servers (vLLM / llama.cpp).
  • Hybrid Dual-Engine Architecture:
    • A deterministic legal pattern engine with high-precision regex extraction for instant, zero-latency detection of common trap formulations.
    • Google Gemma's open-weight model provides contextual nuance, semantic risk synthesis, and dynamic scope creep email generation.
    • Zero external npm/pip runtime dependencies for the core server (server.py), running cleanly on Python's built-in standard library for instant execution.
  • Frontend: Responsive, glassmorphic single-page app with native dark mode, tabbed navigation, 1-click clipboard integration, and real-time state management.
  • Testing: Comprehensive automated test suite (tests/test_auditor.py) validating trap detections across real-world freelance agreements.

System Architecture Diagram

flowchart TD
    A[Freelancer Contract / SOW Text] --> B[ContractGuard Web Interface]
    B --> C[ContractGuard REST API]

    subgraph Engine[Dual-Engine Processing Core]
        C --> D[Deterministic Legal Pattern Engine]
        C --> E[Google Gemma 2 Open-Weight Model\nLocal Ollama / vLLM]
        D --> F[Freelancer Fatal 7 Evaluator]
        E --> F
    end

    F --> G[0-100 Risk Scorecard]
    F --> H[Legal Exposure Explanation]
    F --> I[1-Click Redline Counter-Clauses]

    J[Client Scope Creep Request] --> K[Scope Creep Defender]
    K --> L[3 Polished Boundary Emails:\n1. Diplomatic & Upsell\n2. Firm Change Order\n3. Quick Boundary]

Why Does Open Innovation Matter?

In this week's challenge, DEV asks: Why does open innovation matter for what you built?

For a legal tool protecting solopreneurs, open innovation is not a stylistic choice β€” it is an existential business necessity:

  1. Client Confidentiality & Non-Disclosure (NDA) Compliance: Freelance contracts contain non-public rates, client roadmap features, and strict NDAs. Uploading these documents to closed, proprietary cloud AI platforms risks violating client confidentiality and breaching your contract. With open-weight models like Google Gemma, inference runs locally on the freelancer's laptop. Client data never leaves the device.
  2. Economic Viability (90%+ Gross Margin for the Side Hustle): If you charge $9/month or $5/audit, closed API providers charging per token would devour your revenue on multi-page SOWs. By running Gemma locally or on low-cost shared GPU instances, marginal serving costs are near zero, creating a sustainable 90%+ gross margin micro-SaaS.
  3. No Vendor Lock-In or Sudden Deprecations: Proprietary APIs change pricing, apply unpredictable content filters, or deprecate models without warning. With an open-weight model, the weights belong to the creator forever.
  4. Offline Freedom: Freelancers frequently work from airplanes, trains, or coffee shops without reliable Wi-Fi. ContractGuard runs completely offline.

What's Next?

  • PDF & DOCX Drag-and-Drop: Adding in-browser client-side OCR for direct PDF contract uploads without third-party services.
  • Jurisdiction-Specific Modules: Fine-tuning Gemma on specific legal statutes such as the NYC Freelance Isn't Free Act and California AB5 contractor laws.
  • Contract Diff Viewer: Visual side-by-side redline comparison showing the original contract next to the negotiated version.

Thank you to the DEV and MLH teams, and to DigitalOcean, Google Gemma, and Hacktoberfest for organizing this challenge!

Top comments (0)