cssgraph
Provides CSS intelligence for AI coding agents by indexing class names, properties, and at-rules, enabling lookups of style context, cascade overrides, and file impact.
Supports CSS Modules by indexing locally scoped class names and their references, allowing agents to trace class usage and evaluate the blast radius of changes.
Adds support for Less stylesheets, indexing selectors, variables, and imports to provide style context, cascade analysis, and impact information.
Adds support for Sass and SCSS stylesheets, including nested selectors and variables, enabling agents to query style definitions, overrides, and file-level effects.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@cssgraphWhich files use .btn-primary and what overrides it?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
cssgraph
CSS Intelligence for AI Coding Agents
Surgical style context · fewer tool calls · faster answers · 100% local
Why cssgraph?
When an AI agent needs to understand CSS — where is .btn-primary defined, what properties does it have, which selectors cascade over it, which JSX components reference it — it discovers style the slow way: grep, glob, and Read, one file at a time, reconstructing the cascade by hand.
cssgraph hands the agent the exact style context it needs in one call. It's a pre-built knowledge graph of every className, CSS property, variable, and at-rule in your stylesheets — so instead of crawling files, the agent asks one question and gets back the properties, overrides, specificity, callers, and file-level impact in full.
Related MCP server: MindGraph
Installation
For Humans
Copy and paste this prompt to your LLM agent (Claude Code, Cursor, Codex, etc.):
Install and configure cssgraph by following the instructions here:
https://raw.githubusercontent.com/mack-peng/cssgraph/main/docs/guide/installation.mdOr 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/cssgraph/main/docs/guide/installation.mdQuick Start
1. Initialize
npm i -g cssgraph
cd your-project
cssgraph init --workers 8Indexes all style files (CSS, SCSS, Less, Sass), JSX/TSX className references, CSS-in-JS, CSS Modules, and view templates (ERB/Haml/HTML) — enabling every MCP tool.
Pass --workers <n> to control parallel parse threads (default: cpu cores - 1).
Requires Node.js >= 22.5.0 (for node:sqlite).
2. Wire up your agent
cssgraph mcp-installAuto-detects and configures opencode, Claude Code, Cursor, Codex CLI, Gemini CLI,
Hermes Agent, Antigravity IDE, and Kiro. Writes MCP server config, instructions
block, and an Agent Skill (SKILL.md + references/pitfalls.md) that teaches
agents when to use each of the 13 cssgraph tools, how to chain them into
workflows, and what pitfalls to avoid.
Or add to any MCP agent manually:
{
"mcpServers": {
"cssgraph": {
"type": "stdio",
"command": "cssgraph",
"args": ["serve", "--mcp"]
}
}
}3. No more syncing
Auto-sync is enabled by default. The MCP server watches your project and updates the graph on every file change — while your agent edits code, or you add/modify/delete CSS files. The index is never stale.
How It Works
┌───────────────────────────────────────────────────────────┐
│ AI Agent │
│ │
│ "What code files use .btn-primary?" │
│ calls cssgraph_rule — one tool call │
│ │ │
└─────────────────────────────┬─────────────────────────────┘
│
▼
┌───────────────────────────────────────────────────────────┐
│ cssgraph MCP Server │
│ │
│ rule · O(1) exact selector lookup · loose/strict impact │
│ explore · properties + overrides + specificity + callers │
│ │ │
│ ▼ │
│ SQLite knowledge graph │
│ classNames · properties · variables · at-rules │
│ edges · FTS5 full-text search │
└───────────────────────────────────────────────────────────┘Extraction — PostCSS parses CSS/SCSS/Less/Sass into ASTs. CSS-in-JS (
styled.div), JSX className references, and template class attributes extracted from.jsx/.tsx/.erb/.hamlfiles.Storage — Everything goes into a local SQLite database (
.cssgraph/cssgraph.db) with FTS5 full-text search. WAL-mode + batch commits for write performance. FTS triggers and unique indexes are deferred during bulk load for speed.Graph — Edges connect related nodes:
contains(selector→property),nests(parent→child selector),overrides(higher specificity selector overrides lower),imports(file→imported file),references(JSX/view file→className, property→CSS variable).Git-first scanning —
git ls-filesfor instant file discovery. Falls back to filesystem walk on non-git projects.Parallel parsing — Files dispatched in batches to worker threads via
Promise.all. Parses complete concurrently; results flushed in file order for correctness.Auto-Sync — Native OS file events, debounced, incrementally synced.
CLI Reference
cssgraph init [path] [-w, --workers <n>] # Initialize + build graph
cssgraph index [path] [-w, --workers <n>] # Rebuild from scratch
cssgraph query <className> # Search for className selectors
cssgraph explore <query...> # Full style context for a className
cssgraph details <selector> # O(1) exact selector → file:line lookup
cssgraph rule <selector> [--strict] # Selector impact: exact + loose/strict files
cssgraph impact-selector <selector> # Code files affected by a selector
cssgraph impact <className> # Blast radius of changing a className
cssgraph unused # Find unreferenced class selectors
cssgraph cascade <className> # Visualize cascade path
cssgraph diagnose <className> [chain...] # Static anchor diagnosis (height/scroll)
cssgraph property <query...> # Search by CSS property value
cssgraph files [path] # Project style file tree
cssgraph status [path] # Index statistics
cssgraph sync [path] # Incremental update
cssgraph serve --mcp # Start MCP server
cssgraph mcp-install # Auto-wire to your AI agent (alias: install)
cssgraph skill-install # Install/update SKILL.md only (no MCP config changes)
cssgraph skill-uninstall # Remove SKILL.md only (no MCP config changes)
cssgraph mcp-uninstall # Remove from your AI agent (alias: uninstall)
cssgraph version # Print installed versionJSX and View File Scanning (default)
cssgraph always scans:
JSX/TSX/JS/TS/ES6 —
classNamereferences, CSS-in-JS, CSS ModulesView templates —
.erb,.haml,.htmlfiles forclass="..."attributes and Haml.classnameshorthand
This enables cssgraph_impact, cssgraph_callers, and cssgraph_rule to track both component files AND template files that reference each className.
Project | Total files | First index | Nodes | Edges |
Small | ~50 | ~15s | ~16K | ~50K |
Production monorepo | ~11K | ~3-5m | ~780K | ~22M |
MCP Tools
Tool | Purpose |
| PRIMARY: Full style context for a className — properties, overrides, specificity, callers |
| Search for className selectors by name |
| Find JSX components referencing a className |
| Blast radius of changing a className |
| Blast radius of a full CSS selector (exact match + loose/strict file impact) |
| Find code files (JS/TS/JSX/TSX) affected by a CSS selector |
| O(1) exact selector lookup (no edges, lightweight) |
| Find class selectors with no incoming references |
| Visualize the cascade path for a className |
| Static anchor diagnosis for scroll/height issues — classifies height declarations as DEFINITE / INDEFINITE / UNVERIFIABLE along the ancestor chain |
| Search selectors by CSS property value |
| Indexed style file tree |
| Index health check |
Complementary Tool: cssprobe-cli
cssgraph is a static analysis tool — it reads your source code and answers where a class is defined, what cascades over it, and what a change would affect. For runtime questions — what a page actually renders in a browser (overflow, scroll chains, computed height chains, containing block hijacks) — use cssprobe-cli, which opens a real browser and reads computed styles plus DOM metrics. The two tools complement each other:
cssgraph (static) | cssprobe-cli (runtime) | |
Analyzes | source code (CSS/SCSS/Less + JSX/TSX + templates) | live browser (computed styles + DOM) |
Answers | where a class is defined, cascade, impact, unused CSS | actual rendered layout, overflow, scroll, height chains |
When | before/without a browser | after static analysis, to verify at runtime |
Usage |
|
|
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)
npm i -g cssprobe-cli
cssprobe-cli open https://example.com
cssprobe-cli inspect .btn-primary
cssprobe-cli findings .btn-primaryInstall: npm install -g cssprobe-cli (requires Node.js >= 22.5.0). See npm / GitHub.
Supported Languages
Language | Extension | Extraction |
CSS |
| PostCSS standard |
SCSS |
| postcss-scss plugin |
Less |
| postcss-less plugin |
Sass (indented) |
| Compile → PostCSS |
PostCSS custom |
| PostCSS standard |
JSX / TSX |
| className + CSS-in-JS |
JavaScript / TypeScript |
| className + CSS Modules |
ERB (Rails) |
|
|
Haml (Rails) |
|
|
HTML |
|
|
CSS Modules |
| Dynamic import resolution |
Tailwind |
| v3 JS config + v4 CSS config |
Production Scale
Project | Total files | First index | Nodes | Edges |
Small | ~50 | ~15s | ~16K | ~50K |
Production monorepo | ~11K | ~3-5m | ~780K | ~22M |
Project Configuration
Zero-config by default. Optional .cssgraph.json at your project root:
{
"exclude": ["static/vendor/", "**/legacy/**"],
"extensions": {
".pcss": "css"
}
}Built-in default excludes (always applied): **/*.test.*, **/*.stories.*, **/*.spec.*, **/*.min.*, **/__tests__/**, **/__snapshots__/**, **/__mocks__/**, **/generated/**, **/spec/**, **/vendor/**.
Supported Platforms
Platform | Architectures | Install |
macOS | x64, arm64 | npm |
Linux | x64, arm64 | npm |
Windows | x64, arm64 | npm |
If cssgraph is useful
A ⭐ star helps other developers discover it — and tells us to keep shipping.
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Codebase graphs, caller impact analysis, and recorded project context for AI coding agents.
Give your AI agent a persistent map of your project's structure, dependencies, and bugs.
Codebase intelligence for AI agents — dead code, blast radius, ownership.
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to query a pre-built semantic knowledge graph of code, reducing token usage and tool calls. Supports 16 tools for code exploration, analysis, and context building.5 npm7MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to query and analyze code across multiple repositories through a unified knowledge graph, with tools for symbol search, impact analysis, and graph algorithms.17 npmMIT
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to query a codebase as a knowledge graph, providing token-budgeted context, search, and impact analysis via MCP tools.MIT
- AlicenseNot gradedqualityBmaintenanceEnables coding agents to query a local, versioned knowledge graph of a software project, retrieving overviews, context packs, evidence, and explanations to make informed changes.MIT