Data Sources

SkillDev tools

For querying, retrieving, verifying, downloading, exporting, and bulk-collecting official Chinese laws, regulations, rules, treaties, and specific legal articles. Use this skill aggressively when the user asks to 查法律、查法规、查条例、查规章、查条约、查法条、查第几条、找法律依据、引用法律依据、核验现行有效、判断是否废止/已修改/尚未生效、下载法规全文、导出法规目录、批量下载法规文件

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the Data Sources skill

What this skill tells your AI

The instructions your AI receives, as published by zongziforu/cn-law-hub in SKILL.md and read by ahel’s review.

#DatabaseScriptSourceType
1国家法律法规数据库 (NPC)scripts/download.pyflk.npc.gov.cnJSON API
2国家规章库 (Gov Rules)scripts/gov_rules_crawler.pygov.cn/zhengce/xxgk/gjgzkAthena API + HTML
3外交条约库 (Treaty)scripts/treaty_crawler.pytreaty.mfa.gov.cnHTML
4国务院政策文件库scripts/gov_policy_library.pysousuo.www.gov.cnREST API (GET)
5司法部行政法规库scripts/moj_law_crawler.pyxzfg.moj.gov.cnHTML
6党内法规库scripts/party_law_crawler.pywww.12371.cnHTML
7国防部法规文库scripts/mod_law_crawler.pywww.mod.gov.cnHTTP
8税务法规库scripts/tax_law_crawler.pyfgk.chinatax.gov.cnREST API (POST)
9生态环境部法规规章scripts/mee_law_crawler.pymee.gov.cnHTML
10最高人民法院发布栏目scripts/court_law_crawler.pycourt.gov.cnHTML

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 --exact to reduce noise.
  • Broad topic (e.g. "出租车", "环境保护"): use fuzzy search (default).
  • Full-text match: add --range content when 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):

CodeMeaning
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:

CommandWhenOutput
--preview <id>Understand structure firstTitle, article count, TOC
--article <id> "第X条"Know the article numberSingle article text
--article <id> --grep "kw"Find articles by keyword in one lawAll 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

  1. Only state 现行有效, 已废止, 已修改, or 尚未生效 when the official page or API response explicitly provides that status.
  2. If the source has no explicit validity field, say: "官方页面未明确标注效力状态".
  3. Do not infer validity from file accessibility or recency of publication date.
  4. Always return: official URL, file type, issuing authority, publication date, and retrieval date — even when status is absent.
  5. For same-name / multi-version documents, flag the ambiguity and verify amendment, repeal, and effective-date information.
  6. Distinguish document types: 法律, 行政法规, 地方性法规, 规章, 司法解释, 司法文件, 党内法规, 政策文件, 通知, 案例, 条约. Do not conflate.
  7. 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

ScriptPurposeKey flagsOutput dir
scripts/download.pyNPC search, download, article, preview--search, --exact, --range, --status, --download, --article, --preview, --urls-onlystdout, files
scripts/article_search.pyCross-law article-level searchkeyword, --law, --range, --max-laws, --context, --json, --offset, --resumestdout
scripts/gov_rules_crawler.pyGov.cn rules--search, --categories, --download, --infogov_rules_output/
scripts/treaty_crawler.pyMFA treaties--search, --collections, --download, --infotreaty_output/
scripts/gov_policy_library.pyState Council policies--search, --range, --category, --yeargov_policy_output/
scripts/moj_law_crawler.pyMoJ admin regulations--search, --range, --statusmoj_law_output/
scripts/party_law_crawler.pyParty regulations (12371.cn)--search, --categoryparty_law_output/
scripts/mod_law_crawler.pyMOD law library--search, --categorymod_law_output/
scripts/tax_law_crawler.pyTax regulations (chinatax)--search, --categorytax_law_output/
scripts/mee_law_crawler.pyMEE env regulations--search, --categorymee_law_output/
scripts/court_law_crawler.pySPC announcements--search, --categorycourt_law_output/
scripts/region_classifier.pyProvince/city classification--classify, --matrixJSON/CSV

Each script has --help. Run it for detailed parameter lists.


Reference Files

Read these on demand, not proactively:

FileRead when...
references/setup.mdFirst run, dependency issues, or switching agent environments
references/api_reference.mdNeed full NPC API payloads, field mappings, auth, or pagination details
references/gov_rules_api_reference.mdGov Rules auth issues (401/403) or response field parsing
references/gov_policy_api_reference.mdNeed State Council API parameter details beyond --help
references/treaty_api_reference.mdTreaty HTML structure or field extraction patterns
references/page_structure.mdBrowser automation — page layout, selectors, UI-only search flow
references/kimi_bridge_adapter.mdRunning on Kimi Agent or Claude Code + kimi-webbridge
references/codex_adapter.mdRunning on Codex
references/batch_collection.mdLarge-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: ossFile paths 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.

Signals

GitHub stars
68
Forks
14
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
cn-law-hub
Source
github.com/zongziforu/cn-law-hub