Skip to navigation

Claude Code

Set up Doc Detective agent tools with Claude Code to test your documentation using natural language.

Prerequisites

Installation

From any project directory, run:

npx doc-detective install agents --agent claude

The command auto-detects Claude Code and prompts for install scope (project or user-global) if you don’t pass --scope. It then invokes Claude Code’s native plugin management to add the doc-detective/agent-tools marketplace and install the doc-detective plugin. It pins the marketplace to the agent-tools ref that matches your Doc Detective version. For which ref that is, see install agents. Re-run the same command any time to update to the latest version. The command is idempotent and prints “already up to date” when nothing has changed.

Useful flags:

  • --scope project or --scope global: skip the scope prompt.
  • --yes: non-interactive; requires --agent and --scope.
  • --force: reinstall even if already up to date.
  • --dry-run: print planned actions without executing them.

If the claude binary isn’t on your PATH but ~/.claude/ exists, the command edits your settings file directly (adding extraKnownMarketplaces and enabledPlugins). Claude Code then prompts to complete the install on its next launch.

Fallback installation

If npx doc-detective install agents isn’t an option, install via Claude Code’s own slash commands.

  1. Open Claude Code:

    claude
  2. Add the Doc Detective marketplace and install the plugin:

    /plugin marketplace add doc-detective/agent-tools#v2
    /plugin install doc-detective@doc-detective

    The #v2 suffix pins the marketplace to the same agent-tools ref that install agents uses.

Bootstrap a project

Set up Doc Detective in your repository using a slash command:

/doc-detective-init

Or describe what you want in plain language:

Set up Doc Detective in this project. Scan for documentation files, create a config, and generate tests for any procedures you find.

The bootstrapping process:

  1. Detects documentation files (.md, .mdx, .adoc, .rst, .html, .dita)
  2. Generates a .doc-detective.json configuration file
  3. Creates test specifications for procedures with step-by-step instructions
  4. Runs the tests and fixes failures

Generate tests for existing pages

Convert a documentation file into a test specification using a slash command:

/doc-detective-generate docs/getting-started.md

Or ask in plain language:

Generate Doc Detective tests for the getting started guide. Save the output to a JSON file in the tests folder.

You can also ask for more specific behavior:

Create tests for docs/new-feature.md and merge them with the existing test spec in tests/existing-spec.json.

Language server

Installing the plugin also bundles a Doc Detective language server with Claude Code. It gives Claude Code authoring-time feedback on your test specs. It runs the same schema checks as the test runner, but it surfaces them the moment the agent edits a spec. Claude Code reads that feedback as it writes and fixes structural mistakes before a test runs. You spend fewer round trips on failed runs.

The language server activates automatically after installation, with nothing for you to set up. It provides three things:

  • Diagnostics: Claude Code sees schema errors inline as it edits specs (*.spec.json, *.spec.yaml, and *.spec.yml) and .doc-detective.* config files. It also sees them for inline tests in Markdown, AsciiDoc, HTML, and DITA. A common mistake is writing {"action": "goTo"} instead of the compact {"goTo": "https://example.com"} form. The language server produces a single clear message instead of a cascade of schema errors.
  • Completion (*.spec.json files only): Suggestions for action keys and their fields, with schema-aware snippets for values.
  • Hover (*.spec.json files only): Action descriptions pulled straight from the schema.

To avoid noise, the language server stays silent on files that aren’t Doc Detective documents. It engages on specs and config files by name. It also engages on any file whose $schema points at a Doc Detective schema, and on JSON with a top-level tests array. In Markdown, AsciiDoc, HTML, and DITA files, it checks only the inline test statements and ignores the rest of the content. A document with no inline tests gets no feedback, and neither does an unrelated package.json.

The language server runs through your project’s Doc Detective CLI, falling back to npx when the project has no local copy. It’s specific to Claude Code and doesn’t apply to the other agent tools these docs cover.