Skip to main content
skill CX Codex

contract-clause-analyzer — Claude Code skill: flag contract risks

The contract-clause-analyzer skill parses construction contract clauses, classifies them by type, flags risks, and extracts deadlines and payment amounts. Requires Python 3.

MIT 127 installs ★ 434 updated 2026-10-19

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill contract-clause-analyzer -a claude-code
Open on GitHub

What contract-clause-analyzer does

contract-clause-analyzer applies NLP to break down contract text into sections and analyze each clause. It categorizes clauses by type—payment, schedule, change orders, termination, indemnification, insurance, warranty, dispute resolution, liability, force majeure—and assigns a risk level (high, medium, low) based on keywords and phrasing. The skill then extracts obligations, key dates, and monetary amounts, returning a structured report with a risk summary.

Python 3 must be available in PATH for the skill to run. It processes contracts on macOS, Linux, and Windows. Useful for legal teams, project managers, and contractors who need to spot critical risks and obligations without reading every line.

What it helps with

  • surface high-risk clauses in a contract at a glance
  • extract payment terms, deadlines, and monetary limits
  • classify contract sections by legal type
  • identify obligations tied to specific dates
  • get a risk breakdown before negotiating

Example prompts for the agent

  • Analyze this construction contract and flag clauses with high risk
  • Extract all payment schedules and retainage terms from the agreement
  • Show me the key obligations and dates I need to track in this subcontractor agreement

How to install contract-clause-analyzer

1Skills CLI (Vercel)

npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill contract-clause-analyzer -a claude-code

2Manually: put the files in place

~/.claude/skills/contract-clause-analyzer/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/contract-clause-analyzer/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about contract-clause-analyzer

How do I install contract-clause-analyzer in Claude Code?

Run npx skills add datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction --skill contract-clause-analyzer -a claude-code, then check ~/.claude/skills/contract-clause-analyzer/SKILL.md.

What does contract-clause-analyzer do?

It parses construction contracts, categorizes clauses, assesses risk levels, and pulls out dates, amounts, and obligations for both parties.

What do I need to run this skill?

Python 3 in your PATH. The skill runs on macOS, Linux, and Windows.

Source text

SKILL.md · MIT
---
name: "contract-clause-analyzer"
description: "Analyze construction contract clauses. Identify risks, obligations, and key terms using NLP."
homepage: "https://datadrivenconstruction.io"
metadata: {"openclaw": {"emoji": "📋", "os": ["darwin", "linux", "win32"], "homepage": "https://datadrivenconstruction.io", "requires": {"bins": ["python3"]}}}
---
# Contract Clause Analyzer

## Business Case

### Problem Statement
Contract review is time-consuming and error-prone:
- Important clauses missed
- Risk provisions overlooked
- Inconsistent interpretation
- Long review cycles

### Solution
AI-assisted contract clause analysis that identifies key provisions, flags risks, and extracts critical terms.

## Technical Implementation

```python
import pandas as pd
from datetime import datetime, date
from typing import Dict, Any, List, Optional
from dataclasses import dataclass, field
from enum import Enum
import re


class ClauseType(Enum):
    SCOPE = "scope"
    PAYMENT = "payment"
    SCHEDULE = "schedule"
    CHANGE_ORDER = "change_order"
    TERMINATION = "termination"
    INDEMNIFICATION = "indemnification"
    INSURANCE = "insurance"
    WARRANTY = "warranty"
    DISPUTE = "dispute"
    LIABILITY = "liability"
    FORCE_MAJEURE = "force_majeure"
    SAFETY = "safety"
    COMPLIANCE = "compliance"
    OTHER = "other"


class RiskLevel(Enum):
    HIGH = "high"
    MEDIUM = "medium"
    LOW = "low"
    INFO = "info"


@dataclass
class ContractClause:
    clause_id: str
    section: str
    title: str
    text: str
    clause_type: ClauseType
    risk_level: RiskLevel
    key_terms: List[str] = field(default_factory=list)
    obligations: List[str] = field(default_factory=list)
    deadlines: List[str] = field(default_factory=list)
    amounts: List[str] = field(default_factory=list)
    notes: str = ""


@dataclass
class AnalysisResult:
    contract_name: str
    analyzed_date: datetime
    total_clauses: int
    clauses: List[ContractClause]
    risk_summary: Dict[str, int]
    key_dates: List[Dict[str, str]]
    key_amounts: List[Dict[str, str]]


class ContractClauseAnalyzer:
    """Analyze construction contract clauses."""

    RISK_KEYWORDS = {
        'high': ['indemnify', 'sole discretion', 'waive', 'forfeit', 'liquidated damages',
                 'consequential', 'unlimited liability', 'hold harmless', 'no limit'],
        'medium': ['shall', 'must', 'required', 'obligated', 'responsible', 'liable',
                   'penalty', 'default', 'breach'],
        'low': ['may', 'should', 'reasonable', 'mutual', 'consent', 'approval']
    }

    CLAUSE_PATTERNS = {
        ClauseType.PAYMENT: ['payment', 'invoice', 'retainage', 'progress payment'],
        ClauseType.SCHEDULE: ['schedule', 'completion date', 'milestone', 'time is of the essence'],
        ClauseType.CHANGE_ORDER: ['change order', 'modification', 'additional work', 'variation'],
        ClauseType.TERMINATION: ['termination', 'terminate', 'cancellation'],
        ClauseType.INDEMNIFICATION: ['indemnif', 'hold harmless', 'defend'],
        ClauseType.INSURANCE: ['insurance', 'coverage', 'policy', 'insured'],
        ClauseType.WARRANTY: ['warranty', 'guarantee', 'defect', 'workmanship'],
        ClauseType.DISPUTE: ['dispute', 'arbitration', 'mediation', 'litigation'],
        ClauseType.LIABILITY: ['liability', 'damages', 'limitation'],
        ClauseType.FORCE_MAJEURE: ['force majeure', 'act of god', 'unforeseen'],
    }

    def __init__(self):
        self.clauses: List[ContractClause] = []

    def analyze_text(self, contract_name: str, text: str) -> AnalysisResult:
        """Analyze contract text."""
        self.clauses = []

        # Split into sections/clauses
        sections = self._split_into_sections(text)

        for i, section in enumerate(sections):
            clause = self._analyze_clause(f"CL-{i+1:03d}", section)
            self.clauses.append(clause)

        # Generate summary
        risk_summary = {
            'high': sum(1 for c in self.clauses if c.risk_level == RiskLevel.HIGH),
            'medium': sum(1 for c in self.clauses if c.risk_level == RiskLevel.MEDIUM),
            'low': sum(1 for c in self.clauses if c.risk_level == RiskLevel.LOW)
        }

        key_dates = []
        key_amounts = []
        for clause in self.clauses:
            for d in clause.deadlines:
                key_dates.append({'clause': clause.clause_id, 'date': d})
            for a in clause.amounts:
                key_amounts.append({'clause': clause.clause_id, 'amount': a})

        return AnalysisResult(
            contract_name=contract_name,
            analyzed_date=datetime.now(),
            total_clauses=len(self.clauses),
            clauses=self.clauses,
            risk_summary=risk_summary,
            key_dates=key_dates,
            key_amounts=key_amounts
        )

    def _split_into_sections(self, text: str) -> List[Dict[str, str]]:
        """Split contract into sections."""
        sections = []
        # Simple split by numbered sections
        pattern = r'(\d+\.[\d\.]*\s+[A-Z][^\.]+)'
        parts = re.split(pattern, text)

        current_title = ""
        for i, part in enumerate(parts):
            if re.match(r'\d+\.[\d\.]*\s+[A-Z]', part):
                current_title = part.strip()
            elif part.strip() and current_title:
                sections.append({
                    'title': current_title,
                    'text': part.strip()
                })
                current_title = ""

        # If no sections found, treat whole text as one
        if not sections and text.strip():
            sections.append({'title': 'Contract Text', 'text': text.strip()})

        return sections

    def _analyze_clause(self, clause_id: str, section: Dict[str, str]) -> ContractClause:
        """Analyze single clause."""
        text = section.get('text', '')
        title = section.get('title', '')
        text_lower = text.lower()

        # Determine clause type
        clause_type = self._determine_type(text_lower)

        # Assess risk level
        risk_level = self._assess_risk(text_lower)

        # Extract key terms
        key_terms = self._extract_key_terms(text)

        # Extract obligations
        obligations = self._extract_obligations(text)

        # Extract dates
        deadlines = self._extract_dates(text)

        # Extract amounts
        amounts = self._extract_amounts(text)

        return ContractClause(
            clause_id=clause_id,
            section=clause_id,
            title=title,
            text=text[:500] + "..." if len(text) > 500 else text,
            clause_type=clause_type,
            risk_level=risk_level,
            key_terms=key_terms,
            obligations=obligations,
            deadlines=deadlines,
            amounts=amounts
        )

    def _determine_type(self, text: str) -> ClauseType:
        """Determine clause type from content."""
        for clause_type, keywords in self.CLAUSE_PATTERNS.items():
            if any(kw in text for kw in keywords):
                return clause_type
        return ClauseType.OTHER

    def _assess_risk(self, text: str) -> RiskLevel:
        """Assess risk level of clause."""
        high_count = sum(1 for kw in self.RISK_KEYWORDS['high'] if kw in text)
        medium_count = sum(1 for kw in self.RISK_KEYWORDS['medium'] if kw in text)

        if high_count >= 2:
            return RiskLevel.HIGH
        elif high_count >= 1 or medium_count >= 3:
            return RiskLevel.MEDIUM
        elif medium_count >= 1:
            return RiskLevel.LOW
        return RiskLevel.INFO

    def _extract_key_terms(self, text: str) -> List[str]:
        """Extract key defined terms."""
        # Look for quoted terms or capitalized multi-word phrases
        patterns = [
            r'"([^"]+)"',
            r"'([^']+)'",
            r'\b([A-Z][a-z]+(?:\s+[A-Z][a-z]+)+)\b'
        ]
        terms = []
        for pattern in patterns:
            matches = re.findall(pattern, text)
            terms.extend(matches[:5])
        return list(set(terms))[:10]

    def _extract_obligations(self, text: str) -> List[str]:
        """Extract obligation statements."""
        patterns = [
            r'(?:contractor|owner|party)\s+shall\s+([^\.]+)',
            r'(?:contractor|owner|party)\s+must\s+([^\.]+)',
            r'(?:contractor|owner|party)\s+is\s+(?:required|obligated)\s+to\s+([^\.]+)'
        ]
        obligations = []
        for pattern in patterns:
            matches = re.findall(pattern, text, re.IGNORECASE)
            obligations.extend(matches[:3])
        return obligations[:5]

    def _extract_dates(self, text: str) -> List[str]:
        """Extract date references."""
        patterns = [
            r'\b\d{1,2}/\d{1,2}/\d{2,4}\b',
            r'\b(?:January|February|March|April|May|June|July|August|September|October|November|December)\s+\d{1,2},?\s+\d{4}\b',
            r'\b\d+\s+(?:calendar|working|business)\s+days\b',
            r'\bwithin\s+\d+\s+days\b'
        ]
        dates = []
        for pattern in patterns:
            matches = re.findall(pattern, text, re.IGNORECASE)
            dates.extend(matches)
        return dates[:5]

    def _extract_amounts(self, text: str) -> List[str]:
        """Extract monetary amounts."""
        patterns = [
            r'\$[\d,]+(?:\.\d{2})?',
            r'\b\d+(?:,\d{3})*(?:\.\d{2})?\s*(?:dollars|USD)\b',
            r'\b\d+(?:\.\d+)?%\b'
        ]
        amounts = []
        for pattern in patterns:
            matches = re.findall(pattern, text, re.IGNORECASE)
            amounts.extend(matches)
        return amounts[:5]

    def get_high_risk_clauses(self) -> List[ContractClause]:
        """Get all high-risk clauses."""
        return [c for c in self.clauses if c.risk_level == RiskLevel.HIGH]

    def export_analysis(self, result: AnalysisResult, output_path: str):
        """Export analysis to Excel."""
        with pd.ExcelWriter(output_path, engine='openpyxl') as writer:
            # Summary
            summary_df = pd.DataFrame([{
                'Contract': result.contract_name,
                'Analyzed': result.analyzed_date,
                'Total Clauses': result.total_clauses,
                'High Risk': result.risk_summary['high'],
                'Medium Risk': result.risk_summary['medium'],
                'Low Risk': result.risk_summary['low']
            }])
            summary_df.to_excel(writer, sheet_name='Summary', index=False)

            # Clauses
            clause_data = [{
                'ID': c.clause_id,
                'Title': c.title[:50],
                'Type': c.clause_type.value,
                'Risk': c.risk_level.value,
                'Key Terms': ', '.join(c.key_terms[:3]),
                'Obligations': len(c.obligations),
                'Dates': ', '.join(c.deadlines[:2]),
                'Amounts': ', '.join(c.amounts[:2])
            } for c in result.clauses]
            pd.DataFrame(clause_data).to_excel(writer, sheet_name='Clauses', index=False)

        return output_path
```

## Quick Start

```python
analyzer = ContractClauseAnalyzer()

# Analyze contract text
contract_text = open("contract.txt").read()
result = analyzer.analyze_text("Construction Contract", contract_text)

print(f"High risk clauses: {result.risk_summary['high']}")

# Get risky clauses
high_risk = analyzer.get_high_risk_clauses()
for clause in high_risk:
    print(f"{clause.clause_id}: {clause.title}")
```

## Resources
- **DDC Book**: Chapter 5 - Contract Management

© datadrivenconstruction · MIT · datadrivenconstruction/DDC_Skills_for_AI_Agents_in_Construction

Similar skills

All skills for AI and ML →
Sentiment Analyzer — Emotions, Confidence & Key Phrases axel-belfort Sentiment Analyzer — Emotions, Confidence & Key Phrases is an MCP server for Claude Code that analyzes sentiment, emotions, confidence, and key phrases in text. CX Codex +1 4,789installs contract-analyzer OneWave-AI contract-analyzer is a Claude Code skill that extracts key contract terms, flags risks and unusual clauses, and compares provisions with industry standards. It also suggests negotiation points. CX Codex +1 438installs contract-writer Jake Schincariol The contract-writer skill for Claude Code turns call notes and a proposal into a services agreement, then drafts an email to send it. After approval, it creates a PDF and records a returned signed copy as a won deal. CX Codex +1 ★ 83repo stars risk-assessment staskh risk-assessment calculates risk metrics for stocks and positions: volatility, beta, Value at Risk, and maximum drawdown. Use it to assess position risk and determine sizing. CX Codex +1 113installs downtrend-duration-analyzer tradermonty downtrend-duration-analyzer — a skill for Claude Code and five other platforms that processes historical price data to find peak-to-trough periods and outputs interactive HTML histograms broken down by sector and market cap tier. CX Codex +1 3,400installs contract-delivery-kickoff gasserane contract-delivery-kickoff turns a signed supplier contract into a first-session pack: a workbook that totals days against the contracted ceiling, an internal brief, a supplier agenda and a note template. CX Codex +1 134installs

From the same set156

The whole set →
cost-prediction cost-prediction forecasts construction project budgets using historical data with Linear Regression, KNN, and Random Forest models. Requires Python 3 and scikit-learn to train on your project dataset. CX Codex +1 128installs docx-construction docx-construction generates construction Word documents such as subcontracts, bid proposals, daily jobsite logs, and transmittal letters using dynamic Python templates. CX Codex +1 128installs cash-flow-forecaster cash-flow-forecaster forecasts project cash flows using cost items and schedule data, producing payment timelines and S-curves. CX Codex +1 127installs submittal-tracker submittal-tracker tracks construction submittals across reviews, revisions, and approval stages. Keeps document logs organized and flags overdue items. CX Codex +1 127installs meeting-minutes-generator The meeting-minutes-generator skill generates structured meeting minutes for construction projects, tracking decisions and action items. Requires Python 3. CX Codex +1 126installs bim-visual-programming-automation bim-visual-programming-automation automates BIM tasks with Dynamo Python nodes and Revit API routines. Extracts element quantities, calculates take-offs, and batch updates parameters. CX Codex +1 126installs pdf-construction pdf-construction extracts data from RFI forms, splits drawing sets by sheet, parses CSI specifications, and builds submittal packages from construction PDFs. CX Codex +1 126installs punch-list-manager punch-list-manager is a Claude Code skill that tracks construction deficiencies from site walks through final acceptance, including assignments, deadlines, photos, and verification. CX Codex +1 125installs

Project sponsors

Companies that keep this analytics open