mcpField
P
prodlint

prodlint

本地服务
prodlint.com开发工具15今天更新

关于 prodlint

prodlint 是用于检查 AI 编码工具生成应用的静态分析工具,面向希望评估代码投产准备度的开发者。它以 52 条规则检查安全性、可靠性、性能和 AI 代码质量,无需配置或 LLM。

主要功能

  1. 0152 条生产准备度规则
  2. 02覆盖安全、可靠性与性能
  3. 03检查 AI 代码质量问题
  4. 04支持 JSON、SARIF 与基线
  5. 05提供可操作的修复提示

适用场景

  1. 01在提交前扫描 AI 生成的应用代码
  2. 02在 CI 中阻止关键问题进入构建
  3. 03将扫描结果上传至 GitHub Code Scanning

MCP 相关

prodlint 内置 MCP 服务,提供只读的 scan 和 scan-web 工具。MCP 客户端可扫描项目目录或网站,并获取评分、分类结果和发现项。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"prodlint-prodlint": {
"command": "npx",
"args": [
"-y",
"prodlint-mcp"
]
}
}
}
启动命令npx -y prodlint-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmprodlint-mcp0.10.4

工具

2

收录的工具列表 · 更新于 1 天前

参数类型必填说明
pathstring是要扫描的项目目录的绝对路径
ignorearray否要忽略的 Glob 模式

详细介绍

prodlint

npm version npm downloads License: MIT

为氛围编程应用做好生产环境就绪准备。

针对氛围编程应用的静态分析。标记 Cursor、v0、Bolt 和 Copilot 生成的安全性、可靠性、性能和 AI 质量问题——虚构的导入、缺失的身份验证、硬编码的密钥、未经验证的服务端操作等。零配置,无需 LLM,共 52 条规则。

npx prodlint
  prodlint v0.10.4
  Scanned 148 files · 2 critical · 5 warnings · 1 info

  src/app/api/checkout/route.ts
    12:1  INFO  No rate limiting — anyone could spam this endpoint and run up your API costs  rate-limiting
    28:5  WARN  Empty catch block silently swallows error  shallow-catch

  src/actions/submit.ts
    5:3   CRIT  Server action uses formData without validation  next-server-action-validation
      ↳ Validate with Zod: const data = schema.safeParse(Object.fromEntries(formData))

  src/lib/db.ts
    1:1   CRIT  Package "drizzle-orm" is imported but not in package.json  hallucinated-imports

  Scores
  security        72 ████████████████░░░░  (8 issues)
  reliability     85 █████████████████░░░  (4 issues)
  performance     95 ███████████████████░  (1 issue)
  ai-quality      90 ██████████████████░░  (3 issues)

  Overall: 82/100 (weighted)

  2 critical · 5 warnings · 4 info

为什么?

氛围编程是最快的构建方式。快速发布意味着要确认代码已做好生产环境就绪准备,而不只是能通过编译。硬编码的密钥、虚构的软件包、缺失的身份验证和 XSS 攻击向量都能通过类型检查,看起来也没问题,但它们还不能用于生产环境。

prodlint 会检查 TypeScript 和 ESLint 不会检查的内容:你的氛围编程应用是否已做好生产环境就绪准备。

安装

npx prodlint                              # Run directly (no install)
npx prodlint ./my-app                     # Scan specific path
npx prodlint --json                       # JSON output for CI
npx prodlint --sarif                      # SARIF 2.1.0 for GitHub Code Scanning
npx prodlint --summary                    # Quick pass/fail + top 3 blockers
npx prodlint --profile startup            # Only critical findings
npx prodlint --profile strict             # All findings including info
npx prodlint --baseline .prodlint-baseline.json   # Only new findings
npx prodlint --ignore "*.test.ts"         # Ignore patterns
npx prodlint --min-severity warning       # Only warnings and criticals
npx prodlint --quiet                      # Suppress badge output

或者安装它:

npm i -D prodlint     # Project dependency
npm i -g prodlint     # Global install

4 个类别中的 52 条规则

安全性(27 条规则)
规则检查内容
secrets源代码中硬编码的 API 密钥、令牌和密码
auth-checks没有身份验证的 API 路由
env-exposure仅限服务端使用的密钥中包含 NEXT_PUBLIC_
input-validation未经验证便使用请求正文
cors-configAccess-Control-Allow-Origin: *,通配符与凭据组合时升级为严重问题
unsafe-htmldangerouslySetInnerHTML 使用用户数据
sql-injection使用字符串插值的 SQL 查询(可识别 ORM)
open-redirect将用户输入传入 redirect()
rate-limiting没有速率限制器的 API 路由
phantom-dependency存在于 node_modules 中、但未列入 package.json 的软件包
insecure-cookie缺少 httpOnly/secure/sameSite 属性的会话 Cookie
leaked-env-in-logsconsole.log 调用中包含 process.env.*
insecure-random使用 Math.random() 生成令牌、密钥或会话 ID
next-server-action-validation服务端操作使用 formData,但未通过 Zod/模式进行验证
env-fallback-secret安全敏感的环境变量使用硬编码的回退值
verbose-error-responseAPI 响应中泄露错误堆栈跟踪或错误消息
missing-webhook-verification未验证签名的 Webhook 路由
server-action-auth包含修改操作但没有身份验证检查的服务端操作
eval-injectioneval()、new Function()、动态代码执行
next-public-sensitive密钥环境变量使用 NEXT_PUBLIC_ 前缀
ssrf-risk服务端代码中将用户控制的 URL 传给 fetch
path-traversal文件系统操作中使用未经清理的用户输入
unsafe-file-upload未验证类型或大小的文件上传处理器
supabase-missing-rls迁移文件中的 CREATE TABLE 未启用 RLS
deprecated-oauth-flowOAuth 隐式授权模式(response_type=token)
jwt-no-expiry签名的 JWT 令牌未设置过期时间
client-side-auth-only客户端组件中的密码比较或身份验证逻辑
可靠性(11 条规则)
规则检查内容
hallucinated-imports导入 package.json 中不存在的包
error-handling异步操作没有 try/catch
unhandled-promise未使用 await 或 .catch 处理的悬空 Promise
shallow-catch吞掉错误的空 catch 代码块
missing-loading-state获取数据却没有加载状态的客户端组件
missing-error-boundary没有对应 error.tsx 的路由布局
missing-transaction多次 Prisma 写入未使用 $transaction
redirect-in-try-catchtry/catch 中的 redirect()——Next.js 的 redirect 会抛出异常,catch 会将其吞掉
missing-revalidation执行数据库变更却没有 revalidatePath 的服务端操作
missing-useeffect-cleanup有订阅或计时器却没有 cleanup 返回值的 useEffect
hydration-mismatch服务端组件渲染路径中使用 window/Date.now()/Math.random()
性能(6 条规则)
规则检查内容
no-sync-fsAPI 路由中使用 readFileSync
no-n-plus-one循环中的数据库调用
no-unbounded-query.findMany() / .select('*') 未设置上限
no-dynamic-import-loop循环中的 import()
server-component-fetch-self服务端组件请求自身的 API 路由
missing-abort-controllerFetch/axios 调用没有超时或 AbortController
AI 质量(8 条规则)
规则检查内容
ai-smellsany 类型、console.log、堆积的 TODO 注释
placeholder-content生产代码中残留 Lorem ipsum、示例邮箱、“your-api-key-here”
hallucinated-api.flatten()、.contains()、.substr()——AI 臆造的方法
stale-fallback生产代码中硬编码 localhost:3000
comprehension-debt超过 80 行的函数、过深嵌套、参数过多
codebase-consistency项目中命名约定不一致
dead-exports没有任何地方导入的导出函数
use-client-overuse未使用任何客户端 API 的文件却添加了 "use client"

智能检测

prodlint 可避免常见的误报:

  • AST 解析——基于 Babel 分析 13 条规则(导入、catch 代码块、重定向、try/catch 中的重定向、SSRF、路径遍历、JWT、HTML 注入、水合、事务、环境变量泄漏、循环、SQL),并在失败时回退到正则表达式
  • Monorepo 支持——自动解析 npm/yarn/pnpm 工作区依赖
  • 框架识别——Prisma、Drizzle、Supabase、Knex 和 Sequelize 白名单可避免误报 SQL 注入
  • 中间件检测——检测 Clerk、NextAuth、Supabase 中间件(middleware.ts,或 Next.js 16 中的 proxy.ts),并降低与身份验证相关问题的严重性
  • 块注释识别——忽略 /* */ 内的模式
  • 路径别名支持——@/、~/ 和 tsconfig 路径不会被标记为臆造导入
  • 路由豁免——身份验证、webhook、健康检查和 cron 路由不进行身份验证/速率限制检查
  • 测试/脚本文件识别——降低非生产文件的问题严重性
  • 修复建议——问题包含可执行的 fix 提示及修复代码

评分

每个类别的起始分均为 100。每个问题的扣分如下:

严重性扣分每条规则上限
critical-8最多 1 次
warning-2最多 2 次
info-0.5最多 3 次

递减收益:某个类别扣分达到 30 分后,后续扣分减半;达到 50 分后,后续扣分减至四分之一。

加权总分:安全性 40%、可靠性 30%、性能 15%、AI 质量 15%。最低为 0。存在任何 critical 问题时,退出代码为 1。

GitHub Action

添加到 .github/workflows/prodlint.yml:

name: Prodlint
on: [pull_request]

jobs:
  scan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: prodlint/prodlint@v1
        with:
          threshold: 50

会将评分明细作为 PR 评论发布,并在扫描发现严重问题或分数低于 threshold 时使构建失败。每个 Action 版本都会运行对应的 prodlint 版本,因此固定 Action 版本(@v1、版本标签或提交 SHA)也会固定扫描器版本。

输入默认值描述
path.要扫描的路径
threshold0通过所需的最低分数(0-100)
fail-on-criticaltrue扫描发现严重问题时使构建失败;设为 false 时报告问题,但不会使构建失败
ignore用逗号分隔的要忽略的 glob 模式
commenttrue发布包含结果的 PR 评论
输出描述
score总分(0-100)
critical严重问题的数量
SARIF + GitHub Code Scanning

将 prodlint 结果上传到 GitHub 的 Security 选项卡:

- name: Run prodlint
  run: npx prodlint --sarif > prodlint.sarif

- name: Upload SARIF
  uses: github/codeql-action/upload-sarif@v4
  with:
    sarif_file: prodlint.sarif
    category: prodlint
现有项目的基线

逐步采用 prodlint,避免被已有问题淹没:

# Save current state as baseline
npx prodlint --baseline-save .prodlint-baseline.json

# CI only fails on NEW findings
npx prodlint --baseline .prodlint-baseline.json

MCP 服务

在 Cursor、Claude Code 或任何兼容 MCP 的编辑器中使用 prodlint:

Claude Code:

claude mcp add prodlint -- npx -y prodlint-mcp

Cursor / Windsurf:

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

prodlint-mcp 是内置于 prodlint 的服务的轻量启动器。它随每个 prodlint 版本一同发布,因此始终运行匹配的扫描器。

向你的 AI 提问:“在此项目上运行 prodlint”,它便会直接调用 scan 工具。

工具输入返回内容
scanpath(项目目录)、可选的 ignore、minSeverity(critical / warning / info)、categories、maxFindings(默认值为 30)分数、分类分数,以及按严重程度从高到低排列的问题。即使超出 maxFindings,也会列出所有严重问题。
scan-weburl网站分数、等级,以及 14 项 Agent 就绪度检查

这两个工具都会返回 Markdown 摘要和结构化输出(structuredContent 与各自的 outputSchema 相匹配),并且都标记为只读(readOnlyHint)。GitHub Copilot 代码审查等托管审查工具要求工具具有此标记,才会调用 MCP 工具。

网站评分

检查任何已部署网站是否为 AI Agent 做好准备——包含 14 项检查,涵盖 llms.txt、TDMRep、AgentCard、AI-Disclosure、HTTP Signatures(RFC 9421)等新兴标准。

npx prodlint --web example.com
npx prodlint --web example.com --json     # JSON output
  prodlint site score
  example.com · 14 checks

  Score: 42 C  ████████░░░░░░░░░░░░

  ✗ AI-Disclosure Header          0/10  No AI-Disclosure header found.
  ✗ Content-Usage Directives      0/10  No Content-Usage directives found.
  ✗ TDMRep                        0/10  No TDMRep found.
  ✗ A2A AgentCard                  0/5  No agent-card.json found.
  ✗ ai.txt                         0/5  No ai.txt found at site root.
  ! llms.txt                       2/5  llms.txt found but missing key sections.
  ✓ robots.txt                   10/10  robots.txt found with 15 rules.
  ✓ Sitemap                      10/10  Valid sitemap with 42 URLs.
  ✓ Structured Data              10/10  Found JSON-LD structured data.
  ✓ OpenGraph                    10/10  Complete OpenGraph tags found.
  ✓ Page Speed                    5/5   Loaded in 0.8s.
  ✓ AI Bot Directives             5/5   AI-specific bot rules found.
  ✓ WebMCP Tools                   0/5  No WebMCP tools detected.

  7 passed · 5 failed · 1 warnings

  Full results: https://prodlint.com/score?url=example.com

也可以在 prodlint.com/score 互动查询分数。

面向 AI 工具

prodlint 专为 AI 生成代码的模式而设计。每条规则都用于检查 AI 编码工具一再引发的生产环境问题,而不是吹毛求疵地检查代码风格。

忽略问题

忽略单行问题:

// prodlint-disable-next-line secrets
const key = "sk_test_example_for_docs"

忽略整个文件(放在文件顶部):

// prodlint-disable secrets

编程接口

import { scan } from 'prodlint'

const result = await scan({ path: './my-project' })
console.log(result.overallScore) // 0-100
console.log(result.findings)     // Finding[]

徽章

[![prodlint](https://img.shields.io/badge/prodlint-85%2F100-brightgreen)](https://prodlint.com)

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。