Skip to content

Coding Standards

These standards apply to all contributions -- skills, agents, dashboard code, MCP server tools, and documentation. Following them ensures consistency and prevents common errors.


Jurisdiction: England & Wales Only

Critical Rule

Every skill, agent, and output is scoped exclusively to England & Wales law. This is a hard requirement -- not a guideline.

DoDo Not
Reference the Housing Act 1988Reference the Housing (Scotland) Act 1987
Reference the Land Registration Act 2002Reference the Land Registration (Scotland) Act 2012
Say "England and Wales"Say "the UK" when referring to legal jurisdiction
Reference ICO as the supervisory authorityReference the Scottish Information Commissioner
Omit non-E&W statutes entirelyInclude Scottish/NI equivalents "for completeness"

If a user asks about Scottish or Northern Irish law, the correct response is to state that this tool is scoped to England & Wales and recommend consulting a solicitor qualified in the relevant jurisdiction.


Disclaimer Block

Every user-facing output must start with the standard disclaimer. This is non-negotiable and load-bearing for the project:

AI-Generated Legal Analysis -- This output is produced by AI and does not
constitute legal advice. It is intended as a starting point for review.
Always consult a qualified solicitor before signing contracts or relying
on generated legal documents. This tool is designed for use under the
laws of England and Wales.

INFO

Do not omit, paraphrase, shorten, reposition, or move this disclaimer to a footer. Use it verbatim at the top of every output. Skills and agents include it in their output templates.


Risk Indicators

Use the standardised three-tier risk indicator format throughout all skills and agents:

IndicatorEmojiMeaningUsage
High Risk🔴Material legal exposure; must address before signingImmediate attention required
Medium Risk🟡Notable concern; should address during negotiationShould be addressed
Low Risk🟢Minor or no concern; well-draftedAcceptable, standard terms

In Markdown output:

markdown
| Risk Level | Count | Clauses |
|------------|-------|---------|
| 🔴 High Risk | 3 | Termination, Liability, IP |
| 🟡 Medium Risk | 5 | Payment, Notice, ... |
| 🟢 Low Risk | 8 | Governing Law, Severability, ... |

Input Handling

All skills must support exactly three input methods. Never remove support for any of them:

#MethodToolWhen
1File pathRead toolUser provides a path to a file
2Pasted textDirect inputUser pastes contract text into the chat
3URLWebFetchUser provides a URL to fetch

If the user invokes a skill without specifying input, prompt them to provide one of the three options.


Output File Naming

All generated documents are saved as Markdown files in the current working directory with standardised naming:

Document TypePatternExample
Contract reviewCONTRACT-REVIEW-[name]-[YYYY-MM-DD].mdCONTRACT-REVIEW-Acme-Corp-2025-03-15.md
Contract comparisonCONTRACT-COMPARISON-[YYYY-MM-DD].mdCONTRACT-COMPARISON-2025-03-15.md
NDANDA-[party-name]-[YYYY-MM-DD].mdNDA-TechStart-Ltd-2025-03-15.md
Terms of serviceTERMS-OF-SERVICE-[company]-[YYYY-MM-DD].mdTERMS-OF-SERVICE-Widgets-Inc-2025-03-15.md
Privacy policyPRIVACY-POLICY-[company]-[YYYY-MM-DD].mdPRIVACY-POLICY-Widgets-Inc-2025-03-15.md
Property analysisPROPERTY-ANALYSIS-[address]-[YYYY-MM-DD].mdPROPERTY-ANALYSIS-42-High-Street-2025-03-15.md
Tenancy reviewTENANCY-REVIEW-[address]-[YYYY-MM-DD].mdTENANCY-REVIEW-Flat-3-Oak-Lane-2025-03-15.md
GDPR auditGDPR-AUDIT-[name]-[YYYY-MM-DD].mdGDPR-AUDIT-DataFlow-Ltd-2025-03-15.md
IP reviewIP-REVIEW-[name]-[YYYY-MM-DD].mdIP-REVIEW-PatentCo-2025-03-15.md
Debt reviewDEBT-REVIEW-[debtor]-[YYYY-MM-DD].mdDEBT-REVIEW-Smith-Trading-2025-03-15.md
Immigration reviewIMMIGRATION-REVIEW-[name]-[YYYY-MM-DD].mdIMMIGRATION-REVIEW-J-Patel-2025-03-15.md
Will reviewWILL-REVIEW-[testator]-[YYYY-MM-DD].mdWILL-REVIEW-E-Thompson-2025-03-15.md

Skill Files

Skills are pure Markdown prompts with no runtime code:

RuleRationale
No imports or require() statementsSkills are prompt documents, not code
No shared library referencesEach skill is self-contained
No environment variable accessSkills run within Claude Code, not a runtime
Include all analysis frameworks inlineDo not reference external files for scoring criteria
Use tables for structured contentTables render consistently and are parseable
Include example output with exact structureShows the expected format precisely
Professional but accessible languageExplain legal concepts in plain English alongside technical terms
Be specific about WHY something is riskyNot just THAT it is risky
Always suggest specific alternative languageWhen flagging issues in contracts

Agent Output Contracts

Agent output must match the structure expected by the parent orchestrator:

RuleRationale
Use the exact table format defined in the agent fileParent orchestrator parses the output
Include summary statisticsUsed for weighted scoring in aggregation
Use unique identifiers for each findingEnables cross-referencing between agents (e.g., CL-001, DP-003)
Include a "Handoff to Other Agents" sectionDocuments dependencies explicitly

Breaking Change Risk

Changing an agent's output contract without updating the parent orchestrator will break the aggregation step. Always update both files together in the same PR.


Dashboard: TypeScript & React

General TypeScript

RuleExample
Use interface for object shapesinterface Review { ... }
Use as const for literal arrays["legal-review", ...] as const
Avoid any -- use unknown and narrowerror instanceof Error ? error.message : "Unknown"
Export types from lib/types.tsCentral type definitions
All files must be .ts or .tsxNo .js or .jsx in the dashboard

React Components

RuleDetails
Use "use client" for client componentsTop of file directive for pages using hooks/browser APIs
Use existing shadcn/ui primitivesCard, Badge, Button, Dialog, Tabs, Table, Select, Input
Use CSS variables for themingtext-primary, bg-muted, not text-blue-600
Avoid inline stylesUse Tailwind utility classes exclusively
Follow existing component patternsCheck dashboard/components/ for examples

API Routes

RuleDetails
Validate all inputUse validateReviewRouteBody() or similar validation
Handle errors consistentlyUse mapReviewRouteError() pattern for error responses
Return JSON responsesNextResponse.json({ ... }) with appropriate status codes
Use correct HTTP status codes400 for bad input, 401 for auth, 413 for too large, 429 for rate limits, 500 for server errors
Never log or store API keysKeys are passed through to the Anthropic SDK, never persisted
Support SSE for long-running operationsFollow the text/event-stream pattern in the review route

Tests

RuleDetails
Tests compile to .test-dist/TypeScript test files are compiled by tsc -p tsconfig.test.json
Use node:test runnerNot Jest, not Vitest -- the project uses Node.js built-in test runner
Test file naming: *.test.tsPlace alongside the module being tested in lib/
Must run npm test to recompileEditing .ts without recompiling has no effect on test execution
Use node:assert/strictStandard Node.js assertion library
typescript
import { describe, it } from "node:test"
import assert from "node:assert/strict"

describe("yourFunction", () => {
  it("should handle the expected case", () => {
    const result = yourFunction(input)
    assert.strictEqual(result, expected)
  })

  it("should throw for invalid input", () => {
    assert.throws(() => yourFunction(null), /expected error message/)
  })
})

MCP Server

RuleDetails
TypeScript with strict modetsconfig.json has strict: true
Build to dist/npm run build compiles with tsc
Tests run on compiled outputSame pattern as dashboard: build then node --test
Tool names use snake_casesearch_legislation, lookup_statute, check_in_force
Return structured JSONAll MCP tool responses return typed objects
Use zod for input validationSchema validation for all tool parameters

Git Conventions

Branch Names

feat/partnership-review-skill
fix/limitation-period-calculation
docs/update-legislation-reference
refactor/extract-validation-utils
test/add-document-extraction-tests

Commit Messages

Follow conventional commit format with imperative mood:

feat: add intellectual property review skill
fix: correct limitation period for deed contracts
docs: update legislation reference table
refactor: extract common validation into api-route-utils
test: add tests for document-extraction edge cases
chore: update Anthropic SDK to latest version
PrefixWhen
feat:New feature or skill
fix:Bug fix
docs:Documentation only
refactor:Code restructuring, no behaviour change
test:Adding or updating tests
chore:Dependencies, tooling, configuration

What Not to Do

Do NotReason
Reference Scottish/NI statutesJurisdiction is England & Wales only
Omit the disclaimerRequired on all output, no exceptions
Use non-standard risk indicatorsConsistency across all 38 skills
Remove an input method from a skillAll three (file, paste, URL) must be supported
Store API keys server-sideSecurity model requires client-side key storage only
Add runtime code to skillsSkills are pure Markdown prompts
Change agent output without updating orchestratorBreaks aggregation in the parent skill
Run tests without rebuildingTests run from compiled .test-dist/, not TypeScript source
Use hard-coded colours in componentsUse CSS variables / Tailwind theme tokens
Use any type in TypeScriptUse unknown and narrow with type guards

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