CLI and agents

Run the same contract check from a terminal, in CI, or from an AI agent.

Documentation pages

The analysis behind the editor is also available outside it, with the same results and a versioned JSON report (schema 1.0).

CLI

openapi-guard [workspace] [--spec <path>]... [--format json]
  • Without --spec, every contract found in the workspace is analyzed; repeat --spec to choose several.
  • Exit code 0 means no drift, 1 means drift was found, and 2 means the analysis could not run: for example no contract was found, or a --spec file cannot be parsed. (Found contracts that cannot be parsed are skipped while another can be analyzed.)
  • --include, --exclude, and --implementation-path-prefix match the settings of the same names.

Where source could not be analyzed (for example AWS Lambda dispatch through a custom router), the report lists each place under limitations, with its reason and location; operations such places could serve are not reported missing. The text output prints them after the result.

The CLI ships with the extension and as the npm package @stackblender/openapi-guard.

AI agents

  • In VS Code agent mode, reference #checkOpenApiContract to have the agent check the open workspace. The result is paged JSON; the tool changes nothing.
  • The package also provides openapi-guard-mcp, a local MCP server exposing the same check as check_openapi_contract.

None of these make network requests.