by ZongziForu
中国法条与法律法规检索 Agent Skill|Chinese legal research Agent Skill for retrieving and verifying Chinese laws from official sources|支持具体法条检索、现行有效核验、10 个官方法律数据源
# Add to your Claude Code skills
git clone https://github.com/ZongziForu/cn-law-hubcn-law-hub is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by ZongziForu. 中国法条与法律法规检索 Agent Skill|Chinese legal research Agent Skill for retrieving and verifying Chinese laws from official sources|支持具体法条检索、现行有效核验、10 个官方法律数据源. It has 104 GitHub stars.
cn-law-hub's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/ZongziForu/cn-law-hub" and add it to your Claude Code skills directory (see the Installation section above). cn-law-hub ships a SKILL.md manifest, so compatible agents can discover and load it automatically.
cn-law-hub is primarily written in Python. It is open-source under ZongziForu on GitHub, so you can review or fork the full source.
Yes. AgentsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh cn-law-hub against similar tools.
No comments yet. Be the first to share your thoughts!
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
| # | 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.
Decide before calling the script — never default to fuzzy for everything:
--exact to reduce noise.--range content when you need documents where the keyword appears in the body, not just the title.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.
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.
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}.
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.
When reporting results, always identify the document type and source database explicitly. Use the format:
来源: [数据库名称] ([URL])
文件类型: [法律/行政法规/规章/司法解释/党内法规/政策文件/通知/...]
发布机关: [authority]
发布日期: [date]
效力状态: [现行有效/已废止/...] 或 "官方页面未明确标注效力状态"
| 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.
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.
ossFile paths from detail API are not directly downloadable — always use --download. bbbs = unique law ID.全部, 双边, 多边./fabu/gengduo/{id}.html → {id}_{n}.html). No search API.面向 Claude Code、Codex、Kimi 等 AI Agent 的中国大陆法条与法律法规检索 Skill,直接检索全国人大、国务院、司法部、最高人民法院等 10 个官方来源,支持具体条文检索、跨法规正文搜索、现行有效筛选与官方原文下载。
Chinese legal research Agent Skill for retrieving and verifying Chinese laws from official sources.
覆盖 10 个官方数据源:
flk.npc.gov.cngov.cn/zhengce/xxgk/gjgzk/treaty.mfa.gov.cnsousuo.www.gov.cnxzfg.moj.gov.cnwww.12371.cn/special/dnfg/www.mod.gov.cn/gfbw/fgwx/fgk.chinatax.gov.cnmee.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 |
当你需要查询、核验、下载或引用中国官方法律法规、规章、条约和具体法条时,可以直接让 agent 使用本 skill。多数情况下,你不需要手动运行脚本,只需要用自然语言说明任务,agent 会根据 SKILL.md 自动选择合适的数据源、脚本和参数。
如果你希望确保在当前工作中使用本 skill,也可以在请求中直接使用 /cn-law-hub 指令(尤其在你没有使用能力较强的模型时)。
典型场景包括:查法规全文、核验现行有效状态、查询某法第几条、按关键词检索具体法条、为法律咨询/案例分析/合规审查提供官方法条依据、批量下载法规文件或导出法规目录。
例如:
帮我查《劳动合同法》第三十八条,并引用现行有效版本。
找一下关于物业管理的现行有效地方性法规。
帮我检索包含“违约金”的具体法条,并按法规名称列出来。
这个劳动争议案例可能涉及哪些现行有效法律依据?
你可以使用类似表达:
如果只是一般法律概念解释、普通写作润色,且不需要核验官方法律法规原文,则不一定需要调用本 skill。
--exact 精确匹配,主题/关键词用模糊匹配--status 3 仅返回现行有效法规--preview 查看结构,--article 按条号或关键词查条文scripts/article_search.py 在多部法规正文中定位具体法条建议使用 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 压缩包。
直接把仓库链接丢给 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+)。注册完成后,用"帮我查《劳动合同法》第三十八条"验证。
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 的核心能力。
# 精确搜索已知法规名,并优先返回现行有效版本
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 <bbbs_id>
# 清空缓存
python scripts/download.py --cache-clear
缓存位置:~/.cache/{namespace}/(共 10 个 namespace,每个数据源独立)。
缓存 TTL 与自动清理:
CacheManager 在每次运行时机会式自动清理(每 7 天最多完整扫描一次),无需手动干预--cache-clear 用于立即清空当前数据源的全部缓存城市级 authority 通常不含省份名,例如 "广州市人民代表大会常务委员会" 不会包含 "广东省"。region_classifier.py 自动处理这个问题:
python scripts/download.py --search "物业管理条例" --urls-only --size 100 > urls.json
python scripts/region_classifier.py --classify < urls.json > classified.json
python scripts/region_classifier.py --matrix matrix.csv < classified.json
from scripts.region_classifier import classify_by_authority
classify_by_authority("广州市人民代表大会常务委员会")
# {
# "province": "广东省",
# "province_short": "广东",
# "city": "广州市",
# "level": "city",
# "is_municipality": False,
# "authority": "广州市人民代表大会常务委员会"
# }
详见 references/batch_collection.md。批量采集请使用自适应限速,并避免重复、大量、高频请求。
MCP 版是什么:把同一套检索能力封装成一个标准 MCP server(一个进程、
5 个工具),任何 MCP 兼容 agent 都能连接调用。它与 Skill 版共享全部
scripts/ 爬虫代码,mcp_server.py 只做转发,不修改任何现有文件。
和 Skill 版怎么选:
/cn-law-hub 调用,或需要下载原文、批量采集等完整工作流 —— 这是主路径。pip install "mcp>=2.0.0"
python3 scripts/mcp_server.py # 启动 stdio server(等待 MCP 客户端连接)
pip install "mcp>=2.0.0"
python3 scripts/mcp_server.py # 启动 stdio server(等待 MCP 客户端连接)
Claude Code 会自动读取仓库根目录的 .mcp.json,打开项目即接入;
其他 agent 的配置见 references/mcp_setup.md。
提供 5 个工具:
| 工具 | 说明 |
|---|---|
search_laws(source, keyword, category?, size?) |
统一搜索 10 个数据源 |
get_law_detail(source, url) |
拉取单条记录详情 |
query_article(bbbs_id, query?, grep?) |
按条号/关键词查单部法律法条 |
preview_law(bbbs_id) |
预览法律结构(条数 / 编号格式 / 前 20 条) |
article_search(keyword, law_keyword?, max_laws?, context?) |
跨法规法条级搜索 |
cn-law-hub/
├── SKILL.md # 给 agent 看的 skill 主文档
├── README.md # 本文件
├── CHANGELOG.md # 更新日志
├── LICENSE # Apache License 2.0 全文
├── NOTICE # 版权与贡献者声明(Apache-2.0 要求)
├── CITATION.cff # 机器可读引用信息
├── requirements.txt # Python 依赖
├── requirements-dev.txt # 开发依赖(测试/覆盖率)
├── pytest.ini # pytest 配置
├── .mcp.json # Claude Code MCP 配置(可选,MCP 接入用)
├── scripts/
│ ├── common/ # 共享工具包
│ │ ├── __init__.py # 统一导入与向后兼容别名
│ │ ├── cache.py # 缓存管理
│ │ ├── chinese_numerals.py # 中文数字转换
│ │ ├── cli_utils.py # CLI 参数辅助
│ │ ├── constants.py # 全局常量
│ │ ├── docx_utils.py # DOCX 解析与法条提取
│ │ ├── file_io.py # 文件读写
│ │ ├── logger.py # 日志
│ │ ├── ratelimit.py # HTTP 客户端与智能限速
│ │ └── text_utils.py # 文本清洗与工具函数
│ ├── download.py # NPC 搜索、下载、导出 URL、预览/查询法条
│ ├── article_search.py # NPC 跨法规法条级关键词搜索
│ ├── gov_rules_crawler.py # 国家规章库爬虫
│ ├── treaty_crawler.py # 外交条约库爬虫
│ ├── gov_policy_library.py # 国务院政策文件库
│ ├── moj_law_crawler.py # 司法部行政法规库
│ ├── party_law_crawler.py # 党内法规库 (12371.cn)
│ ├── mod_law_crawler.py # 国防部法规文