SummerSec/semantic-linter

Semantic-Linter 是一个面向 LLM 指令文件的插件与 CLI,用来收窄语义边界过宽的表达。它主要用于 SKILL.md、AGENTS.md、CLAUDE.md、prompt 文档、command 文档等指令资产,帮助减少因为措辞过宽带来的幻觉和范围漂移。

catalog descriptioncatalog 简介 / catalog description:一款面向 LLM 指令文件的插件和命令行工具,用于检测语义边界过宽的用词,并提供受保护的 Hook、项目级本地规则注入,以及针对 Skill、Prompt 和 Agent 的语义陷阱检查。

Project Overview项目介绍

Semantic-Linter is a plugin and command-line tool for checking LLM instruction files that identifies overly broad semantic expressions to reduce model hallucination and scope drift. It works with common instruction assets like SKILL.md, AGENTS.md, CLAUDE.md, prompt documents, and command definitions. It supports three AI coding agent platforms: Claude Code, Codex, and DeepSeek Harness, each with its own dedicated installation process. For Claude Code, you install it from the plugin marketplace with three commands: add the repository, install the plugin, then reload plugins. For Codex, installation is similar, though it uses AGENTS.md rule blocks instead of Claude’s hook manifest.

Semantic-Linter uses a layered design instead of the older pointer-only approach. It injects a compact rule pointer at session start, propagates the pointer to subagents when they start, and runs checks at multiple points in the workflow: before user prompts are submitted, before tools write or edit files, and after writes are completed. It also keeps the bin/scan.js CLI entry for explicit scanning of a single file, an entire directory, or the current working directory. The default mode is guarded, which enables the rule pointer plus pre-write and post-write checks, while other modes like off, pointer, and strict are also available.

For DeepSeek Harness, you first need to install the official DSH CLI globally, then add this repository as a bundle to your desired profile using the dsh plugin command. Local development can be done by adding the current working directory directly to the profile. To initialize a local rule set for your existing project, run the build-rules.js script to generate a semantic-rules.md file and add managed rule blocks to AGENTS.md or CLAUDE.md. You can customize behavior through the optional .semantic-linter.json config file, which supports settings like ignored paths, default mode, and rule source strategy. The project includes full test coverage for core functionality, and you can run all tests with the npm test command.

Semantic-Linter 是一款面向大语言模型指令文件的插件与命令行工具,核心功能是检测并收窄语义边界过宽的表达,减少因措辞模糊导致的模型幻觉和任务范围漂移。它支持对 SKILL.md、AGENTS.md、CLAUDE.md 以及各类 prompt 文档、命令文档等指令资产做语义检查,可在 Claude Code、Codex 以及 DeepSeek Harness 三个平台安装使用,不同平台都提供了对应的适配接入方式。

它采用分层设计架构,默认启用 guarded 运行模式,会在会话启动时注入规则指针,子代理启动时传播规则,用户提交提示词前和工具写入修改前后分别做检查,还保留了独立的 CLI 入口,支持手动扫描单文件、整个目录或当前工作区。规则默认采用项目优先策略,先查找项目本地的 semantic-rules.md 规则文件,不存在时再回退使用插件自带规则。

对于 DeepSeek Harness 用户,需要先安装官方 DSH CLI,再通过 dsh plugin 命令将本仓库作为 bundle 添加到对应 profile 配置中。项目支持通过 .semantic-linter.json 自定义配置,可设置忽略规则、默认运行模式、规则来源等参数。要在现有项目中初始化本地规则,可运行指定脚本生成规则文件和对应受管指令区块。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 2 warnings2 项注意
  • No license declared - all rights reserved by default; ask the author before commercial use or redistribution未声明开源许可证 —— 默认「保留所有权利」,商用或再分发前先问作者
  • Only 2 stars - very few users, little community feedback星标只有 2,几乎没人在用,遇到问题缺少社区反馈
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile headless add github:SummerSec/semantic-linter

把 SummerSec/semantic-linter 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

English Version

Semantic-Linter

Semantic-Linter 是一个面向 LLM 指令文件的插件与 CLI,用来收窄语义边界过宽的表达。它主要用于 SKILL.md、AGENTS.md、CLAUDE.md、prompt 文档、command 文档等指令资产,帮助减少因为措辞过宽带来的幻觉和范围漂移。

当前架构

Semantic-Linter 现在使用分层设计,不再是旧的 pointer-only 方案:

  • SessionStart 注入一条紧凑的 STL: 规则指针,指向当前生效的 semantic-rules.md
  • SubagentStart 把同样的规则指针传播给子代理
  • UserPromptSubmit 可以在提示词进入模型前提醒宽边界表达
  • PreToolUse 会在 Write 和 Edit 修改指令文件前给出预警
  • PostToolUse 会在写入后再次检查结果,并记录升级状态
  • bin/scan.js 仍然保留为显式 CLI 扫描入口,可扫描单文件、目录或当前工作区

默认运行模式是 guarded:

  • off:关闭 semantic-linter
  • pointer:只保留轻量规则指针
  • guarded:规则指针 + 写入期检查
  • strict:规则指针 + 写入期检查 + prompt 扫描

规则来源策略

默认使用 project-first 规则解析策略:

  1. 从当前编辑文件或工作区开始,向上查找最近的 semantic-rules.md
  2. 如果项目内没有,则回退到插件自带的 semantic-rules.md

你也可以通过 .semantic-linter.json 强制使用 plugin-only。

安装

Claude Code

claude plugin marketplace add SummerSec/semantic-linter
claude plugin install semantic-linter@summersec-semantic-linter
/reload-plugins

Codex

codex plugin marketplace add SummerSec/semantic-linter
codex plugin add semantic-linter@semantic-linter

Codex 不直接消费 Claude 的 hook manifest。它的项目级接入方式是把受管规则块写入 AGENTS.md。

DeepSeek Harness

安装官方 DSH CLI,并把本仓库作为 bundle 加入需要使用的 profile:

npm install -g @deepseek-ai/dsh@0.1.0-rc.6
dsh plugin --profile headless add github:SummerSec/semantic-linter
dsh plugin --profile web add github:SummerSec/semantic-linter

本地开发时可以在仓库根目录执行:

dsh plugin --profile headless add .

如果 pnpm 返回 ERR_PNPM_ADDING_TO_ROOT,在命令末尾追加 --ignore-workspace-root-check 后重试。

这个 DSH bundle 会把仓库根目录 skills/ 下的四个 Skill 注册到 ctx.skills。DSH 还会读取工作区中的 AGENTS.md 或 CLAUDE.md;调用 rules-installer 后,项目可以通过受管规则块按需读取 semantic-rules.md。

DSH 不会直接执行本仓库的 Claude hook manifest。DSH 下提供的是 packaged Skill + 项目 instruction pointer;SessionStart、SubagentStart、UserPromptSubmit、PreToolUse、PostToolUse 和 /stl-mode 仍仅属于 Claude hook 路径。

项目初始化

如果你想把项目本地规则注入到当前仓库,可以运行:

node /absolute/path/to/semantic-linter/scripts/build-rules.js --existing "$(pwd)"

这会生成:

  • semantic-rules.md
  • AGENTS.md 和或 CLAUDE.md 中的受管规则区块

如果两个文件都不存在,脚本会根据宿主环境创建默认目标:

  • Codex 或 auto:AGENTS.md
  • Claude:CLAUDE.md

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-liquid-glass 下一个 Next dsh-llm-volcengine →