Install
openclaw skills install @cyz9827/safety-kb-query安全生产法规知识库查询工具。当用户需要查标准是否存在、搜索法规、对比标准清单、查看条款内容、统计知识库规模、检查数据质量时使用。触发词:查知识库、搜法规、标准存在吗、对比标准、查条款、KB查询、safety-review、法规检索、标准时效、数据质量检查
openclaw skills install @cyz9827/safety-kb-queryThis skill provides unified, schema-adaptive query access to the safety-review knowledge base (SQLite database). It eliminates the need to manually write connection scripts, guess field names, or handle encoding issues every time.
Database location: ~/.openclaw-autoclaw/skills/safety-review/db/knowledge.db
safety-review SQLite databaseTrigger phrases (Chinese): 查知识库、搜法规、标准有没有、对比标准、查条款、数据质量、法规检索
Detect available Python command first:
python --version
Use python or python3 based on availability.
The knowledge base path defaults to:
C:\Users\13503\.openclaw-autoclaw\skills\safety-review\db\knowledge.db
Override via environment variable KB_PATH if needed.
All commands are executed via scripts/kb_query.py. Output is JSON for programmatic consumption.
search)Find regulations matching a keyword across multiple fields.
python scripts/kb_query.py search <keyword> [--mode fuzzy|exact] [--limit N]
| Parameter | Description | Default |
|---|---|---|
keyword | Search term (standard number, title fragment, etc.) | Required |
--mode | fuzzy (LIKE match) or exact (equality) | fuzzy |
--limit | Maximum results | 20 |
Example scenarios:
search GB16423search 紧急避险search "AQ/T 2033-2023" --mode exactcheck) ⭐ Most UsefulGiven a list of standards, report which exist and which are missing — the primary gap analysis tool.
python scripts/kb_query.py check <standard1> <standard2> <standard3> ...
Output fields per result:
found: booleanid: regulation ID (if found)document_number: stored document numbertitle: regulation title (truncated)status: current statustext_length: character count of full_textclause_count: number of associated clausesExample:
python scripts/kb_query.py check "GB 16423" "AQ/T 2033" "AQ 2034" "国发[2010]23号"
info)Get comprehensive info about a specific regulation by ID.
python scripts/kb_query.py info <regulation_id>
Returns all columns from regulations table + clause count + linked std_registry entry (if any).
clauses)Retrieve clauses of a regulation, with optional filtering.
python scripts/kb_query.py clauses <regulation_id> [--filter <keyword>]
stats)Overview of knowledge base contents.
python scripts/kb_query.py stats
Returns: total regulations, total clauses, total books, status breakdown, domain distribution.
schema)Auto-detect and print table structures (useful when DB schema changes).
python scripts/kb_query.py schema
conflicts) ⭐ ImportantDetect potential data quality issues:
python scripts/kb_query.py conflicts
When user provides a document that references standards and asks "which ones are missing":
check command with the extracted listconflicts for deeper analysissafety-kb-import)search with user's keywordsinfo to get details on relevant entriesclausessafety-kb-import for writing--mode exact when possibleclauses command truncates content to 200 chars for readability; use info to get full text| Skill | Role |
|---|---|
safety-kb-query (this one) | Query/read operations only |
safety-kb-import | Import/write new regulations into the database |
standard-update-courseware | Update training courseware based on standard changes |
| Error | Cause | Solution |
|---|---|---|
Database not found | Wrong path or DB moved | Check DEFAULT_DB_PATH or set KB_PATH env var |
no such column | DB schema changed | Run schema command to see actual columns |
| Empty search results | Keyword too specific or not in DB | Try --mode fuzzy with shorter keywords |
| Garbled output | Terminal encoding issue | Pipe output through chcp 65001 (Windows) or redirect to file |