Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Access UK laws and statutory instruments via the Legislation.gov.uk API
.claude/skills/brycewang-stanford-uk-legislation-api/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -18% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 175% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 175% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 60% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 157% | 0% |
The Legislation.gov.uk API, maintained by The National Archives, provides open access to the full text of UK legislation from 1267 to the present day. The database covers over 100,000 items including Acts of Parliament, Statutory Instruments, Scottish and Welsh legislation, and Northern Ireland statutes. All data is available as structured XML with Dublin Core metadata, Atom feeds, and HTML. The API supports point-in-time versions showing how legislation read at any given date, plus amendment tracking.
No authentication or API key is required. The API is fully open. Respect rate limits by adding reasonable delays between bulk requests.
All legislation follows the pattern:
https://www.legislation.gov.uk/{type}/{year}/{number}| Type Code | Description | Example | |-----------|-------------|---------| | ukpga | UK Public General Act | /ukpga/2010/15 (Equality Act 2010) | | uksi | UK Statutory Instrument | /uksi/2020/1374 | | asp | Act of Scottish Parliament | /asp/2020/13 | | asc | Act of Senedd Cymru (Wales) | /asc/2021/4 | | nia | Northern Ireland Act | /nia/2022/2 | | ukla | UK Local Act | /ukla/2008/1 | | ukdsi | UK Draft Statutory Instrument | /ukdsi/2023/123 | | eur | Retained EU Legislation | /eur/2016/679 (GDPR) |
bash# Fetch the Equality Act 2010 — returns structured XML with Dublin Core metadata curl "https://www.legislation.gov.uk/ukpga/2010/15/data.xml" # Response: <Legislation DocumentURI="http://www.legislation.gov.uk/ukpga/2010/15" # NumberOfProvisions="564"> # <dc:title>Equality Act 2010</dc:title> # <dc:description>An Act to make provision to require Ministers...</dc:description> # Fetch Data Protection Act 2018 curl "https://www.legislation.gov.uk/ukpga/2018/12/data.xml" # Response: <dc:title>Data Protection Act 2018</dc:title> # NumberOfProvisions="1181" # Fetch a Statutory Instrument curl "https://www.legislation.gov.uk/uksi/2020/1374/data.xml" # Response: <dc:title>The Health Protection (Coronavirus, Restric...</dc:title>
bash# Fetch a single section curl "https://www.legislation.gov.uk/ukpga/2010/15/section/1/data.xml" # Fetch table of contents curl "https://www.legislation.gov.uk/ukpga/2010/15/contents/data.xml" # Fetch a specific Part curl "https://www.legislation.gov.uk/ukpga/2010/15/part/1/data.xml" # Fetch a Schedule curl "https://www.legislation.gov.uk/ukpga/2010/15/schedule/1/data.xml"
bash# Search by title — returns HTTP 300 with multiple matches curl "https://www.legislation.gov.uk/id?title=equality+act" # Browse by type, title keyword, and year curl "https://www.legislation.gov.uk/ukpga?title=data+protection&year=2018" # List recent Acts via Atom feed curl "https://www.legislation.gov.uk/new/ukpga/data.feed" # Response: <openSearch:totalResults> with <entry> elements per Act
bash# Changes affecting a specific Act (Atom feed, paginated) curl "https://www.legislation.gov.uk/changes/affected/ukpga/2010/15/data.feed" # Response: <title>Changes to Legislation</title> # <leg:totalPages>25</leg:totalPages> # Each <entry> describes one amendment with source and target provisions # Changes made BY a specific Act curl "https://www.legislation.gov.uk/changes/affecting/ukpga/2010/15/data.feed"
bash# Legislation as it stood on a specific date curl "https://www.legislation.gov.uk/ukpga/2010/15/2015-01-01/data.xml" # Enacted (original) version curl "https://www.legislation.gov.uk/ukpga/2010/15/enacted/data.xml"
| Suffix | Format | Content-Type | |--------|--------|-------------| | /data.xml | Legislation XML (CLML) | application/xml | | /data.feed | Atom feed | application/atom+xml | | /data.csv | CSV export | text/csv | | (none) | HTML rendering | text/html |
The primary XML format uses the Crown Legislation Markup Language (CLML) schema with namespaces for legislation, ukm:Metadata, and Dublin Core (dc:, dct:) elements. Each document includes NumberOfProvisions, RestrictExtent (geographic applicability like E+W+S+N.I.), and RestrictStartDate.
eur) and its UK modificationspythonimport requests from xml.etree import ElementTree as ET BASE = "https://www.legislation.gov.uk" NS = {"leg": "http://www.legislation.gov.uk/namespaces/legislation", "ukm": "http://www.legislation.gov.uk/namespaces/metadata", "dc": "http://purl.org/dc/elements/1.1/", "atom": "http://www.w3.org/2005/Atom"} def get_legislation(leg_type: str, year: int, number: int) -> dict: """Fetch UK legislation metadata and full XML.""" url = f"{BASE}/{leg_type}/{year}/{number}/data.xml" resp = requests.get(url) resp.raise_for_status() root = ET.fromstring(resp.content) meta = root.find(".//ukm:Metadata", NS) return { "title": meta.findtext("dc:title", namespaces=NS), "description": meta.findtext("dc:description", namespaces=NS), "provisions": root.attrib.get("NumberOfProvisions"), "extent": root.attrib.get("RestrictExtent"), "uri": root.attrib.get("DocumentURI"), "xml": resp.content } # Example: fetch the Equality Act 2010 act = get_legislation("ukpga", 2010, 15) print(f"{act['title']} — {act['provisions']} provisions, extent: {act['extent']}") # Output: Equality Act 2010 — 564 provisions, extent: E+W+S+N.I.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 25,403 | 13,379 | -47% | 1 | 1 | 0% | 4,895 | 4,028 | -18% | 0 | 0 | — |
case-02 | fail→pass | 14,426 | 3,229 | -78% | 1 | 1 | 0% | 970 | 2,668 | +175% | 0 | 0 | — |
case-03 | pass→pass | 5,275 | 2,742 | -48% | 1 | 1 | 0% | 991 | 2,574 | +160% | 0 | 0 | — |
case-04 | pass→pass | 7,705 | 3,030 | -61% | 1 | 1 | 0% | 1,527 | 2,606 | +71% | 0 | 0 | — |
case-05 | pass→pass | 10,126 | 2,655 | -74% | 1 | 1 | 0% | 2,095 | 2,562 | +22% | 0 | 0 | — |
case-06 | pass→pass | 4,298 | 3,199 | -26% | 1 | 1 | 0% | 843 | 2,666 | +216% | 0 | 0 | — |
case-07 | pass→pass | 5,640 | 2,359 | -58% | 1 | 1 | 0% | 1,034 | 2,475 | +139% | 0 | 0 | — |
case-08 | fail→pass | 16,655 | 6,137 | -63% | 1 | 1 | 0% | 1,118 | 3,079 | +175% | 0 | 0 | — |
case-09 | pass→pass | 6,991 | 3,192 | -54% | 1 | 1 | 0% | 1,257 | 2,593 | +106% | 0 | 0 | — |
case-10 | pass→pass | 4,639 | 2,976 | -36% | 1 | 1 | 0% | 834 | 2,488 | +198% | 0 | 0 | — |
case-11 | pass→pass | 5,920 | 3,327 | -44% | 1 | 1 | 0% | 1,008 | 2,650 | +163% | 0 | 0 | — |
case-12 | pass→pass | 7,012 | 16,728 | +139% | 1 | 1 | 0% | 1,419 | 3,012 | +112% | 0 | 0 | — |
case-13 | pass→pass | 7,402 | 3,387 | -54% | 1 | 1 | 0% | 1,287 | 2,657 | +106% | 0 | 0 | — |
case-14 | fail→pass | 10,032 | 4,522 | -55% | 1 | 1 | 0% | 1,635 | 2,614 | +60% | 0 | 0 | — |
case-15 | fail→pass | 14,863 | 2,943 | -80% | 1 | 1 | 0% | 981 | 2,518 | +157% | 0 | 0 | — |
case-16 | pass→pass | 11,066 | 2,882 | -74% | 1 | 1 | 0% | 1,816 | 2,549 | +40% | 0 | 0 | — |
case-22 | fail→fail | 16,566 | 11,139 | -33% | 1 | 1 | 0% | 2,909 | 4,077 | +40% | 0 | 0 | — |
case-17 | fail→pass | 5,440 | 2,411 | -56% | 1 | 1 | 0% | 898 | 2,390 | +166% | 0 | 0 | — |
case-18 | pass→pass | 7,055 | 3,044 | -57% | 1 | 1 | 0% | 1,354 | 2,602 | +92% | 0 | 0 | — |
case-19 | fail→pass | 11,565 | 4,778 | -59% | 1 | 1 | 0% | 1,998 | 2,914 | +46% | 0 | 0 | — |
case-20 | fail→fail | 13,811 | 12,757 | -8% | 1 | 1 | 0% | 2,526 | 4,459 | +77% | 0 | 0 | — |
case-21 | fail→fail | 6,877 | 5,100 | -26% | 1 | 1 | 0% | 1,180 | 2,978 | +152% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted, and 19 counted toward the lift figure. The other 3 produced results that are not comparable between the two arms, so they are excluded from the headline rather than averaged into it. The headline lift of +32 percentage points is the difference between those two pass rates over the 19 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.