cn-law-hub
从国家法律法规数据库等 10 个官方数据源检索中国法律法规、规章与条约原文,支持精确法条抽取、时效性核验与批量下载。适用于法律咨询、案例分析、合同与合规审查等必须引用现行有效条文原文的场景,避免误引已废止或已被修改的法条。
git clone https://github.com/ZongziForu/cn-law-hub.gitBefore / After 效果对比
2 组打开浏览器逐个官网搜索法规名称,进入全文页面再用 Ctrl+F 翻找目标条文,还得自己判断该法规是否已废止、已修改或尚未生效,一条法律依据往往要花二三十分钟。
一条命令按标题精确检索并直接抽取「第X条」原文,同时返回现行有效状态与官方来源链接,几秒内拿到可直接引用的条文依据,无需人工比对时效性。
name: cn-law-hub description: >- 用于查询、检索、核验、下载、导出、批量采集中国官方法律法规、规章、条约和具体法条。Use this skill aggressively when the user asks to 查法律、查法规、查条例、查规章、查条约、查法条、查第几条、找法律依据、引用法律依据、核验现行有效、判断是否废止/已修改/尚未生效、下载法规全文、导出法规目录、批量下载法规文件、按关键词检索具体法条、展开法条分析,或在中国法律咨询、案例分析、合规审查、合同审查、劳动争议、行政法分析、公司合规、数据合规、政策研究中需要调用、核验或引用中国现行有效法律法规原文作为依据。Trigger also when phrases such as 依法、依规、依照法律规定、法律法规 imply a need to verify specific statutory authority or article-level text. Covers 国家法律法规数据库 (flk.npc.gov.cn), 国家规章库 (gov.cn), 外交条约库 (treaty.mfa.gov.cn), 国务院政策文件库 (sousuo.www.gov.cn), 司法部行政法规库 (xzfg.moj.gov.cn), 党内法规库 (12371.cn), 国防部法规文库 (mod.gov.cn), 税务法规库 (fgk.chinatax.gov.cn), 生态环境部法规规章 (mee.gov.cn), and 最高人民法院发布栏目 (court.gov.cn). Supports 标题/正文检索, 精确/模糊检索, 时效性过滤, 分类过滤, 分页, 排序, 单篇下载, 批量下载, 法条级抽取, 地区/制定机关分类, and browser fallback. Trigger when the answer may depend on current effective Chinese statutes, regulations, rules, treaties, article text, official document status, or official source attribution. Do not use for purely general legal theory, generic writing, or legal reasoning that does not require retrieving or verifying official Chinese legal documents.
Data Sources
| # | Database | Script | Source | Type |
|---|---|---|---|---|
| 1 | 国家法律法规数据库 (NPC) | scripts/download.py | flk.npc.gov.cn | JSON API |
| 2 | 国家规章库 (Gov Rules) | scripts/gov_rules_crawler.py | gov.cn/zhengce/xxgk/gjgzk | Athena API + HTML |
| 3 | 外交条约库 (Treaty) | scripts/treaty_crawler.py | treaty.mfa.gov.cn | HTML |
| 4 | 国务院政策文件库 | scripts/gov_policy_library.py | sousuo.www.gov.cn | REST API (GET) |
| 5 | 司法部行政法规库 | scripts/moj_law_crawler.py | xzfg.moj.gov.cn | HTML |
| 6 | 党内法规库 | scripts/party_law_crawler.py | www.12371.cn | HTML |
| 7 | 国防部法规文库 | scripts/mod_law_crawler.py | www.mod.gov.cn | HTTP |
| 8 | 税务法规库 | scripts/tax_law_crawler.py | fgk.chinatax.gov.cn | REST API (POST) |
| 9 | 生态环境部法规规章 | scripts/mee_law_crawler.py | mee.gov.cn | HTML |
| 10 | 最高人民法院发布栏目 | scripts/court_law_crawler.py | court.gov.cn | HTML |
All scripts share --search, --info, --size, --output, --rate-limit, --no-cache, --cache-stats, --cache-clear. Run python <script> --help for full parameter lists.
Core Rules
Search Strategy (applies to ALL data sources)
Decide before calling the script — never default to fuzzy for everything:
- Known title (e.g. "物业管理条例", "北京市生活垃圾管理条例"): use
--exactto reduce noise. - Broad topic (e.g. "出租车", "环境保护"): use fuzzy search (default).
- Full-text match: add
--range contentwhen you need documents where the keyword appears in the body, not just the title. - Ambiguous: ask the user, or run both exact+fuzzy and compare.
Status Filtering
NPC status codes (sxx / --status):
| Code | Meaning |
|---|---|
1 | 已废止 |
2 | 已修改 |
3 | 现行有效 |
4 | 尚未生效 |
Other sources use their own status values (e.g. --status effective for MoJ). Check --help per script.
Article-Level Queries (NPC)
For individual articles instead of full documents:
| Command | When | Output |
|---|---|---|
--preview <id> | Understand structure first | Title, article count, TOC |
--article <id> "第X条" | Know the article number | Single article text |
--article <id> --grep "kw" | Find articles by keyword in one law | All matching articles |
Supports Chinese numerals (第三十八条), Arabic (第38条), or bare numbers (38).
For cross-law article search, use scripts/article_search.py <keyword> --max-laws N.
Rate Limiting
Auto mode picks by estimated requests: OFF (≤10), FIXED 5 req/s (11–100), ADAPTIVE 1–8 req/s with 429 backoff (>100). Override: --rate-limit {off|fixed|adaptive}.
Caching
Local file cache enabled (~/.cache/ per namespace). Search results: 1h TTL. Detail metadata: 24h. DOCX: 7 days. Use --no-cache to bypass, --cache-stats to inspect.
Validity Rules — MANDATORY
- Only state 现行有效, 已废止, 已修改, or 尚未生效 when the official page or API response explicitly provides that status.
- If the source has no explicit validity field, say: "官方页面未明确标注效力状态".
- Do not infer validity from file accessibility or recency of publication date.
- Always return: official URL, file type, issuing authority, publication date, and retrieval date — even when status is absent.
- For same-name / multi-version documents, flag the ambiguity and verify amendment, repeal, and effective-date information.
- Distinguish document types: 法律, 行政法规, 地方性法规, 规章, 司法解释, 司法文件, 党内法规, 政策文件, 通知, 案例, 条约. Do not conflate.
- Never write "现行法律" as a generic label for all official publications.
Document Type Attribution
When reporting results, always identify the document type and source database explicitly. Use the format:
来源: [数据库名称] ([URL])
文件类型: [法律/行政法规/规章/司法解释/党内法规/政策文件/通知/...]
发布机关: [authority]
发布日期: [date]
效力状态: [现行有效/已废止/...] 或 "官方页面未明确标注效力状态"
Script Routing Summary
| Script | Purpose | Key flags | Output dir |
|---|---|---|---|
scripts/download.py | NPC search, download, article, preview | --search, --exact, --range, --status, --download, --article, --preview, --urls-only | stdout, files |
scripts/article_search.py | Cross-law article-level search | keyword, --law, --range, --max-laws, --context, --json, --offset, --resume | stdout |
scripts/gov_rules_crawler.py | Gov.cn rules | --search, --categories, --download, --info | gov_rules_output/ |
scripts/treaty_crawler.py | MFA treaties | --search, --collections, --download, --info | treaty_output/ |
scripts/gov_policy_library.py | State Council policies | --search, --range, --category, --year | gov_policy_output/ |
scripts/moj_law_crawler.py | MoJ admin regulations | --search, --range, --status | moj_law_output/ |
scripts/party_law_crawler.py | Party regulations (12371.cn) | --search, --category | party_law_output/ |
scripts/mod_law_crawler.py | MOD law library | --search, --category | mod_law_output/ |
scripts/tax_law_crawler.py | Tax regulations (chinatax) | --search, --category | tax_law_output/ |
scripts/mee_law_crawler.py | MEE env regulations | --search, --category | mee_law_output/ |
scripts/court_law_crawler.py | SPC announcements | --search, --category | court_law_output/ |
scripts/region_classifier.py | Province/city classification | --classify, --matrix | JSON/CSV |
Each script has --help. Run it for detailed parameter lists.
Reference Files
Read these on demand, not proactively:
| File | Read when... |
|---|---|
references/setup.md | First run, dependency issues, or switching agent environments |
references/api_reference.md | Need full NPC API payloads, field mappings, auth, or pagination details |
references/gov_rules_api_reference.md | Gov Rules auth issues (401/403) or response field parsing |
references/gov_policy_api_reference.md | Need State Council API parameter details beyond --help |
references/treaty_api_reference.md | Treaty HTML structure or field extraction patterns |
references/page_structure.md | Browser automation — page layout, selectors, UI-only search flow |
references/kimi_bridge_adapter.md | Running on Kimi Agent or Claude Code + kimi-webbridge |
references/codex_adapter.md | Running on Codex |
references/batch_collection.md | Large-scale collection (200+ items), batch download workflows |
Browser fallback: only when the API/script fails or UI-only search is required. Read references/page_structure.md first.
Key Notes by Data Source
- NPC:
ossFilepaths from detail API are not directly downloadable — always use--download.bbbs= unique law ID. - Gov Rules: Requires dynamic RSA auth from the frontend JS bundle; may expire during long runs. Restart on 401/403.
- Treaty: Pure HTML, no API. Collections:
全部,双边,多边. - Party Law (12371.cn): No search API; keyword filtering is client-side on titles only.
- MOD: Static HTML, no search API. Client-side title filtering.
- Tax: POST API, requires session cookie (auto-managed). Channel ID auto-discovered.
- MEE: Static HTML, categories pre-loaded in page. No search API. Standards (环保标准) excluded.
- Court: List pages paginated (
/fabu/gengduo/{id}.html→{id}_{n}.html). No search API.
--- README.md ---
CN Law Hub — 中国法条检索 / PRC Statute & Regulation Search for AI Agents
面向 Claude Code、Codex、Kimi 等 AI Agent 的中国大陆法条与法律法规检索 Skill,直接检索全国人大、国务院、司法部、最高人民法院等 10 个官方来源,支持具体条文检索、跨法规正文搜索、现行有效筛选与官方原文下载。
Chinese legal research Agent Skill for retrieving and verifying Chinese laws from official sources.
覆盖 10 个官方数据源:
- 国家法律法规数据库(NPC) —
flk.npc.gov.cn - 国家规章库(Gov Rules) —
gov.cn/zhengce/xxgk/gjgzk/ - 外交条约库(Treaty) —
treaty.mfa.gov.cn - 国务院政策文件库 —
sousuo.www.gov.cn - 司法部行政法规库 —
xzfg.moj.gov.cn - 党内法规库 —
www.12371.cn/special/dnfg/ - 国防部法规文库 —
www.mod.gov.cn/gfbw/fgwx/ - 税务法规库 —
fgk.chinatax.gov.cn - 生态环境部法规规章 —
mee.gov.cn/ywgz/fgbz/ - 最高人民法院发布栏目 —
court.gov.cn/fabu/
| Official sources | Article-level search | Cross-law search |
|---|---|---|
| Validity filtering | Chinese local & national regulations | Claude Code & Codex |
什么时候使用这个 Skill
当你需要查询、核验、下载或引用中国官方法律法规、规章、条约和具体法条时,可以直接让 agent 使用本 skill。多数情况下,你不需要手动运行脚本,只需要用自然语言说明任务,agent 会根据 SKILL.md 自动选择合适的数据源、脚本和参数。
如果你希望确保在当前工作中使用本 skill,也可以在请求中直接使用 /cn-law-hub 指令(尤其在你没有使用能力较强的模型时)。
典型场景包括:查法规全文、核验现行有效状态、查询某法第几条、按关键词检索具体法条、为法律咨询/案例分析/合规审查提供官方法条依据、批量下载法规文件或导出法规目录。
例如:
帮我查《劳动合同法》第三十八条,并引用现行有效版本。
找一下关于物业管理的现行有效地方性法规。
帮我检索包含“违约金”的具体法条,并按法规名称列出来。
这个劳动争议案例可能涉及哪些现行有效法律依据?
你可以使用类似表达:
- 查法律、查法规、查条例、查规章、查条约、查法条
- 查第几条、查询某法第几条、找某条法律依据
- 找法律依据、引用法律依据、引用法条、展开法条分析
- 核验现行有效、判断是否废止、是否已修改、是否尚未生效
- 下载法规全文、批量下载法规文件、导出法规目录
- 按关键词检索具体法条、跨法规查找相关条文
- 查询地方性法规、按地区/制定机关分类
- 在法律咨询、案例分析、合规审查、合同审查、劳动争议、行政法分析、公司合规、数据合规、政策研究中,需要调用中国现行有效法律法规原文作为依据
- 当问题中出现“依法”“依规”“依照法律规定”“根据现行规定”等表达,并且需要核验具体法律依据时,也适合调用本 skill
如果只是一般法律概念解释、普通写作润色,且不需要核验官方法律法规原文,则不一定需要调用本 skill。
功能概览
- 多数据源支持:NPC 国家法律法规数据库、国家规章库、外交条约库、国务院政策文件库、司法部行政法规库、党内法规库、国防部法规文库、税务法规库、生态环境部法规规章、最高人民法院发布栏目
- 标题/正文检索:支持标题关键词、正文关键词两种搜索范围
- 精确/模糊策略:已知标题用
--exact精确匹配,主题/关键词用模糊匹配 - 现行有效状态筛选:
--status 3仅返回现行有效法规 - 单篇下载:DOCX(WPS 版)/ PDF(公报原版)
- 单条法条查询:
--preview查看结构,--article按条号或关键词查条文 - 跨法规法条级搜索:
scripts/article_search.py在多部法规正文中定位具体法条 - 批量采集:支持一次性采集 200–300 条法规的完整工作流
- 智能限速:根据任务大小自动选择 OFF / FIXED / ADAPTIVE 模式,避免 429
- 本地缓存:搜索结果、元数据、DOCX 文件默认缓存,复访提速
- URL 导出:云端 agent 可只导出签名下载 URL,供本地下载使用
- 地域/制定机关分类:内置省市映射,自动识别国家级、省级、设区市级
- 多环境支持:Kimi Agent、Claude Code via kimi-webbridge、Codex;其中 Kimi Agent 与 Claude Code via kimi-webbridge 共用同一套 browser adapter,因为两者的浏览器操作语义一致
安装
建议使用 Python 3.10+。
pip install -r requirements.txt
部分旧法规可能使用 .doc 格式,需要安装可选系统工具:
# macOS
brew install antiword catdoc
# Debian/Ubuntu
apt-get install antiword catdoc
如需通过 MCP 接入(可选,见下文):
pip install "mcp>=2.0.0"
一键安装
两种接入方式二选一,代码相同,只是接入形态不同:
| Skill 版(推荐,主路径) | MCP 版(可选) | |
|---|---|---|
| 形态 | 注册为 agent 的 Skill,自然语言或 /cn-law-hub 调用 | 一个 stdio server,暴露 5 个 MCP 工具 |
| 适用 | Claude Code / Codex / Kimi 等支持 skill 的 agent | 任意 MCP 兼容 agent(Claude Code / Cline / Cursor / Kimi / Codex) |
| 依赖 | 仅 requirements.txt | 额外 pip install "mcp>=2.0.0" |
| 配置 | agent 注册 skill | 见 references/mcp_setup.md;Claude Code 自动读 .mcp.json |
发布版请从 Releases 下载 Source code 压缩包。
方式 A:Skill 版(用 Agent 自动配置)
直接把仓库链接丢给 agent,让它自己完成下载、安装依赖和注册 skill。复制以下提示词即可:
请安装并配置这个 Skill:https://github.com/ZongziForu/cn-law-hub/releases/tag/v2.0.2
从上述 release 下载 Source code 压缩包,或 clone 仓库。先阅读仓库中的 SKILL.md 和 references/setup.md,并识别当前平台正确的 skills 目录。不要直接把整个仓库复制到最终安装目录;请先下载到临时目录,再仅安装以下运行时文件:
SKILL.mdscripts/references/requirements.txtLICENSENOTICE不要拷贝
tests/、pytest.ini、CHANGELOG.md、requirements-dev.txt、.mcp.json、*.pyc、__pycache__。安装依赖:
pip install -r requirements.txt(Python 3.10+)。注册完成后,用"帮我查《劳动合同法》第三十八条"验证。
方式 B:MCP 版
pip install "mcp>=2.0.0"
python3 scripts/mcp_server.py # 启动 stdio server(等待 MCP 客户端连接)
Claude Code 打开仓库即自动读取根目录 .mcp.json 接入;其他 agent 的配置方法见 references/mcp_setup.md。
快速开始
多数情况下,你不需要手动执行下面的命令。只要用自然语言向 agent 描述任务,agent 会根据 SKILL.md 自动选择合适的数据源、脚本和参数。
下面的命令主要用于本地手动运行、调试、复现结果,或帮助你理解本 skill 的核心能力。
国家法律法规数据库(NPC)
# 精确搜索已知法规名,并优先返回现行有效版本
python scripts/download.py --search "物业管理条例" --exact --status 3 --size 20
# 按主题/关键词模糊搜索
python scripts/download.py --search "出租车" --status 3 --size 50
# 下载单部法规
python scripts/download.py --download <bbbs_id> --format docx output.doc
# 查看法规结构并查询具体法条
python scripts/download.py --preview <bbbs_id>
python scripts/download.py --article <bbbs_id> "第三十八条"
# 跨法规检索具体法条
python scripts/article_search.py "违约金" --range content --max-laws 5 --context 1
国家规章库与外交条约库
# 国家规章库
python scripts/gov_rules_crawler.py --search "管理办法" --categories 部门规章 --size 20
# 外交条约库
python scripts/treaty_crawler.py --collections 双边 --search "上海合作组织" --size 20
更多参数见 SKILL.md 和 references/。
常见工作流
查询单条/多条法条
当你只需要核对某一条或搜索某部法规内的关键词时,不必把整部法规塞进 agent 上下文。
# 预览法规结构
python scripts/download.py --preview <bbbs_id>
# 按条号查询(自动识别中文/阿拉伯数字)
python scripts/download.py --article <bbbs_id> "第三十八条"
python scripts/download.py --article <bbbs_id> "第38条"
python scripts/download.py --article <bbbs_id> "38"
# 在单部法规中 grep 关键词
python scripts/download.py --article <bbbs_id> --grep "经济补偿"
跨法规法条级搜索
scripts/article_search.py 用于在多部法规中查找包含关键词的具体法条:
# 在标题含关键词的法规中搜索
python scripts/article_search.py "违约金" --max-laws 5 --context 1
# 在全文含关键词的法规中搜索
python scripts/article_search.py "违约金" --range content --max-laws 5
# 限定只查某一部法规
python scripts/article_search.py "善意取得" --law 民法典 --context 0
# JSON 输出
python scripts/article_search.py "违约金" --max-laws 3 --json
# 分批检索
python scripts/article_search.py "违约金" --range content --max-laws 5 --offset 5
python scripts/article_search.py "违约金" --range content --max-laws 5 --resume
智能限速与缓存
# 大任务使用自适应限速
python scripts/download.py --search "出租车" --urls-only --size 200 --rate-limit adaptive
# 查看缓存
python scripts/download.py --cache-stats
# 单次禁用缓存
python scripts/download.py --no-cache --info <
...
用户评价 (0)
发表评价
暂无评价
统计数据
用户评分
为此 Skill 评分