ContractGuard

by he-yufengVerified

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.

174
Stars
25
Forks
Python
Language
8/23/2026
Added
View on GitHubDownload ZIP

⚠️ Third-Party Software Notice

This skill is third-party open-source software developed and hosted independently on GitHub. SkillTip is an informational directory and does not control or maintain the underlying repository. Any security checks displayed are automated and limited in scope. Review the source code before installing.

Read the Terms of Service

Installation

Add to your Claude Code skills directory:

# Add to your Claude Code skills
git clone https://github.com/he-yufeng/ContractGuard

Getting Started

Guides for using skills like ContractGuard.

Security Report

Verified

Last scanned: —

{
  "status": "PASSED",
  "issues": []
}

README.md

ContractGuard — never sign a bad contract again

Upload any contract → get red flags, unfair terms, and plain-English explanations in seconds.

PyPI License: MIT Python 3.10+ CI

English · 中文  ·  Demo · Quick Start · How It Works


Why ContractGuard?

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?

  • Structured analysis, not a wall of text — you get categorized red flags, warnings, protections, and a fairness score
  • Actionable suggestions for every issue found — not just "this is bad" but "change it to this"
  • Consistent output format via Pydantic models — easy to integrate into other tools
  • CLI-first design — one command, beautiful terminal output, no browser needed
  • Works with any LLM — OpenRouter, OpenAI, Ollama (fully local/private)

Demo

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

Quick Start

1. Install

pip install contractguardian

2. Set up your API key

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

3. Scan a contract

contractguard scan my-contract.pdf

That's it. Three steps, under 60 seconds.

Usage

# 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

Python API

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.

Supported File Formats

FormatExtensionNotes
PDF.pdfText-based PDFs. Scanned/image-based PDFs require OCR (coming soon).
Word.docxMicrosoft Word documents
Plain Text.txtPlain text files
Markdown.mdMarkdown files
Rich Text.rtfRich Text Format files

Supported Contract Types

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 TypeWhat ContractGuard Checks
Residential LeasesRent increases, deposit refundability, maintenance obligations, landlord access rights, early termination penalties, habitability guarantees
NDAs / ConfidentialityScope of "confidential information" (too broad?), duration, non-solicitation, non-compete, carve-outs for prior knowledge, return/destruction of materials
Employment ContractsNon-compete scope & duration, IP assignment (does employer own your side projects?), termination notice period, severance, at-will vs. for-cause, benefits
Freelance / ContractorPayment terms & schedule, kill fees, IP ownership, indemnification, scope creep protections, late payment penalties
SaaS Terms of ServiceData ownership & portability, auto-renewal & cancellation, SLA guarantees, limitation of liability, unilateral modification rights
Loan AgreementsInterest rate (fixed vs. variable), prepayment penalties, default triggers, personal guarantee scope, collateral requirements
Purchase AgreementsWarranty terms, return/refund policy, liability limits, dispute resolution (arbitration vs. court), force majeure

How It Works

ContractGuard pipeline

  1. 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.

  2. Detect — Sends the extracted text to the LLM, which automatically identifies the contract type (lease, NDA, employment, etc.) and adjusts its analysis strategy.

  3. Analyze — The AI agent reviews every clause and categorizes findings into four groups:

    • Red Flags — Serious issues that could cause financial harm, legal liability, or loss of rights. These are things you should push back on before signing.
    • Warnings — Moderate concerns that are worth discussing but aren't necessarily deal-breakers. Common in many contracts but still worth knowing about.
    • Protections — Good clauses that protect your interests. These are things the contract got right.
    • Missing Protections — Standard clauses that are absent from the contract. Their absence may leave you exposed.
  4. 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.

  5. Verify — A deterministic statute checklist runs alongside the LLM, checking the rules where a wrong answer is a violation, not an opinion: probation length and pay caps, penalty scope, non-compete duration and compensation, the 150/200/300% overtime pay floors (PRC labor law), earnest-money ratio and lease-term caps (PRC Civil Code). Each check returns violation / ok / unknown, and "unknown" is reported honestly when the clause is missing instead of passing as compliance. Disable with --no-checklist.

  6. Report — Outputs results as a beautiful Rich-formatted terminal report, or exports to Markdown/JSON/HTML for sharing or further processing.

Configuration

LLM Providers

ContractGuard uses the OpenAI-compatible API format, so it works with virtually any LLM provider:

ProviderSetupBest For
OpenRouterexport OPENROUTER_API_KEY=sk-or-...Access to 100+ models through one API key
OpenAIexport OPENAI_API_KEY=sk-... + export OPENAI_BASE_URL=https://api.openai.com/v1Direct access to GPT-4o, o1, etc.
Anthropic (via OpenRouter)Use --model anthropic/claude-sonnet-4Best reasoning for complex contracts
Ollama (local)export OPENAI_BASE_URL=http://localhost:11434/v1Maximum privacy — data never leaves your machine
Azure OpenAISet OPENAI_BASE_URL to your Azure endpointEnterprise compliance
Any OpenAI-compatible APISet OPENAI_BASE_URL and OPENAI_API_KEYSelf-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.

FAQ

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'.

Roadmap

Shipped: batch scanning (analyze many contracts in one run) and contract comparison (diff two versions and surface what changed, clause by clause).

Planned:

  • OCR for scanned PDFs — handle image-only contracts, not just text PDFs, which is where a lot of real paperwork actually lives.
  • Jurisdiction-aware analysis — judge clauses against a chosen jurisdiction (US state law, EU, China), since whether a term is risky depends on where it's enforced.
  • Clause-by-clause negotiation drafts — for each red flag, draft suggested replacement language, turning the report into the start of a redline.
  • A web UI — a Streamlit/Gradio front end for people who won't touch a CLI, with the same local-only handling.
  • Pre-built contract templates — a few common contract types with known red flags, useful both as a starting point and as a test corpus.

Related Projects

ContractGuard is one of my applied agent projects. A few others worth a look:

  • CoreCoder — want to understand how a coding agent really works? Read the whole ~1k-line engine end to end, not a black box.
  • RepoWiki — dropped into an unfamiliar codebase? It gives you a guided wiki and a where-to-start reading path, a self-hostable DeepWiki alternative.
  • FindJobs-Agent — stop sifting job boards by hand: it ranks postings against your resume and runs mock interviews.
  • GitSense — want to contribute to open source? It finds issues worth your time and gauges whether your PR will get merged.
  • CodeABC — understand any codebase even if you don't code, built for non-programmers.

Contributing

Contributions are welcome! Here's how you can help:

  • Report bugs — Open an issue with the contract type and expected behavior
  • Add contract samples — More sample contracts for testing (with intentional red flags)
  • Improve prompts — Better LLM prompts for more accurate analysis
  • Add languages — Test with contracts in different languages and report results
  • Build integrations — MCP server, VS Code extension, Slack bot, etc.

License

MIT — use it however you want.

Frequently Asked Questions

What is ContractGuard?

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 174 GitHub stars.

Is ContractGuard safe to use?

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.

How do I install ContractGuard?

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).

What programming language is ContractGuard written in?

ContractGuard is primarily written in Python. It is open-source under he-yufeng on GitHub, so you can review or fork the full source.

Are there alternatives to ContractGuard?

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.

Comments (0)

No comments yet. Be the first to share your thoughts!

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI Agentsai-agentsanthropicclaude-code
View details
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI Agentsai-agentsbrainstorming
View details

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI Agentsai-agentsanthropicclaude-code
View details

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI Agentsclaude-codeai-tools
View details

claude-code

by anthropics

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

120,03119,897Shell
AI Agents
View details

Developers Also Liked

Based on votes and bookmarks from developers who liked this skill

ECC

by affaan-m

10

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

242,21936,702JavaScript
AI Agentsai-agentsanthropicclaude-code
View details
15

An agentic skills framework & software development methodology that works.

234,96620,863Shell
AI Agentsai-agentsbrainstorming
View details

n8n

by n8n-io

12

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

201,88160,308TypeScript
MCP Serversapisai-tools
View details

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

185,94028,768JavaScript
AI Agentsai-agentsanthropicclaude-code
View details

cc-switch

by farion1231

3

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode, OpenClaw, Grok Build & Hermes Agent. Only official website: ccswitch.io

128,8688,826Rust
AI Agentsclaude-codeai-tools
View details