This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle
π‘οΈ ClauseShield: 100% Privacy-First Local Contract Reviewer for Freelancers
Freelancing is liberatingβuntil you get handed a 12-page commercial Master Services Agreement (MSA) packed with dense legal jargon.
Most freelancers face an impossible trilemma:
- Pay $400/hour for legal counsel: Completely unaffordable for a $3,000 to $10,000 project.
- Blindly sign the contract: Risking silent IP grabs, 2-year non-compete clauses, Net-90 payment terms, and uncapped liability.
- Paste the contract into ChatGPT or Claude: Violating client non-disclosure agreements (NDAs), leaking trade secrets, and transmitting private commercial rates to third-party cloud servers.
To solve this dilemma, I built ClauseShieldβa 100% offline, privacy-first desktop application engineered specifically for freelancers, independent contractors, and creative consultants. Powered by open-weight models (Llama 3.1 via Ollama), ClauseShield performs local PDF text extraction, pinpoints predatory clauses verbatim, generates an actionable risk assessment, and drafts polite, battle-tested counter-negotiation language and client emails.
Zero cloud calls. Zero API tokens. Zero NDA violations.
What I Built
ClauseShield is an AI-powered legal audit copilot built specifically around the financial and legal realities of solo knowledge workers.
Who Would Pay For It?
- Independent Software Developers & DevOps Engineers: Protecting against broad work-for-hire clauses that steal pre-existing code libraries, boilerplates, and open-source tooling.
- UI/UX & Graphic Designers: Preventing clients from owning preliminary concepts, design systems, and rejected design drafts prior to final payment.
- Copywriters, Strategists & Consultants: Shielding against punitive non-competes and non-solicitation clauses that lock them out of entire industries.
- Boutique Agencies & Studios: Streamlining incoming vendor and client contract reviews without incurring thousands in retainer legal fees.
A tool like Ironclad or ContractPodAi charges enterprise organizations tens of thousands of dollars annually. A dedicated, privacy-first desktop utility like ClauseShield offered at $12/month or a $49 lifetime license is an instant return-on-investment for any freelancer after saving a single invoice or retained IP asset.
Key Capabilities
-
Freelancer-Protective Legal Audit Engine:
- IP Grab Detection: Identifies broad work-for-hire language that attempts to assign pre-existing background IP, and ensures IP assignment strictly occurs after 100% payment receipt.
- Cash Flow Safeguards: Flags Net 60/90 terms, unfair invoice dispute holdbacks, and missing late payment interest penalties.
- Non-Competes & Restraints on Trade: Warns against illegal or restrictive covenants that prevent working with other clients in the same market.
- Scope Creep Controls: Detects subjective 'client satisfaction' acceptance criteria and enforces structured change-order procedures.
- Uncapped Liability: Flags one-sided indemnification clauses and demands liability caps limited strictly to total fees paid under the contract.
-
Actionable Negotiation Deliverables:
-
Color-Coded Risk Scorecard: Instant visual triage (
π’ Low,π‘ Medium,π΄ High,π¨ Dangerous). - Clause-by-Clause Redlines: Quotes the offending contract language verbatim alongside professional counter-language ready to paste directly into contract revisions.
- Polite Client Negotiation Email: Automatically formats a courteous, collaborative email explaining the rationale behind the requested revisions so freelancers don't feel awkward advocating for themselves.
- Exportable Markdown Audit: One-click download of the complete review report for archival and record-keeping.
-
Color-Coded Risk Scorecard: Instant visual triage (
Demo
ClauseShield runs locally as an interactive Streamlit desktop application at http://localhost:8501.
flowchart LR
A[Contract PDF] --> B[Local PDF Extraction\npdfplumber]
B --> C[Structured Legal Prompt\nprompts.py]
C --> D[Local Ollama Engine\nLlama 3.1 8B @ localhost:11434]
D --> E[Real-Time Token Stream]
E --> F[Risk Scorecard & Badges]
E --> G[Itemized Redlines & Counter-Clauses]
E --> H[Client Negotiation Email Draft]
E --> I[Downloadable Markdown Report]
User Workflow
-
Ollama Service Detection: The sidebar automatically checks whether the Ollama local daemon is running (
π’ Ollama Service Active) and dynamically pulls all locally downloaded models fromhttp://localhost:11434/api/tags. -
Select Model & Priorities: Select
llama3.1(orllama3.2:3bfor ultra-fast low-resource CPU inference) and toggle review priorities (IP Rights, Payment Terms, Non-Competes, Scope Creep, Liability). - Upload Contract PDF: Upload any standard SOW, MSA, or Freelance Agreement. The app parses the document in-memory and displays real-time statistics (total pages, word count, character count).
- Audit Contract Locally: Click the audit button to initiate streaming inference. Tokens stream live onto the screen with zero cloud lag.
-
Review & Negotiate:
- Inspect the Risk Scorecard.
- Review each flagged clause with suggested counter-clauses.
- Copy the customized Client Negotiation Email Draft into your email client.
- Download the full Markdown report for your records.
Code
The complete source code is open source and hosted on GitHub:
Direct Link: https://github.com/AbhavyaManchanda/ClauseSheild
Project Structure
ClauseSheild/
βββ clauseshield/
β βββ app.py # Streamlit desktop UI, reactive state & streaming displays
β βββ analyzer.py # Local PDF extraction (pdfplumber) & streaming Ollama client
β βββ prompts.py # Legal audit prompts, risk classification & redline templates
β βββ create_sample_contract.py # Script generating synthetic test contracts
β βββ sample_predatory_contract.pdf # Reproducible test PDF with classic predatory traps
β βββ requirements.txt # Minimal dependencies (streamlit, ollama, pdfplumber)
β βββ README.md # Comprehensive setup, hardware sizing & usage guide
βββ .gitignore # Clean repository exclusions
βββ LICENSE # Permissive MIT Open Source License
Core Architecture Highlights
1. In-Memory PDF Extraction (analyzer.py)
def extract_text_from_pdf(pdf_file: Any) -> dict[str, Any]:
extracted_pages = []
with pdfplumber.open(pdf_file) as pdf:
for idx, page in enumerate(pdf.pages, start=1):
raw = page.extract_text() or ""
clean = re.sub(r"[ \t]+", " ", raw).strip()
extracted_pages.append({"page": idx, "text": clean})
return {"text": "\n\n".join(p["text"] for p in extracted_pages), ...}
2. Streaming Local Model Inference (analyzer.py)
def analyze_contract_text(contract_text, model="llama3.1", host="http://localhost:11434", custom_focus=None, stream=True):
client = ollama.Client(host=host)
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": build_analysis_prompt(contract_text, custom_focus)}
]
response = client.chat(
model=model,
messages=messages,
options={"temperature": 0.1, "top_p": 0.9},
stream=stream
)
for chunk in response:
yield chunk.get("message", {}).get("content", "")
How I Built It
ClauseShield is architected entirely around open-source AI and local tooling:
-
Inference Runtime β Ollama:
- Leverages Ollama as the local model daemon, listening on
http://localhost:11434. - Tested and optimized with Llama 3.1 8B (Meta) for deep legal reasoning, and Llama 3.2 3B for lightweight, high-speed execution on standard laptops.
- Uses low-temperature decoding (
0.1) to ensure strict fidelity to contract text, preventing hallucinated clauses while generating legally robust redlines.
- Leverages Ollama as the local model daemon, listening on
-
Full-Stack Desktop Interface β Streamlit & Python:
- Streamlit provides a responsive, single-page application framework.
- Built with custom CSS card components, reactive session state, dynamic error handling for Ollama connectivity, and real-time token streaming.
- Zero telemetry, zero web trackers, and zero external analytics.
-
Deterministic Prompt Engineering (
prompts.py):- Structured prompt hierarchy instructing the model to act as an unyielding freelancer-protective legal advocate.
- Output enforces strict markdown sections: Overall Risk Score, Executive Assessment, Flagged Clauses with exact quotes and counter-language, and a Ready-to-Send Client Email.
Why Does Open Innovation Matter?
Open innovation is not just an implementation detail for ClauseShieldβit is the only reason the project can exist legally and commercially.
1. Absolute Privacy & Non-Disclosure Agreement (NDA) Compliance
Commercial contracts are strictly confidential. When a freelancer receives an enterprise MSA or SOW, the document routinely contains proprietary product architectures, unannounced project roadmaps, client identities, and confidential billing rates.
- Transmitting that text to a closed cloud API (OpenAI, Anthropic, or Google Cloud) constitutes an immediate breach of standard NDA confidentiality terms.
- With open-weight models running locally via Ollama, contract text never leaves volatile memory. No data touches third-party infrastructure.
2. Viable Unit Economics for Micro-SaaS & Side Hustles
Commercial legal AI services charge $30β$100 per document review because they pass through steep cloud API token costs.
- Reviewing a 15-page contract with a 128k context window on closed APIs can cost $0.15 to $0.40 per run.
- With open-weight models running on local hardware (or self-hosted commodity compute), the marginal inference cost is exactly $0.00. This enables solo developers to offer accessible, flat-fee or one-time pricing models that genuinely serve freelancers.
3. Model Sovereignty & Freedom from Vendor Lock-In
With closed APIs, developers are subject to arbitrary rate limits, pricing hikes, policy shifts, and sudden model deprecations.
- By building on open standards with Ollama, users can freely toggle between Llama 3.1, Gemma 2, Mistral, or fine-tuned legal domain models without changing a single line of application code.
My First User
To test ClauseShield in a real-world scenario, I shared it with a fellow freelance full-stack engineer who had just received a 5-page draft Statement of Work from a digital marketing agency for a $6,500 web application build.
What ClauseShield Caught:
- The Silent IP Trap: Section 4 stipulated that the contractor assigned all intellectual property rights to the client "upon creation"βmeaning the client would own the code before paying a single dollar.
- Missing Pre-Existing IP Exclusion: The clause had no carve-out for the developer's existing open-source utility libraries and starter templates.
- Payment Term: Net-60 payment with no late payment fee interest.
The Result:
Using ClauseShield's generated counter-language and polite email template, the freelancer responded:
"The draft looks great overall, and I'm excited to get started! I just have a couple of standard protective redlines regarding payment terms (requesting Net-15) and reserving ownership of my pre-existing development starter kit until final payment receipt."
The client approved the revisions in less than 24 hours without pushback!
User Feedback:
"Reviewing this with a lawyer would have cost half of my initial deposit. Running ClauseShield on my laptop took 25 seconds, flagged the exact IP trap I missed on my first read, and gave me polite pushback wording so I didn't sound hostile to my client. This is an essential tool for anyone freelancing."
Prize Categories
- Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle (Theme: Build something with open-weight models or open-source AI that someone would actually pay for)
- Open-Source AI & Local Inference
Built with β€οΈ during Hacktoberfest 2026. Empowering freelancers with open-source AI sovereignty.
Top comments (0)