Skip to content
CLI tool · Testing

Lighthouse for AI agents

The Lighthouse CLI for AI agents: audit performance, accessibility, and SEO in headless Chrome and save JSON reports an agent can compare between runs.

lighthouseby Google ChromeOfficial MCP option
What it is

What Lighthouse does for an agent

Lighthouse is Google Chrome's open-source auditing tool. The CLI loads a page in Chrome and scores it for performance, accessibility, best practices, and SEO, with a list of specific problems.

With JSON output an agent can read the scores and failing audits, make a change, and run the audit again to see whether it helped.

Install

Install Lighthouse

The install commands from the official docs. Check it worked with lighthouse --version.

npm (global, needs Chrome installed)
npm install -g lighthouse
Auth

Signing in Lighthouse for an agent

No sign-in. Lighthouse needs a local Chrome or Chromium install.

Common agent tasks

What agents use Lighthouse for

Example commands with placeholder names. Swap in your own project, app, or file names.

  1. Audit a local page and save JSON

    lighthouse
    lighthouse http://localhost:3000 --output=json --output-path=./lighthouse.json --chrome-flags="--headless" --quiet
  2. Audit only performance and accessibility

    lighthouse
    lighthouse http://localhost:3000 --only-categories=performance,accessibility --output=json --output-path=./lh.json --chrome-flags="--headless" --quiet
  3. Audit with desktop settings

    lighthouse
    lighthouse http://localhost:3000 --preset=desktop --output=json --output-path=./lh-desktop.json --chrome-flags="--headless" --quiet
  4. Read the scores from a report

    lighthouse
    jq '.categories | map_values(.score)' lighthouse.json
Safety

Safety rules for agents

Safe to run without asking

  • lighthouse <local or staging URL> ...
  • jq over saved reports

Ask a human first

  • repeated audits of a production site
  • audits of sites the user does not own
  • Audit production builds served locally or on staging; dev servers give misleading scores.
  • Scores vary between runs. Compare the median of several runs before calling a change a win.
  • Do not loop audits against production or third-party sites.
Agent instructions

AGENTS.md or CLAUDE.md snippet

Paste this into the instruction file your agent reads at the start of every session, then adjust the rules to your setup.

AGENTS.md
## Lighthouse (lighthouse)

Use `lighthouse` for auditing pages for performance, accessibility, SEO, and best practices.

- Check it is installed with `lighthouse --version`. If it is missing, ask before installing it.
- Auth: none needed.
- Run without asking (read-only): `lighthouse <local or staging URL> ...`, `jq over saved reports`.
- Ask a human first (changes or deletes things): `repeated audits of a production site`, `audits of sites the user does not own`.
- Audit production builds served locally or on staging; dev servers give misleading scores.
- Scores vary between runs. Compare the median of several runs before calling a change a win.
- Do not loop audits against production or third-party sites.
- Prefer JSON output where the command supports it, and keep output short.
CLI or MCP server?

Lighthouse or an MCP server?

An official MCP option exists. Lighthouse itself has no MCP server, but the Chrome DevTools team publishes an official Chrome DevTools MCP server that can record performance traces in a live browser. Use the CLI for repeatable scored audits.

Rule of thumb: in a terminal agent that a human has signed in, the CLI is usually faster and cheaper in context. In a chat client without a shell, or when you want a fixed set of typed tools, use an MCP server.

Same category
All Testing tools
FAQ

Lighthouse questions

How do I install Lighthouse?

npm (global, needs Chrome installed): npm install -g lighthouse. Check the install with lighthouse --version, and see the Google Chrome docs for other platforms.

How does an AI agent authenticate Lighthouse?

No sign-in. Lighthouse needs a local Chrome or Chromium install. There is nothing to set up: an agent can use it as soon as lighthouse --version succeeds.

Which Lighthouse commands are safe for an agent to run?

Commands that only read state are safe to run without asking: lighthouse <local or staging URL> ...; jq over saved reports. Ask a human before anything that changes or deletes something: repeated audits of a production site; audits of sites the user does not own.

Is there an MCP server for Lighthouse?

Lighthouse itself has no MCP server, but the Chrome DevTools team publishes an official Chrome DevTools MCP server that can record performance traces in a live browser. Use the CLI for repeatable scored audits.