How the Patent-Application Sub-Skill Converts Disclosure Documents into Patent Application Sets

The patent-application sub-skill converts disclosure documents into patent application sets through a six-stage pipeline that validates inputs, generates figures, audits claims, checks support, and produces Word documents for filing.

This conversion system is part of the handsomestWei/patent-disclosure-skill repository. The patent-application sub-skill takes completed disclosure outputs (交底 files) and transforms them into the four-part package required for Chinese patent filing: 权利要求书 (claims), 说明书 (description), 说明书摘要 (abstract), and 说明书附图 (drawings).

The Four-Part Patent Application Output

Each conversion produces these deliverables:

Part Source Format Output Format
权利要求书 (claims) 权利要求书.md 权利要求书.docx
说明书 (description) 说明书.md 说明书.docx
说明书摘要 (abstract) 说明书摘要.md 说明书摘要.docx
说明书附图 (drawings) 说明书附图.md (optional) 说明书附图.docx (if present)

The pipeline generates black-and-white SVG/PNG figures alongside these documents.

Stage 1: Material Gating with material_gate.py

The patent-application conversion begins with validation. The material_gate.py script in skills/patent-application/tools/ verifies that all required disclosure artifacts exist before any processing starts.

It checks for:

On failure, the script exits with code 2 and prints a machine-readable status line:

APPLICATION_GATE: ok=0 type=- missing=disclosure

Success yields APPLICATION_GATE: ok=1, allowing the pipeline to continue.

Stage 2: Figure Generation Pipeline

Two scripts handle patent-application figure production from the YAML figure plan:

render_invention_figures.py

Reads figure_plan.yaml and generates SVG files for embedding:

python skills/patent-application/tools/render_invention_figures.py \
    --plan outputs/patent-application/{case}/figures/invention_figures.yaml \
    --out-dir outputs/patent-application/{case}/figures

Outputs APPLICATION_FIG status lines indicating success or failure.

compose_application_figure.py

Merges line-art sources with rendered figures for custom compositions:

python skills/patent-application/tools/compose_application_figure.py \
    --source <lineart_or_scene> --fig 3 \
    --out-dir outputs/patent-application/{case}/figures

Both scripts reside in skills/patent-application/tools/ and emit parseable status output for automation.

Stage 3: Claims Structural Audit with audit_claims.py

The patent-application sub-skill validates claim structure before conversion. The audit_claims.py script parses the claims Markdown and checks:

  • Numbered claim block validity
  • Sequential numbering without gaps
  • Claim 1 does not reference later claims (no forward references)
  • Absence of promotional language

Execution:

python skills/patent-application/tools/audit_claims.py \
    outputs/patent-application/{case}/权利要求书.md

Output format:

APPLICATION_CLAIMS: ok=1 errors=0 warnings=2

Stage 4: Support Verification with check_support.py

Every claim must have supporting material. The check_support.py script in skills/patent-application/tools/ walks the output directory to verify each claim links to at least one figure or description excerpt:

python skills/patent-application/tools/check_support.py \
    --dir outputs/patent-application/{case}

Missing support triggers an APPLICATION_SUPPORT error line. The tool ensures patent-application outputs meet enablement requirements.

Stage 5: Markdown-to-Word Conversion with emit_application_docx.py

The final patent-application stage converts all Markdown parts to Word documents. The emit_application_docx.py script uses an internal md_to_docx.py wrapper around the Python-Docx library:

python skills/patent-application/tools/emit_application_docx.py \
    --dir outputs/patent-application/{case}

Individual conversions emit:

DOCX: ok=1 path=outputs/patent-application/{case}/权利要求书.docx

Final summary line:

APPLICATION_DOCX: ok=1 written=4 failed=0

Python API for Single-File Conversion

For programmatic use, import directly from the tool:

from pathlib import Path
from skills.patent_application.tools.emit_application_docx import emit_one

md_path = Path("outputs/patent-application/my_case/说明书.md")
docx_path = emit_one(md_path, prefer_omml=True)
print(f"Converted {md_path} → {docx_path}")

Complete Pipeline Execution

The patent-application sub-skill has no single orchestrator script. Run tools sequentially per the sub-skill README:


# 1. Validate disclosure completeness

python skills/patent-application/tools/material_gate.py \
    --case-dir outputs/my_case

# 2. Generate figures from plan

python skills/patent-application/tools/render_invention_figures.py \
    --plan outputs/patent-application/my_case/figures/invention_figures.yaml \
    --out-dir outputs/patent-application/my_case/figures

# 3. Audit claim structure

python skills/patent-application/tools/audit_claims.py \
    outputs/patent-application/my_case/权利要求书.md

# 4. Verify claim support

python skills/patent-application/tools/check_support.py \
    --dir outputs/patent-application/my_case

# 5. Compose custom figure (optional)

python skills/patent-application/tools/compose_application_figure.py \
    --source assets/lineart.svg --fig 3 \
    --out-dir outputs/patent-application/my_case/figures

# 6. Produce final Word documents

python skills/patent-application/tools/emit_application_docx.py \
    --dir outputs/patent-application/my_case

Each step prints machine-readable status lines (APPLICATION_* or DOCX:) for downstream automation decisions.

Key Implementation Files

File Purpose Location
material_gate.py Disclosure validation gate skills/patent-application/tools/
render_invention_figures.py SVG figure generation from YAML plan skills/patent-application/tools/
compose_application_figure.py Custom figure composition skills/patent-application/tools/
audit_claims.py Claim structure validation skills/patent-application/tools/
check_support.py Claim-to-support verification skills/patent-application/tools/
emit_application_docx.py Markdown-to-Word conversion orchestrator skills/patent-application/tools/
md_to_docx.py Core conversion library (Python-Docx wrapper) skills/patent-application/tools/
README.md Usage documentation for the sub-skill skills/patent-application/

Summary

The patent-application sub-skill converts disclosure documents into patent application sets through:

  • Material gating that validates all required inputs exist before processing
  • Figure generation from YAML plans into SVG/PNG outputs
  • Claims auditing that enforces structural rules and numbering validity
  • Support checking ensuring every claim has enabling disclosure
  • Document conversion producing Word files ready for filing

Each stage emits parseable status output, making the pipeline suitable for integration with automation systems that need to halt on validation failures.

Frequently Asked Questions

What file formats does the patent-application sub-skill accept as input?

The patent-application sub-skill accepts Markdown (*.md) and Word (*.docx) disclosure files, plus YAML schema files (structure_schema.yaml, appearance_schema.yaml) and a figure_plan.yaml for figure generation. The material_gate.py script validates these inputs before any conversion begins.

Can I run individual stages without executing the full pipeline?

Yes. Each tool in skills/patent-application/tools/ operates independently. You can run audit_claims.py alone to validate claims, or emit_application_docx.py alone if inputs are already verified. The modular design supports targeted debugging and partial re-runs.

What happens if a claim references a figure that doesn't exist?

The check_support.py script detects this during Stage 4 and outputs an APPLICATION_SUPPORT error line. The pipeline does not auto-generate missing figures—you must resolve the discrepancy in the disclosure or figure plan before final document production.

How does the conversion handle mathematical formulas in Markdown?

The emit_application_docx.py script accepts a prefer_omml=True parameter that generates Office Math Markup Language for equations. This ensures formulas render correctly in the final Word documents required for patent filing.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →