From patent-writer
Generates CNIPA-compliant black-and-white engineering-style patent diagrams (PNG) including method flowcharts, apparatus block diagrams, system architectures, and hardware cross-sections using Gemini API.
npx claudepluginhub jiutuhky/my-super-capsule --plugin patent-writerThis skill uses the workspace's default tool permissions.
通过 Google Gemini Image API 生成符合中国国家知识产权局(CNIPA)标准的纯黑白工程制图风格专利附图。
Guides Next.js Cache Components and Partial Prerendering (PPR): 'use cache' directives, cacheLife(), cacheTag(), revalidateTag() for caching, invalidation, static/dynamic optimization. Auto-activates on cacheComponents: true.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Share bugs, ideas, or general feedback.
通过 Google Gemini Image API 生成符合中国国家知识产权局(CNIPA)标准的纯黑白工程制图风格专利附图。
| 变量名 | 必需 | 说明 |
|---|---|---|
GEMINI_API_KEY | 是(优先) | Gemini API 密钥 |
GOOGLE_API_KEY | 备选 | 当 GEMINI_API_KEY 未设置时使用 |
GEMINI_BASE_URL | 否(优先) | 自定义 API 端点 |
GOOGLE_API_BASE_URL | 备选 | 当 GEMINI_BASE_URL 未设置时使用 |
Python 依赖:pip install google-genai
Read ${CLAUDE_PLUGIN_ROOT}/skills/patent-diagram-drawing/references/patent-diagram-spec.md to load CNIPA diagram standards (line weights, numbering formats, layout rules). Strictly follow all rules defined there.
Locate the project working directory (output/temp_[uuid]/). If invoked as /write-patent Step 2, reuse the directory from Step 1. Read:
04_content/description.md — 具体实施方式全文03_outline/structure_mapping.json — 结构映射(图号、模块编号对应关系)Based on description content and structure mapping, identify all diagrams to generate:
| 类型 | 触发条件 | 编号 |
|---|---|---|
| 方法流程图 | 每个方法权利要求对应一张 | S101, S102... |
| 装置结构框图 | 每个装置权利要求对应一张 | 201, 202... |
| 系统架构图 | 涉及多组件交互时 | 301, 302... |
| 硬件截面图 | 涉及物理结构时 | 引出线编号 |
Read ${CLAUDE_PLUGIN_ROOT}/skills/patent-diagram-drawing/references/prompt-templates.md to get prompt templates. Select the template matching the diagram type (flowchart, apparatus, system, cross-section) and fill in placeholders from description.md and structure_mapping.json.
Create output directories, then execute for each diagram:
mkdir -p {PROJECT_DIR}/05_diagrams/{flowcharts,structural_diagrams,cross_sections}
GEMINI_API_KEY="${GEMINI_API_KEY:-$GOOGLE_API_KEY}" \
GEMINI_BASE_URL="${GEMINI_BASE_URL:-$GOOGLE_API_BASE_URL}" \
python3 "${CLAUDE_PLUGIN_ROOT}/skills/patent-diagram-drawing/scripts/generate.py" \
"<PROMPT>" --ratio 3:4 -o "<OUTPUT_PATH>" --size 2K -v
<PROMPT>: Full English prompt constructed from template with placeholders filled<OUTPUT_PATH>: Absolute path to output PNG (e.g., 05_diagrams/flowcharts/method_flow.png)If generation fails or quality check does not pass, retry up to 3 times with strengthened prompt constraints.
Verify each generated PNG against the checklist:
05_diagrams/
├── flowcharts/ # 方法流程图
├── structural_diagrams/ # 装置结构框图
└── cross_sections/ # 硬件截面图
File naming: snake_case English, .png extension.
references/patent-diagram-spec.md — CNIPA 附图绘制风格规范(线宽、编号、布局、文字等详细要求)references/prompt-templates.md — 4 种附图类型的 Gemini API prompt 模板及占位符说明| 问题 | 解决方案 |
|---|---|
GEMINI_API_KEY not set | 设置 GEMINI_API_KEY 或 GOOGLE_API_KEY |
No image generated | 检查 prompt 长度和内容,重试 |
| 中文显示乱码 | 在 prompt 中要求 "Chinese text labels",重试 |
| 出现彩色元素 | 加强黑白要求,重试(最多3次) |
Rate limit exceeded | 等待 30-60 秒后重试 |
Content blocked | 调整 prompt 措辞,避免敏感词 |