Spanish legislation as a Git repo

github.com

700 points by enriquelop 17 hours ago


_ache_ - 14 hours ago

In France, not only our law are versioned. It's formally proved too!

https://catala-lang.org/

*Edit*: Woah ! The French crew is here. We are at least 5 quoting a variation of <https://www.legifrance.gouv.fr/> for versioning.

enriquelop - 17 hours ago

I built a pipeline that converts all Spanish state legislation into version-controlled Markdown. Each law is a file, each reform is a real git commit with the historical date. 8,642 laws, 27,866 commits.

The idea: legislation is just patches on patches on patches. Git already solves this. Instead of reading "strike paragraph 3 and replace with...", you get an actual diff.

The repo is the product. Browse any law, git log to see its full reform history, git diff to see exactly what changed.

Built the pipeline in ~4 hours with Claude Code. Source is BOE (Spain's official gazette) consolidated legislation API.

Exploring whether there's a business here — structured legislation API for legaltech/compliance, or just a useful open dataset. Curious what HN would build with this data.

lcrisci - 13 hours ago

I love it. This is a step in the right direction to have a transparent database of existing laws and be able to consult them with your AI or anything capable to reason about them and explain the status quo of our national laws. I would love to see a similar setup for other countries.

wrxd - 12 hours ago

It would have been cool if the commit authors reflected the actual politicians responsible for the reforms. Find a law, run `git blame` and immediately know who’s responsible for it

j-bos - 16 hours ago

This is brilliant. I wish this were available for all legislations. There's so many inefficiencies that are trivially solved with existing tech frameworks.

theptip - 14 hours ago

Nice! I was just implementing this for CA state bills.

Is the parsing/uploading code shared somewhere else?

Definitely the kind of idea that would have been below my activation energy pre-Claude.

I think this approach should be standard, I have always wondered why the source of truth for these documents is not moved to a repo like git.

Quarrel - 16 hours ago

Great project.

For others wondering, while most of the Franco-era laws were nuked in 1978, this does include lots of old laws (ie pre-20th C).

However, the source material starts with a sqashed commit in 1960 :) So no changelog before that. The BOE source though is pretty phenomonal, they've scanned files going back to the 1600s so far.

cyrusradfar - 16 hours ago

I think this is great. Only limit of git is I can't imagine "git blame" works. It would be nice to know who voted for and against each patch. Git isn't structured for collaborative commits.

enriquelop - 8 hours ago

OP here. Thank you for the incredible response — I did not expect this.

Many of you asked if the code is shared. It is now: https://github.com/legalize-dev

The pipeline is multi-country by design. France already works as a second country (Légifrance data). Adding a new country means implementing 4 Python interfaces for your national gazette. The rest (markdown, git, web, API) is generic.

I wrote a guide for contributors who want to add their country: https://github.com/legalize-dev/legalize-pipeline/blob/main/...

From this thread alone, people asked about Germany, Portugal, Sweden, Finland, Netherlands, and Brazil. If you know your country's open data source for legislation, a PR is the best way to help.

I'll be honest — I don't know how much time I'll be able to dedicate to this, but I'd love to build something big. Legislation is massive and scaling to more countries takes real infrastructure. I'm setting up an Open Collective to fund hosting and development: https://opencollective.com/legalize

Live site with browsable laws + diffs: https://legalize.dev

Everything is still very precarious, time to time.

Thank you

vitorbaptistaa - 15 hours ago

Congratulations! This is a very cool project. A few years ago there were similar ones -- browse gitlaw.

In Brazil we have lexml, a standard to describe the law and their changes over time. It's surprisingly complex.

josalhor - 15 hours ago

Not only would be cool for laws to have appropiate time stamps so we can "go back in time to how it was at a certain moment", but also if we could have proper git commit diffs of how laws change over time. See this: https://www.boe.es/buscar/act.php?id=BOE-A-2015-11430

You can see how certain articles have the option to check "how that particular article was at each moment in time". That would be way harder to track, but it would be awesome if not only could you "go back in time and see what the law was" but also "how its been evolving".

sigio - 15 hours ago

I did the same with a limited subset of dutch laws a while back: https://github.com/sigio?tab=repositories&q=wetboek

zaep - 16 hours ago

Nobody seems to have (yet) mentioned the most recent (rn) commit [1] dated 2099. I can't really figure out where the date came from, at the source noted in the commit I find no '2099', I can't see it being a joke, if it's a bug it's not obvious to me..

I'm sure I won't be the only one curious, please enlighten me.

[1]: <https://github.com/EnriqueLop/legalize-es/commit/424cbc96507...>

comboy - 15 hours ago

Add CI to check if new laws don't contradict with any existing ones.

PhilipV - 12 hours ago

Well done. I believe that Governments should have a Open Licence for copyright purposes like exists in the UK that allows Govt docs to be used for commercial purposes without issue. I would want to propose a step forward there so that the next generation of this open licence actually has a data set approach to making data sets available - possibly at cost. Governments are losing the ability to charge for nominal items in paper as digital is so openly available - they can make a revenue on providing data at large to public so that others can build or simply if not for free.

Well done and great to see items like this and great to see the comments.

pilingual - 12 hours ago

One idea behind the PoC Right to Privacy Act is having tests. A recurring theme with conservative Justices is clarity of legal text.

Testing may not exhaust all scenarios but it is useful to see where loopholes may exist or whether a bill that sneaks in while you aren't paying attention is unfavorable to your values.

https://github.com/righttoprivacyact/bill/blob/main/tests/te...

maCDzP - 14 hours ago

Nice, I am going to this for Swedish law! Any suggestions on how one can model parliament voting when a law passes using GitHub? Or all the work that preceded a law, that’s like a feature request or a bug report.

matthewgard1 - 11 hours ago

I did something very similar for some US state level laws. "Legit" legislative git.

Useful for alerts in our concern area, and monitoring proposed legislation iteration and flow through committees to keep ahead.

I can imagine quite a few other more civic interest uses as well!

Hoping to open source some later myself, seems an area ripe for some open civic citizen/hacker projects. Bet some fun startups could be made on top too, gl.

MinimalAction - 14 hours ago

The general sentiment here is that it's a great project. Could someone please explain why? All I'm seeing is that laws are updated with commits within markdown files.

ks2048 - 14 hours ago

A couple things I noticed opening one random page (https://github.com/EnriqueLop/legalize-es/blob/master/spain/...)

It left out the tables (e.g. under 2.1 Materiales.) and the images (e.g see the very bottom).

sebastianconcpt - 13 hours ago

We need something like this for every country.

boredatoms - 13 hours ago

Is there something like this for the US?

wyan - 8 hours ago

The fact that the oldest current law in the list is about places where nuns are allowed to be buried is quite amusing, in some sort of way.

dorianmariecom - 16 hours ago

for france there is https://www.lafabriquedelaloi.fr/

wouldbecouldbe - 16 hours ago

This is really great, anyone know of a Dutch version?

8bitsrule - 14 hours ago

Looks like we're heading toward some resolution to the old problem 'ignorance of the law is no excuse'. Born in a world with plenty of laws, the jeopardy that goes with them, and no easy and reliable resources, that would certainly be welcome.

bertil - 15 hours ago

This is a key project, and I’m sure many countries have enough developers who might try and get it done, but a project that can do it for most legal systems (assuming the sources are on-line) would help a lot more people access legal resources.

coopykins - 16 hours ago

Hey, very nice! Seems like a great way to have LLMs answer questions about the laws more reliably.

0x3f - 15 hours ago

Neat. I wonder if there are commercial products that are formal specifications of laws, decisions, etc. Such that you can reason on them via solvers etc.

throwaway_2626 - 16 hours ago

This is amazing. I have a couple of suggestions: - Maybe breaking the "Spain" folder into subfolders? Not sure what categories could be used, but browsing would be easier. - There's a missed opportunity in having different authors for the commits (maybe the "legislatura" number), and possibly, tags/labels including the political parties that voted in favor of each.

I'll take a look at data to enrich it :).

larsiusprime - 16 hours ago

Is the idea that the commits themselves are also time stamped with the date of the legislation/amendment too?

d0m - 16 hours ago

I wonder which country will be the first to be run entirely by AI instead of corrupt politicians

reality_inspctr - 12 hours ago

love this. I did something similar w the US Constitution. https://usconstitutionapi.com/

rwmj - 16 hours ago

This is great. Compare it to British legislation which is frankly a mess of patches. Example picked fairly much at random, this law was originally passed in 1990 and has been "patched" regularly:

https://www.legislation.gov.uk/ukpga/1990/18/section/9

Laws being passed are these ludicrous sets of patches:

https://www.legislation.gov.uk/ukpga/2015/9/part/1

SweetSoftPillow - 15 hours ago

We need it for every country and every law in the history of humanity

ivanjermakov - 16 hours ago

I'm surprised the world is not running a system where laws are formally encoded using some DSL that would allow making decision (guilty/not guilty) using formal logic. Perhaps there is not much interest from law making/enforcing parties for this either.

notorandit - 10 hours ago

That's how it should be everywhere!

d--b - 16 hours ago

I think French laws have been on website that’s like that for a while

sandbx - 13 hours ago

Did you try more heading levels for the article names?

Ericson2314 - 14 hours ago

All legislatures need to work this way as soon as possible!

makaking - 14 hours ago

I love this. This made me think that logging all legislation in a public VCS might be a very good way to leverage superintelligence while maintaining democracy. I want this for Germany.

drob518 - 15 hours ago

The date of the last commit is 2099.

MomsAVoxell - 16 hours ago

Great idea! I hope you did something like:

  $ git commit --amend --author="Author Name <author@spanish.gov>" --no-edit
.. with the details for the author of each commit.

Then, it would be simply amazing to run gource, sit back, and watch where all the noise is coming from.

Gource:

https://github.com/acaudwell/gource

What gource looks like:

https://gource.io/

I’ve long wanted to see gource applied in other sociologically-relevant contexts and this’d be a real good one ..

smashah - 16 hours ago

I've been saying for years that any and all legal documents (and all lawyers) should be required to be on/use git

sh-cho - 13 hours ago

Good Idea!

AtomicOrbital - 14 hours ago

all of government data including all laws especially tax law needs to be put online and optimized by ML

saglogog - 15 hours ago

Nice

TZubiri - 16 hours ago

I've seen something like this before, here's the Argentina constitution as a git repo, with reforms as commits. Much shorter in scope, but this was pre LLM coding

P.S: Sadly my PR amendment was repealled

LukeB42 - 12 hours ago

law.py — A Distributed Legislature: https://gist.githubusercontent.com/float64co/deb887691f13dee...

adjejmxbdjdn - 16 hours ago

Love this idea

anthk - 7 hours ago

Heh, with the BOE you need a Common Lisp expert in order to parse that. Some legal sentences look like a text from Marx, and not the Commie ones.

devnotes77 - 15 hours ago

[dead]

techsystems - 11 hours ago

[dead]

canaryai - 14 hours ago

[dead]

Gianniii - 14 hours ago

[dead]

peterhadlaw - 16 hours ago

[flagged]