Law download

From MinBZK/regelrecht · View interactive version

Law download is an AI agent skill from the GitHub repository MinBZK/regelrecht. Downloads Dutch official legal publications including national laws, local regulations, and implementation policies from government sources (wetten.overheid.nl, lokaleregelgeving.overheid.nl). Use this skill proactively when: user mentions downloading, fetching, or importing a Dutch law by name or B

How to use this skill

Skill file

Law Download

Downloads official Dutch legal publications from government sources (national

and local) and converts them to the regelrecht YAML format.

Pipeline: /law-download (this skill) → /law-interpret (adds machine_readable logic)

Use this skill first to create a text-only YAML file, then use /law-interpret

to add machine-readable execution logic to it.

What This Skill Does

  1. Searches for Dutch regulations in government databases:
  1. Presents search results with identifiers (BWBR, CVDR) and metadata
  2. Downloads the XML from the official repository
  3. Parses the XML to extract articles and metadata
  4. Converts to YAML format with text only (no machine_readable sections)
  5. Saves to corpus/regulation/nl/{layer}/{law_id}/{date}.yaml

Supported Regulation Types

National Level (BWB)

Local Level (CVDR)

Important Constraints

Step-by-Step Instructions

Step 1: Determine Database to Search

Based on the regulation type, choose the appropriate database:

For National Regulations: Use x-connection=BWB

For Local Regulations: Use x-connection=CVDR

If unclear: Search both databases and combine results

Step 2: Search for the Regulation

API Endpoint (BWB):

https://zoekservice.overheid.nl/sru/Search?operation=searchRetrieve&version=1.2&x-connection=BWB&query={QUERY}&maximumRecords=10

API Endpoint (CVDR):

https://zoekservice.overheid.nl/sru/Search?operation=searchRetrieve&version=1.2&x-connection=CVDR&query={QUERY}&maximumRecords=10

Query Construction:

Examples:

# Search BWB
https://zoekservice.overheid.nl/sru/Search?operation=searchRetrieve&version=1.2&x-connection=BWB&query=dcterms.title%20any%20"zorgtoeslag"&maximumRecords=10

# Search CVDR for municipal regulations
https://zoekservice.overheid.nl/sru/Search?operation=searchRetrieve&version=1.2&x-connection=CVDR&query=dcterms.title%20any%20"afvalstoffenverordening"&maximumRecords=10

# Search specific municipality
https://zoekservice.overheid.nl/sru/Search?operation=searchRetrieve&version=1.2&x-connection=CVDR&query=overheidcvdr.organisatietype==gemeenten%20AND%20dcterms.creator==Amsterdam%20AND%20dcterms.title%20any%20"afval"&maximumRecords=10

Step 3: Parse Search Results

Extract from the XML response:

For BWB results:

For CVDR results:

Present results to user with format:

Found {N} results:

1. {Title}
   ID: {BWBR_ID or CVDR_ID}
   Type: {Type}
   Organization: {Creator} (if CVDR)
   Latest version: {Date}

2. ...

Ask user: "Which regulation would you like to download? (Enter number or ID)"

Step 4: Download XML Files

Once user selects a regulation, download the appropriate XML files:

For BWB (National) Regulations:

A. WTI File (Metadata):

https://repository.officiele-overheidspublicaties.nl/bwb/{BWBR_ID}/{BWBR_ID}.WTI

B. Toestand File (Legal Text):

https://repository.officiele-overheidspublicaties.nl/bwb/{BWBR_ID}/{DATE}/xml/{BWBR_ID}_{DATE}.xml

For CVDR (Local) Regulations:

Download the CVDR XML directly:

https://repository.overheid.nl/{CVDR_PATH}/xml/{CVDR_ID}.xml

Where CVDR_PATH is extracted from the search results <gzd:resourceIdentifier>.

If date not specified by user, use the latest version from search results.

Use WebFetch or Bash with curl to download these files.

Step 5: Parse Metadata XML

Extract the following from the WTI XML:

XML Namespaces:

xmlns:bwb-dl="http://www.geonovum.nl/bwb-dl/1.0"

Fields to Extract:

Step 6: Parse Legal Text XML for Articles

XML Namespaces:

xmlns:bwb="http://www.overheid.nl/2011/BWB"

Article Structure in XML:

<artikel eId="chp_X__art_Y" wId="BWBR..." status="goed">
  <kop>
    <label>Artikel</label>
    <nr status="officieel">Y</nr>
  </kop>
  <lid eId="..." status="goed">
    <lidnr status="officieel">1</lidnr>
    <al>Legal text here...</al>
  </lid>
  <lid>
    <lidnr>2</lidnr>
    <al>More text...</al>
  </lid>
</artikel>

Extraction Logic:

  1. Find all <artikel> elements
  2. For each article:
  1. Generate article URL:

```

https://wetten.overheid.nl/{BWBR_ID}/{DATE}#Artikel{NUMBER}

```

Step 7: Generate YAML File

Target Structure:

$schema: https://raw.githubusercontent.com/NederlandseDigitaleDienst/regelrecht/refs/tags/schema-v0.8.24/schema/v0.8.24/schema.json
$id: "{LAW_SLUG}"
name: "{LAW_TITLE}"
regulatory_layer: "{MAPPED_LAYER}"
publication_date: "{YYYY-MM-DD}"
valid_from: "{YYYY-MM-DD}"
url: "https://wetten.overheid.nl/{BWBR_ID}/{DATE}"
bwb_id: "{BWBR_ID}"

articles:
  - number: "{ARTICLE_NUMBER}"
    text: |
      {MARKDOWN_TEXT}
    url: "https://wetten.overheid.nl/{BWBR_ID}/{DATE}#Artikel{NUMBER}"
  - number: "{NEXT_ARTICLE}"
    text: |
      {MORE_TEXT}
    url: "..."

Important:

Step 8: Save File

Directory Structure:

corpus/regulation/nl/{regulatory_layer_lowercase}/{law_id}/{valid_from}.yaml

Example:

corpus/regulation/nl/wet/wet_op_de_zorgtoeslag/2025-01-01.yaml
corpus/regulation/nl/ministeriele_regeling/regeling_standaardpremie/2025-01-01.yaml

Create directories if they don't exist.

Step 9: Validate YAML Against Schema (with repair loop)

The generated YAML has to pass just validate. The schema is the single

source of truth.

just validate {FILE_PATH}

If validation fails — repair (up to 3 rounds):

  1. Read the error output carefully, identify broken fields/structure
  2. Fix the YAML with the Edit tool
  3. Re-run just validate
  4. If still failing after 3 rounds, stop and report the errors to the user

Common validation issues:

Do NOT proceed to Step 10 with invalid YAML. A file that fails validation

cannot be used by /law-interpret in the next step.

Step 10: Confirm with User

Report:

✓ Downloaded and converted {REGULATION_TITLE}
  ID: {BWBR_ID or CVDR_ID}
  Type: {Type}
  Articles: {COUNT}
  Saved to: {FILE_PATH}
  ✅ Schema validation: PASSED

The YAML file contains the legal text only.
To add machine-readable execution logic, run /law-interpret on this file.

Error Handling

If search returns no results:

If XML download fails:

If XML parsing fails:

Tips for Success

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.