Skip to content

Utilities

Two utility commands: professional PDF report generation and sample document downloading for testing.

Generates a professional A4 PDF report from the most recent analysis output, suitable for client delivery.

Syntax

bash
/legal report-pdf

No arguments required. The command automatically locates the most recent analysis file in the current working directory.

Prerequisites

RequirementInstallation
Python 3.8+Pre-installed on macOS; apt install python3 on Linux
reportlabpip3 install reportlab

Missing reportlab

If reportlab is not installed, the command will display:

ERROR: reportlab is required. Install with: pip3 install reportlab

Install it with pip3 install reportlab before running the command.

How It Works

The command uses scripts/generate_legal_pdf.py to transform analysis Markdown into a branded PDF.

Step 1 -- Locate the source analysis. The script searches the current directory for files matching these patterns (in priority order):

CONTRACT-REVIEW-*.md
FREELANCER-REVIEW-*.md
COMPLIANCE-AUDIT-*.md
NDA-REVIEW-*.md

It also matches any .md file containing "Contract Safety Score", "Freelancer Fairness Score", or "Compliance Scorecard".

Step 2 -- Parse the Markdown. The script extracts structured data: scores, risk levels, clauses, recommendations, and metadata.

Step 3 -- Generate the PDF. The output is a professional A4 document with:

FeatureDescription
Score gaugesCircular SVG-style gauge graphics showing the overall score (0--100) with colour coding
Risk chartsVisual distribution of clause risk levels across the document
Colour-coded tablesRed for high risk, amber for medium, green for low -- matching the standard risk indicators
Action checklistPrioritised remediation items with checkboxes
Page layoutProper headers, footers, page numbering, and legal disclaimer on every page
BrandingProfessional colour palette: dark navy primary, medium blue secondary, bright blue accent

Colour Palette

The PDF uses a consistent colour scheme defined in the script:

ColourHexUsage
Primary#1a365dHeaders, titles
Secondary#2d5f8aSubheadings, borders
Accent#3182ceLinks, highlights
Success#38a169Low risk, passing checks
Warning#d69e2eMedium risk, warnings
Danger#e53e3eHigh risk, failures
Background#f7fafcAlternating table rows

Example Workflow

bash
# Step 1: Run an analysis
/legal review ./contracts/service-agreement.pdf

# Step 2: Generate the PDF
/legal report-pdf

Output

PDF file saved to the current working directory, named based on the source analysis file.

Client-Ready Output

The generated PDF is designed to be sent directly to clients or attached to advice letters. It includes the standard AI-generated disclaimer and professional formatting throughout.

Error Handling

ConditionBehaviour
No analysis file foundDisplays: "No contract review data found in the current directory. Please run /legal review <file> first."
reportlab not installedDisplays installation instructions and exits with code 1
Parse failureGraceful degradation -- outputs what it can extract

Downloads 30 sample legal documents across 3 quality tiers for testing AI Legal UK commands.

Syntax

bash
/legal fetch-samples <type>

Supported Types

TypeWhat Is Downloaded
contractsTemplate contracts, model agreements, sample commercial terms
employmentEmployment contract templates, HR policies, settlement agreements
propertyTenancy agreements, lease templates, conveyancing documents
corporateArticles of association, shareholder agreements, board resolutions, Companies House filings
compliancePrivacy policies, GDPR templates, DPIAs, cookie policies
templatesGeneral legal templates from law societies and government sources
case-lawCourt judgments, case summaries, tribunal decisions
allAll of the above categories

Quality Tiers

Documents span three quality tiers for comprehensive testing:

TierCountPurposeCharacteristics
Good~10Well-drafted documentsStrong protections, full compliance, market-standard clauses, proper execution
Mixed~10Average quality documentsSome gaps, partial compliance, common weaknesses, typical real-world drafting
Bad~10Deliberately flawed documentsMissing clauses, compliance failures, unfair terms, expired provisions, non-compliant execution

Why Three Tiers?

The tier spread ensures you can test the full range of analysis output. Good-tier documents should score 80+, mixed-tier documents should score 50--79, and bad-tier documents should score below 50. This validates that the analysis correctly identifies strengths and weaknesses.

Sources

Documents are sourced from publicly available UK legal resources:

SourceWhat It Provides
GOV.UKModel contracts, template agreements, regulatory guidance, statutory forms
ACASEmployment contract templates, settlement agreement guides, HR policy templates
ICODPIA templates, privacy notice templates, data protection guidance
Law SocietyPractice notes, model clauses, standard form documents
Companies HouseFiled articles of association, confirmation statements, annual accounts

Directory Structure

Documents are saved to a samples/ directory in the current working directory, organised by category:

samples/
  contracts/
    good/
    mixed/
    bad/
  employment/
    good/
    mixed/
    bad/
  property/
    good/
    mixed/
    bad/
  ...

Examples

bash
# Download all 30 sample documents
/legal fetch-samples all

# Download only employment templates
/legal fetch-samples employment

# Download only corporate governance documents
/legal fetch-samples corporate

Network Required

This command downloads documents from public sources and requires an active internet connection. Downloads may take a few minutes depending on connection speed.

Using Samples for Testing

After downloading, you can test any AI Legal UK command against the samples:

bash
# Test contract review against a good document
/legal review ./samples/contracts/good/service-agreement.md

# Test employment review against a bad document
/legal employment ./samples/employment/bad/zero-hours-contract.md

# Generate a PDF from the analysis
/legal report-pdf

AI Legal UK · The Counsel — Established MMXXVI · Built for England & Wales · Not legal advice.