Back to skills
SKILL.md
Contract Risk Analyzer
ASecurityContract 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
Works with
Security analysis
100/100Pro scans all 13 files and shows the line behind each finding
npx -y skills add CSlawyer1985/legal-skillhub --skill contract-risk-analyzer --agent claude-codeAre you the author of Contract Risk Analyzer?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/cslawyer1985-contract-risk-analyzer)---
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.md
- SKILL.md
- references/changelog.md
- references/risk-checklist.md
- scripts/__init__.py
- scripts/ai_extractor.py
- scripts/contract_type_detector.py
- scripts/feishu_notifier.py
- scripts/main.py
- scripts/pdf_extractor.py
- scripts/report_generator.py
- scripts/risk_analyzer.py
- scripts/test_contract_analyzer.py
Attribution
Comments
Loading commentsβ¦