by he-yufeng
AI agent that reads the fine print so you don't have to. Upload any contract → get red flags, unfair terms, and plain-English explanations in seconds.
# Add to your Claude Code skills
git clone https://github.com/he-yufeng/ContractGuardGuides for using ai agents skills like ContractGuard.
Last scanned: 5/30/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-05-30T16:15:57.145Z",
"npmAuditRan": true,
"pipAuditRan": true
}ContractGuard is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by he-yufeng. AI agent that reads the fine print so you don't have to. Upload any contract → get red flags, unfair terms, and plain-English explanations in seconds. It has 181 GitHub stars.
Yes. ContractGuard passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/he-yufeng/ContractGuard" and add it to your Claude Code skills directory (see the Installation section above).
ContractGuard is primarily written in Python. It is open-source under he-yufeng on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh ContractGuard against similar tools.
No comments yet. Be the first to share your thoughts!
Upload any contract → get red flags, unfair terms, and plain-English explanations in seconds.
English · 中文 · Demo · Quick Start · How It Works
Every year, millions of people sign contracts they don't fully understand — apartment leases with hidden penalties, employment agreements with overly broad non-competes, NDAs that silently strip away your rights. Hiring a lawyer costs $300-500/hour. Most people just sign and hope for the best.
ContractGuard changes that. It's an open-source AI agent that reads every clause of your contract, flags problems in plain language, and tells you exactly what to negotiate — all in under 30 seconds.
What makes it different from ChatGPT?
contractguard scan my-lease.pdf
✔ Parsed my-lease.pdf (4,521 characters)
⬤ RED FLAGS (5 found)
==================================================
1. Non-refundable security deposit
Clause: Section 3
"The security deposit is non-refundable and shall
be retained by Landlord upon termination"
Most states require deposits to be refundable.
This clause is likely illegal in California.
Suggestion: Remove "non-refundable" language.
2. Unlimited landlord access without notice
Clause: Section 5
"Landlord shall have the right to enter the Property
at any time, with or without notice"
California law requires 24-hour written notice.
Suggestion: Add "with 24 hours written notice"
… 3 more red flags, 3 warnings, 2 protections, 4 missing protections …
FAIRNESS SCORE: D (28/100)
5 red flags 3 warnings 2 protections 4 missing
pip install contractguardian
ContractGuard works with any OpenAI-compatible API. Pick one:
Option A: OpenRouter (recommended) — access to Claude, GPT-4, DeepSeek, Gemini, and 100+ models through a single API key:
export OPENROUTER_API_KEY=sk-or-...
Option B: OpenAI directly:
export OPENAI_API_KEY=sk-...
export OPENAI_BASE_URL=https://api.openai.com/v1
Option C: Local models via Ollama — your contract data never leaves your machine:
export OPENAI_BASE_URL=http://localhost:11434/v1
export OPENAI_API_KEY=ollama
contractguard scan my-contract.pdf
That's it. Three steps, under 60 seconds.
# Scan a PDF, DOCX, or TXT
contractguard scan lease.pdf
# Pick any OpenRouter / OpenAI / Ollama model
contractguard scan contract.pdf --model openai/gpt-4o
# Export a markdown report, or structured JSON for scripting
contractguard scan contract.pdf --output report.md
contractguard scan contract.pdf --json --output report.json
# Scan a whole folder, or diff two versions of a contract
contractguard batch ./contracts/ --output-dir reports/
contractguard compare lease-v1.pdf lease-v2.pdf
from contractguard.analyzer import analyze_contract
from contractguard.parser import extract_text
result = analyze_contract(extract_text("my-lease.pdf"))
print(f"{result.fairness_grade} ({result.fairness_score}/100)")
for flag in result.red_flags:
print(f"- {flag.title} ({flag.clause}): {flag.suggestion}")
--json emits the full structured result — contract type, parties, key terms, red flags, warnings, protections, and fairness score — as a Pydantic-backed object ready to pipe into other tools.
| Format | Extension | Notes |
|---|---|---|
.pdf |
Text-based PDFs. Scanned/image-based PDFs require OCR (coming soon). | |
| Word | .docx |
Microsoft Word documents |
| Plain Text | .txt |
Plain text files |
| Markdown | .md |
Markdown files |
| Rich Text | .rtf |
Rich Text Format files |
ContractGuard automatically detects the contract type and tailors its analysis accordingly. Each type has specific red flags and industry-standard protections it checks for:
| Contract Type | What ContractGuard Checks |
|---|---|
| Residential Leases | Rent increases, deposit refundability, maintenance obligations, landlord access rights, early termination penalties, habitability guarantees |
| NDAs / Confidentiality | Scope of "confidential information" (too broad?), duration, non-solicitation, non-compete, carve-outs for prior knowledge, return/destruction of materials |
| Employment Contracts | Non-compete scope & duration, IP assignment (does employer own your side projects?), termination notice period, severance, at-will vs. for-cause, benefits |
| Freelance / Contractor | Payment terms & schedule, kill fees, IP ownership, indemnification, scope creep protections, late payment penalties |
| SaaS Terms of Service | Data ownership & portability, auto-renewal & cancellation, SLA guarantees, limitation of liability, unilateral modification rights |
| Loan Agreements | Interest rate (fixed vs. variable), prepayment penalties, default triggers, personal guarantee scope, collateral requirements |
| Purchase Agreements | Warranty terms, return/refund policy, liability limits, dispute resolution (arbitration vs. court), force majeure |

Parse — Extracts text from your document (PDF, DOCX, TXT). For PDFs, uses pdfplumber to handle complex layouts. For DOCX, uses python-docx to read all paragraphs.
Detect — Sends the extracted text to the LLM, which automatically identifies the contract type (lease, NDA, employment, etc.) and adjusts its analysis strategy.
Analyze — The AI agent reviews every clause and categorizes findings into four groups:
Score — Generates an overall fairness grade from A+ (excellent, fair to both parties) to F (heavily one-sided, many red flags). The score is based on the number and severity of issues found, balanced against protections present.
Report — Outputs results as a beautiful Rich-formatted terminal report, or exports to Markdown/JSON for sharing or further processing.
ContractGuard uses the OpenAI-compatible API format, so it works with virtually any LLM provider:
| Provider | Setup | Best For |
|---|---|---|
| OpenRouter | export OPENROUTER_API_KEY=sk-or-... |
Access to 100+ models through one API key |
| OpenAI | export OPENAI_API_KEY=sk-... + export OPENAI_BASE_URL=https://api.openai.com/v1 |
Direct access to GPT-4o, o1, etc. |
| Anthropic (via OpenRouter) | Use --model anthropic/claude-sonnet-4 |
Best reasoning for complex contracts |
| Ollama (local) | export OPENAI_BASE_URL=http://localhost:11434/v1 |
Maximum privacy — data never leaves your machine |
| Azure OpenAI | Set OPENAI_BASE_URL to your Azure endpoint |
Enterprise compliance |
| Any OpenAI-compatible API | Set OPENAI_BASE_URL and OPENAI_API_KEY |
Self-hosted models, vLLM, etc. |
Default model is anthropic/claude-sonnet-4. google/gemini-2.5-pro handles very long contracts (1M context), deepseek/deepseek-chat is the budget pick, and any Ollama model keeps your data local.
Is this legal advice? No. ContractGuard is an educational tool for understanding contract terms in plain language, not a substitute for a licensed attorney.
Is my contract data sent to the cloud? Only to the LLM provider you configure. For full privacy, use a local model via Ollama — the text never leaves your machine. ContractGuard itself stores and logs nothing.
What's the maximum contract length?
About 30,000 tokens (~60 pages); longer documents are truncated. Use a large-context model like google/gemini-2.5-pro for very long contracts.
Can I use it in CI/CD?
Yes. --json gives parseable output; exit code is 0 on success, 1 on error. E.g. contractguard scan contract.pdf --json | jq '.red_flags | length'.
Shipped: batch scanning (analyze many contracts in one run) and contract comparison (diff two versions and surface what changed, clause by clause).
Planned: