DEV Community

Harjas
Harjas

Posted on

Lim Local: an offline contract checker for freelancers, built with Gemma 4

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

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

What I Built

Imagine you are a freelance developer and a new client sends you a contract. Payment is due 90 days after you send the invoice, and only after the client's own customer has paid them. The IP clause says everything you write belongs to the client the moment you write it, even if they never pay you. You would like a second opinion before you sign.

You have two bad choices. A contracts lawyer often charges $300 to $800 an hour, which is hard to justify on a small project. Or you can paste the contract into a cloud AI tool, but that can break the NDA you signed, because the client never agreed to let anyone else read their draft.

Lim Local is a command-line tool that gives you that second opinion on your own laptop. The contract never leaves your computer.

You give it a contract file (.md, .txt, .docx or a text-based .pdf). It finds the three clauses that cause freelancers the most trouble: payment terms, IP ownership, and indemnification and liability (who has to pay when something goes wrong). It compares each one with the open Common Paper standard terms and writes one HTML report that looks like a Wikipedia page. For every clause, the report shows:

  • a risk rating: LOW, MEDIUM or HIGH
  • the exact sentences from the contract that caused each warning
  • the original clause next to a suggested rewrite
  • one polite sentence you can send back to the client

Here is a real example from my test contract. The tool flags this sentence:

Payment is explicitly conditioned upon Client successfully collecting licensing disbursement from its ultimate institutional enterprise client.

and in the suggested rewrite, the payment clause says:

Client agrees to remit payment within thirty (30) days of receipt of invoice.

Who would pay for it? Solo freelancers and small agencies who sign client contracts without a lawyer. My idea is a packaged desktop app with a one-time price (something like $29), plus paid add-on packs for other kinds of clauses, such as non-competes. I have not sold anything yet, and the price is a guess.

Demo

This short video shows Lim Local auditing a test contract and the report it writes.

Audit summary table showing document metadata and clause risk counts

Side-by-side clause comparison table showing original contract text against suggested redline

The test contract in the demo has deliberately unfair terms.

To try it yourself:

git clone https://github.com/harjasbb07-eng/Lim-Local.git
cd Lim-Local
npm install
ollama pull gemma4:e2b-it-qat
npm run audit -- sample_sow.md
Enter fullscreen mode Exit fullscreen mode

Then open audit_sample_sow.html in your browser.

Code

Lim Local

An offline contract triage tool for independent contractors and small agencies. It reads a client contract, finds three high-risk clauses, compares them with the Common Paper standard terms, and writes a single-file HTML report with risk ratings, redlines and negotiation lines. Everything runs on your own machine with a local Gemma 4 model through Ollama.

Lim Local is a preliminary triage aid. It is not legal advice.

The problem

Freelancers and boutique studios regularly receive client-drafted Master Services Agreements (MSAs) and Statements of Work (SOWs) that contain unbalanced terms:

  • Long payment periods (Net-60, Net-90) or "pay-when-paid" conditions.
  • Immediate assignment of all work product, including the contractor's own pre-existing tools, whether or not the client has paid.
  • One-sided, uncapped indemnification with no waiver of lost profits or consequential damages.

A commercial contracts lawyer costs roughly $300 to $800 per hour, which is hard to justify for a routine SOW…




The code is MIT licensed. The README lists what the tool cannot do.

How I Built It

The model. Lim Local uses Gemma 4 (gemma4:e2b-it-qat), a small open model from Google. It runs through Ollama, a free program that runs AI models on your own computer. The tool only talks to 127.0.0.1, which is your own machine. On my laptop (RTX 4050, 6 GB video memory) a full audit usually takes 10 to 20 seconds.

The steps.

  1. reader.ts pulls the text out of the file.
  2. splitter.ts cuts it into sections and picks one section for each of the three clause types.
  3. auditor.ts compares each section with 13 sections of the Common Paper Professional Services Agreement (PSA) Standard Terms v1.1, copied word for word. They are licensed CC BY 4.0.
  4. The code looks for red flags and sets the rating. Gemma writes the suggested rewrite and the polite sentence.
  5. generate_report.ts writes the report. Anything that comes from the contract or the model is HTML-escaped.

Code decides, Gemma writes. Two or more red flags means HIGH, one means MEDIUM, none means LOW. LOW does not mean the clause is safe. It only means none of my checklist items were found.

What broke along the way. A small model is not a good judge on its own. These are the problems I hit:

  1. The model copied my checklist. I gave Gemma a list of red flags and asked what it found. On a fair contract, it gave my own list back as its findings. Now it has to quote the contract, and the code checks that the quote is really in the clause.
  2. It quoted a protective sentence as proof of a bad term. A fair contract said "Upon receipt of full payment, Contractor assigns...", and the model used that sentence as evidence for "assignment before payment". So the IP clause came back HIGH. I added word patterns for what each red flag looks like, and patterns for the protections that cancel it.
  3. Ratings changed between runs. On one run the model would report a problem and on the next it would skip it. Now the code looks for each red flag itself, and the model does not decide what counts.
  4. Hidden thinking used up the answer space. Gemma 4 can think silently before it answers, and those hidden thoughts used up the space I gave it for the answer. The answer got cut off in the middle, and the program crashed on the broken output. One early run took 74 seconds and two of the three clauses failed. Ollama also gives Gemma 4 a small memory window by default (4,096 tokens). I turned the thinking off and raised the window to 8,192. The same contract now takes about 15 seconds.
  5. Common Paper words leaked into rewrites. The rewrites said things like "Payment Period" and "Provider" in contracts that used "Freelancer" and "15 days". The code now replaces those words with plain wording and the contract's own names for the parties.
  6. My first outside test found three more bugs. The tester's contract calls the freelancer "Freelancer", not "Contractor". It also said a liability cap "does not apply", and my rule saw the word "cap" and decided a cap existed. Two of the three clauses came back MEDIUM when they should have been HIGH. After the fixes, all three came back HIGH.

What I tested.

Document Result
sample_sow.md, deliberately unfair 3 HIGH
sample_fair_sow.md (also as .docx and .pdf), balanced 3 LOW
messy_sow.txt, headings with no numbers 3 HIGH
example.txt, a government-style sample with fictional data Payment MEDIUM (no deadline, 10 percent holdback). The other two clauses are not in the file, and the report says so.
Tester's .docx, a fictional contract with a deliberately bad addendum 3 HIGH

This is a small set. I tuned the rules while looking at most of these files, so please do not read it as an accuracy score. The tester's file was the first one I had not tuned against, and it found the bugs above.

What it cannot do.

  • The rules are English keyword patterns, so unusual wording can slip through.
  • It checks only one section per clause type. If a contract has a fair clause and a worse addendum on the same topic, only the higher-scoring one is reviewed.
  • If a SOW points to a separate master agreement, those clauses show up as not found.
  • Gemma's rewrites can add terms the original did not have, such as a 30-day payment period. Always compare the rewrite with the full contract.
  • Scanned PDFs do not work.
  • I have only tested it on Windows 11.
  • Lim Local is a triage aid, not legal advice.

I used AI chat assistants and a coding extension to help write and review the code. I ran and tested every change myself. The tester's contract was also drafted with AI and is marked as a fictional test file.

Why Does Open Innovation Matter?

The contract stays on the laptop. This is the reason the project exists. A freelancer under an NDA cannot send a client's draft to a closed cloud service. Because the model is open, it runs on the freelancer's own machine, and after the one-time model download the tool needs no internet.
I also checked this myself: I switched off my laptop’s Wi-Fi, ran an audit on sample_sow.md, and it finished normally.

It costs nothing per contract. There is no bill for each page, so a one-time price like $29 can work as a business. A tool built on a paid cloud API would pay for every audit, and every upload would add a privacy risk.

I could change how the model behaves. Because the model runs on my own machine, I could turn off its hidden thinking, set its memory window, and put code checks around its answers. That is how I went from a model that copied my checklist to a tool that gives steady ratings.

Where a closed model would be better. A large cloud model would probably read a contract more carefully than a small one. But it would break the one rule this tool has to follow, which is that the contract never leaves the machine. For this problem, a small model that stays local is the better trade.

My First User

One independent tester cloned the repo and ran Lim Local on their own laptop, which has an RTX 2050 with 4 GB of video memory. It worked on that smaller card. On their last run, a full contract took 35.9 seconds. That is slower than on my laptop, but it finished. I do not have times for their earlier runs.

They sent me a contract and two complaints. I fixed all three problems:

  1. The terminal looked frozen for a few seconds while the model loaded on the first call. The tool now prints a loading message and shows progress for each clause.
  2. Each run overwrote the previous report. Reports are now named after the contract, for example audit_sample_sow.html.
  3. Their test contract exposed the three rule bugs described above.

I do not have their exact words, so this is my summary of what they told me and not a quote. They said that if Lim Local really works well and keeps them from pasting their contracts into a cloud AI tool, they would definitely pay a one-time fee for it. They did not name an amount, but they said a finished product would be worth something to them.

Nobody has paid yet, so I still do not know the right price.

Prize Categories

Best Use of Gemma. Gemma 4 runs locally through Ollama and writes the suggested rewrites and the negotiation sentences.

Top comments (0)