This 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: bash
python --version
Use python or python3 based on availability.
The knowledge base path defaults to: text
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.
bash
python scripts/kb_query.py search <keyword> [--mode fuzzy|exact] [--limit N]
ParameterDescriptionDefaultkeywordSearch term (standard number, title fragment, etc.)Required--mode``fuzzy (LIKE match) or exact (equality)fuzzy``--limitMaximum results20
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.
bash
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:
bash
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.
bash
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.
bash
python scripts/kb_query.py clauses <regulation_id> [--filter <keyword>]
stats)Overview of knowledge base contents.
bash
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).
bash
python scripts/kb_query.py schema
conflicts) ⭐ ImportantDetect potential data quality issues:
bash
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 textSkillRolesafety-kb-query (this one)Query/read operations onlysafety-kb-importImport/write new regulations into the databasestandard-update-coursewareUpdate training courseware based on standard changes
ErrorCauseSolutionDatabase not foundWrong path or DB movedCheck DEFAULT_DB_PATH or set KB_PATH env varno such columnDB schema changedRun schema command to see actual columnsEmpty search resultsKeyword too specific or not in DBTry --mode fuzzy with shorter keywordsGarbled outputTerminal encoding issuePipe output through chcp 65001 (Windows) or redirect to file