SpecLock
快速入门
npx speclock protect # Install in your project (creates CLAUDE.md if missing)
speclock mcp install claude-code # Wire up MCP for Claude Code (or cursor, windsurf, cline, codex)
speclock doctor # Verify everything is set up correctly就是这样。你的 AI 现在有了它无法忽视的规则。默认模式为 WARN(仅发出响亮的警告,不进行拦截)。如需开启强制执行,请使用 speclock protect --strict。
Related MCP server: @event4u/agent-config
v5.5.4 有什么新功能
默认 WARN 模式 — 不再有误报拦截。改为响亮的警告。通过
--strict或SPECLOCK_STRICT=1开启严格模式。speclock mcp install <client>— 适用于 Claude Code、Cursor、Windsurf、Cline、Codex 的自动安装程序。无需再手动编辑 JSON。Greenfield 支持 — 在新项目中运行
speclock protect会自动创建带有安全默认值的 CLAUDE.md。speclock doctor— 健康检查,验证安装、git 钩子、规则文件和 MCP 集成。为任何问题打印精确的修复命令。
什么是 SpecLock?
SpecLock 是一个 AI 约束引擎,可在每次 AI 编码会话中强制执行你的项目规则。 你的 AI 总是在破坏你禁止它触碰的东西 —— SpecLock 让它停止。
命令参考
speclock protect # Install pre-commit hook + extract locks from rule files
speclock protect --strict # Hard enforcement mode (blocks violations)
speclock doctor # Health check — verifies install, hooks, rules, MCP
speclock mcp install <client> # Wire up MCP server (claude-code, cursor, windsurf, cline, codex)
speclock check "action description" # Test if an action would conflict with locks
speclock add-lock "rule" # Add a new lock
speclock list-locks # Show all locks
speclock enforce hard|advisory # Change enforcement mode完整命令参考:npx speclock help
You: "Never touch the auth system"
AI: 🔒 Locked.
... 5 sessions later ...
You: "Add social login to the login page"
AI: ⚠️ BLOCKED — violates lock "Never touch the auth system"
Matched: auth → authentication (synonym), login → auth (concept)
Confidence: 100%
Should I find another approach?在 Claude 的独立测试套件中获得 100/100 分。19 个套件共 991 项测试。0 误报。每次检查耗时 15.7 毫秒。
问题所在
AI 编码工具现在有了记忆。Claude Code 有 CLAUDE.md。Cursor 有 .cursorrules。Mem0 也存在。
但没有强制执行的记忆是无用的。
你的 AI 记得 你使用 PostgreSQL —— 然后它切换到 MongoDB,因为它“看起来更好”。你的 AI 记得 你的身份验证设置 —— 然后在“修复”错误时重写了它。你在 3 次会话前说“永远不要触碰支付逻辑” —— AI 根本不在乎。
记住并不代表尊重。 没有现有的工具能阻止 AI 破坏你锁定的内容。
工作原理
你设置约束。SpecLock 强制执行它们 —— 跨会话、跨工具、跨团队。
speclock lock "Never modify auth files" → auto-guards src/auth/*.ts
speclock lock "Database must stay PostgreSQL" → catches "migrate to MongoDB"
speclock lock "Never delete patient records" → catches "clean up old data"
speclock lock "Don't touch the payment flow" → catches "streamline checkout"语义引擎不进行关键词匹配。它理解:
“清理旧数据” = 删除(委婉语检测)
“简化结账流程” = 修改支付流程(同义词 + 概念映射)
“暂时禁用日志记录” = 禁用日志记录(时间规避检测)
“更新 UI 并删除用户表” = 隐藏违规(复合句拆分)
并且它知道什么是安全的:
“启用审计日志” 当锁定的规则说“永远不要禁用审计日志”时 → 无冲突(意图对齐)
各平台快速入门
Bolt.new / Aider / 任何 npm 平台
npx speclock setup --goal "Build my app" --template nextjs创建 SPECLOCK.md,将规则注入 package.json,生成 .speclock/context/latest.md。AI 会自动读取这些文件。
Claude Code
添加到 .mcp.json:
{
"mcpServers": {
"speclock": {
"command": "npx",
"args": ["-y", "speclock", "serve", "--project", "."]
}
}
}Cursor / Windsurf / Cline
相同的配置 —— 添加到 .cursor/mcp.json 或等效文件。
Lovable (无需安装)
前往 Settings → Connectors → New MCP server
输入 URL:
https://speclock-mcp-production.up.railway.app/mcp将 项目说明 粘贴到 Knowledge 中
为什么选择 SpecLock 而不是替代品?
Claude Memory | Mem0 |
| SpecLock | |
记住上下文 | 是 | 是 | 手动 | 是 |
阻止 AI 破坏内容 | 否 | 否 | 否 | 是 |
语义冲突检测 | 否 | 否 | 否 | 100/100 分,0% 误报 |
防篡改审计追踪 | 否 | 否 | 否 | HMAC-SHA256 链 |
强制执行 (AI 无法继续) | 否 | 否 | 否 | 是 |
SOC 2 / HIPAA 合规导出 | 否 | 否 | 否 | 是 |
加密存储 (AES-256-GCM) | 否 | 否 | 否 | 是 |
RBAC + API 密钥认证 | 否 | 否 | 否 | 4 种角色 |
代码即策略 DSL | 否 | 否 | 否 | YAML 规则 |
适用于 Bolt.new, Lovable 等 | 否 | 否 | 否 | 是 |
其他工具只是记住。SpecLock 负责强制执行。
语义引擎
不是关键词匹配 —— 而是通过 Gemini Flash 混合模型进行真正的语义分析,实现通用领域覆盖。在 Claude 的独立对抗性测试电池(7 个套件,包括误报、问题框架、补丁网关和差异分析)中得分 100/100。
底层技术: 65+ 同义词组 · 80+ 委婉语映射 · 领域概念图(金融科技、电子商务、物联网、医疗保健、SaaS、支付、游戏、电信、政府) · 意图分类器 · 复合句拆分器 · 时间规避检测器 · 动词时态归一化 · UI 美化检测 · 安全意图模式 · 被动语态解析 —— 全部使用纯 JavaScript。Gemini Flash 混合模型用于灰色地带情况 ($0.01/1000 次检查)。
强制执行
两种模式:
Advisory (default): AI gets a warning, decides what to do
Hard mode: AI is BLOCKED — MCP returns isError, AI cannot proceedspeclock enforce hard # Enable hard mode — violations above threshold are blocked可配置阈值 — 默认 70%。仅高置信度冲突会被拦截。
附带理由覆盖 —
speclock override <lockId> "JIRA-1234: 由 CTO 批准"(记录到审计追踪)自动升级 — 锁定被覆盖 3 次以上 → 自动标记以供审查
企业安全
API 密钥认证 + RBAC
speclock auth create-key --role developer --name "CI Bot"
# → sk_speclock_a1b2c3... (shown once, stored as SHA-256 hash)角色 | 读取 | 写入锁定 | 覆盖 | 管理员 |
| 是 | — | — | — |
| 是 | — | 附带理由 | — |
| 是 | 是 | 是 | — |
| 是 | 是 | 是 | 是 |
AES-256-GCM 加密
export SPECLOCK_ENCRYPTION_KEY="your-secret"
speclock encrypt # Encrypts brain.json + events.log at restPBKDF2 密钥派生 (100K 次迭代)。认证加密。符合 HIPAA 2026 标准。
HMAC 审计链
每个事件都会获得一个链接到前一个事件的 HMAC-SHA256 哈希。修改任何内容 —— 链条就会断裂。
$ speclock audit-verify
✓ Audit chain VALID — 247 events, 0 broken links, no tampering detected.合规导出
speclock export --format soc2 # SOC 2 Type II report (JSON)
speclock export --format hipaa # HIPAA PHI protection report
speclock export --format csv # All events for auditor spreadsheets代码即策略
用于组织范围强制执行的声明式 YAML 规则:
# .speclock/policy.yml
rules:
- name: "HIPAA PHI Protection"
match:
files: ["**/patient/**", "**/medical/**"]
actions: [delete, modify, export]
enforce: block
severity: critical
- name: "No direct DB mutations"
match:
files: ["**/models/**"]
actions: [delete]
enforce: warn
severity: high在项目之间导入和导出策略。在整个组织内共享约束模板。
REST API v2
实时约束检查、补丁审查和自主系统:
# Patch Gateway (v5.1)
POST /api/v2/gateway/review { description, files, useLLM }
# AI Patch Firewall (v5.2)
POST /api/v2/gateway/review-diff { description, files, diff, options }
POST /api/v2/gateway/parse-diff { diff }
# Typed constraint checking
POST /api/v2/check-typed { metric, value, entity }
POST /api/v2/check-batch { checks: [...] }
# SSE streaming (real-time violations)
GET /api/v2/stream
# Spec Compiler
POST /api/v2/compiler/compile { text, autoApply }
# Code Graph
GET /api/v2/graph/blast-radius?file=src/core/memory.js
GET /api/v2/graph/lock-map
POST /api/v2/graph/build51 个 MCP 工具
工具 | 功能 |
| 在项目中初始化 SpecLock |
| 完整上下文包(核心工具) |
| 设置项目目标 |
| 添加约束 + 自动保护文件 |
| 软删除锁定 |
| 记录架构决策 |
| 添加固定笔记 |
| 记录部署配置 |
工具 | 功能 |
| 针对所有锁定的语义冲突检查 |
| 切换建议/强制模式 |
| 附带理由覆盖(记录审计) |
| 查看覆盖审计追踪 |
| 分析 git diff 针对锁定的情况 |
| 扫描约束违规 |
| 预提交时审计暂存文件 |
工具 | 功能 |
| 开始会话 + 完整简报 |
| 结束会话 + 记录摘要 |
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityFmaintenanceGovernance kernel for AI agents — policy enforcement, code safety verification, multi-model hallucination detection (CMVK), trust attestation (IATP), and immutable audit trails. Works with Claude Desktop, Cursor, and any MCP client.72MIT

@event4u/agent-configofficial
AlicenseAqualityAmaintenanceUniversal AI Agent OS — governed skills, rules, and commands for AI coding assistants (Claude Code, Augment, Cursor, Copilot, Windsurf). Read-only MCP bridge serves prompts and resources from a release-pinned content bundle.6203,0057MIT- Alicense-qualityBmaintenanceAI-powered codebase health analysis — detects dead code, circular dependencies, coupling issues, and architectural drift. 6 MCP tools for Claude Desktop, Cursor, Windsurf, and Slack.63MIT
- Flicense-qualityAmaintenanceAnalyzes repositories, explains architecture, calculates change impact, and enforces guardrails for AI Agents like Claude Code, Cursor, and Codex via MCP tools.
Related MCP Connectors
33 tools that make AI write, implement, and verify intent against explicit, testable constraints.
Zero-install security baseline for AI coding agents — OWASP/CWE-cited rules over MCP.
Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/sgroy10/speclock'
If you have feedback or need assistance with the MCP directory API, please join our Discord server