Code-to-Skill: Building Regulation Converter for Openclaw

Convert building-code PDFs and regulations into auditable, searchable AI skills with indexed clauses, preserved legal wording, structured tables, and cross-standard references.

51comic
v1.0.4
Aug 11, 2026
1
55
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install code-to-skill

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install code-to-skill using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Code-to-Skill: Building Regulation Converter?

Code-to-Skill transforms architectural standards, Chinese GB specifications, industry procedures, and legal regulations into structured, queryable AI skills. Instead of summarizing regulatory text, it indexes every numbered clause by trigger conditions, requirement type, keywords, and related provisions.

The workflow preserves the original force of regulatory language, including mandatory, recommended, permitted, and prohibited wording such as 应, 宜, 可, 不应, and 不得. It also extracts decision-making tables into JSON, generates Markdown for agent-readable documentation, and builds cross-reference maps for connected standards. Openclaw Skills users can use the generated skill for design review, compliance research, and targeted clause lookup without loading an entire regulation into context.

Code-to-Skill: Building Regulation Converter Use Cases

  • Convert a GB 50xxx building standard or fire-protection regulation PDF into an AI skill.
  • Search directly for a numbered clause such as 5.5.21 or a topic such as fire separation distance or egress width.
  • Support architectural design, engineering review, plan checking, construction reference, and compliance research.
  • Extract fire-resistance, separation-distance, occupancy, egress, and other regulatory tables as machine-readable JSON.
  • Map internal references and citations to external standards such as other GB specifications.
  • Analyze a regulation before generation when users need a structure, cost, and scope report first.
  • Update an existing regulation skill with local supplements, explanatory notes, or a newer edition.
  • Build regulation knowledge bases for Openclaw Skills while retaining version and source metadata.

How Code-to-Skill: Building Regulation Converter Works

  1. Validate the input PDF path and optional regulation slug; if no PDF is provided, stop and request the source document rather than inventing regulatory content.
  2. Confirm regulation metadata, including the identifier, edition, issuing body, explanatory notes, and intended use case.
  3. Locate the shared book-to-skill extraction engine and extract the PDF into full_text.txt plus metadata.json using text mode.
  4. Estimate pages, characters, tokens, clause count, tables, and external references, then request confirmation before full conversion.
  5. For regulations larger than 50k tokens, inspect and process the extracted text in sections using clause-number and table-pattern searches.
  6. Analyze the document structure, chapters, appendices, numbered clauses, tables, and references to other standards.
  7. Confirm whether to process the entire regulation, selected chapters, or topic-filtered content.
  8. Create a regulation-specific directory using a slug such as gb-50016-2018, with separate clauses and tables directories.
  9. Generate clause Markdown files containing the verbatim source text, force-level labels, trigger-condition explanations, related clauses, table links, and search keywords.
  10. Extract every identified table into both Markdown and JSON, including columns, rows, units, notes, source sections, and referencing clauses.
  11. Generate the master SKILL.md, clause index, mandatory-force map, terminology file, and cross-reference graph for targeted agent retrieval.
  12. Run the shared security scan and mandatory-force audit, verify random clauses against the extracted source, confirm referenced tables exist, clean temporary files, and report the generated artifacts.
  13. For updates, read the existing indexes, merge local supplements or version changes without silently overwriting the original structure, and repeat the audit.

Code-to-Skill: Building Regulation Converter Setup

Install the required PDF extraction dependency before using the converter:

openclaw skills install book-to-skill

Locate the shared extraction script in the workspace or supported agent skill directories, then run it against the regulation PDF:

python3 <path-to-extract.py> <path-to-regulation.pdf> --mode text --install-missing ask

The extractor produces a working directory containing book_skill_work/full_text.txt and metadata.json. Confirm the extracted metadata before generating the skill. The expected invocation is:

code-to-skill <path-to-regulation.pdf> [regulation-slug]

For OpenClaw, generated skills are placed under <workspace>/skills/<REGULATION_SLUG>/. Create the output directories when needed:

mkdir -p "$SKILLS_HOME/<REGULATION_SLUG>/clauses"
mkdir -p "$SKILLS_HOME/<REGULATION_SLUG>/tables"

After generation, run the shared scanner from the book-to-skill installation:

python3 <book-to-skill-directory>/tools/scan_generated_skill.py <generated-regulation-skill-directory>

Clean temporary extraction artifacts after validation:

rm -rf /tmp/book_skill_work

The skill is also designed to work with compatible roots used by GitHub Copilot CLI and Claude Code, including ~/.agents/skills and ~/.claude/skills. A valid source PDF is required; a regulation number alone is not sufficient.

Code-to-Skill: Building Regulation Converter Data Schema & Taxonomy

The generated regulation skill follows a predictable, retrieval-oriented file taxonomy:

Path Purpose
SKILL.md Master metadata, usage instructions, clause index, chapter overview, force distribution, table index, references, and limitations.
clause-index.md Complete index of numbered clauses, topics, force levels, and trigger keywords.
clauses/chNN-*.md Chapter-grouped clause files containing verbatim regulatory text and metadata.
tables/<table-id>.md Human-readable table with source, applicability, references, notes, and usage guidance.
tables/<table-id>.json Programmatic table representation for structured queries and downstream automation.
cross-refs.md Internal clause links, external standard references, and optional inbound references.
mandatory-map.md Matrix of mandatory, prohibited, recommended, and permitted requirements.
terminology.md Definitions and terminology extracted from the regulation.
supplements/ Optional local-standard additions and documented differences.
version-history.md Optional record of revisions and edition changes.

Each clause records its source number, original text, force level, trigger conditions, related clauses, linked tables, and searchable keywords. Force labels distinguish or 必须 as Shall, 不应 as Shall Not, 不得 or 严禁 as Must Not, as Should, 不宜 as Should Not, and as May. Explanatory notes are stored separately and explicitly marked as non-mandatory guidance.

Table JSON uses fields such as table_id, description, source, columns, rows, referenced_by, notes, and units. Regulation metadata includes the regulation identifier, edition, issuing authority, explanatory-note availability, intended use case, scope, estimated size, clause count, table count, and external standards cited.

Code-to-Skill: Building Regulation Converter Advanced Features

  • Full conversion, analyze-only, and update or supplement operating modes.
  • Trigger-based retrieval by natural-language topic, clause number, or table identifier.
  • Exact preservation and per-subclause tagging of mandatory legal force wording.
  • Separate handling of explanatory notes so interpretive material is not confused with enforceable requirements.
  • Large-regulation processing with token estimation and REPL-style text segmentation for documents over 50k tokens.
  • Dual Markdown and JSON table output for human review and programmatic querying.
  • Internal and external cross-reference graphs connecting clauses to other standards.
  • Lazy-loading architecture that keeps the master SKILL.md concise and loads clause files on demand.
  • Version-aware updates, local-standard supplements, and documented merge behavior.
  • Security scanning through the shared book-to-skill tooling.
  • Mandatory-force audits that compare generated clauses with source text, verify one force label per clause, sample-check verbatim accuracy, and validate table links.
  • Compatible skill-root conventions for OpenClaw, GitHub Copilot CLI, and Claude Code.
  • Designed for Openclaw Skills workflows while maintaining clear warnings that the generated reference tool does not replace professional architectural or engineering judgment.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*