Promptlint MCP

io.github.sean-sunagaku由 GitHub 帳號 sean-sunagaku 發布v0.1.3更新於 Oct 24, 2026

Static linter for AI prompts: contradictions, redundancy, ambiguity, and fluff.

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

檢查英文 AI 提示詞中的矛盾、重複、語意不清與冗詞,並可回傳精簡版本以節省 token。

可以做什麼
這是一套針對英文散文式提示詞的靜態分析工具,適用於系統提示詞、代理指令與工具描述。它提供兩個工具:lint_prompt 會回傳一行摘要,以及包含評分、問題與 token 數量的完整 JSON;trim_prompt 則回傳精簡後的提示詞與節省統計。規則涵蓋成對的對立指令、近似重複的句子、過長的圍欄程式碼範例、指涉不明的代名詞,以及禮貌性冗詞。兩個工具都是純函式且不保存狀態。
適用情境
適合在撰寫或審閱系統提示詞與代理指令時使用,以便在送出前找出隱含的矛盾或冗長表述。也適合從冗長的提示詞中回收 token。它不是程式碼檢查工具,只處理英文散文。
執行需求
需要 Node.js 18 或更新版本。以本機 stdio 程序執行,通常透過 npx -y promptlint-mcp 或全域安裝啟動。未宣告任何帳號、API 金鑰、環境變數或標頭,工具不會使用網路或檔案系統存取。
安裝前請注意
trim_prompt 只會移除冗詞,不會解決矛盾、重複或語意不清,因此應先執行 lint。精簡會改寫提示詞文字,使用前請先檢查輸出。提示詞由該工具在本機處理。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

promptlint-mcp

[npm] [npm downloads] [GitHub stars] [MIT License] [Node 18+] [MCP compatible]

Lint AI prompts like code. Save tokens. Catch contradictions.

A static analyzer for AI prompts — system prompts, agent instructions, tool descriptions — that runs as a CLI and as an MCP server so Claude Code (or any MCP-aware agent) can lint prompts before sending them.


Quick demo

Run promptlint on a typical (silently broken) system prompt:

text
$ node src/cli.mjs examples/bad-prompt.md
promptlint examples/bad-prompt.md  score  14/100  tokens 367 → 307 (-60, 16% saved)  issues 14
  info   [ambiguous-pronoun] Pronoun "that" has no clear referent (line 1)         → Replace with a concrete noun, e.g. "this" → "the config file".  ...  error  [contradiction] Contradicting directives (length): "concise" vs "detailed"         → Pick one, or scope each with a clear condition (e.g. by task type).  error  [contradiction] Contradicting directives (commenting): "do not add comments" vs "explain each step"         → Pick one, or scope each with a clear condition (e.g. by task type).  info   [trailing-fluff] "please" fluff (match 1 of 1)         → Delete. AIs do not need politeness tokens.         · Please  ...

Two error-level contradictions caught, score clamped to 14/100, 60 tokens (16%) reclaimable via --trim.

And here's --trim in action on a small input:

text
$ echo "You are a helpful assistant. Please always be concise. Thank you for your help! When the user asks a question, handle it carefully." | node src/cli.mjs - --trim
You are a helpful assistant. Always be concise. When the user asks a question, handle it carefully.

See docs/promo/ for posting drafts and the (TODO) asciinema cast.


Why

  • Contradictions: "be concise" + "be thorough" ships silently and wastes tokens on every request. promptlint flags paired opposites (length / tone / frequency / commenting / asking) as error.
  • Redundancy: near-duplicate sentences (Jaccard > 0.6) get one warn apiece — delete one.
  • Ambiguous pronouns: "use it" / "handle that" without a mid-sentence referent is flagged with a line number. Start-of-sentence capitals do NOT count as referents, so normal English doesn't false-positive.
  • Long code examples: fenced code blocks over ~1200 chars or 30 lines trigger a warn — examples are almost always trimmable to shape-only.
  • Politeness fluff: Please / Thanks / I hope this helps / Let me know if… / Feel free to… are detected, counted, and (with --trim) stripped while keeping your actual imperatives intact.

Scope: English prompts, prose — not source code. A Japanese prompt or a file of JavaScript will look clean even if it isn't.


Install

Install both the CLI and the MCP server in one go:

sh
npm install -g promptlint-mcp

Two binaries are placed on your $PATH:

BinWhat it is
promptlintthe CLI (lint a file or stdin)
promptlint-mcpthe MCP server (stdio transport)

Run without installing

sh
# CLI: lint a filenpx -p promptlint-mcp promptlint <file>
# CLI: lint stdinecho "be concise and thorough" | npx -p promptlint-mcp promptlint -
# MCP server (auto-launched by Claude Code via mcp config; see below)npx -y promptlint-mcp

From source (hacking on it)

sh
git clone https://github.com/sean-sunagaku/promptlint-mcp.gitcd promptlint-mcpnpm installnode src/cli.mjs examples/bad-prompt.md

Requires Node >= 18. Zero runtime deps other than the MCP SDK.


CLI usage

Default human report

sh
node src/cli.mjs examples/bad-prompt.md
promptlint examples/bad-prompt.md  score  14/100  tokens 367 → 307 (-60, 16% saved)  issues 14
  info   [ambiguous-pronoun] Pronoun "that" has no clear referent (line 1)         → Replace with a concrete noun, e.g. "this" → "the config file".  ...  error  [contradiction] Contradicting directives (length): "concise" vs "detailed"         → Pick one, or scope each with a clear condition (e.g. by task type).  error  [contradiction] Contradicting directives (commenting): "do not add comments" vs "explain each step"         → Pick one, or scope each with a clear condition (e.g. by task type).  info   [trailing-fluff] "thanks" fluff (match 1 of 2)         → Delete. AIs do not need politeness tokens.         · Thank you  info   [trailing-fluff] "please" fluff (match 1 of 1)         → Delete. AIs do not need politeness tokens.         · Please  info   [trailing-fluff] "hope-helps" fluff (match 1 of 1)         → Delete. AIs do not need politeness tokens.         · I hope this helps  ...

A clean prompt (see examples/good-prompt.md) returns score 100/100 with zero issues — silence is a feature.

--json for machine consumption

sh
node src/cli.mjs examples/bad-prompt.md --json
json
{  "score": 14,  "issues": [    {      "rule": "ambiguous-pronoun",      "severity": "info",      "message": "Pronoun \"that\" has no clear referent (line 1)",      "line": 1,      "suggestion": "Replace with a concrete noun, e.g. \"this\" → \"the config file\"."    },    {      "rule": "contradiction",      "severity": "error",      "message": "Contradicting directives (length): \"concise\" vs \"detailed\"",      "suggestion": "Pick one, or scope each with a clear condition (e.g. by task type)."    }  ],  "trimmed": "…",  "tokensBefore": 367,  "tokensAfter": 307,  "saved": 60,  "savedPercent": 16}

Empty input adds "note": "empty input". Pure-fluff input (e.g. "Thanks!") that would otherwise trim to empty instead returns the original with "trimmerFallback": true — a safe drop-in never hands a blank prompt to your LLM.

--trim to print trimmed output (for piping)

sh
echo "You are a helpful coding assistant. Please always be concise. Thank you for your help! When the user asks a question, handle it carefully. If they provide code, review it. Let me know if anything is unclear. I hope this helps!" \  | node src/cli.mjs - --trim
You are a helpful coding assistant. Always be concise. When the user asks a question, handle it carefully. If they provide code, review it.

Fenced code blocks are preserved verbatim. Quoted strings ("…") and inline backticks (`…`) are masked before fluff removal so example text survives untouched.

Stdin

sh
cat prompt.md | node src/cli.mjs -

The report header shows promptlint <stdin>.

Other flags

sh
node src/cli.mjs --rules      # list the 5 rule IDs, one per linenode src/cli.mjs --help       # usage

Exit codes

CodeMeaning
0no errors (warn/info ok)
1at least one error-severity issue
2bad usage (missing file, read failure, etc.)

MCP server usage

Register with Claude Code in one command (no clone, no global install needed):

sh
claude mcp add promptlint -- npx -y promptlint-mcp

Or add this to ~/.claude.json (user scope) or project .mcp.json (project scope):

json
{  "mcpServers": {    "promptlint": {      "command": "npx",      "args": ["-y", "promptlint-mcp"]    }  }}

If you've globally installed the package, the absolute-path form also works and skips npx's first-run download:

json
{  "mcpServers": {    "promptlint": {      "command": "promptlint-mcp"    }  }}

Tools exposed

ToolInputReturns
lint_prompt{ text: string }Two text content items: [0] human one-line summary ("score: X/100 · issues: N · tokens: A → B …"), [1] full JSON of the lint() result (parse with JSON.parse(result.content[1].text)).
trim_prompt{ text: string }Two text content items: [0] the trimmed prompt, [1] a savings footer ("Saved N tokens (P%). Original: A, trimmed: B."). Does NOT resolve contradictions, redundancy, or ambiguity — run lint_prompt for those.

Both tools are pure / idempotent. No network, no filesystem, no state.


Rules

IDSeverityWhat it catchesExample trigger
contradictionerrorPaired opposing directives on length / tone / frequency / prohibition / commenting / asking"be concise" + "be thorough"
redundancywarnTwo sentences with Jaccard word-set similarity > 0.6Two paragraphs that both say "respond in English" with different wording
long-examplewarnFenced code block > 1200 chars or > 30 linesA 40-line helper function pasted inline
ambiguous-pronouninfoit / this / that / these / those with no mid-sentence concrete referent"Use it to figure out what to do."
trailing-fluffinfoPoliteness / filler: please, thanks, I hope this helps, let me know if…, feel free to…, sorry, certainly/absolutely/of course"Please refactor the code. Thanks!"

Score formula: 100 - (errors*25 + warns*10 + infos*3), then clamped to <=59 if any error exists and <=79 if 2+ warnings exist. Severity ceilings are a traffic-light: any error = red zone, regardless of count.


Pricing & Roadmap

Free (OSS, MIT)

  • CLI (node src/cli.mjs) — all three modes (report / JSON / trim), all 5 rules.
  • MCP server (node src/mcp.mjs) — both tools, unlimited use.
  • No account, no telemetry, no network.

Pro (planned, $9/mo)

  • Team-shared custom rule dictionary (your project's bannned phrases, required headers, forbidden contradictions).
  • Per-project lint history with diff view.
  • Cross-project token-savings dashboard ("your team saved 1.2M tokens this month").

Pro is not shipped yet. No signup form today — 👍 the early-access issue (#1) to register interest. We DM invites in 👍 order.


Development

Smoke test

sh
npm run lint:self         # lints examples/bad-prompt.md

Expected: exit 1 (2 error contradictions), score in the low teens, all rules firing. If this drifts, a rule regressed.

Baseline

examples/good-prompt.md must always score 100/100 with 0 issues. If a change breaks that, the change is wrong.

Adding a rule

Rules live in src/linter.mjs. Each rule is a plain function:

js
function ruleFooBar(text) {  // return an array of { rule, severity, message, samples?, suggestion, line? }  return [];}

Add it to the issues array inside lint() and append its ID to the RULES export. If it targets prose (not code), run it against the maskCodeBlocks() copy so fenced examples don't trigger it. If it needs sentence splitting, reuse splitSentences (quote-aware) or splitSentencesPreservingDelims (quote-aware, keeps delimiters for the trimmer).

Contradictions

Extend CONTRADICTION_PAIRS at the top of src/linter.mjs. Each entry is:

js
{ a: ["keyword-a", ...], b: ["keyword-b", ...], label: "short-label" }

Existing labels: length, tone, frequency, prohibition, commenting, asking.


Community

How this was built

This package was produced end-to-end by two AI agent teams:

  • ai-auto-improve-app — built and polished the product. Customer AI uses the tool and writes feedback → Developer AI patches the code → repeat. Each round's commit (round-001 … round-003) is the developer-AI's response to that round's customer-AI feedback.
  • ai-launch-team — published and distributed it. 5 sub-agents handled npm publish, GitHub Release, awesome-mcp PRs, Discussions threads, social copy drafts, and SVG/PNG asset generation.

Combined, this took the product from "empty repo" to "v0.1.2 on npm + 2 awesome-mcp PRs + 2 Discussions seed threads + 4 Issues + full social drafts" with the only manual step being the platform-mandated SMS / OTP authentications (X account creation, npm 2FA setup) — the rest was AI.

License

MIT — see LICENSE.

來源:README.md,提交 8a31da8

工具

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

版本歷史

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

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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