Upload a contract PDF to receive AI-powered text extraction, contract type detection, and a detailed risk analysis report with severity grading and recommend...
# Contract Intelligence Review **Slug:** contract-intelligence-review **Platform:** ClawHub (clawhub.ai) **Category:** Legal & Compliance / Productivity **Tags:** contract, risk, legal, PDF, AI, analysis, contract-review --- ## What This Skill Does Upload any contract PDF and get an instant AI-powered risk analysis report. Automatically detects contract type (Labor, Procurement, Sales, Lease, NDA), extracts key terms, and generates a structured risk list graded by severity (HIGH / MEDIUM / LOW). Supports both Chinese and English contracts. Ideal for procurement teams, HR departments, freelancers, and small businesses needing quick contract reviews without hiring a lawyer. --- ## Workflow ### Step 1 — Receive Contract File Download the PDF: - Feishu attachment → use `feishu_im_bot_image` or `feishu_im_user_fetch_resource` with `type=file` - Local path → use directly - URL → use `web_crawl` or fetch Store at `/tmp/contracts/<uuid>.pdf`. ### Step 2 — Extract Text from PDF Try in order: 1. **PyMuPDF (fitz)** — best for text-based PDFs 2. **pdfplumber** — good for tables 3. **OCR (pytesseract)** — for scanned/image PDFs (with `chi_sim+eng` language packs) If text extraction yields < 50 characters, offer OCR processing. ### Step 3 — Detect Contract Type Classify from extracted text: - Labor Contract - Procurement Contract - Sales Contract - Lease Contract - NDA / Confidentiality Agreement - Other Detect language: Chinese / English / Bilingual. ### Step 4 — AI Risk Analysis Send extracted text to AI model. Returns structured JSON: - Summary (200 words or less) - Key terms table (PRO tier) - Risk list with level (HIGH/MEDIUM/LOW), category, description, clause reference, recommendation - Overall risk score (1-10) ### Step 5 — Render Report Deliver a formatted markdown report: - Summary - Key terms table (PRO) - Risk list by severity level - Statistics - Legal disclaimer ### Step 6 — Export (PRO) CSV export available for Standard and above tiers. --- ## Tiered Features | Feature | FREE | PRO | |---------|------|-----| | Contract types | Other only | All 6 types | | Summary + Risk list | ✅ | ✅ | | Key terms table | ❌ | ✅ | | Excel/CSV export | ❌ | ✅ | | Batch processing | ❌ | ✅ | | Risk comparison | ❌ | ✅ | --- ## Pricing **Per-call billing (no monthly fee):** | Tier | Price per Call | |------|---------------| | FREE | $0.00 USDT | | PRO | $0.01 USDT | Each contract analysis = one billable call. --- ## Billing This skill uses **SkillPay** (skillpay.me) for per-call billing. **Fee:** $0.0100 USDT per call (all paid tiers) **External API:** `https://skillpay.me/api/v1/billing` **Data transmitted:** User identifier (`FEISHU_USER_ID` environment variable) Billing occurs at the start of each contract analysis. If balance is insufficient, the tool returns a `payment_url` where the user can recharge. --- ## Required Environment Variables | Variable | Description | |----------|-------------| | `FEISHU_USER_ID` | Feishu user open_id for billing identification | | `OPENAI_API_KEY` | AI model API key (OpenAI, MiniMax, or OpenAI-compatible endpoint) | | `OPENAI_API_BASE` | Base URL for AI API (optional, defaults to MiniMax endpoint) | | `SKILL_BILLING_API_KEY` | Builder API Key from skillpay.me (required for paid calls) | | `SKILL_BILLING_SKILL_ID` | Skill slug on SkillPay (defaults to `contract-intelligence-review`) | --- ## Error Handling | Error | Handling | |-------|----------| | PDF yields < 50 chars | Offer OCR; if OCR also fails, report failure and suggest a text-based PDF | | AI analysis fails | Return error; suggest retry | | Insufficient balance | Return `payment_url` for recharge | | Network error on billing | Allow call through in dev mode (no charge) | | Unsupported file type | Inform user only PDF is supported | --- ## Technical Stack - **PDF Text:** PyMuPDF (fitz) + pdfplumber - **OCR:** pytesseract + pdf2image (language packs: `chi_sim+eng`) - **AI Analysis:** OpenAI-compatible API (MiniMax / OpenAI / custom endpoint) - **Report Export:** CSV module (Excel-compatible) - **Billing:** SkillPay API (skillpay.me) --- ## Output Example ``` ## Contract Risk Analysis Report **Contract Type:** Labor Contract **Language:** Chinese **Overall Risk Score:** 6/10 — Medium Risk **Text Extraction:** Direct extraction --- ### Summary [200-word summary in contract language] --- ### Key Terms | Term | Content | |------|---------| | Parties | Employer / Employee | | Contract Value | Not specified | | Payment Terms | Monthly salary, 15th of each month | ... ### Risk Report #### HIGH Risk (2 items) 1. **No overtime pay rate specified** - Category: liability - Clause: Article 4 - Description: ... - Recommendation: ... #### MEDIUM Risk (1 item) ... --- **Disclaimer:** This report is for informational purposes only and does not constitute legal advice. ```
don't have the plugin yet? install it then click "run inline in claude" again.