agentleFS
RobThePCGuyRobThePCGuy/Claude-Patent-Creator/CLAUDE.md

Claude-Patent-Creator

CLAUDE.md195 starsChanged 8 months agoMITView on GitHub

What happens automatically: 1. Installs package from GitHub 2. Detects GPU (NVIDIA/Apple Silicon/CPU) 3. Uninstalls CPU PyTorch if GPU detected 4. Installs correct PyTorch (CUDA 12.8/MPS/CPU) 5. Restarts setup in subprocess with GPU-enabled PyTorch 6. Downloads MPEP PDFs and builds index with GPU acceleration 7. Registers MCP server with Claude Code Optional: Use venv if preferred What you can do now: - Search 100M+ patents via BigQuery (worldwide) - Search US patent law (MPEP, 35 USC, 37 CFR) - Search…

  • Reads credentials
  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

10 rules. About 0 are common, 8 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Search 100M+ patents via BigQuery (worldwide)

    line 46
  2. Distinctive:

    Search US patent law (MPEP, 35 USC, 37 CFR)

    line 47
  3. Distinctive:

    Search EPO patent law (EPC, EPO Guidelines) and PCT rules

    line 48
  4. Distinctive:

    Search EP patents via EPO OPS API (full-text claims/description)

    line 50
  5. Distinctive:

    Create complete patent applications from scratch

    line 52
  6. Very specific:

    The install.py script handles this correctly: If manually installing, ALWAYS install PyTorch first.

    line 262
  7. Very specific:

    The install.py script handles this via path_utils.py: Always use PathFormatter.format_for_claude_mcp() when constructing paths …

    line 277
  8. Distinctive:

    Include MPEP citations in error messages: when relevant

    line 478
  9. Distinctive:

    Test on both CPU and GPU: if modifying search code

    line 480
  10. Distinctive:

    Follow existing analyzer patterns: when adding new analyzers

    line 482

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Quick Start

As a Claude Code Plugin (Recommended)

# In Claude Code — add the marketplace and install the plugin
/plugin marketplace add RobThePCGuy/Claude-Patent-Creator
/plugin install claude-patent-creator-standalone@claude-patent-creator

As a pip Package (MCP Server Mode)

# One-line install (works with or without venv)
pip install git+https://github.com/RobThePCGuy/Claude-Patent-Creator.git && patent-creator setup

# Restart Claude Code

# Test the system
# Ask Claude: "Search MPEP for claim definiteness requirements"
# Ask Claude: "Search for patents about neural networks filed in 2024"

What happens automatically:

  1. Installs package from GitHub
  2. Detects GPU (NVIDIA/Apple Silicon/CPU)
  3. Uninstalls CPU PyTorch if GPU detected
  4. Installs correct PyTorch (CUDA 12.8/MPS/CPU)
  5. Restarts setup in subprocess with GPU-enabled PyTorch
  6. Downloads MPEP PDFs and builds index with GPU acceleration
  7. Registers MCP server with Claude Code

Optional: Use venv if preferred

python -m venv venv
venv\Scripts\activate  # Windows
source venv/bin/activate  # Linux/macOS
pip install git+https://github.com/RobThePCGuy/Claude-Patent-Creator.git && patent-creator setup

What you can do now:

  • Search 100M+ patents via BigQuery (worldwide)
  • Search US patent law (MPEP, 35 USC, 37 CFR)
  • Search EPO patent law (EPC, EPO Guidelines) and PCT rules
  • Review patent applications for USPTO, EPO, or PCT compliance
  • Search EP patents via EPO OPS API (full-text claims/description)
  • Generate patent-style technical diagrams
  • Create complete patent applications from scratch

Project Overview

Claude Patent Creator - An MCP server providing USPTO MPEP-based patent creation guidance using RAG (Retrieval Augmented Generation).

Core Capabilities

FeatureDescriptionStatus
MPEP SearchSearch Manual of Patent Examining Procedure + 35 USC + 37 CFRReady
Patent Law SearchCross-jurisdiction search across US, EPO, and PCT lawReady
Patent SearchSearch 100M+ worldwide patents via BigQueryReady
EPO Patent SearchSearch EP patents via EPO OPS API (full-text claims)Ready
IPC SearchSearch patents by IPC classification codeReady
Patent Family SearchFind related patents across jurisdictionsReady
US Claims ReviewAutomated 35 USC 112(b) compliance checkingReady
EPO Claims ReviewArt. 84 EPC compliance checking (Art. 123(2) added-matter not implemented)Partial
US Specification ReviewWritten description, enablement, best mode analysisReady
EPO Specification ReviewArt. 83 EPC sufficiency of disclosure (Art. 123(2) added-matter not implemented)Partial
US Formalities CheckMPEP 608 compliance (abstract, title, drawings)Ready
EPO Formalities CheckRules 42-49 EPC complianceReady
PCT Formalities CheckPCT Rules 5-12 complianceReady
Diagram GenerationPatent-style technical diagrams (Graphviz)Ready
Patent CreationComplete patent application drafting workflowReady

Technology Stack

MCP Python SDK 2.x (MCPServer)
+- RAG Pipeline: FAISS + BM25 + HyDE + Cross-Encoder Reranking
+- Embeddings: BGE-base-en-v1.5 (768-dim)
+- Reranker: MS-MARCO MiniLM-L-6-v2
+- Patent Search: Google BigQuery (100M+ patents worldwide)
+- EPO Search: EPO OPS API v3.2 (EP full-text claims/description)
+- Legal Sources: MPEP + 35 USC + 37 CFR + EPC + EPO Guidelines + PCT Rules
+- Validation: Pydantic v2 with type safety
+- Logging: Structured JSON/human formats
+- GPU Acceleration: PyTorch CUDA 12.8

Skills System

Claude will automatically activate specialized skills based on your task. These skills provide deep expertise for specific workflows:

SkillActivate WhenWhat It Provides
setup-assistantInstalling, configuring, authenticating, or troubleshooting setupComplete installation lifecycle from pre-checks to first-use validation
development-assistantAdding features, creating MCP tools, extending functionalityFeature development lifecycle with templates and best practices
index-managerBuilding, rebuilding, or optimizing the MPEP indexMPEP index lifecycle from PDF downloads to production optimization
troubleshooting-assistantEncountering errors, performance issues, or unexpected behaviorSystematic 6-step diagnostic methodology for all components
testing-assistantRunning tests, validation, or quality assuranceComplete test suite execution and validation workflows
patent-reviewerReviewing patent applications for USPTO complianceExpert review system with automated compliance checking
patent-claims-analyzerReviewing claims specifically for 35 USC 112(b)Deep-dive claims analysis (definiteness, antecedent basis, structure)
patent-searchSearching patents, prior art, or competitive intelligenceBigQuery (100M+) search workflows via MCP tools
bigquery-patent-searchQuick BigQuery-only patent searchingKeyword, CPC, and patent detail retrieval across 100M+ patents
mpep-searchFinding MPEP sections, statutes, or regulationsHybrid RAG search across MPEP, 35 USC, 37 CFR
patent-diagram-generatorCreating technical diagrams for patentsGraphviz-based diagram generation
patent-application-creatorDrafting patent applications interactivelyGuided end-to-end creation (prior art, claims, spec, diagrams, compliance)
prior-art-searchConducting novelty or freedom-to-operate analysisPrior art search and analysis workflows
epo-patent-analyzerReviewing patents for EPO complianceArt. 84 (claims), Art. 83 (sufficiency), Rules 42-49 (formalities)
epo-patent-searchSearching EP patents via EPO OPS + BigQueryEPO OPS API + BigQuery cross-jurisdiction search
pct-applicationPreparing PCT international applicationsPCT Rules 5-12 compliance, unity of invention
epc-searchSearching EPC, EPO Guidelines, PCT rulessearch_patent_law with jurisdiction filtering

Each skill includes its reference documentation in skills/[skill-name]/SKILL.md.


Subagents System

For long-running, complex workflows that benefit from context isolation, use specialized subagents that work autonomously:

SubagentUse WhenDurationWhat It Delivers
patent-creatorDrafting complete patent applications autonomously (markdown + SVG output; DOCX/PDF conversion required before filing)~55-80 minDraft filing package (specification, claims, abstract, diagrams, validation report)
prior-art-searcherConducting comprehensive prior art searches without interruption15-30 minPatentability report (novelty/obviousness analysis, top 10 prior art, claim strategy, IDS list)

When to Use Subagents vs Skills

Use Subagents when:

  • Long-running workflows (10+ minutes)
  • User wants to continue other work during execution
  • Benefits from uninterrupted focus
  • Produces complete deliverable at end

Use Skills when:

  • Interactive workflows needing user input
  • User wants to see progress/ask questions
  • Fast operations (<10 minutes)
  • Benefits from conversation context

Example:

  • "Create a patent for my invention, use subagent" -> patent-creator works for 55-80 min independently
  • "Help me create a patent interactively" -> patent-reviewer skill guides you step-by-step

Subagents are located in agents/ at the repo root and have access to all MCP tools.


Slash Commands

Quick-access workflows for common patent tasks:

CommandDescriptionUse When
/create-patentDraft patent application workflow (6 phases, ~55-80 min, markdown/SVG output)Drafting a NEW patent application from scratch
/full-reviewComprehensive parallel review (claims + spec + formalities)Reviewing an EXISTING complete application
/review-claimsClaims-only analysis (35 USC 112b)Focused claims compliance checking
/review-specificationSpecification analysis (35 USC 112a)Focused specification adequacy review
/review-formalitiesFormalities check (MPEP 608)Abstract, title, drawings compliance
/review-epo-claimsEPO Art. 84 claims analysisEPO claims clarity, conciseness, support
/review-epo-formalitiesEPO Rules 42-49 formalities checkEPO-specific formalities compliance
/check-pct-formalitiesPCT Rules 5-12 formalities checkPCT international application compliance
/create-epo-patentEPO patent creation workflowCreate patent targeting EPO filing
/search-epoEPO patent searchSearch via EPO OPS API + BigQuery

System Architecture

Visual Architecture

+---------------------------------------------------------+
|                   Claude Code / User                     |
+----------------+----------------------------------------+
                 | MCP Protocol (stdio)
+----------------v----------------------------------------+
|              MCPServer (server.py)                       |
|  +-------------------------------------------------+   |
|  | MCP Tools: 35+ tools for patent review & search |   |
|  +-------------------------------------------------+   |
+--+------+------+------+---------------------+-----+----+
   |      |      |      |                     |     |
   v      v      v      v                     v     v
+----+ +-----+ +----+ +----------+ +-------+ +--------+
|MPEP| | BQ  | |EPO | |US + EPO  | | PCT   | |Diagrams|
|+EPC| |100M+| |OPS | |+ PCT     | |Forms  | |(Graphvz|
|+PCT| |     | |API | |Analyzers | |       | |        |
+--+-+ +--+--+ +--+-+ +----+-----+ +--+----+ +--------+
   |      |       |         |          |
   v      v       v         v          v
+--------------------------------------------------+
|       RAG Pipeline (Hybrid Search)               |
| FAISS Vector + BM25 Lexical + HyDE + Reranking  |
| Sources: MPEP + USC + CFR + EPC + EPO + PCT     |
+--------------------------------------------------+

Directory Structure

.claude-plugin/          # Plugin marketplace + manifest
+-- plugin.json          # Plugin identity and component paths
+-- marketplace.json     # Marketplace catalog for distribution

mcp_server/              # Core MCP server and tools
+-- server.py            # MCPServer entry point (main)
+-- mpep_search.py       # US + EPO + PCT hybrid RAG search
+-- bigquery_search.py   # BigQuery patent search (100M+ patents)
+-- epo_api.py           # EPO OPS API v3.2 client
+-- epo_downloaders.py   # EPO/WIPO legal document downloaders
+-- claims_analyzer.py   # 35 USC 112(b) compliance checker
+-- epo_claims_analyzer.py     # Art. 84 EPC compliance checker
+-- specification_analyzer.py  # 112(a) adequacy checker
+-- epo_specification_analyzer.py  # Art. 83 EPC sufficiency checker
+-- formalities_checker.py     # MPEP 608 formalities
+-- epo_formalities_checker.py # Rules 42-49 EPC formalities
+-- pct_formalities_checker.py # PCT Rules 5-12 formalities
+-- diagram_generator.py       # Graphviz diagram tools

commands/                # Slash commands (11)
skills/                  # Specialized skills (15)
agents/                  # Autonomous agents (10)
hooks/                   # Event-driven hooks
scripts/                 # Testing and setup utilities
data/                    # Index storage (git-ignored)
pdfs/                    # MPEP/USC/CFR PDFs (git-ignored)

Critical Gotchas

NumPy 2.x and FAISS Compatibility

Resolved: As of faiss-cpu 1.13.0 (Nov 2025), numpy 2.x is fully supported. The project requires faiss-cpu>=1.13.0 and numpy>=1.26.0,<3.0.0.

Legacy note: faiss-cpu 1.12.0 and earlier were compiled against numpy 1.x and would crash with ImportError: numpy.core.multiarray failed to import. This was fixed upstream in PR #4523.

PyTorch Installation Order (CRITICAL)

Problem: Installing sentence-transformers before PyTorch results in CPU-only PyTorch, even on GPU systems.

Solution:

# CORRECT ORDER:
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128
pip install sentence-transformers  # Now uses existing GPU torch

# WRONG ORDER (results in CPU-only):
pip install sentence-transformers  # Installs CPU torch as dependency
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu128  # Won't upgrade

The install.py script handles this correctly. If manually installing, ALWAYS install PyTorch first.

Windows Path Handling in MCP Config

Problem: MCP registration fails with backslashes in Windows paths.

Solution:

# CORRECT (forward slashes):
claude mcp add ... -- "C:/Users/<YOUR_USER>/venv/Scripts/python.exe" "C:/Users/<YOUR_USER>/server.py"

# WRONG (backslashes):
claude mcp add ... -- "C:\Users\<YOUR_USER>\venv\Scripts\python.exe" "C:\Users\<YOUR_USER>\server.py"

The install.py script handles this via path_utils.py. Always use PathFormatter.format_for_claude_mcp() when constructing paths programmatically.

Virtual Environment Activation

Problem: ModuleNotFoundError when running scripts manually.

Solution:

# ALWAYS activate first for manual operations:
venv\Scripts\activate  # Windows
source venv/bin/activate  # Linux/macOS

# Then run commands:
python scripts/test_gpu.py
patent-creator health

Note: Claude Code activates venv automatically. This only matters for manual terminal operations.

NumPy Version Requirements

NumPy 2.x is supported with faiss-cpu >=1.13.0 (enforced in pyproject.toml). If you encounter numpy-related import errors, ensure faiss-cpu is at least 1.13.0:

pip install "faiss-cpu>=1.13.0"

Git Bash Required on Windows

Problem: claude mcp add command fails on Windows.

Solution:

# Install Git for Windows (includes Git Bash)
# https://git-scm.com/download/win

# Set environment variable
export CLAUDE_CODE_GIT_BASH_PATH=C:/Program Files/Git/bin/bash.exe

# Or add to .env:
CLAUDE_CODE_GIT_BASH_PATH=C:\dev\Git\bin\bash.exe

Debugging MCP Server Issues

Enable debug logging:

PATENT_LOG_LEVEL=DEBUG patent-creator health

Claude Code MCP logs:

# Linux/macOS
~/.config/claude/logs/mcp.log

# Windows
%APPDATA%\claude\logs\mcp.log

Run Claude Code in debug mode:

claude --debug

MCP config file location (for manual fixes):

# Linux/macOS
~/.config/claude/mcp_config.json

# Windows
%APPDATA%\claude\mcp_config.json

Quick Reference

Essential Commands

# System health check
patent-creator health

# Rebuild MPEP index
patent-creator rebuild-index

# Verify MCP configuration
patent-creator verify-config

# Check BigQuery authentication
patent-creator check-bigquery

# Test GPU
python scripts/test_gpu.py

# Test BigQuery
python scripts/test_bigquery.py

# Full system test
python scripts/test_install.py

Key File Locations

ItemLocationDescription
MCP Servermcp_server/server.pyMain entry point
MPEP Indexmcp_server/index/FAISS + BM25 index files
MPEP PDFspdfs/Downloaded USPTO documents
Dependenciespyproject.tomlAll package requirements
Configuration.envEnvironment variables
CLI Toolmcp_server/cli.pypatent-creator command
Skills.claude/skills/Specialized skill documentation
Subagentsagents/Autonomous workflow subagents
Commands.claude/commands/Slash command definitions

Environment Variables

# Required
GOOGLE_CLOUD_PROJECT=your_project_id
ANTHROPIC_API_KEY=<YOUR_ANTHROPIC_API_KEY>

# EPO OPS API (optional — for EP patent search with full-text claims)
EPO_OPS_KEY=your_epo_consumer_key          # Free at developers.epo.org
EPO_OPS_SECRET=your_epo_consumer_secret

# Optional (with defaults)
PATENT_LOG_LEVEL=INFO              # Logging level
PATENT_LOG_FORMAT=human            # Log format
PATENT_ENABLE_METRICS=true         # Performance tracking
PATENT_MPEP_USE_HYDE=false         # HyDE for MPEP
PATENT_OPERATION_TIMEOUT=300       # Operation timeout (seconds)

# Windows only
CLAUDE_CODE_GIT_BASH_PATH=C:\dev\Git\bin\bash.exe

Version Compatibility Matrix

ComponentMin VersionMax VersionRecommendedCritical Notes
Python3.93.143.113.14 experimental
PyTorch2.0latest2.9.1+cu128CUDA 12.8 support
sentence-transformers5.1.2<6.05.1.2Requires transformers 4.41.0+
transformers4.57.1<5.04.57.1HuggingFace models
NumPy1.26.0<3.0latestnumpy 2.x supported with faiss-cpu >=1.13.0
faiss-cpu1.13.0latest1.13.2numpy 2.x support added in 1.13.0
Pydantic2.10.0latest2.10.0+V2 required
google-cloud-bigquery3.38.0latest3.38.0+Patent search (100M+)
anthropic0.72.1latest0.72.1+Claude API (optional)
openai2.8.0latest2.8.0+OpenAI API (optional)

Common Code Patterns

Add MCP Tool:

@mcp.tool()
@validate_input(YourInputModel)
@track_performance
def your_tool(param: str) -> dict:
    """Tool description for Claude."""
    return {"result": "data"}

Search MPEP:

from mcp_server.mpep_search import MPEPIndex
index = MPEPIndex()
results = index.search("claim definiteness", top_k=5)

Search BigQuery Patents:

from mcp_server.bigquery_search import BigQueryPatentSearch
search = BigQueryPatentSearch()
results = search.search_patents("neural networks", limit=10)

Getting Help

For detailed guidance on specific tasks, Claude will automatically activate the appropriate skill:

  • Installation issues? -> setup-assistant skill
  • Want to add a feature? -> development-assistant skill
  • Something broken? -> troubleshooting-assistant skill
  • Need to rebuild index? -> index-manager skill
  • Running tests? -> testing-assistant skill

Each skill contains comprehensive reference documentation and step-by-step workflows.


Best Practices

  1. Always activate venv for manual operations (Claude Code handles automatically)
  2. Use patent-creator CLI for system operations (health, rebuild, verify)
  3. Test with patent-creator health after changes
  4. Add performance monitoring to expensive operations (@track_performance)
  5. Use Pydantic validation for all new MCP tools (type safety + errors)
  6. Include MPEP citations in error messages when relevant
  7. Maintain backward compatibility with graceful fallbacks
  8. Test on both CPU and GPU if modifying search code
  9. Use structured logging with contextual fields
  10. Follow existing analyzer patterns when adding new analyzers
  11. Return JSON-serializable types from MCP tools (dict, list, primitives)
  12. Write detailed docstrings for MCP tools (Claude sees them)
  13. Use OperationTimer for sub-operation profiling
  14. Check settings.has_bigquery_configured() before using BigQuery
  15. Always use forward slashes in paths for MCP configuration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.