Contract Analyzer — Contract Analysis, Drafting, and Review Pipeline
An agent team collaborates to perform clause analysis, drafting/revision, risk assessment, comparison review, and comprehensive opinion.
Warning: This pipeline does not replace professional legal advice.
Execution Mode
Agent Team — 5 agents communicate directly via SendMessage and cross-verify each other's work.
Agent Composition
| Agent |
File |
Role |
Type |
| clause-analyst |
.claude/agents/clause-analyst.md |
Clause structure, interpretation, essential clause verification |
general-purpose |
| clause-drafter |
.claude/agents/clause-drafter.md |
Clause drafting, amendment proposals |
general-purpose |
| risk-assessor |
.claude/agents/risk-assessor.md |
Legal and business risk assessment |
general-purpose |
| comparison-reviewer |
.claude/agents/comparison-reviewer.md |
Standard/previous version comparison, negotiation points |
general-purpose |
| contract-coordinator |
.claude/agents/contract-coordinator.md |
Comprehensive opinion, consistency verification |
general-purpose |
Workflow
Phase 1: Preparation (Performed Directly by Orchestrator)
- Extract from user input:
- Contract Text: The contract to analyze (file or text)
- Contract Type: Sale/Service/Lease/NDA/Employment/License, etc.
- Party Position: User's position as Party A or Party B
- Special Concerns (optional): Specific clauses, risks, comparison targets
- Comparison Target (optional): Standard template, previous version
- Create the
_workspace/ directory in the project root
- Organize the input and save to
_workspace/00_input.md
- If contract text is available, copy to
_workspace/original_contract.md
- Determine the execution mode based on the requested scope
Phase 2: Team Assembly and Execution
| Order |
Task |
Owner |
Dependencies |
Output |
| 1 |
Clause Analysis |
clause-analyst |
None |
_workspace/01_clause_analysis.md |
| 2a |
Risk Assessment |
risk-assessor |
Task 1 |
_workspace/03_risk_assessment.md |
| 2b |
Comparison Review |
comparison-reviewer |
Task 1 |
_workspace/04_comparison_report.md |
| 3 |
Clause Drafting/Revision |
clause-drafter |
Tasks 1, 2a, 2b |
_workspace/02_draft_clauses.md |
| 4 |
Comprehensive Opinion |
contract-coordinator |
Tasks 1, 2a, 2b, 3 |
_workspace/05_final_opinion.md |
Tasks 2a (Risk) and 2b (Comparison) are executed in parallel.
Inter-agent Communication Flow:
- clause-analyst completes -> Delivers risk clauses to risk-assessor, structural info to comparison-reviewer
- risk-assessor + comparison-reviewer complete -> Deliver modification requirements to clause-drafter
- clause-drafter completes -> contract-coordinator comprehensively verifies all deliverables
- contract-coordinator: If Red inconsistencies found, requests revision from relevant agent -> rework -> re-verify (up to 2 times)
Phase 3: Integration and Final Deliverables
- Review all files in
_workspace/
- Verify that all Red required actions in the comprehensive opinion are reflected in the amendments
- Report the final summary to the user:
- Clause Analysis Report —
01_clause_analysis.md
- Amendments —
02_draft_clauses.md
- Risk Assessment —
03_risk_assessment.md
- Comparison Review —
04_comparison_report.md
- Comprehensive Opinion —
05_final_opinion.md
Modes by Request Scope
| User Request Pattern |
Execution Mode |
Agents Deployed |
| "Review this contract", "Full analysis" |
Full Analysis |
All 5 agents |
| "Draft a contract", "Write a contract" |
Drafting Mode |
clause-drafter + risk-assessor + contract-coordinator |
| "Just assess the risk" |
Risk Mode |
clause-analyst + risk-assessor |
| "Compare with previous version" |
Comparison Mode |
clause-analyst + comparison-reviewer |
| "Modify this clause" |
Amendment Mode |
clause-drafter only |
Using Existing Files: If comparison targets (standard, previous version) are provided, comparison-reviewer utilizes them.
Data Transfer Protocol
| Strategy |
Method |
Purpose |
| File-based |
_workspace/ directory |
Storing and sharing main deliverables |
| Message-based |
SendMessage |
Real-time delivery of key information, revision requests |
| Web Browsing |
WebSearch/WebFetch |
Standard templates, related laws, case law research |
Error Handling
| Error Type |
Strategy |
| No contract text |
Switch to drafting mode based on standard template for the contract type |
| Party position unclear |
Analyze from both Party A and Party B perspectives, request position confirmation from user |
| Governing law unclear |
Default analysis based on domestic law, note possibility of other applicable laws |
| Web search failure |
Work based on general legal knowledge, note "latest case law unverified" |
| Agent failure |
Retry once -> if failed, proceed without that deliverable, note omission in report |
Test Scenarios
Normal Flow
Prompt: "Review this software development service contract. We are Party B (the contractor)." + contract file provided
Expected Results:
- Clause Analysis: Full structure map, clause-by-clause legal and practical analysis, essential clause check
- Risk Assessment: Risks from Party B's perspective, disadvantageous clause identification, mitigation strategies
- Comparison Review: Differences from software development standard contract
- Amendments: Revised wording for disadvantageous clauses, additional protective clauses
- Comprehensive Opinion: Signing feasibility, required modification list, checklist
New Drafting Flow
Prompt: "Draft a freelance design service contract. I am Party A."
Expected Results:
- Drafting Mode: clause-drafter creates standard service contract draft
- risk-assessor checks risks of the drafted document
- contract-coordinator performs final verification
Error Flow
Prompt: "Check if this contract is okay" + English NDA provided
Expected Results:
- English NDA analysis, key terms annotated in both languages
- Analysis based on domestic law, with explanation of common law practice differences
- Governing law verification recommendation included in comprehensive opinion
Agent Extension Skills
| Agent |
Extension Skill |
Purpose |
| risk-assessor, clause-analyst |
clause-risk-database |
Risk clause pattern DB, risk scoring algorithm |
| clause-drafter, comparison-reviewer |
negotiation-playbook |
Negotiation strategy framework, amendment wording templates |
1---2name: contract-analyzer3description: A pipeline where an agent team performs contract analysis, drafting, review, and risk assessment. Use this skill for contexts such as 'review the contract', 'contract analysis', 'draft a contract', 'contract risk assessment', 'contract review', 'clause modification', 'contract comparison', 'NDA review', 'service agreement', 'lease agreement', 'employment contract', 'license agreement', and other contract management tasks. Note: Providing legal counsel, conducting litigation, notarization, and court document preparation are outside the scope of this skill.4---56# Contract Analyzer — Contract Analysis, Drafting, and Review Pipeline78An agent team collaborates to perform clause analysis, drafting/revision, risk assessment, comparison review, and comprehensive opinion.910> Warning: This pipeline does not replace professional legal advice.1112## Execution Mode1314**Agent Team** — 5 agents communicate directly via SendMessage and cross-verify each other's work.1516## Agent Composition1718| Agent | File | Role | Type |19|-------|------|------|------|20| clause-analyst | `.claude/agents/clause-analyst.md` | Clause structure, interpretation, essential clause verification | general-purpose |21| clause-drafter | `.claude/agents/clause-drafter.md` | Clause drafting, amendment proposals | general-purpose |22| risk-assessor | `.claude/agents/risk-assessor.md` | Legal and business risk assessment | general-purpose |23| comparison-reviewer | `.claude/agents/comparison-reviewer.md` | Standard/previous version comparison, negotiation points | general-purpose |24| contract-coordinator | `.claude/agents/contract-coordinator.md` | Comprehensive opinion, consistency verification | general-purpose |2526## Workflow2728### Phase 1: Preparation (Performed Directly by Orchestrator)29301. Extract from user input:31 - **Contract Text**: The contract to analyze (file or text)32 - **Contract Type**: Sale/Service/Lease/NDA/Employment/License, etc.33 - **Party Position**: User's position as Party A or Party B34 - **Special Concerns** (optional): Specific clauses, risks, comparison targets35 - **Comparison Target** (optional): Standard template, previous version362. Create the `_workspace/` directory in the project root373. Organize the input and save to `_workspace/00_input.md`384. If contract text is available, copy to `_workspace/original_contract.md`395. Determine the **execution mode** based on the requested scope4041### Phase 2: Team Assembly and Execution4243| Order | Task | Owner | Dependencies | Output |44|-------|------|-------|-------------|--------|45| 1 | Clause Analysis | clause-analyst | None | `_workspace/01_clause_analysis.md` |46| 2a | Risk Assessment | risk-assessor | Task 1 | `_workspace/03_risk_assessment.md` |47| 2b | Comparison Review | comparison-reviewer | Task 1 | `_workspace/04_comparison_report.md` |48| 3 | Clause Drafting/Revision | clause-drafter | Tasks 1, 2a, 2b | `_workspace/02_draft_clauses.md` |49| 4 | Comprehensive Opinion | contract-coordinator | Tasks 1, 2a, 2b, 3 | `_workspace/05_final_opinion.md` |5051Tasks 2a (Risk) and 2b (Comparison) are executed **in parallel**.5253**Inter-agent Communication Flow:**54- clause-analyst completes -> Delivers risk clauses to risk-assessor, structural info to comparison-reviewer55- risk-assessor + comparison-reviewer complete -> Deliver modification requirements to clause-drafter56- clause-drafter completes -> contract-coordinator comprehensively verifies all deliverables57- contract-coordinator: If Red inconsistencies found, requests revision from relevant agent -> rework -> re-verify (up to 2 times)5859### Phase 3: Integration and Final Deliverables60611. Review all files in `_workspace/`622. Verify that all Red required actions in the comprehensive opinion are reflected in the amendments633. Report the final summary to the user:64 - Clause Analysis Report — `01_clause_analysis.md`65 - Amendments — `02_draft_clauses.md`66 - Risk Assessment — `03_risk_assessment.md`67 - Comparison Review — `04_comparison_report.md`68 - Comprehensive Opinion — `05_final_opinion.md`6970## Modes by Request Scope7172| User Request Pattern | Execution Mode | Agents Deployed |73|---------------------|----------------|-----------------|74| "Review this contract", "Full analysis" | **Full Analysis** | All 5 agents |75| "Draft a contract", "Write a contract" | **Drafting Mode** | clause-drafter + risk-assessor + contract-coordinator |76| "Just assess the risk" | **Risk Mode** | clause-analyst + risk-assessor |77| "Compare with previous version" | **Comparison Mode** | clause-analyst + comparison-reviewer |78| "Modify this clause" | **Amendment Mode** | clause-drafter only |7980**Using Existing Files**: If comparison targets (standard, previous version) are provided, comparison-reviewer utilizes them.8182## Data Transfer Protocol8384| Strategy | Method | Purpose |85|----------|--------|---------|86| File-based | `_workspace/` directory | Storing and sharing main deliverables |87| Message-based | SendMessage | Real-time delivery of key information, revision requests |88| Web Browsing | WebSearch/WebFetch | Standard templates, related laws, case law research |8990## Error Handling9192| Error Type | Strategy |93|-----------|----------|94| No contract text | Switch to drafting mode based on standard template for the contract type |95| Party position unclear | Analyze from both Party A and Party B perspectives, request position confirmation from user |96| Governing law unclear | Default analysis based on domestic law, note possibility of other applicable laws |97| Web search failure | Work based on general legal knowledge, note "latest case law unverified" |98| Agent failure | Retry once -> if failed, proceed without that deliverable, note omission in report |99100## Test Scenarios101102### Normal Flow103**Prompt**: "Review this software development service contract. We are Party B (the contractor)." + contract file provided104**Expected Results**:105- Clause Analysis: Full structure map, clause-by-clause legal and practical analysis, essential clause check106- Risk Assessment: Risks from Party B's perspective, disadvantageous clause identification, mitigation strategies107- Comparison Review: Differences from software development standard contract108- Amendments: Revised wording for disadvantageous clauses, additional protective clauses109- Comprehensive Opinion: Signing feasibility, required modification list, checklist110111### New Drafting Flow112**Prompt**: "Draft a freelance design service contract. I am Party A."113**Expected Results**:114- Drafting Mode: clause-drafter creates standard service contract draft115- risk-assessor checks risks of the drafted document116- contract-coordinator performs final verification117118### Error Flow119**Prompt**: "Check if this contract is okay" + English NDA provided120**Expected Results**:121- English NDA analysis, key terms annotated in both languages122- Analysis based on domestic law, with explanation of common law practice differences123- Governing law verification recommendation included in comprehensive opinion124125## Agent Extension Skills126127| Agent | Extension Skill | Purpose |128|-------|----------------|---------|129| risk-assessor, clause-analyst | `clause-risk-database` | Risk clause pattern DB, risk scoring algorithm |130| clause-drafter, comparison-reviewer | `negotiation-playbook` | Negotiation strategy framework, amendment wording templates |