Back to Directory/Developer Tools

io.github.mack-peng/cssprobe-cli

Runtime CSS probe — inspect layout, overflow, scroll chains in a real browser. For AI agents.

Developer ToolsTypeScriptv0.3.0

cssprobe-cli

Runtime CSS probe — inspect layout, scroll, colors, backgrounds, fonts and more in a live browser. Built for both humans and AI agents.

License: MIT Node.js npm version npm downloads GitHub stars

Static + runtime CSS diagnosis for AI agents — pair with cssgraph (the CSS knowledge graph) for the full picture.


Why cssprobe-cli?

When an AI agent needs to debug CSS — why is this element overflowing, what's the actual rendered layout, is this container scrollable — it can't see the browser. It guesses from static code, missing runtime-only issues like overflow, scroll chains, and containing block hijacks.

cssprobe-cli gives the agent eyes. It opens a real browser, collects computed styles and metrics via injected JavaScript, analyzes them with a confidence model, and returns structured findings — all in one command. The agent asks a question about any selector and gets back the DOM tree, ASCII layout diagram, overflow warnings, and scroll diagnosis without leaving the terminal.


Installation

For Humans

Copy and paste this prompt to your LLM agent (Claude Code, Cursor, Codex, etc.):

Install and configure cssprobe-cli by following the instructions here:
https://raw.githubusercontent.com/mack-peng/cssprobe-cli/main/docs/guide/installation.md

Or read the Installation Guide, but seriously, let an agent do it. Humans fat-finger configs.

For LLM Agents

Fetch the installation guide and follow it:

curl -s https://raw.githubusercontent.com/mack-peng/cssprobe-cli/main/docs/guide/installation.md

Or install directly:

npm install -g cssprobe-cli
cssprobe-cli skill-install

How It Works

┌───────────────────────────────────────────────────────────┐
│                      AI Agent                              │
│                                                           │
│  "Is .sidebar overflowing?"                               │
│      calls: cssprobe-cli inspect .sidebar                 │
│                             │                             │
└─────────────────────────────┬─────────────────────────────┘
                              │
                              ▼
┌───────────────────────────────────────────────────────────┐
│                  cssprobe-cli daemon                       │
│                                                           │
│  collector (IIFE) → analyzer (pure) → renderer (md/json)  │
│                             │                             │
│                             ▼                             │
│               Playwright browser (Chromium)                │
│     getBoundingClientRect · getComputedStyle · DOM walk    │
└───────────────────────────────────────────────────────────┘
  1. Session — open spawns a daemon process managing a browser. Commands connect via Unix socket.
  2. Collector — Injected as IIFE into the page. Walks the DOM, reads computed styles, declared values, and element metrics.
  3. Analyzer — Pure Node.js functions. Classifies findings with confidence levels (DEFINITE / INDEFINITE / UNVERIFIABLE).
  4. Renderer — Outputs Markdown (default) or JSON. Includes ASCII layout diagram, DOM tree, and findings.

Quick Start

1. Inspect a Page

# Open browser (non-blocking, starts daemon session)
cssprobe-cli open https://getbootstrap.com/docs/5.3/examples/checkout

# Inspect with CSS selector
cssprobe-cli inspect .container

# Show ASCII layout diagram
cssprobe-cli layout .container

# Show only issues/warnings
cssprobe-cli findings .container

# Close browser when done
cssprobe-cli close

2. Login-Protected Pages

# Open browser in headed mode
cssprobe-cli open https://mysite.com --headed

# User manually logs in...

# Save session state for future use
cssprobe-cli state-save --name mysite

# Reopen with saved state (no login needed)
cssprobe-cli open https://mysite.com --state state.json --headed

3. JSON Output

cssprobe-cli inspect body --json
cssprobe-cli inspect body --json | jq '.findings[] | {id, confidence, message}'

4. Use as an MCP Server (AI clients)

cssprobe-cli ships an MCP server (stdio), so AI clients call it as a native tool — no shell needed:

cssprobe-cli mcp-install          # auto-detect and configure installed clients
cssprobe-cli mcp-install --target=claude,cursor,codex
cssprobe-cli mcp-install --local  # write project-scoped config

Manual configuration for any MCP client:

{
  "mcpServers": {
    "cssprobe-cli": { "command": "cssprobe-cli", "args": ["mcp"] }
  }
}

Exposes 10 tools: cssprobe_open, cssprobe_inspect, cssprobe_tree, cssprobe_layout, cssprobe_findings, cssprobe_eval, cssprobe_screenshot, cssprobe_inject_css, cssprobe_close, cssprobe_status. Remove with cssprobe-cli mcp-uninstall.


Commands

Session Management

CommandDescription
open [url]Open browser in session mode (non-blocking)
open [url] --headedShow browser window
open [url] --state <file>Open with saved cookies + localStorage
open [url] --viewport 1280x720Custom viewport size
closeClose browser session
close --allClose all sessions across all workspaces
statusShow session status

CSS Inspection

CommandDescription
inspect <selector>Full CSS diagnosis (computed values, declared values, findings)
inspect <selector> --layoutInclude ASCII layout diagram
inspect <selector> --briefCompact: tree sketch + warnings/errors only
inspect <selector> --jsonStructured JSON output
tree <selector>DOM tree structure
layout <selector>ASCII layout diagram
findings <selector>Only issues/warnings/errors

CSS Injection

CommandDescription
inject-css <css>Inject CSS into current page

Browser

CommandDescription
resize <width> <height>Resize browser viewport
eval <expression>Evaluate JavaScript (browser context); DOM nodes are auto-serialized
playwright <call>Execute Playwright API (Node.js context)
screenshotTake screenshot (saves to ~/.cssprobe-cli/screenshots/, --out to override)

Interaction

CommandDescription
click <selector>Real mouse click (auto-scroll + actionability wait; works with custom React components)
hover <selector>Real mouse hover
type <selector> <text>Fill text (replaces value); --press Enter to submit; --sequential for real key events
wait-for <selector>Wait for selector state (--state visible|hidden|attached|detached, --timeout ms)
wait-for --js "<predicate>"Wait until a JS predicate is truthy
wait-for --network-idleWait until the page is network-idle
run <file>Run a multi-step flow script

click / hover support --nth N (1-based, default first match), --force (skip actionability checks) and --timeout ms. Without --nth, multiple matches fail (strict) to prevent wrong-target clicks.

State

CommandDescription
state-import <file>Import cookies from Netscape format
state-saveSave current browser session state (cookies + localStorage)

Configuration

CommandDescription
config-showShow current config
config-set <key> <value>Set config value
config-listList all profiles
config-use <name>Switch active profile
config-new <name>Create new profile
config-pathShow config file path

Multi-step Flows

The interaction commands drive a page step by step; run turns a sequence into a versionable script:

cssprobe-cli open https://example.com/editor
cssprobe-cli wait-for .editor-canvas
cssprobe-cli click ".layout-switch" --nth 1
cssprobe-cli type ".block-title input" "Hello" --press Enter
cssprobe-cli inspect .block-grid --json
cssprobe-cli close

For repeatable flows, write a script and run it with one command. The script runs inside the daemon session (full Playwright page access):

// flow.js
export default async ({ page, click, waitFor, type, inspect, screenshot, log }) => {
  await page.goto('https://example.com/editor', { waitUntil: 'domcontentloaded' });
  await waitFor('.editor-canvas', { state: 'visible', timeout: 10000 });

  await click('.layout-switch', { nth: 1 });
  await waitFor({ js: "() => document.body.dataset.layout === 'two-col'" });

  await type('.block-title input', 'Hello', { press: 'Enter', sequential: true, clear: true });
  await waitFor({ networkIdle: true });

  const { findings } = await inspect('.block-grid', { format: 'json' });
  log('findings:', findings.length);
  await screenshot({ path: './after-layout-switch.png' });

  return { findings: findings.length };
};
cssprobe-cli run ./flow.js        # --timeout ms for the whole script (default 300000, 0 = unlimited)

Scripts must default-export an async function receiving the API object: page, click, hover, type, waitFor, inspect, screenshot, log. screenshot relative paths resolve against the script's directory; logs (log() and console.*) are collected and returned with the result. On failure the command exits 1, prints the collected logs, and keeps the session alive.

Scripts are executed by the local daemon with full Node privileges — only run trusted scripts.


Confidence Model

Every finding carries a confidence level:

LevelMeaning
DEFINITEBased on computed values (facts from getComputedStyle) or accessible declared values
INDEFINITEDeclared value uses % — resolves at runtime
UNVERIFIABLEDeclared value missing or from blocked cross-origin stylesheet

The report header shows: confidence: DEFINITE 8 | INDEFINITE 0 | UNVERIFIABLE 1


Complementary Tool: cssgraph

cssprobe-cli is a runtime CSS probe — it opens a real browser and reads what is actually rendered. For static questions about the source code — where is .btn-primary defined, what cascades over it, which components reference it, what would change if I edited it — use cssgraph, a local SQLite knowledge graph of every className, property, variable, and at-rule in your stylesheets. The two tools complement each other:

cssgraph (static)cssprobe-cli (runtime)
Analyzessource code (CSS/SCSS/Less + JSX/TSX + templates)live browser (computed styles + DOM)
Answerswhere a class is defined, cascade, impact, unused CSSactual rendered layout, overflow, scroll, height chains
Whenbefore/without a browserafter static analysis, to verify at runtime
Usagecssgraph init + explore/rule/impactopen + inspect/layout/findings

Recommended workflow for a style problem — go static first, then verify at runtime:

# 1. Static: find the definitions, cascade, and blast radius (cssgraph)
cssgraph explore .btn-primary
cssgraph cascade .btn-primary

# 2. Runtime: confirm what actually renders (cssprobe-cli)
cssprobe-cli open https://example.com
cssprobe-cli inspect .btn-primary
cssprobe-cli findings .btn-primary

Install: npm install -g cssgraph (requires Node.js >= 22.5.0). It exposes 12 MCP tools (cssgraph_explore, cssgraph_rule, cssgraph_impact, …) plus CLI commands. See npm / GitHub.


Configuration

# Set values
cssprobe-cli config-set browser chromium
cssprobe-cli config-set depth 8
cssprobe-cli config-set viewport 375x812

# Profile management
cssprobe-cli config-new staging
cssprobe-cli -p staging config-set browser firefox
cssprobe-cli config-use staging

Priority: CLI flags > Environment variables > Config file

--browser       CSSPROBE_BROWSER
--depth         CSSPROBE_DEPTH
--headed        CSSPROBE_HEADED
--viewport      CSSPROBE_VIEWPORT
-p, --profile   CSSPROBE_PROFILE

Config file: ~/.cssprobe-clirc


Supported Platforms

PlatformArchitectures
macOSx64, arm64
Linuxx64, arm64
Windowsx64, arm64

Development

npm install
npm run build       # tsc + esbuild collector + daemon entry + generate help.json
npm test            # Run unit tests (58 tests)
npx tsc --noEmit    # Type check only

If cssprobe-cli is useful

A ⭐ star helps other developers discover it — and tells us to keep shipping.


License

MIT

Installation

Source-derived launch command. Check the maintainer’s required arguments and credentials before running:

bash
npx -y cssprobe-cli

Set up in your AI client

Merge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.

json
{
  "mcpServers": {
    "io-github-mack-peng-cssprobe-cli": {
      "command": "npx",
      "args": [
        "-y",
        "cssprobe-cli"
      ]
    }
  }
}

Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.

Claude Desktop setup reference

Package

cssprobe-clinpm

Compatible MCP Clients

io.github.mack-peng/cssprobe-cli works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.

  • Claude Desktop~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.
  • Cursor~/.cursor/mcp.jsonRestart Cursor for changes to take effect.
  • VS Code.vscode/mcp.jsonReload VS Code window for changes to take effect.
  • Windsurf~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect.
  • Claude Code.mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.

Learn More