safety-kb-query.

v1.0.0

安全生产法规知识库查询工具。当用户需要查标准是否存在、搜索法规、对比标准清单、查看条款内容、统计知识库规模、检查数据质量时使用。触发词:查知识库、搜法规、标准存在吗、对比标准、查条款、KB查询、safety-review、法规检索、标准时效、数据质量检查

0· 50·0 current·0 all-time

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for cyz9827/safety-kb-query.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "safety-kb-query." (cyz9827/safety-kb-query) from ClawHub.
Skill page: https://clawhub.ai/cyz9827/safety-kb-query
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install safety-kb-query

ClawHub CLI

Package manager switcher

npx clawhub@latest install safety-kb-query
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (safety KB query) match the implementation: the included script opens a local SQLite database and implements search, check, info, clauses, stats, schema, and conflicts commands. The declared functionality (read/query only) aligns with what the code does.
Instruction Scope
SKILL.md and the script instruct running the local Python CLI against a local DB path. The skill supports overriding the DB via KB_PATH env var (optional); the README default DB path uses a Windows-style path referencing user '13503' while the code uses a tilde-expanded path — minor inconsistency but not a functional mismatch. The script only reads local DB tables and does not reference external network endpoints or other system credentials.
Install Mechanism
No install spec or external downloads. The skill is instruction + a single Python script that runs on the host; nothing is written to disk by an installer and no external packages or URLs are fetched by the skill.
Credentials
No required environment variables or credentials are declared. The skill accepts an optional KB_PATH environment variable to point to the DB; this is reasonable but means the script will open whichever SQLite file path is provided. Users should avoid pointing KB_PATH to unrelated or sensitive databases (the script will read any SQLite file it can access).
Persistence & Privilege
always is false and the skill is read-only; it does not attempt to modify other skills or system-wide settings. Autonomous invocation is allowed (platform default) but the skill's actions are limited to reading the specified DB.
Assessment
This skill appears to do what it says: read-only queries against a local SQLite knowledge DB. Before installing, verify: 1) the database path the skill will use (DEFAULT_DB_PATH / KB_PATH) points to the correct knowledge.db and not to any unrelated or sensitive database; 2) inspect scripts/kb_query.py yourself (it's short and uses only sqlite3/os/json/no networking); 3) run the script in a restricted environment or with a copy of the DB if you want to be cautious; and 4) if you expect the DB on a non-Windows host, adjust the default path or set KB_PATH accordingly. If any of these checks raise concerns (e.g., KB_PATH already set to a secret DB), do not install or run the skill until corrected.

Like a lobster shell, security has layers — review code before you run it.

latestvk97dh6f49ejecyz7nn78dpzt4s85h646
50downloads
0stars
1versions
Updated 2d ago
v1.0.0
MIT-0

Safety KB Query — 安全生产法规知识库查询工具

Overview

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

When to Use This Skill

  • User asks about whether a standard/regulation exists in the knowledge base
  • User needs to search for regulations by keyword, number, or title
  • User wants to compare a list of standards against what's in the database (gap analysis)
  • User needs to view clause content of a specific regulation
  • User requests statistics or health checks on the knowledge base
  • Any task involving the safety-review SQLite database

Trigger phrases (Chinese): 查知识库、搜法规、标准有没有、对比标准、查条款、数据质量、法规检索

How to Use

Prerequisites

  1. Detect available Python command first:

    python --version
    

    Use python or python3 based on availability.

  2. 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.

Core Commands

All commands are executed via scripts/kb_query.py. Output is JSON for programmatic consumption.

1. Search Regulations (search)

Find regulations matching a keyword across multiple fields.

python scripts/kb_query.py search <keyword> [--mode fuzzy|exact] [--limit N]
ParameterDescriptionDefault
keywordSearch term (standard number, title fragment, etc.)Required
--modefuzzy (LIKE match) or exact (equality)fuzzy
--limitMaximum results20

Example scenarios:

  • "看看 GB16423 有没有" → search GB16423
  • "搜一下紧急避险相关的" → search 紧急避险
  • "精确查找 AQ/T 2033-2023" → search "AQ/T 2033-2023" --mode exact

2. Check Standard Existence (check) ⭐ Most Useful

Given 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: boolean
  • id: regulation ID (if found)
  • document_number: stored document number
  • title: regulation title (truncated)
  • status: current status
  • text_length: character count of full_text
  • clause_count: number of associated clauses

Example:

python scripts/kb_query.py check "GB 16423" "AQ/T 2033" "AQ 2034" "国发[2010]23号"

3. Regulation Details (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).

4. Query Clauses (clauses)

Retrieve clauses of a regulation, with optional filtering.

python scripts/kb_query.py clauses <regulation_id> [--filter <keyword>]

5. Database Statistics (stats)

Overview of knowledge base contents.

python scripts/kb_query.py stats

Returns: total regulations, total clauses, total books, status breakdown, domain distribution.

6. Schema Inspection (schema)

Auto-detect and print table structures (useful when DB schema changes).

python scripts/kb_query.py schema

7. Data Quality Check (conflicts) ⭐ Important

Detect potential data quality issues:

  • Empty content: Regulations with NULL or very short full_text (<100 chars)
  • No clauses: Regulations without any associated clause records
  • Title/doc_no mismatch: Document number suggests a topic but title doesn't match (e.g., ID:94 containing "粮油加工" instead of mining safety content)
python scripts/kb_query.py conflicts

Workflow Integration

Typical Gap Analysis Workflow (for courseware/training materials)

When user provides a document that references standards and asks "which ones are missing":

  1. Extract referenced standards from the user's document
  2. Run check command with the extracted list
  3. Present results as a table showing: ✅ Found / ❌ Missing / ⚠️ Data Issue
  4. If data issues found, run conflicts for deeper analysis
  5. Recommend next steps (import missing ones via safety-kb-import)

Typical Search Workflow

  1. Run search with user's keywords
  2. If results found, use info to get details on relevant entries
  3. If user needs clause-level detail, use clauses
  4. Present findings in readable format (table, summary)

Known Limitations

  • Read-only: This skill only queries; use safety-kb-import for writing
  • Encoding: Script uses UTF-8 output; ensure terminal supports it
  • Fuzzy search performance: On large databases (>2000 records), LIKE queries may be slower; use --mode exact when possible
  • Clause truncation: clauses command truncates content to 200 chars for readability; use info to get full text

Relationship with Other Skills

SkillRole
safety-kb-query (this one)Query/read operations only
safety-kb-importImport/write new regulations into the database
standard-update-coursewareUpdate training courseware based on standard changes

Troubleshooting

ErrorCauseSolution
Database not foundWrong path or DB movedCheck DEFAULT_DB_PATH or set KB_PATH env var
no such columnDB schema changedRun schema command to see actual columns
Empty search resultsKeyword too specific or not in DBTry --mode fuzzy with shorter keywords
Garbled outputTerminal encoding issuePipe output through chcp 65001 (Windows) or redirect to file

Version History

  • 1.0.0 (2026-04-25): Initial release with 7 commands (search, check, info, clauses, stats, schema, conflicts)

Comments

Loading comments...