
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.
概覽
為 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 金鑰或環境變數。僅支援桌面端,不提供網頁可執行版本。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Cssgraph,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
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]
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.):
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:
Quick Start
1. Initialize
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
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:
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
- 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
JSX and View File Scanning (default)
cssgraph always scans:
- JSX/TSX/JS/TS/ES6 —
classNamereferences, CSS-in-JS, CSS Modules - View 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.
MCP Tools
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:
Recommended workflow for a style problem — go static first, then verify at runtime:
Install: npm install -g cssprobe-cli (requires Node.js >= 22.5.0). See npm / GitHub.
Supported Languages
Production Scale
Project Configuration
Zero-config by default. Optional .cssgraph.json at your project root:
Built-in default excludes (always applied): **/*.test.*, **/*.stories.*, **/*.spec.*, **/*.min.*, **/__tests__/**, **/__snapshots__/**, **/__mocks__/**, **/generated/**, **/spec/**, **/vendor/**.
Supported Platforms
If cssgraph is useful
A ⭐ star helps other developers discover it — and tells us to keep shipping.
License
MIT
來源:README.md,提交 6f8726d
工具
0版本歷史
1- v0.6.3最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分