返回 Skill 列表
extension
分类: 其它需要 API Key

Contract Risk Analyzer · 合同风险智能审查

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

person作者: user_26bdbd50hubcommunity

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

# 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

# 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

from scripts.pdf_extractor import extract_text

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

AI Field Extraction

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

from scripts.risk_analyzer import annotate_risks

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

Report Generation

from scripts.report_generator import generate_report

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

Feishu Push

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