How Design Patent Disclosures Are Generated in the *patent-disclosure-skill* Repository

Design patent disclosures are generated through a six-stage pipeline that validates design briefs against a strict schema, selects between existing line-art, image-to-image, or text-to-image generation modes, and assembles final markdown and Word documents while enforcing a strict prohibition against including CAD diagrams.

The patent-disclosure-skill repository implements a deterministic workflow for transforming raw design materials—CAD files, reference photos, and textual specifications—into complete disclosure documents. This system orchestrates the entire process through specialized Python tools that enforce scoring thresholds and content policies. Understanding how design patent disclosures are generated requires tracing the pipeline from source collection through final document assembly.

Stage 1: Collecting Source Material and Figure Plans

The process begins in the case directory, where a figure_plan.yaml (or .json) file catalogs every figure extracted during the patent search phase. Each entry in this plan carries a kind attribute—such as photo_clean, cad, or lineart—and a role designation indicating whether it was rejected or accepted.

In skills/patent-disclosure/tools/image_gen.py, the function load_plan reads this configuration, while pick_design_photos and pick_sources filter the available assets. The system also invokes qualified_lineart to identify any existing line-art files that meet quality thresholds. Only materials passing these initial filters proceed to the validation stage.

Stage 2: Validating the Design Line-Art Brief

Before generation begins, the system validates the design_lineart_brief.yaml file against the schema defined in design_lineart_brief.schema.yaml. This brief specifies the overall shape, the faces to be claimed, and any prohibited elements that must be excluded from the final output.

The run_check function in skills/patent-disclosure/tools/design_lineart_gate.py orchestrates this validation, calling validate_brief to ensure all required fields are present and that referenced images actually exist on disk. If validation fails, the function returns a list of specific errors; if successful, the pipeline proceeds to mode selection.


# Example: Validate a design line-art brief

from skills.patent_disclosure.tools.design_lineart_gate import run_check, parse_enabled
from pathlib import Path

case_dir = Path("outputs/example_case")
enabled = parse_enabled(cli_flag=False, skip=False)
result = run_check(case_dir, enabled=enabled)
if result["ok"]:
    print("Brief is valid")
else:
    print("Errors:", result["errors"])

Stage 3: Deciding the Generation Mode

The planner module evaluates three possible line-art sources using the decide_mode function in image_gen.py. This function returns a JSON decision object containing the selected mode, any fallback options, and policy flags such as cad_never_in_disclosure.

The selection hierarchy follows this priority:

  • Existing qualified line-art – Used when available files score ≥ 70 % (the MIN_LINEART_SCORE threshold).
  • Image-to-image (img2img) – Triggered when reference images exist and meet the minimum source score of ≥ 50 % (MIN_SOURCE_SCORE).
  • Text-to-image (txt2img) – Deployed as a fallback when no qualified reference images are available.

Critically, the system flags CAD diagrams as "material only" through the cad_never_in_disclosure flag. These files are excluded from the disclosure entirely and never used as line-art.


# Example: Decide the generation mode for a case directory

from skills.patent_disclosure.tools.image_gen import load_plan, decide_mode
from pathlib import Path

case_dir = Path("outputs/example_case")
plan = load_plan(case_dir)                # reads figure_plan.yaml / .json

decision = decide_mode(plan, case_dir)    # returns mode, fallback, etc.

print(decision["mode"])                  # → "existing_lineart" | "img2img" | "txt2img"

Stage 4: Building the Line-Art Jobs

Once the mode is determined, the system constructs a job record for each view defined in the brief. The build_jobs function in design_lineart_gate.py (coordinated with attach_job_mode in image_gen.py) assembles the following for each view:

  • Resolved source image paths (source_paths).
  • A generated prompt embedding the product name, overall shape, and specific design points.
  • The intended output path (lineart_assist/<view>_lineart.png).

These job specifications are serialized to lineart_assist/design_lineart_jobs.json, which serves as the instruction set for the host image-generation service.


# Example CLI: Prepare line-art jobs after a successful validation

python tools/design_lineart_gate.py \
    --case-dir outputs/example_case \
    --prepare-jobs

# Produces: outputs/example_case/lineart_assist/design_lineart_jobs.json

Stage 5: Rendering Line-Art via the Host

The actual rendering is delegated to an external host LLM or image-generation service. The host reads design_lineart_jobs.json and executes according to the gen_mode field:

  • Existing line-art files are copied directly without modification.
  • Img2img processing uses the provided reference images as structural guides.
  • Txt2img generation creates new line-art from the embedded text prompts when no references exist.

All outputs are forced to black-and-white line art. The system explicitly prohibits color, logos, and internal structures in the final images.

Stage 6: Assembling the Final Disclosure Document

In the final stage, the system aggregates all approved visual assets into publication formats. The design_photos_in_disclosure logic automatically embeds clean product photos (photo_clean kind) into the output when the patent type is design.

The assembly process invokes:

The final deliverables include disclosure.md and disclosure.docx, both containing the validated line-art and photography but strictly excluding any CAD source files.

Key Constraints and Scoring Thresholds

The repository enforces strict policies to ensure compliance with design patent standards:

  • CAD Exclusion – CAD diagrams are tagged cad_never_in_disclosure and treated as "material only." They are never embedded in the disclosure or converted to line-art (see decide_mode in image_gen.py, lines 8‑10).
  • Quality Thresholds – Existing line-art must score ≥ 70 % (MIN_LINEART_SCORE), while source reference images require ≥ 50 % (MIN_SOURCE_SCORE). These checks are implemented in is_qualified_existing_lineart and is_source_candidate.

Summary

  • The pipeline requires a valid figure_plan.yaml listing all source images and a design_lineart_brief.yaml defining the design views and constraints.
  • Three generation modes are supported: existing line-art, img2img, and txt2img, selected automatically based on file availability and quality scores.
  • CAD files are strictly prohibited from appearing in final disclosures, while clean product photos (photo_clean) are automatically embedded for design patents.
  • The system outputs both markdown and Word documents via md_to_docx.py and mermaid_render.py, with all line-art rendered in black-and-white without logos or internal structures.

Frequently Asked Questions

Why are CAD diagrams excluded from design patent disclosures?

According to the source code in image_gen.py, CAD diagrams are flagged with cad_never_in_disclosure and treated exclusively as "material only" references. This policy ensures that the final disclosure contains only polished line-art suitable for patent submission, avoiding the technical clutter and perspective distortions common in raw CAD exports.

What score thresholds determine if an image can be used in the disclosure?

The system enforces a 70% minimum score (MIN_LINEART_SCORE) for existing line-art to be used directly, and a 50% minimum score (MIN_SOURCE_SCORE) for reference images to qualify as img2img candidates. These thresholds are checked in the is_qualified_existing_lineart and is_source_candidate functions within the image generation tools.

How does the system choose between img2img and txt2img generation?

The decide_mode function evaluates availability in a strict hierarchy: it first checks for existing qualified line-art (≥ 70% score), then falls back to img2img if reference photos exist and meet the 50% threshold, and finally resorts to txt2img only when no suitable reference images are available. This decision is recorded in the mode field of the JSON decision object.

What files are required to initiate the design patent disclosure workflow?

The pipeline requires two primary configuration files in the case directory: figure_plan.yaml (or .json) listing all figures with their kinds and roles, and design_lineart_brief.yaml specifying the design views, overall shape, and prohibited elements. The brief must validate against design_lineart_brief.schema.yaml before job generation can proceed.

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 →