Skip to content
Back to skills

Contract Risk Analyzer

ASecurity

Contract Risk Analyzer β€” Upload contract PDF, AI auto-extracts key clauses and annotates risk points, outputs structured risk report (summary + key terms table + πŸ”΄πŸŸ πŸŸ‘ three-tier risk list). Supports 6 contract types: purchase/sales/service/labor/lease/NDA. Trigger: contract review, contract risk, contract analysis, contract check

  • 9 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 25, 2026
toolspythongoazureapi

Works with

  • api

Security analysis

A100/100

Pro scans all 13 files and shows the line behind each finding

Scanned September 25, 2026

npx -y skills add CSlawyer1985/legal-skillhub --skill contract-risk-analyzer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Contract Risk Analyzer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Contract Risk Analyzer
[![Security: A β€” Skills Directory](https://www.skillsdirectory.com/api/skills/cslawyer1985-contract-risk-analyzer/badge)](https://www.skillsdirectory.com/skills/cslawyer1985-contract-risk-analyzer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: contract-risk-analyzer
description: "Contract Risk Analyzer β€” Upload contract PDF, AI auto-extracts key clauses and annotates risk points, outputs structured risk report (summary + key terms table + πŸ”΄πŸŸ πŸŸ‘ three-tier risk list). Supports 6 contract types: purchase/sales/service/labor/lease/NDA. Trigger: contract review, contract risk, contract analysis, contract check"
---

# Contract Risk Analyzer

Upload contract PDF β†’ AI auto-extracts key clauses β†’ risk annotation β†’ structured risk report.

**No legal judgment β€” only structured extraction and risk annotation.**

---

## Core Features

- **Contract type detection**: Auto-identifies 6 types (purchase/sales/service/labor/lease/NDA)
- **Text extraction**: PyMuPDF + pdfplumber dual-engine for complete coverage
- **AI structured extraction**: OpenAI-compatible API, user provides their own key
- **Risk annotation**: Industry risk library + three-tier classification (πŸ”΄ High 🟠 Medium 🟑 Low)
- **Feishu push**: Risk report auto-sent as Feishu interactive card

---

## AI Agent Workflow

```python
# 1. Upload contract PDF and analyze
result = analyze_contract(
    pdf_path="/path/to/contract.pdf",
    api_key="sk-...",                  # OpenAI-compatible API Key (user-provided)
    base_url="https://api.openai.com/v1",
    model="gpt-4o-mini",
    user_focus="payment cycle and breach liability",
)

# result returns:
# {
#   "contract_type": "Purchase Contract",
#   "summary": "This contract is a purchase agreement between XXX and YYY for...",
#   "key_terms": [
#     {"category": "Parties", "content": "...", "risk": ""},
#     ...
#   ],
#   "risks": [
#     {"level": "πŸ”΄", "item": "Amount clause left blank", "suggestion": "..."},
#     ...
#   ],
#   "report_markdown": "..."  # Full report in Markdown
# }

# 2. Push Feishu card (optional)
send_feishu_notification(
    open_id="ou_xxx",
    report_markdown=result["report_markdown"],
    contract_type=result["contract_type"],
)
```

---

## Usage Examples

### Example 1: Analyze a Purchase Contract
```
User: Review this purchase contract
[upload contract.pdf]
```
β†’ PDF text extraction β†’ type detection β†’ AI extraction β†’ risk annotation
β†’ Returns: risk report (summary + key terms table + risk list)

### Example 2: Review Labor Contract and Push to Feishu
```
User: Review this labor contract and send me the report
[upload labor_contract.pdf]
```
β†’ Analysis complete β†’ Feishu interactive card pushed to user

---

## Output Format

### Risk Report Structure

```markdown
# Contract Risk Review Report

**Contract Type:** Purchase Contract
**Review Date:** 2026-04-20
**Disclaimer:** Auto-generated by AI, for reference only, not legal advice.

## 1. Summary

[200-word summary of core contract content]

## 2. Key Terms

| Category | Content | Risk Note |
|----------|---------|-----------|
| Parties | Party A: XXX Co. | β€” |
| Amount | Β₯100,000 | β€” |
| Payment Terms | Within 30 days after signing | ⚠️ No specific latest payment date |
| Breach Liability | Breaching party compensates losses | ⚠️ No liquidated damages clause |
| ... | ... | ... |

## 3. Risk Points

### πŸ”΄ High Risk (Requires Attention)
1. **Amount clause blank**: Contract amount not fully stated...
2. **Unilateral breach liability**: Party A's liability significantly lighter than Party B's...

### 🟠 Medium Risk (Review Recommended)
1. **Payment without clear deadline**: ...
2. **NDA period exceeds 2 years**: ...

### 🟑 Low Risk (Note)
1. **No termination clause**: ...
```

---

## Contract Types & Extracted Fields

| Contract Type | Core Fields |
|--------------|-------------|
| Purchase | Party A, Party B, items, amount, payment terms, delivery, quality standards, breach liability |
| Sales | Party A, Party B, items, amount, payment terms, delivery, quality warranty, breach liability |
| Service | Party A, Party B, services, amount, payment terms, service period, acceptance criteria, breach liability |
| Labor | Employer, Employee, position, salary, work location, work hours, contract term, social insurance |
| Lease | Landlord, Tenant, property, rent, deposit, term, renewal, maintenance responsibility |
| NDA | Party A, Party B, confidential content, period, scope, breach liability |

---

## Risk Checklist

### πŸ”΄ High Risk (Red Flags)
- Amount undefined or left blank
- Severely asymmetric breach liability (one-sided)
- Liquidated damages > 30% of actual loss
- Jurisdiction in distant/foreign court unfavorable to us
- No termination clause or extremely strict termination conditions
- Unlimited joint liability clause
- Standard terms not bolded or not explicitly disclosed

### 🟠 Medium Risk (Caution)
- Payment without clear deadline
- NDA period exceeds 2 years
- Non-compete scope too broad
- IP ownership ambiguous
- Force majeure clause missing or too loose
- Dispute resolution unfavorable for enforcement

### 🟑 Low Risk (Note)
- Notice method not specified
- Number of contract copies not agreed
- Attachment-body inconsistency risk
- Language version conflict not addressed

---

## Technical Details

### PDF Text Extraction

```python
from scripts.pdf_extractor import extract_text

# PyMuPDF primary, pdfplumber fallback
text = extract_text(pdf_path)
```

### AI Field Extraction

```python
from scripts.ai_extractor import extract_fields

fields = extract_fields(
    text=contract_text,
    contract_type="Purchase",
    api_key="sk-...",
    base_url="https://api.openai.com/v1",
    model="gpt-4o-mini",
)
```

### Risk Annotation

```python
from scripts.risk_analyzer import annotate_risks

risks = annotate_risks(
    text=contract_text,
    fields=extracted_fields,
)
```

### Report Generation

```python
from scripts.report_generator import generate_report

report = generate_report(
    contract_type=contract_type,
    summary=summary,
    key_terms=key_terms,
    risks=risks,
)
```

### Feishu Push

```python
from scripts.feishu_notifier import send_feishu_notification

notification = send_feishu_notification(
    open_id="ou_xxx",
    report_markdown=report_markdown,
    contract_type=contract_type,
    contract_name="Contract Name",
    risk_summary={"πŸ”΄": 1, "🟠": 2, "🟑": 0},
    top_risks=[{"level": "πŸ”΄", "item": "High risk item"}],
)

# Agent sends via feishu_im_user_message tool:
feishu_im_user_message(
    action="send",
    receive_id_type="open_id",
    receive_id=notification["open_id"],
    msg_type="interactive",
    content=notification["card_json"],
)
```

**Graceful degradation**: If Feishu authorization is not granted, only output local report β€” do not error out.

---

## Configuration

Users provide their own API key (OpenAI-compatible), supports:
- OpenAI API, Azure OpenAI, Claude (via compatible proxy), DeepSeek, any OpenAI-compatible API

---

## Pricing

| Tier | Price | Contracts/Mo | Features |
|------|-------|:------------:|----------|
| Free | Β₯0 | 3/mo | Basic risk annotation, text summary |
| Standard | Β₯29/mo | 30/mo | 6 contract types, Excel report |
| Pro | Β₯99/mo | 200/mo | Batch processing, risk comparison |
| Max | Β₯299/mo | Unlimited | API priority |

---

## FAQ

**Q: Are scanned PDFs supported?**
A: Basic support for text-based PDFs. Scanned documents need OCR β€” pair with miaoda-doc-parse skill.

**Q: Are English contracts supported?**
A: Yes, configure a model that supports English in base_url.

**Q: Is contract content stored?**
A: No β€” content is processed and deleted immediately, fully compliant with data privacy requirements.

**Q: How is API configured?**
A: User passes api_key at call time via the api_key parameter, supports OpenAI-compatible endpoints.

**Q: Can multiple contracts be processed in batch?**
A: Pro tier supports batch processing β€” upload multiple PDFs and generate comparison reports.

---

## Directory Structure

```
contract-risk-analyzer/
β”œβ”€β”€ SKILL.md
β”œβ”€β”€ README.md
β”œβ”€β”€ references/
β”‚   β”œβ”€β”€ contract_types.md
β”‚   └── risk_library.md
└── scripts/
    β”œβ”€β”€ main.py               # Entry: analyze_contract()
    β”œβ”€β”€ pdf_extractor.py      # PyMuPDF + pdfplumber text extraction
    β”œβ”€β”€ contract_type_detector.py  # Type detection
    β”œβ”€β”€ ai_extractor.py        # AI field extraction
    β”œβ”€β”€ risk_analyzer.py       # Risk annotation
    β”œβ”€β”€ report_generator.py    # Report generation
    β”œβ”€β”€ feishu_notifier.py     # Feishu card push
    └── test_contract_analyzer.py
```

---

## License

MIT

> For paid plans, visit [YK-Global.com](https://yk-global.com)

Files in this skill

  • README.md1.7 KB
  • SKILL.md8.4 KB
  • references/changelog.md1.5 KB
  • references/risk-checklist.md1.9 KB
  • scripts/__init__.py49 B
  • scripts/ai_extractor.py11.6 KB
  • scripts/contract_type_detector.py3.2 KB
  • scripts/feishu_notifier.py7.3 KB
  • scripts/main.py10.2 KB
  • scripts/pdf_extractor.py3 KB
  • scripts/report_generator.py6.7 KB
  • scripts/risk_analyzer.py10.1 KB
  • scripts/test_contract_analyzer.py10.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…