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.
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 Lighthouse
The install commands from the official docs. Check it worked with lighthouse --version.
npm install -g lighthouse
Signing in Lighthouse for an agent
No sign-in. Lighthouse needs a local Chrome or Chromium install.
What agents use Lighthouse for
Example commands with placeholder names. Swap in your own project, app, or file names.
Audit a local page and save JSON
lighthouse http://localhost:3000 --output=json --output-path=./lighthouse.json --chrome-flags="--headless" --quiet
Audit only performance and accessibility
lighthouse http://localhost:3000 --only-categories=performance,accessibility --output=json --output-path=./lh.json --chrome-flags="--headless" --quiet
Audit with desktop settings
lighthouse http://localhost:3000 --preset=desktop --output=json --output-path=./lh-desktop.json --chrome-flags="--headless" --quiet
Read the scores from a report
jq '.categories | map_values(.score)' lighthouse.json
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 siteaudits 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.
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.
## 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.
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.
Other Testing tools
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.