ClaudeMods
☰
ZH-TW
● 0 人在線上 · 瀏覽 0 次
贊助提交作品
GitHub 儲存庫 · 發布者 ccdwyer

red-squiggle

一個 Claude Code 外掛,會對 Claude 剛編輯的檔案執行型別檢查與 lint,並把錯誤放進同一個工具結果,讓模型在造成問題的那一步就看見壞掉的型別。

已翻譯

關於這個 mod

Red Squiggle hook 會在每次成功的 Edit 或 Write 後執行,針對剛編輯的檔案進行型別檢查與 lint,並把錯誤放入同一個工具結果,讓模型在造成問題的當下看到錯誤,而不是等到幾個回合後測試失敗才發現。

支援的檢查器包括:

  • 專案自帶的 TypeScript(用 --noEmit --incremental 針對包含該檔案的設定檔執行,會追蹤 extends 與 references,並用 --listFiles 判定檔案是否屬於程式)。
  • 專案自帶的 eslint(只有存在設定檔時才執行,使用 --format json --quiet 只回報錯誤)。
  • Python 檔案使用 ruff check --no-fix。

只回報「新」錯誤:每個檢查器會維護基準線並逐一計算錯誤。第一次遇到專案或檔案時先建立基準線,只顯示這次編輯新引入的錯誤,以及這次編輯新弄壞的其他檔案錯誤。輸出會以引號包住的上下文附加在工具結果後方,上限為 20 行,並標示為資料而不是指令。狀態列會顯示檔案是否乾淨或有多少錯誤;檢查器缺少、崩潰或逾時(預設 30 秒)時會 fail-open,保留原始結果。同一個專案一次只執行一個 tsc,專案查找會在 repo 根目錄停止,不會安裝任何東西,也不會改用 npx。

可以透過 /config 切換 tsc、eslint、ruff 和 timeoutSeconds。安裝方式是加入 ccdwyer/claude-mods marketplace 後安裝 red-squiggle。所有檢查都在本機執行,不傳送網路資料,也不收集遙測。授權為 MIT。

安裝

請先查看作者 README,確認 marketplace 與外掛名稱;指令可能隨儲存庫結構而變動。

claude plugin marketplace add ccdwyer/red-squiggle
claude plugin install red-squiggle
原文 / README

Red Squiggle

Red Squiggle demo

A Claude Code mod that type-checks and lints the file Claude just edited and puts any errors into that same tool result. The model sees broken types on the step that caused them, not three turns later when a test run fails.

Red Squiggle runs after each successful Edit or Write. It skips edits that errored and edits staged for review.

| File | Checker | Notes | |---|---|---| | .ts .tsx .js .jsx .mts .cts .mjs .cjs | the project's own TypeScript (node_modules/typescript/bin/tsc) | Runs --noEmit --incremental on the config whose program contains the file. It reads include, exclude, files, allowJs and checkJs through extends (relative, package and array forms) with real glob matching, and recursively follows references. A file that no glob takes, but that may be in a program through an import, is checked against the nearest config, and --listFiles decides. A build-info file goes under node_modules/.cache/red-squiggle/. | | same | the project's own node_modules/.bin/eslint | Only when an eslint config exists. Runs from that config's folder with --format json --quiet, so it reports errors only. | | .py | ruff check --no-fix | Uses .venv/bin/ruff, then venv/bin/ruff, then ruff on PATH. JSON output. |

  • Only new errors. Red Squiggle keeps a baseline of what each checker reported, counted per error, so a second identical error still shows. The first time it sees a project or file in a session, it takes the baseline just before the edit. If that fails, the first run after the edit becomes the baseline and nothing is reported as new. The model sees errors this edit introduced in the file, plus errors it newly broke in other files (tsc). Errors that were already there are counted, not repeated. Every error in a newly created file counts as new.
  • The output reaches the model as quoted context after the tool result, capped at 20 lines and marked as data, not instructions.
  • The status line shows ✓ file clean, ✗ N errors in file, or how many errors are new in other files. "Clean" means the file was proven to be in the program tsc checked (--listFiles). A file outside every program, or a run cut off before it proves the file was checked, reports nothing rather than "clean". Paths are compared through their real spelling (/tmp vs /private/tmp).
  • Fail-open. If a checker is missing, crashes or times out (default 30 s), or if anything else after the write throws, the edit's result comes back untouched.
  • Only one tsc runs per project at a time. Edits that arrive during a run share a single follow-up run.
  • Project lookups stop at the repository root (.git). It never installs anything or falls back to npx.

Settings

/config lists tsc, eslint and ruff toggles and timeoutSeconds.

Install

/plugin marketplace add ccdwyer/claude-mods
/plugin install red-squiggle@ccdwyer-mods
/reload-plugins

Develop

claude plugin validate .
claude plugin test .

What it hooks

Events this mod hooks, as claude plugin validate reads the module:

  • tool.call

Engine calls it makes: $.fs.exists, $.fs.read (via eslintPlan, readJson), $.fs.stat (via canonical), $.process.run (via run), $.state.get, $.state.set, $.ui.status (via annotate).

A tool.call hook sits in the middle of every tool call: it can see the call, refuse it, or add context to its result. This mod uses that only for the behaviour described above.

Privacy

It runs entirely on your machine. It sends nothing over the network. It runs your project's own tsc, eslint and ruff.

The mod collects no analytics or telemetry, and its author receives no data from it.

Full policy: PRIVACY.md.

License

MIT

更多類似作品