Mr. Latte


Law as Code: What Happens When You Put 8,600+ National Laws into Git?

TL;DR Developers are transforming national legislation into version-controlled repositories, turning legal amendments into Git commits. Coupled with new Model Context Protocol (MCP) servers and domain-specific language models, this ‘Law as Code’ movement is making legal history programmatic, searchable, and AI-ready.


Legal systems are notoriously opaque, often trapped in dense PDFs, fragmented government portals, and complex amendment histories. But a growing movement is treating legislation exactly like software source code. By applying developer tools like version control and API integrations to public laws, technologists are creating a new foundation for legal transparency and programmatic access.

Key Points

Recent open-source initiatives have successfully mapped entire national legal frameworks into Git repositories. For example, over 8,600 Spanish laws dating back to 1960 have been converted into Markdown files, with every legislative reform tracked as an independent Git commit using data from the official government BOE (Boletín Oficial del Estado) API. This structured approach is part of a broader legal-tech ecosystem emerging around public data. Projects like boe-mcp and spanish-public-info-radar-mcp are deploying Model Context Protocol (MCP) servers to feed this consolidated legislation directly into LLMs. Alongside domain-specific NLP tools like the lm-legal-es RoBERTa models, these repositories are transforming static legal texts into dynamic, computable datasets.

Technical Insights

From a software engineering perspective, Git’s Directed Acyclic Graph (DAG) is the perfect data structure for legislative history. Traditional legal research requires manually comparing text to find amendments, but version control provides an exact git diff of what changed, timestamped with the official publication date. Furthermore, structuring laws with YAML frontmatter metadata enables programmatic querying that standard government search engines lack. The real technical leap, however, is combining this version-controlled Markdown with modern AI. By exposing these structured repositories via MCP servers, AI agents can reliably retrieve the exact state of a law at any point in time, mitigating the hallucination risks that occur when LLMs ingest unstructured legal PDFs.

Implications

This ‘Law as Code’ paradigm has massive implications for legal tech, compliance automation, and civic transparency. Developers can build tools that alert businesses to regulatory changes via webhooks, while AI assistants like the experimental Canary project can help citizens navigate complex jurisprudence. However, there are limits to the hype. While Git can track textual changes perfectly, it cannot capture the nuances of judicial interpretation or case law precedence. The code may compile, but legal execution remains profoundly human.


As more governments modernize their open data APIs, we will likely see similar version-controlled repositories for other jurisdictions. Will the future of legal compliance look less like reading a textbook and more like running a continuous integration pipeline?

References

Need a freelance expert to plan and build your product? Available to founders, teams, and businesses from product framing through launch.