ClaudeMods
☰
ZH-CN
● 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

更多类似作品