How to Generate a Patent Disclosure Document Using the patent-disclosure-skill

The patent-disclosure-skill generates complete patent disclosure documents through an eight-step pipeline that collects case metadata, scans project files, mines patentable points, searches prior art, previews content, builds the final draft, and performs automated self-checks to produce timestamped Markdown and Word outputs.

The handsomestWei/patent-disclosure-skill repository provides an automated framework for generating patent disclosure documents from raw technical materials. This open-source skill orchestrates a structured workflow that transforms scattered project artifacts into professionally formatted disclosure documents suitable for patent attorneys. The entire process is coordinated through the master skills/patent-disclosure/SKILL.md file, which declares the execution sequence and dependencies for each stage of document generation.

The 8-Step Patent Disclosure Generation Pipeline

The skill implements a linear pipeline where each step corresponds to a specific prompt file. The AgentSkills interface (invoked via commands like /交底书) executes these prompts in strict order, reading each module via the Read tool.

Step 1 – Intake and Case Configuration

The pipeline begins with skills/patent-disclosure/prompts/intake.md. This module collects essential case metadata including the project path, patent type (invention, utility model, or design), document title, and contact information. The intake step establishes the working directory and validates that all required inputs are present before proceeding to material analysis.

Step 2 – Project Material Scanning

Next, skills/patent-disclosure/prompts/project_scan.md recursively reads the supplied source materials. The scanner processes heterogeneous file types—including .docx, .pptx, and source code—and normalizes them into Markdown format for downstream analysis. This conversion ensures that technical content from disparate formats can be uniformly processed by the patent-point mining algorithms.

Step 3 and 4 – Patent-Point Mining

These steps extract and consolidate protectable technical features. The logic branches based on patent type:

Step 3 extracts candidate points, while Step 4 merges them into the final set of protectable features specific to the selected patent category.

The skill executes a lightweight prior-art search via skills/patent-disclosure/prompts/prior_art_search.md. This module performs a "one-word-per-page" search against the CNIPA EPUB database, falling back to web search when necessary. The search results populate Chapter 1 of the disclosure document, establishing the technical background and distinguishing the invention from existing solutions.

Step 6 – Disclosure Preview

Before final rendering, skills/patent-disclosure/prompts/disclosure_preview.md generates a concise preview of the assembled disclosure. This step presents the document structure, key technical points, and prior art references to the user for approval or revision requests, preventing costly re-rendering cycles.

Step 7 – Disclosure Builder

The builder modules render the final Markdown draft according to type-specific templates:

This step creates the timestamped filename following the convention {案件名}_YYYYMMDDHHmmss.md and prepares Mermaid diagram blocks for technical flowcharts and architecture diagrams.

Step 8 – Self-Check and Validation

Finally, skills/patent-disclosure/prompts/disclosure_self_check.md runs internal validation checks. The module verifies formula consistency, cross-section coherence, and structural integrity. If discrepancies are detected, the skill automatically applies corrections; otherwise, it finalizes the document and saves the output to the case directory.

Rendering Diagrams and Exporting to Word

After the Markdown draft is generated, two specialized utilities convert the document into presentation formats.

Converting Mermaid Diagrams to PNG

The tools/mermaid_render.py script processes fenced Mermaid diagram blocks within the Markdown file. Using Playwright (wrapped in tools/browser.py), the renderer converts diagram definitions into high-resolution PNG images. This ensures that technical illustrations appear correctly in the final deliverables.

python skills/patent-disclosure/tools/mermaid_render.py \
    -i outputs/example_case/draft.md \
    -o "outputs/example_case/我的发明_$(date +%Y%m%d%H%M%S).md"

Generating the Final Word Document

The tools/md_to_docx.py utility transforms the validated Markdown into a .docx file, preserving the original Mermaid source blocks while applying professional formatting suitable for legal review.

python skills/patent-disclosure/tools/md_to_docx.py \
    -i "outputs/example_case/我的发明_20240904123045.md" \
    -o "outputs/example_case/我的发明_20240904123045.docx"

Automating the Pipeline Programmatically

You can drive the entire workflow programmatically without interactive Agent sessions. The Python entry point accepts parameters for project path, output directory, and patent type.

import os
import subprocess
import shlex

# 1. Establish the case working directory

case_dir = "outputs/automated_case"
os.makedirs(case_dir, exist_ok=True)

# 2. Execute the full disclosure pipeline

def run_skill(command: str):
    subprocess.run(shlex.split(command), check=True)

run_skill(
    "python -m skills.patent-disclosure.main "
    "--project-path ./technical_materials "
    f"--output-dir {case_dir} "
    "--type invention"
)

This command sequence produces two artifacts:

  • 我的发明_YYYYMMDDHHmmss.md – The complete disclosure with Mermaid source blocks
  • 我的发明_YYYYMMDDHHmmss.docx – The Word document ready for attorney submission

Summary

  • The eight-step pipeline is defined in skills/patent-disclosure/SKILL.md and executes sequentially from intake through self-check
  • Patent-type-specific prompts handle the distinct requirements of invention, utility model, and design patents through dedicated analyzer and builder modules
  • Prior-art search integrates with the CNIPA EPUB database to populate technical background sections automatically
  • Timestamped filenames follow the {案件名}_YYYYMMDDHHmmss.md convention to ensure version control and audit trails
  • Rendering tools (mermaid_render.py and md_to_docx.py) convert technical diagrams and produce attorney-ready Word documents

Frequently Asked Questions

What file formats can the skill scan during project analysis?

The project scanner in skills/patent-disclosure/prompts/project_scan.md recursively processes Microsoft Word documents (.docx), PowerPoint presentations (.pptx), and raw source code files. It normalizes all content into Markdown to enable uniform patent-point mining across heterogeneous technical artifacts.

How does the skill differentiate between invention, utility model, and design patents?

The pipeline branches at Steps 3–4 and Step 7 using type-specific prompt files located in skills/patent-disclosure/prompts/invention/, utility_model/, and design/ subdirectories. Each patent type employs distinct analytical logic for extracting protectable features and applies specialized templates during the disclosure building phase.

What naming convention does the skill use for generated documents?

The disclosure builder enforces a strict timestamped naming convention: {案件名}_YYYYMMDDHHmmss.md (and corresponding .docx). This format incorporates the case name and precise generation timestamp to prevent filename collisions and maintain clear version history throughout the patent application lifecycle.

Can the entire disclosure generation process be automated without manual intervention?

Yes. The skill exposes a Python command-line interface via skills.patent-disclosure.main that accepts --project-path, --output-dir, and --type arguments. Combined with the self-check validation in Step 8, the pipeline can run unattended from material ingestion through final Word document generation, producing attorney-ready deliverables programmatically.

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 →