Skip to main content
Glama
README.md
# style-agent

**Portable style verification toolkit** (Chrome CDP + JSON specs).  
Works as a **CLI**, and optionally as an **MCP server** for any MCP client (Cursor, Claude Code, etc.). Not a Cursor-only plugin.

```text
You: define acceptance + final review
Agent / you: find → inspect → fix CSS → re-check
Channel: Chrome DevTools Protocol (no browser extension required)
```

---

## Quick start (CLI)

```bash
git clone https://github.com/jtrslar/style-agent.git
cd style-agent
npm install
chmod +x launch-chrome.sh

# 1) Start debug Chrome (independent profile)
./launch-chrome.sh http://127.0.0.1:8080/your-page
# or: ./launch-chrome.sh   then navigate manually

# 2) Probe CDP / run a demo spec (adapt selectors to your DOM)
node cli.mjs status
node cli.mjs inspect demo-modal-shell.json
```

Demo specs under `specs/examples/` use neutral class names (`.demo-modal`, …). Copy them into **your app repo** and edit selectors — do not treat examples as a product baseline.

---

## Optional: MCP client

Register the server with your client. Cursor example:

See [`examples/mcp.cursor.json.example`](./examples/mcp.cursor.json.example) (replace the absolute path).

Optional Cursor rule sample: [`examples/cursor/style-agent.mdc`](./examples/cursor/style-agent.mdc).

Then refresh MCP in the client settings.

---

## MCP tools

| Tool | Purpose |
|------|---------|
| `style_status` / `style_tabs` | CDP + open tabs |
| `style_inspect` | JSON spec check (failures only by default) |
| `style_find` | text / css / testid / role → uid |
| `style_styles` | computed-style subtree |
| `style_click` / `style_hover` / `style_wait` | interact then measure |
| `style_spacing` / `style_dialogs` / `style_highlight` | helpers |
| `style_eval` | advanced page expressions |

**No screenshots** in the default path — structured JSON only.

---

## Where specs live

| Kind | Location |
|------|----------|
| **Project specs** | Your app repo, e.g. `style-specs/` or `.kiro/style-specs/` |
| **This repo `specs/examples/`** | Format demos only |

Details: [`SPECS.md`](./SPECS.md).

```bash
node cli.mjs inspect /absolute/path/to/your-app/style-specs/foo.json
# or
export STYLE_AGENT_SPECS_DIR="/absolute/path/to/your-app/style-specs"
```

---

## Layout

```text
index.mjs              MCP server entry (optional)
cli.mjs                CLI
launch-chrome.sh       debug Chrome on CDP
lib/cdp.js             CDP connect
inject/page-runtime.js page-side find + inspect
SPECS.md               project vs example specs
UPGRADE.md             optional Pixelmatch roadmap
specs/examples/        neutral demos only
examples/              MCP / Cursor samples
```

---

## Environment (optional)

| Variable | Default | Meaning |
|----------|---------|---------|
| `STYLE_AGENT_CDP_URL` | `http://127.0.0.1:9222` | CDP endpoint |
| `STYLE_AGENT_SPECS_DIR` | `./specs/examples` | Spec search dir (point at your app in real use) |

---

## Upgrade path

[`UPGRADE.md`](./UPGRADE.md): optional **Pixelmatch gate + style-agent targeted fixes**.  
When `style_status` reports `upgradeStatus=proposed`, ask once whether to adopt it.

---

## Notes

- Log in / CAPTCHA in the debug Chrome window yourself when needed
- Does not replace human visual taste checks; it provides structured diffs for fixing CSS

TDQS

A3.5/5.0

Scored across 12 tools

Disambiguation4/5

Tools are mostly distinct with clear roles: find vs wait, click vs hover, styles vs inspect. However, style_status and style_tabs both list tabs, and style_styles vs style_inspect overlap in reading computed styles, creating minor confusion.

Naming Consistency4/5

All tools share the 'style_' prefix and are lowercase snake_case, forming a recognizable pattern. Some use verbs (find, click, wait) while others use nouns (tabs, dialogs, styles), deviating from a strict verb_noun convention but remaining predictable.

Tool Count5/5

With 12 tools, the set is well-scoped for a style/UI inspection purpose. Each tool covers a needed action without redundancy, fitting comfortably within the ideal 3-15 range.

Completeness4/5

The toolset covers the core lifecycle: health check, locating elements, reading styles, spacing, interactions, waiting, dialog listing, and spec-based inspection. Minor gaps such as missing screenshot or scroll capabilities are workarounds, but the surface is robust for style verification.

Maintenance

ActivitySlowing
ResponsivenessNo issues