Cssgraph

io.github.mack-peng由 GitHub 帳號 mack-peng 發布v0.6.3更新於 Oct 24, 2026

CSS intelligence for AI coding agents — surgical style context, fewer tool calls. 100% local.

已驗證STDIO僅桌面知識與記憶開發者工具

概覽

AI 產生的概覽

為 AI 程式助理提供本機 CSS 知識圖譜,一次呼叫就能查詢類別定義、層疊覆寫與受影響的檔案。

可以做什麼
cssgraph 會把專案的樣式檔(CSS、SCSS、Less、Sass、PostCSS、CSS Modules、Tailwind)以及 JSX/TSX 與檢視樣板索引到本機 SQLite 圖譜,內含 className、屬性、變數、at-rule,以及 contains、nests、overrides、imports、references 等邊。它的 13 個 MCP 工具可回答類別在哪裡定義、哪些規則層疊覆寫它、哪些元件引用它、修改會影響什麼、哪些類別未被使用,以及層疊路徑如何。檔案監看會在程式碼變動時保持索引同步。
適用情境
適合助理在真實專案中處理前端樣式、否則得逐一 grep 與讀取檔案來還原層疊的情況。可用於重構、修改類別前的影響評估,以及找出未使用或被覆寫的選擇器。它只做靜態分析;執行時算繪問題需要另外的瀏覽器工具。
執行需求
透過 stdio 啟動的本機程序,從 npm 套件 cssgraph 安裝。需要 Node.js >= 22.5.0(用於 node:sqlite)以及一個要索引的專案,先在專案中執行 cssgraph init。未宣告帳號、API 金鑰或環境變數。僅支援桌面端,不提供網頁可執行版本。
安裝前請注意
它會讀取專案原始檔,並在專案的 .cssgraph/ 下寫入本機索引,同時監看檔案變動。README 的安裝方式要求代理從某個網址取得安裝指南並執行指令,且 cssgraph mcp-install 會改寫 MCP 伺服器設定並為偵測到的代理安裝技能檔,請先檢查這些變更。不涉及憑證或付款。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Cssgraph,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

cssgraph

CSS Intelligence for AI Coding Agents

Surgical style context · fewer tool calls · faster answers · 100% local

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

[macOS] [Linux] [Windows]


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.


Installation

For Humans

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

text
Install and configure cssgraph by following the instructions here:https://raw.githubusercontent.com/mack-peng/cssgraph/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:

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

Quick Start

1. Initialize

bash
npm i -g cssgraphcd your-projectcssgraph init --workers 8

Indexes 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

bash
cssgraph mcp-install

Auto-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:

json
{  "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                  │└───────────────────────────────────────────────────────────┘
  1. 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/.haml files.
  2. 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.
  3. 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).
  4. Git-first scanning — git ls-files for instant file discovery. Falls back to filesystem walk on non-git projects.
  5. Parallel parsing — Files dispatched in batches to worker threads via Promise.all. Parses complete concurrently; results flushed in file order for correctness.
  6. Auto-Sync — Native OS file events, debounced, incrementally synced.

CLI Reference

bash
cssgraph init [path] [-w, --workers <n>]  # Initialize + build graphcssgraph index [path] [-w, --workers <n>]  # Rebuild from scratchcssgraph query <className>                 # Search for className selectorscssgraph explore <query...>                # Full style context for a classNamecssgraph details <selector>                # O(1) exact selector → file:line lookupcssgraph rule <selector> [--strict]        # Selector impact: exact + loose/strict filescssgraph impact-selector <selector>       # Code files affected by a selectorcssgraph impact <className>                # Blast radius of changing a classNamecssgraph unused                            # Find unreferenced class selectorscssgraph cascade <className>               # Visualize cascade pathcssgraph diagnose <className> [chain...]   # Static anchor diagnosis (height/scroll)cssgraph property <query...>               # Search by CSS property valuecssgraph files [path]                      # Project style file treecssgraph status [path]                     # Index statisticscssgraph sync [path]                       # Incremental updatecssgraph serve --mcp                       # Start MCP servercssgraph 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 version

JSX and View File Scanning (default)

cssgraph always scans:

  • JSX/TSX/JS/TS/ES6 — className references, CSS-in-JS, CSS Modules
  • View templates — .erb, .haml, .html files for class="..." attributes and Haml .classname shorthand

This enables cssgraph_impact, cssgraph_callers, and cssgraph_rule to track both component files AND template files that reference each className.

ProjectTotal filesFirst indexNodesEdges
Small~50~15s~16K~50K
Production monorepo~11K~3-5m~780K~22M

MCP Tools

ToolPurpose
cssgraph_explorePRIMARY: Full style context for a className — properties, overrides, specificity, callers
cssgraph_searchSearch for className selectors by name
cssgraph_callersFind JSX components referencing a className
cssgraph_impactBlast radius of changing a className
cssgraph_ruleBlast radius of a full CSS selector (exact match + loose/strict file impact)
cssgraph_impact_selectorFind code files (JS/TS/JSX/TSX) affected by a CSS selector
cssgraph_detailsO(1) exact selector lookup (no edges, lightweight)
cssgraph_unusedFind class selectors with no incoming references
cssgraph_cascadeVisualize the cascade path for a className
cssgraph_diagnoseStatic anchor diagnosis for scroll/height issues — classifies height declarations as DEFINITE / INDEFINITE / UNVERIFIABLE along the ancestor chain
cssgraph_propertySearch selectors by CSS property value
cssgraph_filesIndexed style file tree
cssgraph_statusIndex 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)
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:

bash
# 1. Static: find the definitions, cascade, and blast radius (cssgraph)cssgraph explore .btn-primarycssgraph cascade .btn-primary
# 2. Runtime: confirm what actually renders (cssprobe-cli)npm i -g cssprobe-clicssprobe-cli open https://example.comcssprobe-cli inspect .btn-primarycssprobe-cli findings .btn-primary

Install: npm install -g cssprobe-cli (requires Node.js >= 22.5.0). See npm / GitHub.


Supported Languages

LanguageExtensionExtraction
CSS.cssPostCSS standard
SCSS.scsspostcss-scss plugin
Less.lesspostcss-less plugin
Sass (indented).sassCompile → PostCSS
PostCSS custom.pcssPostCSS standard
JSX / TSX.jsx .tsxclassName + CSS-in-JS
JavaScript / TypeScript.js .ts .es6className + CSS Modules
ERB (Rails).erbclass="..." extraction
Haml (Rails).haml.classname + {:class =>} extraction
HTML.htmlclass="..." extraction
CSS Modules.module.css .module.scss .module.lessDynamic import resolution
Tailwindtailwind.config.js + CSS @themev3 JS config + v4 CSS config

Production Scale

ProjectTotal filesFirst indexNodesEdges
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:

json
{  "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

PlatformArchitecturesInstall
macOSx64, arm64npm
Linuxx64, arm64npm
Windowsx64, arm64npm

If cssgraph is useful

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


License

MIT

來源:README.md,提交 6f8726d

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.6.3最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分