Inventories a folder of legal documents and merges per-document extraction JSONs into one cited comparison matrix, flagging conflicts, missing citations, LOW-confidence and NOT FOUND cells. Use when reviewing many contracts, NDAs, leases or employment agreements side by side, or when parallel agents have produced extraction files that must be reconciled.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Tabular Document Review?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/borghei-tabular-document-review)
---
name: tabular-document-review
description: >
Inventories a folder of legal documents and merges per-document extraction JSONs into one cited comparison matrix, flagging conflicts, missing citations, LOW-confidence and NOT FOUND cells. Use when reviewing many contracts, NDAs, leases or employment agreements side by side, or when parallel agents have produced extraction files that must be reconciled.
license: MIT + Commons Clause
metadata:
version: 1.0.0
author: The Glass Room
category: legal
domain: document-review
updated: 2026-04-10
tags: [document-review, extraction, comparison-matrix, contracts, bulk-review]
---
> **⚠️ EXPERIMENTAL** — This skill is provided for educational and informational purposes only. It does NOT constitute legal advice. All responsibility for usage rests with the user. Consult qualified legal professionals before acting on any output.
# Tabular Document Review Skill
## Overview
Production-ready toolkit for extracting structured data from multiple legal documents into a comparison matrix with citations. Supports user-defined extraction columns, parallel processing with up to 10 agents, confidence scoring, and output in markdown table or structured JSON. Designed for legal teams performing bulk contract review, NDA comparison, employment agreement analysis, and lease review.
## Table of Contents
- [Tools](#tools)
- [Reference Guides](#reference-guides)
- [Workflows](#workflows)
- [Extraction Scenarios](#extraction-scenarios)
- [Troubleshooting](#troubleshooting)
- [Success Criteria](#success-criteria)
- [Scope & Limitations](#scope--limitations)
- [Anti-Patterns](#anti-patterns)
- [Exit codes](#exit-codes)
- [Tool Reference](#tool-reference)
## Clarify First
Before the review, settle the inputs below. When one is missing or vague and would change the result, ask about it; when it wouldn't, use a sensible default and say which one you used.
- **The extraction columns:** define exactly what each cell holds; a vague "Date" matches dozens of dates, while "Effective Date" with guidance does not.
- **Document set location and formats:** drives discovery and how many parallel agents to allocate (heuristic: one per 5 documents, max 10).
- **Document type:** contracts, NDAs, employment, leases — selects the pre-defined column set and per-column extraction guidance.
Ask about the two or three inputs that matter most for this request, not the whole list. If the user wants a result straight away, produce it and state your assumptions at the top.
## Tools
Both tools use the standard library only, read only your files, and print a verdict line (`PASS` or `FIX n issue(s)`). Every finding quotes the input and gives a fix.
### 1. Document Discovery (`scripts/document_discovery.py`)
Scans a directory for documents, reports what it read and skipped, plans the agent split, and flags empty files, duplicate content and same-name files.
```bash
python3 scripts/document_discovery.py assets/flawed_docs
python3 scripts/document_discovery.py /path/to/ndas --types pdf,docx --format json
python3 scripts/document_discovery.py /path/to/leases --min-size 1024
```
Real output (excerpt) on `assets/flawed_docs`:
```
Read: 3 documents (138 B); types pdf, docx, doc, txt, md, rtf
Agent plan (heuristic: 5 documents per agent, max 10 agents): 1 agent(s), 3 documents each
[empty-file] size 0 bytes
Fix: Re-export or re-download lease_empty.txt, or exclude it with --min-size 1.
[duplicate-content] nda_acme_beta.txt == nda_acme_beta_copy.txt
Fix: Keep one copy (nda_acme_beta.txt) and move the rest out of the review folder so each document is extracted once.
FIX 2 issue(s)
```
### 2. Extraction Aggregator (`scripts/extraction_aggregator.py`)
Merges extraction result JSONs into one matrix and checks them.
```bash
python3 scripts/extraction_aggregator.py --results assets/sample_results/agent_1.json
python3 scripts/extraction_aggregator.py --results-dir assets/flawed_results
python3 scripts/extraction_aggregator.py --results-dir assets/sample_results --format markdown --output review_matrix.md
python3 scripts/extraction_aggregator.py --results-dir assets/sample_results --columns "Parties,Governing Law"
```
Real output (excerpt) on `assets/flawed_results`:
```
Read: 2 documents, 2 columns, 5 extractions (4 cells)
Not found: 1 of 4 cells (25.0%)
[missing-citation] nda_acme_beta.txt / Governing Law: value='Delaware'
Fix: Add a page or section citation (e.g. "p.3, s.2.1"), or mark the cell NOT FOUND.
[conflict] nda_acme_beta.txt / Governing Law: 'Delaware' (agent_1) vs 'New York' (agent_2)
Fix: Open the source, decide which value is right, and delete the other extraction.
FIX 5 issue(s)
```
Confidence labels are whatever the extracting agent reported; the tool counts them and does not verify them. No averaged "confidence score" is produced.
## Exit codes
| Code | Meaning |
|------|---------|
| 0 | Clean: nothing to act on |
| 1 | Findings printed (empty or duplicate files, no documents matched, conflicts, NOT FOUND, LOW confidence, missing citation, bad confidence label, unreadable result file) |
| 2 | Unusable input: directory missing, no result file parseable, results with no documents or columns, unwritable `--output` |
`--format text|json` on both tools (`--format markdown` on the aggregator); `--json` remains an alias.
## Reference Guides
| Reference | Purpose |
|-----------|---------|
| `references/extraction_methodology.md` | Document extraction best practices, JSON schema, agent prompts |
| `references/common_extraction_columns.md` | Pre-defined column sets for contracts, NDAs, employment, leases |
## Workflows
### 5-Step Document Review Pipeline
| Step | Action | Tool | Output |
|------|--------|------|--------|
| 1. Gather Requirements | Define document folder, output filename, columns to extract | Manual | Column list, file path |
| 2. Discover Documents | Scan directory for target documents | `document_discovery.py` | Document manifest JSON |
| 3. Process Documents | Extract values per column with citations (parallel agents) | AI agents (external) | Per-document extraction JSONs |
| 4. Collect Results | Aggregate extraction JSONs into unified matrix | `extraction_aggregator.py` | Consolidated matrix |
| 5. Generate Output | Export as markdown table or structured JSON | `extraction_aggregator.py` | Final deliverable |
### Parallel Processing Strategy
`document_discovery.py` plans one agent per 5 documents, capped at 10 agents. This is a heuristic chosen to keep each agent's context small, not a measured benchmark; adjust to your documents' length.
### Agent Prompt Template
Each agent receives a prompt structured as:
```
You are reviewing {count} legal documents. For each document, extract the
following columns:
{column_definitions}
For each value extracted:
1. Provide the exact value found
2. Include the page number (PDF) or section/paragraph (DOCX/MD)
3. Rate your confidence: HIGH (exact match), MEDIUM (inferred), LOW (uncertain)
4. If not found, record "NOT FOUND" with confidence LOW
Output as JSON per the extraction schema.
```
### Confidence Scoring
| Level | Color Code | Definition |
|-------|-----------|------------|
| HIGH | Green | Exact value found with clear citation |
| MEDIUM | Yellow | Value inferred from context; multiple possible interpretations |
| LOW | Red / Not Found | Value uncertain or not found in document |
### Output Format
**Sheet 1: Document Review**
| Document | Parties | Effective Date | Term | Governing Law | ... |
|----------|---------|---------------|------|---------------|-----|
| contract_a.pdf | Acme / Beta [p.1] | 2026-01-15 [p.2] | 3 years [p.3] | Delaware [p.12] | ... |
| contract_b.pdf | Gamma / Delta [p.1] | NOT FOUND | 2 years [p.4] | New York [p.10] | ... |
**Sheet 2: Summary**
| Metric | Value |
|--------|-------|
| Documents processed | 25 |
| Columns extracted | 8 |
| Not found cells | 3 of 25 |
| Conflicts | 1 |
## Extraction Scenarios
### Contract Review
| Column | What to Extract |
|--------|----------------|
| Parties | All contracting parties with full legal names |
| Effective Date | Contract effective or execution date |
| Term | Duration of the agreement |
| Renewal | Auto-renewal terms and notice period |
| Governing Law | Jurisdiction governing the agreement |
| Liability Cap | Maximum liability amount or formula |
| Indemnification | Indemnification obligations and scope |
| IP Ownership | Intellectual property ownership provisions |
| Termination Rights | Termination triggers and notice requirements |
| Data Protection | Data protection or privacy obligations |
### NDA Review
| Column | What to Extract |
|--------|----------------|
| Parties | Disclosing and receiving parties |
| Type | Mutual or one-way |
| Definition Scope | How "confidential information" is defined |
| Exceptions | Standard exceptions to confidentiality |
| Term | Duration of confidentiality obligations |
| Survival | Survival period after termination |
| Return/Destruction | Obligations on termination |
| Remedies | Available remedies for breach |
## Troubleshooting
| Problem | Cause | Solution |
|---------|-------|----------|
| Discovery finds 0 documents | Wrong path or file types | Verify path exists; check `--types` matches actual file extensions |
| Extraction JSONs have wrong schema | Agent prompt incomplete | Use the extraction schema from `extraction_methodology.md` |
| Aggregator shows conflicts | Multiple values for same cell | Review source documents; aggregator marks conflicts for manual review |
| High "NOT FOUND" rate | Columns too specific for document type | Use column definitions from `common_extraction_columns.md`; broaden definitions |
| Confidence all LOW | Agent unable to locate values | Check column definitions are specific enough; verify document is readable |
| Markdown table misaligned | Long values or special characters | Use `--format json` for machine processing; truncate long values |
| Missing citations | Agent did not include page/section references | Reinforce citation requirement in agent prompt; check extraction schema |
## Success Criteria
Targets below are internal heuristics, not published benchmarks.
- **Extraction Coverage**: 90%+ of defined columns populated across all documents
- **Confidence Distribution**: 70%+ of extractions rated HIGH confidence
- **Citation Accuracy**: Every extracted value includes verifiable page/section citation
- **Processing Speed**: 50+ documents processed within 30 minutes using parallel agents
- **Matrix Completeness**: Final matrix includes all documents and all columns with no orphan rows
## Scope & Limitations
**This skill covers:**
- Document inventory and discovery across PDF, DOCX, TXT, and MD formats
- Aggregation of extraction results from parallel agent processing into unified matrix
- Pre-defined column sets for contracts, NDAs, employment agreements, and leases
- Confidence scoring and conflict detection for extracted values
- Markdown and JSON output formats
**This skill does NOT cover:**
- Actual document parsing or text extraction (requires external libraries or AI agents)
- OCR processing for scanned documents
- Excel/XLSX output generation (use JSON output and convert externally)
- Automated legal analysis or risk assessment of extracted values
- Document comparison or redlining between versions
## Anti-Patterns
| Anti-Pattern | Why It Fails | Better Approach |
|--------------|-------------|-----------------|
| Vague column definitions | "Date" could match dozens of dates in a contract | Use specific definitions: "Effective Date" with guidance on where to look |
| Skipping document discovery | Unknown document count leads to wrong agent allocation | Always run discovery first; use manifest for pipeline planning |
| Ignoring LOW confidence results | Missing or uncertain data treated as fact | Review all LOW confidence cells manually; flag in final report |
| Processing 100+ docs with 1 agent | Slow, context window overflow, quality degradation | Split across agents; discovery proposes one per 5 documents, max 10 |
| No citation requirement | Cannot verify extracted values against source | Require page/section citation for every extraction; reject uncited values |
## Tool Reference
Run `python3 scripts/document_discovery.py --help` and `python3 scripts/extraction_aggregator.py --help` for the full option lists.