Claude review

From yuch85/superdoc-redlines · View interactive version

Claude review is an AI agent skill from the GitHub repository yuch85/superdoc-redlines. Agentic contract review using superdoc-redlines. Spawns parallel sub-agents for comprehensive document review with tracked changes.

How to use this skill

Skill file

/claude-review

Agentic contract review skill that uses the superdoc-redlines library to review and amend legal documents with tracked changes. For large documents (>50K tokens), spawns parallel sub-agents for comprehensive coverage.

Usage

/claude-review [--single-agent|--multi-agent] <document> <instructions>

Arguments:

Examples:

/claude-review contract.docx Convert from UK to Singapore law
/claude-review --multi-agent contract.docx Convert from UK to Singapore law
/claude-review --single-agent large-contract.docx Review warranties only
/claude-review ./contracts/bta.docx Review warranties and update statutory references
/claude-review "Business Transfer Agreement.docx" Adapt for Singapore jurisdiction, update all UK statutes

How It Works

This skill reads $ARGUMENTS for the document path and instructions.

Argument Parsing

Parse arguments as follows:

  1. Check for optional workflow flags: --single-agent or --multi-agent (if present, remove from arguments)
  2. First remaining argument: document path (may be quoted if contains spaces)
  3. Remaining arguments: review instructions (joined as a single string)

If arguments are missing, prompt the user for:

  1. Document path
  2. Review instructions

Workflow Override:

Workflow Selection

Priority 1 - User Override (if specified):

Priority 2 - Automatic Selection (if no flag):

Based on document size, choose the appropriate workflow:

| Document Size | Workflow | Reason |

|---------------|----------|--------|

| < 50K tokens | Single-agent | Direct review per CONTRACT-REVIEW-SKILL.md |

| >= 50K tokens | Multi-agent | Orchestrator + sub-agents per CONTRACT-REVIEW-AGENTIC-SKILL.md |

CRITICAL: User-specified workflow flags override automatic selection.

Step-by-Step Procedure

Step 1: Validate Document

cd /home/tyc/ross-ide-contract/superdoc-redlines
node superdoc-redline.mjs read --input "<document>" --stats-only

Verify the document exists and get statistics:

Step 2: Extract Document Structure

node superdoc-redline.mjs extract --input "<document>" --output "<document>-ir.json"

This creates the block ID mapping needed for edits.

Step 3: Choose Workflow

CRITICAL: If user specified --single-agent or --multi-agent flag, use that workflow regardless of document size.

Otherwise, use automatic selection:

If estimatedTokens < 50,000: Use single-agent workflow

If estimatedTokens >= 50,000: Use multi-agent workflow

Step 4: Discovery Pass

Read all chunks to build the Context Document:

# Read each chunk until hasMore: false
node superdoc-redline.mjs read --input "<document>" --chunk 0 --max-tokens 10000
node superdoc-redline.mjs read --input "<document>" --chunk 1 --max-tokens 10000
# ... continue

Build Context Document with:

Step 5: Amendment Pass

Single-Agent Path

Process each chunk with full Context Document, drafting exact amendments.

Multi-Agent Path
  1. Plan sub-agent assignments (non-overlapping block ranges)
  2. Spawn sub-agents in parallel using Task tool:
Task({
  subagent_type: "general-purpose",
  description: "Review [section] blocks b[start]-b[end]",
  prompt: "[Sub-agent prompt with Context Document and block range]"
})
  1. Each sub-agent produces edits-[section].json
  2. Merge all edit files:
node superdoc-redline.mjs merge \
  edits-*.json \
  -o merged-edits.json \
  -c combine \
  -v "<document>"

Step 6: Validate and Apply

# Validate
node superdoc-redline.mjs validate --input "<document>" --edits "<edits-file>"

# Apply with track changes
node superdoc-redline.mjs apply \
  --input "<document>" \
  --output "<document>-amended.docx" \
  --edits "<edits-file>" \
  --author-name "AI Legal Counsel"

Step 7: Report Results

Report to user:

Reference Documentation

The detailed methodology is documented in:

Sub-Agent Prompt Template

When spawning sub-agents for multi-agent workflow, use this template:

You are a contract review sub-agent. Review your assigned section and produce an edits JSON file.

## Assignment
- Block Range: b[START] to b[END]
- Section: [SECTION_NAME]
- Output: edits-[section].json

## Review Instructions
[USER_INSTRUCTIONS]

## Context Document
[FULL_CONTEXT_DOCUMENT]

## Procedure
1. Read your assigned chunks:
   ```bash
   cd /home/tyc/ross-ide-contract/superdoc-redlines
   node superdoc-redline.mjs read --input "[DOCUMENT]" --chunk [N] --max-tokens 10000
   ```

2. For each block in your range, assess amendments needed based on:
   - The review instructions
   - Defined terms changes from Context Document
   - Provisions requiring deletion or replacement

3. Draft EXACT replacement text (not vague directions)

4. Create edits file:
   ```json
   {
     "version": "0.2.0",
     "agent": "[AGENT_ID]",
     "blockRange": { "start": "b[START]", "end": "b[END]" },
     "edits": [...]
   }
   ```

5. Save to: edits-[section].json

## Rules
- ONLY edit blocks in your assigned range
- Draft exact replacement text
- Use diff: true for surgical edits, diff: false for rewrites
- Cite Singapore statutes with year (e.g., "Companies Act 1967")

Working Directory

All commands should be run from:

/home/tyc/ross-ide-contract/superdoc-redlines

Output Files

| File | Purpose |

|------|---------|

| <document>-ir.json | Extracted document structure with block IDs |

| <document>-context.md | Context Document (for multi-agent) |

| edits-*.json | Edit files from each agent |

| merged-edits.json | Combined edits (multi-agent only) |

| <document>-amended.docx | Final output with tracked changes |

Error Handling

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.