Docs
Cli

Patent Review Workflow

Step-by-step guide to running an automated patent review from the CLI, covering local Git divergence detection, scan initiation, polling, and the structured result envelope.

The markdocket patent review command orchestrates a multi-step automated patent review entirely from your terminal. It handles local repository validation, scan submission, bounded-interval polling, result fetching, and automatic prior-art follow-up — returning a single versioned structured envelope when complete.

Prerequisites

  • @markdocket/cli installed and authenticated (markdocket login)
  • A repository accessible to the MarkDocket platform, or a local Git repository with a clean, pushed state

Running a Review

# Review a remote repository by name or URL
markdocket patent review --repo owner/repo-name

# Review the repository in your current working directory
markdocket patent review --repo .

When you pass --repo ., the CLI inspects your local Git repository before submitting anything to the platform.

Local Git Divergence Detection

Before a scan can proceed against a local repository, the CLI runs a set of Git checks to ensure the remote matches what you intend to scan. If any check fails, the scan is blocked and you are prompted to resolve the issue.

The checks cover:

CheckWhat it detects
Dirty working treeUncommitted modifications or untracked files that would not appear in the remote scan
Unpushed commitsLocal commits not yet pushed to the remote branch — the scan would miss them
SHA divergenceThe local HEAD SHA does not match the remote ref, meaning local and remote histories have diverged

All three conditions must be clear before the workflow proceeds. Resolve them by committing, pushing, or resetting your local branch as appropriate, then re-run the command.

Divergence means scan mismatch. If you skip divergence resolution, the scan result reflects the remote state, not your local working copy. The CLI blocks submission precisely to prevent this confusion.

Scan Submission and Polling

Once divergence checks pass (or when scanning a remote repository directly), the CLI submits a scan job and enters a bounded polling loop.

● Starting patent review scan…
✓ Scan initiated  (job id: prj_a1b2c3d4)
⠸ Polling for results… [elapsed: 0:42]

Polling uses a fixed interval and stops as soon as the job reaches a terminal state — completed, failed, or timed out. You do not need to keep a separate browser tab open.

When the scan completes, the CLI automatically:

  1. Fetches the primary structured result
  2. Fetches the full Markdown report
  3. Runs a prior-art follow-up query for the top three findings

The prior-art follow-up is performed automatically; no extra flags are required.

Structured Result Envelope

The final output is a versioned JSON envelope written to stdout (use --output <file> to write to disk instead). Its top-level shape is:

{
  "schemaVersion": "2026-07-15",
  "kind": "markdocket.patent-review",
  "scan": { ... },
  "findings": [ ... ],
  "priorArt": [ ... ],
  "report": "...",
  "telemetry": { ... },
  "coverageLimits": { ... },
  "legalNotices": "..."
}

Envelope Fields

schemaVersion — A date-stamped string identifying the envelope format. Pin this value if you parse the envelope in downstream tooling; breaking changes will increment it.

kind — Always markdocket.patent-review for patent review results. Use this to distinguish envelope types if you collect multiple result kinds.

scan — Metadata about the submitted scan: repository, ref, SHA, job ID, timestamps, and the configuration used.

findings — An ordered array of patent-relevant findings from the scan. Each finding includes a title, description, confidence level, and relevant file locations.

priorArt — Results of the automatic prior-art follow-up for the top three findings. Each entry links a finding to relevant prior-art references.

report — The full Markdown report as a single string, suitable for rendering or saving as a .md file.

telemetry — Worker timing and diagnostic information embedded by the scan worker. Useful when filing support requests.

coverageLimits — Describes any scope constraints that applied to the scan (for example, file-count caps or language exclusions). Review this section to understand whether any parts of the repository were not analyzed.

legalNotices — Required disclosure text. Do not omit or suppress this field when displaying results to end users.

The report field contains the same information as findings but in human-readable prose form. For programmatic use, prefer findings. For display or sharing, use report.

Output Options

# Write the envelope to a file instead of stdout
markdocket patent review --repo . --output review.json

# Pretty-print to stdout
markdocket patent review --repo . --pretty

# Suppress the full report field (reduces output size)
markdocket patent review --repo . --no-report

MCP Usage

The patent review workflow is also available as a tool when MarkDocket is connected via the Model Context Protocol. The same divergence detection, polling, and structured envelope apply. Because the MCP server applies domain-aware compaction before returning results, very large reports may be summarized with a truncated: true flag in the MCP response; fetch the full envelope via the CLI if you need the complete output.

Billing

Patent review scans consume metered credits. The CLI will surface a billing prompt if your account does not have sufficient balance before the scan is submitted. If a billing limit is reached mid-workflow, the result envelope will be partial and the findings array will reflect only the work completed before the limit was hit. Check coverageLimits in the envelope to confirm whether the scan ran to completion.

Troubleshooting

Scan blocked: dirty working tree Run git status to identify uncommitted changes. Either commit and push them, or stash them before re-running the command.

Scan blocked: unpushed commits Run git push and then re-run markdocket patent review --repo ..

Scan blocked: SHA divergence Your local branch and the remote ref have diverged. Resolve the divergence with a merge, rebase, or reset, then push and re-run.

Polling timed out The scan job did not reach a terminal state within the polling window. Run markdocket patent status --job <job-id> to check progress. The job ID is printed at scan submission and is also available in your MarkDocket dashboard.

Billing block during workflow Add credits via the MarkDocket dashboard or run markdocket billing to review your current balance, then re-submit the scan.

On this page