How to Draft Responses to Patent Office Actions Using the patent-oa Skill

The patent-oa skill automates end-to-end patent office action (OA) response drafting by extracting PDF content, performing semantic case retrieval, and generating structured Word documents ready for filing.

Drafting responses to patent office actions requires analyzing examiner rejections, retrieving relevant prior responses, and composing legally sound arguments. The patent-oa skill in the handsomestWei/patent-disclosure-skill repository provides a modular command-line toolkit that streamlines this workflow through vector-enabled case retrieval and automated document generation. This guide walks through the complete workflow from PDF ingestion to final document export.

Configure the Embedding Environment

Before processing office actions, you must configure the vector store and embedding model that powers semantic case retrieval. The tools/config.py script handles initialization and writes two configuration files: embedding.config.yaml (model settings) and embedding.secrets.yaml (API credentials).

Run these commands once per environment to set up an OpenAI-compatible embedding provider:

python skills/patent-oa/tools/config.py recommend        # Review current configuration

python skills/patent-oa/tools/config.py set --preset openai_compatible --api-key "$OPENAI_KEY"
python skills/patent-oa/tools/config.py selftest        # Verify connectivity and vector store health

The system uses SQLite-Vec for vector storage. If configuration is skipped or invalid, the tools automatically fall back to tag-only filtering, though semantic search significantly improves retrieval accuracy.

Extract and Parse Office Action PDFs

The workflow begins with tools/pdf_text.py, which uses PyMuPDF to extract raw text and structured JSON representations from examiner PDFs. This stage produces two artifacts: {stem}.extracted.txt containing the raw text and {stem}.extracted.json with page-level structure.

Execute extraction with:

python skills/patent-oa/tools/pdf_text.py -i path/to/office_action.pdf

The built-in parsing logic then analyzes the extracted text to identify critical metadata including the notice kind, response deadline, defect items, applicable statutes (e.g., "专利法第22条第3款"), and technology domains. You may optionally save this structured analysis as notice_struct.yaml for manual review before proceeding to draft generation.

Retrieve Similar Cases and Generate Drafts

The core automation happens in tools/search_cases.py, which orchestrates case retrieval and draft creation through the prompts/respond_office_action.md template. This tool performs three critical functions simultaneously:

  • Semantic Search: When vectors are enabled, queries the SQLite-Vec store via embed.py to find historically similar office actions
  • Diff Computation: Analyzes differences between the current case and retrieved precedents
  • Draft Generation: Produces a Markdown response draft (意见陈述草稿_*.md) combining the structured notice data, retrieved cases with similarity scores, and strategy rationale

Run the retrieval and drafting command:

python skills/patent-oa/tools/search_cases.py \
    --pdf path/to/office_action.pdf \
    --patent-type invention \
    --statute "专利法第22条第3款" \
    --defect inventiveness \
    --top-k 5

Output files land in outputs/oa/<case-or-date>/ and include the complete draft with sections for chosen strategy, scoring rationale, and case references. The system strictly enforces that retrieved case IDs are never fabricated and that playbook slugs remain separate from case citations.

Reference Strategy Playbooks

Beyond case law, the skill supports experience playbooks stored in oa/playbooks/{slug} directories. These handbooks provide strategic guidance for specific rejection types but are never cited as legal precedents.

List relevant playbooks for your specific defect types:

python skills/patent-oa/tools/ingest_playbook.py list

The ingest_playbook.py tool matches playbook content against your office action's metadata and surfaces applicable strategies during the draft generation phase, enriching the response with tactical guidance while maintaining citation integrity.

Finalize and Export to Word

After reviewing the generated Markdown draft, you must explicitly accept a version before the system permits Word document generation. This human-in-the-loop requirement ensures legal accuracy before filing.

Convert the accepted draft to DOCX format using tools/emit_opinion_docx.py, which reads assets/opinion_statement.md as its conversion template:

python skills/patent-oa/tools/emit_opinion_docx.py \
    -i outputs/oa/<case>/意见陈述草稿_20230909123000.md

# Produces: 意见陈述草稿_20230909123000.docx in the same directory

Unlike generic conversion utilities, this tool specifically handles Chinese patent document formatting and citation standards required for formal submission.

Ingest Resolved Cases for Future Retrieval

After the office action is resolved, enrich the vector store by ingesting the final response as a new searchable case. This feedback loop improves retrieval quality for future rejections:

python skills/patent-oa/tools/ingest_case.py -i outputs/oa/<case>/意见陈述草稿_<timestamp>.md

The tools/ingest_case.py script indexes the response into the Obsidian-backed vault under the oa/ directory. Use refresh_vault.py to update canvas views and maintain the searchable index of precedents.

Summary

  • Configure the embedding model and SQLite-Vec vector store once using tools/config.py to enable semantic search capabilities
  • Extract office action PDFs via tools/pdf_text.py to generate structured text and JSON representations
  • Retrieve similar historical cases and generate draft responses using tools/search_cases.py, which combines vector search with the respond_office_action.md prompt
  • Reference strategy playbooks via tools/ingest_playbook.py for tactical guidance without conflating handbooks with legal citations
  • Export finalized drafts to Word documents using tools/emit_opinion_docx.py only after explicit human acceptance
  • Ingest resolved cases back into the vault using tools/ingest_case.py to continuously improve future retrieval accuracy

Frequently Asked Questions

What file formats does the patent-oa skill support for office action input?

The skill exclusively processes PDF documents through tools/pdf_text.py, which utilizes PyMuPDF to extract text layers and page structures. The tool outputs both .extracted.txt (raw text) and .extracted.json (structured page data) files, which subsequent stages parse for notice metadata and defect classification.

How does case retrieval work when no embedding model is configured?

When embedding.secrets.yaml is missing or invalid, tools/search_cases.py automatically falls back to tag-only filtering, matching cases purely on metadata fields like patent type, statute citations, and defect classifications. While functional, semantic search via SQLite-Vec embeddings significantly improves recall for conceptually similar rejections that might not share identical tags.

Can I customize the Word document template for specific filing requirements?

Yes. The tools/emit_opinion_docx.py script uses assets/opinion_statement.md as its conversion template. Modifying this Markdown template changes the final DOCX structure, headers, and formatting. However, the tool maintains specific handling for Chinese patent document standards and citation formatting required by patent offices.

How does the system prevent fabrication of case citations?

Strict policy enforcement embedded in skills/patent-oa/SKILL.md and prompts/respond_office_action.md mandates that the assistant never fabricates data, never mix playbook slugs with case IDs, and only emit Word documents after explicit user acceptance. The retrieval pipeline in tools/search_cases.py only references cases that exist in the SQLite-Vec store or tag index, with similarity scores and diff calculations provided for human verification.

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 →