global-law README

项目的 README,来自 github.com/lexifina/global-law。合并为一个 markdown 文件:README.md。

Git for Global Law

The world's law in one git history. Every word traced to the law that wrote it for any country and any date.

An expansion of the same for the US Code, #1 on Hacker News (28/10/26). Semantic, searchable law on a global scale.

https://github.com/user-attachments/assets/f24f3411-24d9-416a-8c45-9cebc817c64e

Free to use: CC0. Fork it, build on it, ship it in a product: no permission or credit needed. The law text sits in each country's repository, under that repository's own terms.

Each body of law is its own repository: a country's law (lexifina/germany-law), a state's or a city's (lexifina/germany-brandenburg-law), or a court's decisions (lexifina/germany-bgh-caselaw). In a dated history every commit is one law taking effect, written by that law; in case law, one decision on the day it was decided. Where the publisher keeps only today's text, or each law as first enacted, the corpus says so (history in manifest.json). This repository holds them all as submodules, arranged by jurisdiction, and moves each one forward to its latest commit. The tools read the In-force date of every commit, so they give the law of any country on any date that its record covers.

global-law/
├── manifest.json                       every corpus: path, repository, history, coverage and dates
├── jurisdiction.json                   the world, and the jurisdictions in it
├── germany/bund/acts/                  a country's law (submodule: lexifina/germany-law)
├── germany/brandenburg/acts/           a state's
├── argentina/buenos-aires/salto/acts/  a city's
├── germany/bgh/caselaw/                a court's decisions
├── tools/                              law.py, the MCP server, countries.py
└── …

Questions as commands

Question Command
Every change to 11 U.S.C. §1182, with the law that made each python3 tools/law.py log united-states/federal/usc/title-11/1182.md
Which law wrote each line of it today? python3 tools/law.py blame 2026-01-01 united-states/federal/usc/title-11/1182.md
§1182 as in force on 1 May 2022 python3 tools/law.py show 2022-05-01 united-states/federal/usc/title-11/1182.md
What changed between two dates python3 tools/law.py diff 2022-05-01 2022-07-01 united-states/federal/usc/title-11/1182.md
The last law in force in every country on a day python3 tools/law.py world 1990-10-03

Each corpus is also a plain git repository (git -C united-states/federal/usc log -- title-11/1182.md); the tools order versions by their In-force date, which matters where a record was not committed in that order.

Outside git, we also host this record publicly, for free:

Both assistants read the record through the free Global law connector (MCP, https://global-law.lexifina.com/mcp); the first time, the chat gives you the link that adds it. Ask in any language; for one country, add ?country=romania to either link.

Host it yourself easily. All it takes is git and Python, and the tools run on your machine:

git clone --depth 1 https://github.com/lexifina/global-law && cd global-law
python3 tools/countries.py add united-states/federal/usc
python3 tools/law.py show 2022-05-01 united-states/federal/usc/title-11/1182.md

Opened in Claude Code, Cursor, VS Code or Codex, the clone also starts a local MCP server with the same tools (MCP.md). FEATURES.md lists every command and FAQ.md how to clone.

Case law

Court decisions sit beside the law, one commit per decision on the day it was decided (switzerland/bund/caselaw), and are added on their own: python3 tools/countries.py add switzerland/caselaw. A decision is a ruling, not a law (Kind: court), so the tools leave it out of everything about law unless you name it. check_precedent says whether the text a decision applied is still in force, and resolve_citations reads citations in each country's usual form (§ 823 Abs. 1 BGB, article 1240 du code civil). manifest.json gives each court's coverage.

More

Videos

https://github.com/user-attachments/assets/6020acb1-53f3-4b65-94a4-fe132b867358

https://github.com/user-attachments/assets/6119b018-5f5b-4bab-a2da-0aad30ef585f

License

This repository is CC0. The law text is in each country's repository, under that repository's own terms.

global-law (lexifina/global-law)

正在搜索数据库…

这是什么?Git for Global Law 把各国的法律整合成一部单一的 git 历史:每个国家的法律语料都是一个子模块,每次提交代表一项法律的生效,生效日期即其成为法律的日期。
这是代码库,还是更像一个法律数据集?它是一个以 git 仓库形式构建的结构化法律数据集,各国法律语料作为子模块挂载其中,另外附带用于查询的 Python 命令行工具(law.py、mcpserver.py)。它不是可以导入使用的代码库。
我到底要怎样查询这个仓库里的法律?连同子模块克隆仓库,然后可以运行 tools/mcpserver.py,将其作为 Claude 或其他 MCP 客户端的 MCP 服务器使用;也可以使用 law.py 命令行工具,或直接对历史记录运行普通的 git 命令。
要运行 MCP 服务器或 law.py,我需要安装什么?只需 Python 3.10+ 和 git;所有功能都在本地通过 stdio 运行,无需 API 密钥,也不依赖任何外部服务。
这里每个国家的法律都完整且是最新的吗?不是。覆盖范围差异很大:有些语料包含一个国家的完整法典,而有些只涵盖少数几部法律或一个样本,例如从美国法典(US Code)中抽取的九个编,或者仅包含英国的特殊教育需求法。
MCP 服务器会把我的法律查询发送到别处吗?不会。它完全在你的电脑上运行,从不联网,因此你的查询内容只留在本地。
我到底能用这些数据做什么?编译后的 git 历史本身采用 CC0 协议,因此你可以派生(fork)、在其基础上开发,或将其用于商业发布,无需获得许可,也无需署名;而每个国家自己仓库中的法律文本则仍遵循该仓库自身的条款。
Claude 等 AI 助手能直接查询这些内容吗?可以。tools/mcpserver.py 提供 18 个只读 MCP 工具,因此 Claude、Claude Desktop、Cursor 或任何 MCP 客户端都可以询问某一日期的法律内容是什么,并同时获得该记录的覆盖期间。
对于早于 git 存在时间的日期,比如 1970 年以前的法律,系统是怎么处理的?由于 git 无法存储 1970 年之前的日期,较早的变动(例如对《基本法》(Grundgesetz)的修改)会被赋予 1970 年的连续提交日期,每次相隔一秒;真实日期保存在每次提交的 In-force 提交尾部字段(trailer)中,工具读取的是这一字段而非 git 时间戳。
整个历史是如何构建的,又如何检验其正确性?tools/build.py 会根据已发布的各国语料确定性地重建整个仓库,并按每次提交的生效日期排序;48 项测试以及 REPRODUCE.md 中记载的逐哈希一致的重建流程共同验证结果。
我能不用 Python 工具,只用普通的 git 吗?可以。git log --first-parent、git grep --recurse-submodules 和 git diff --submodule=diff 等命令可分别用于按时间梳理、跨国全文搜索和跨日期对比;不过应使用 git worktree,而不要直接检出旧的提交。
作者
lexifina
大小
698.3 MB
星标
2.1K
更新
提交Nov 18
时长
21天
提交 · 90 天