# How Mode A (Disclosure Document Writing) Works in patent-disclosure-skill

> Learn how Mode A disclosure document writing works in patent-disclosure-skill. This automated workflow generates patent documents in Markdown and Word through a seven-stage pipeline.

- Repository: [handsomestWei/patent-disclosure-skill](https://github.com/handsomestWei/patent-disclosure-skill)
- Tags: how-to-guide
- Published: 2026-09-01

---

**Mode A (Disclosure Document Writing) is an automated workflow in the patent-disclosure-skill repository that generates complete patent disclosure documents in Markdown and Word formats through a seven-stage pipeline involving type selection, schema filling, figure planning, document building, compliance verification, and optional iteration.**

Mode A (Disclosure Document Writing) serves as the core document generation engine in the **handsomestWei/patent-disclosure-skill** open-source project. This workflow orchestrates LLM prompts and utility scripts to transform raw invention concepts into formal patent disclosure documents compliant with Chinese Patent Office standards. The system operates autonomously from intake through final output, handling directory creation, figure generation, and format conversion without requiring manual file manipulation.

## The Seven-Stage Mode A Workflow

The **Mode A (Disclosure Document Writing)** workflow follows a strictly defined seven-step pipeline implemented through structured prompts in the `prompts/disclosure/` directory.

### 1. Type Selection and Intake

The workflow initiates at **[`prompts/disclosure/intake.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/intake.md)**, where the system presents three patent types: **发明** (Invention), **实用新型** (Utility Model), and **外观设计** (Design). The intake prompt parses the user's selection and routes processing to the appropriate subdirectory. This routing determines which schema templates and builder prompts the system invokes for subsequent stages.

### 2. Schema Generation and Figure Planning

Depending on the selected type, the skill fills specialized schemas that define the invention's structure or appearance. For **实用新型** (Utility Model), the system executes **[`prompts/shared/fill_structure_schema.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/shared/fill_structure_schema.md)** to populate [`structure_schema.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/structure_schema.yaml). For **外观设计** (Design), it uses **[`prompts/shared/fill_appearance_schema.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/shared/fill_appearance_schema.md)** to generate [`appearance_schema.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/appearance_schema.yaml).

These schemas automatically generate a **[`figure_plan.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/figure_plan.yaml)** file that enumerates every figure intended for the disclosure. Each entry includes the flag `use_in_disclosure: true`, which controls figure inclusion. The **[`prompts/disclosure/project_scan.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/project_scan.md)** prompt manages this plan, ensuring **CAD entries** (`kind: cad`) are explicitly excluded from document insertion while allowing line-art and clean photos to proceed.

### 3. Document Construction and Building

The core generation phase relies on type-specific **disclosure builder** prompts located in `prompts/disclosure/{type}/disclosure_builder.md`. The builder assembles the full disclosure text section by section, referencing prepared figures via "如图 N" (as shown in Figure N) syntax.

The builder enforces strict editorial discipline:

- **Timestamp-based naming**: Files use the format `{案件名}_{YYYYMMDDHHmmss}.md`
- **Content restrictions**: No repository footnotes or meta-information allowed
- **Formatting consistency**: Mandatory LaTeX math delimiter compliance
- **Automatic Word conversion**: Integration with **[`tools/shared/md_to_docx.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/shared/md_to_docx.py)** to generate matching `.docx` files

### 4. Compliance Verification and Output

After generation, **[`prompts/disclosure/disclosure_self_check.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/disclosure_self_check.md)** executes a comprehensive validation checklist containing 30+ "禁止" (prohibition) rules. This self-check verifies:

- Absence of stray footnotes
- Correct formula formatting
- Proper figure referencing syntax
- Document structure compliance

Failed checks trigger automatic correction loops before the final output stage. Validated documents save to `outputs/{案件标识}/` with timestamped filenames, accompanied by a revision log named **`交底书修订对话记录.md`** and the Word document conversion.

### 5. Optional Iteration and Refinement

If users request modifications (e.g., strengthening claim sections), the workflow enters iterative refinement through **[`prompts/disclosure/merger.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/merger.md)** and **[`prompts/disclosure/correction_handler.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/correction_handler.md)**. These prompts read the latest draft, apply requested changes, and output new timestamped files while preserving previous versions in the revision history.

## Command-Line Implementation

While the skill automates these steps internally, developers can invoke individual Mode A stages manually:

```bash

# Create case directory structure

mkdir -p outputs/my_new_case

# Execute intake routing

python -m skill.run intake --case outputs/my_new_case

# Fill appropriate schema (utility model example)

python -m skill.run fill_schema --type utility_model --case outputs/my_new_case

# Generate figures (auto-triggered during build)

python -m skill.run image_gen --case outputs/my_new_case

# Build the disclosure document

python -m skill.run build_disclosure --case outputs/my_new_case

# Convert to Word format

python tools/shared/md_to_docx.py \
    -i outputs/my_new_case/案件名_20241015103000.md \
    -o outputs/my_new_case/案件名_20241015103000.docx

```

## Summary

- **Mode A (Disclosure Document Writing)** automates patent disclosure generation through seven distinct stages orchestrated by prompts in `prompts/disclosure/`.
- The workflow supports three patent types (Invention, Utility Model, Design) via type-specific schemas and builders.
- **CAD files** are automatically filtered from document insertion while line-art and photos marked `use_in_disclosure: true` are embedded.
- The system enforces strict formatting rules through **[`disclosure_self_check.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/disclosure_self_check.md)**, checking 30+ compliance criteria before finalizing output.
- All outputs use timestamp-based naming (`{案件名}_{YYYYMMDDHHmmss}.md`) and automatically generate companion Word documents via **[`tools/shared/md_to_docx.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/shared/md_to_docx.py)**.
- Iterative refinement is supported through merger and correction handler prompts that preserve revision history in **`交底书修订对话记录.md`**.

## Frequently Asked Questions

### How does Mode A handle CAD files versus regular images?

According to the source code in **[`prompts/disclosure/project_scan.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/project_scan.md)**, the **Mode A (Disclosure Document Writing)** workflow inspects the [`figure_plan.yaml`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/figure_plan.yaml) entries and explicitly excludes any items marked as CAD (`kind: cad`) from document insertion. Only figures flagged with `use_in_disclosure: true` and appropriate image types (line-art or photos) are embedded in the final markdown and Word documents.

### Which patent document types does Mode A support?

The **[`prompts/disclosure/intake.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/intake.md)** prompt routes the workflow to three distinct builders: **[`prompts/disclosure/invention/disclosure_builder.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/invention/disclosure_builder.md)** for Invention patents (发明), **[`prompts/disclosure/utility_model/disclosure_builder.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/utility_model/disclosure_builder.md)** for Utility Models (实用新型), and **[`prompts/disclosure/design/disclosure_builder.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/design/disclosure_builder.md)** for Design patents (外观设计). Each type utilizes specific schema fillers such as [`fill_structure_schema.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/fill_structure_schema.md) or [`fill_appearance_schema.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/fill_appearance_schema.md) to capture the appropriate technical or aesthetic details.

### What triggers the compliance checking phase in Mode A?

After the disclosure document builder generates the draft, the workflow automatically invokes **[`prompts/disclosure/disclosure_self_check.md`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/prompts/disclosure/disclosure_self_check.md)** to validate the output against 30+ editorial rules. These rules check for prohibited elements like repository footnotes, incorrect LaTeX delimiters, and improper figure references. If violations are detected, the correction handler routes the document back for revision before final output to `outputs/{案件标识}/`.

### Can I manually run individual steps of Mode A without the full automation?

Yes. While the skill orchestrates the complete workflow automatically, the repository exposes discrete CLI commands for each stage, including `intake`, `fill_schema`, `image_gen`, and `build_disclosure`. The **[`tools/shared/md_to_docx.py`](https://github.com/handsomestWei/patent-disclosure-skill/blob/main/tools/shared/md_to_docx.py)** script can also be run independently to convert existing Markdown files to Word format using the `-i` and `-o` parameters.