
Speclock
io.github.sgroy10由 GitHub 账号 sgroy10 发布v5.5.3更新于 Oct 24, 2026
AI Constraint Engine — enforces CLAUDE.md and .cursorrules as laws. 51 MCP tools.
概览
SpecLock 把 CLAUDE.md、AGENTS.md 和 .cursorrules 中的项目规则变成约束,在 AI 编辑、执行命令和提交前进行检查。
- 可以做什么
- SpecLock 读取现有的 AI 规则文件并将其转化为锁定项,在动作执行前进行校验。其 MCP 服务器提供 51 个工具,涵盖约束管理、语义冲突检查、执行模式、会话跟踪、审计验证、合规导出、策略规则、类型化约束、补丁审查和代码图分析。它还提供命令行工具,用于初始化、提交前钩子、漂移评分以及把规则同步到其他编码工具。
- 适用场景
- 当助手要修改的代码库中有某些文件、系统或数据不能被触碰,而你希望这些约束被实际检查而不只是被记住时,值得添加。建议模式可以低风险地查看哪些操作会被标记;严格模式用于必须阻止的动作。
- 运行要求
- 以 npm 包形式在本地通过 stdio 运行(npx speclock),无需账号。可选环境变量包括 SPECLOCK_API_KEY、SPECLOCK_ENCRYPTION_KEY、SPECLOCK_LLM_KEY、GEMINI_API_KEY 和 SPECLOCK_TELEMETRY。部分宿主还提供远程 HTTP 端点。执行强度取决于宿主客户端提供的钩子。
安装
在 SourceWeft 中
- 打开 控制台中的 Speclock,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Rules files tell AI what not to change.
SpecLock enforces them.
Stop Claude Code, Cursor, Codex, Windsurf, and other AI coding tools from crossing project constraints you already wrote in CLAUDE.md, AGENTS.md, and .cursorrules.
[npm version] [npm downloads] [CI] [MIT License] [MCP 51 tools]
Install · See a block · Claude Code plugin · Website · Saves Wall
Why another rules tool? Rules files are context. They can be forgotten, diluted, or overridden during a long coding session. SpecLock turns those rules into checks that run before edits, shell commands, and commits.
See the difference
SpecLock uses semantic conflict detection rather than simple keyword matching. It catches indirect actions such as “clean up old patient data,” “streamline checkout,” or “temporarily disable MFA” when they violate an active constraint.
60-second setup
Run this from the project you want to protect:
When the advisory output looks right, enable blocking:
No account is required. SpecLock runs locally by default, and advisory mode never blocks a change.
Install as a Claude Code plugin
Inside Claude Code, run:
Then protect the current project once:
The plugin automatically starts SpecLock's MCP server and checks Claude Code Write, Edit, and Bash actions before execution. It includes all 51 MCP tools and works alongside your existing CLAUDE.md.
Install on other coding agents
SpecLock is packaged for multiple agent ecosystems, but the enforcement level depends on what each host exposes:
MCP-assisted means the agent can call SpecLock before acting; it does not guarantee interception. Use speclock protect --strict and CI when a constraint must be enforced regardless of the client.
SpecLock has a different job from memory and skills: memory recalls context, skills provide procedures, and SpecLock verifies planned actions against explicit constraints. It reduces constraint drift; it cannot guarantee factual correctness or make a model hallucination-free.
Repository installs supported by current clients:
What you get
Proven in the open
- 10,000+ npm downloads before the native Claude Code plugin release.
- 1,043 automated tests across 24 suites, including adversarial conflicts, false-positive cases, patch analysis, enforcement, auth, and compliance.
- MIT licensed and inspectable end to end.
- Local-first defaults with optional remote features clearly separated.
Commands you will use most
Full reference: npx speclock@latest help
New in v5.8.0
- Portable Agent Plugin packaging for Cursor-compatible discovery.
- Gemini CLI extension packaging with MCP startup and constraint context.
- Codex plugin with a
$speclock-guardrailsskill and pinned MCP server. - GitHub Copilot CLI compatibility through the repository marketplace.
- Explicit per-platform enforcement labels: native hook, MCP-assisted, or Git/CI.
More links and project badges
[Blocked by SpecLock] Smithery · Badge gallery · Sandeep Roy
The Problem
AI coding tools have memory now. Claude Code has CLAUDE.md. Cursor has .cursorrules. Mem0 exists.
But memory without enforcement is useless.
Your AI remembers you use PostgreSQL — then switches to MongoDB because it "seemed better." Your AI remembers your auth setup — then rewrites it while "fixing" a bug. You said "never touch the payment logic" 3 sessions ago — the AI doesn't care.
Remembering is not respecting. No existing tool stops the AI from breaking what you locked.
How It Works
You set constraints. SpecLock enforces them — across sessions, across tools, across teams.
The semantic engine doesn't do keyword matching. It understands:
- "clean up old data" = deletion (euphemism detection)
- "streamline checkout" = modify payment flow (synonym + concept mapping)
- "temporarily disable logging" = disable logging (temporal evasion detection)
- "Update UI and also drop the users table" = hidden violation (compound splitter)
And it knows what's safe:
- "Enable audit logging" when the lock says "Never disable audit logging" → no conflict (intent alignment)
Quick Start by Platform
Bolt.new / Aider / Any npm Platform
Creates SPECLOCK.md, injects rules into package.json, generates .speclock/context/latest.md. The AI reads these automatically.
Claude Code
Install the plugin using the commands above. For MCP-only setup without the
plugin hooks, add this to .mcp.json:
Cursor / Windsurf / Cline
Same config — add to .cursor/mcp.json or equivalent.
Lovable (No Install)
- Go to Settings → Connectors → New MCP server
- Enter URL:
https://speclock-mcp-production.up.railway.app/mcp - Paste project instructions into Knowledge
Why SpecLock Over Alternatives?
Other tools remember. SpecLock enforces.
Semantic Engine
Not keyword matching — semantic analysis with an optional Gemini Flash hybrid for grey-zone and cross-domain cases. The repository includes adversarial, false-positive, question-framing, patch-gateway, and diff-analysis test suites.
Under the hood: 65+ synonym groups · 80+ euphemism mappings · domain concept maps (fintech, e-commerce, IoT, healthcare, SaaS, payments, gaming, telecom, government) · intent classifier · compound sentence splitter · temporal evasion detector · verb tense normalization · UI cosmetic detection · safe-intent patterns · passive voice parsing — all in pure JavaScript. Gemini Flash hybrid for grey-zone cases ($0.01/1000 checks).
Hard Enforcement
Two modes:
- Configurable threshold — default 70%. Only HIGH confidence conflicts block.
- Override with reason —
speclock override <lockId> "JIRA-1234: approved by CTO"(logged to audit trail) - Auto-escalation — lock overridden 3+ times → auto-flags for review
Enterprise Security
API Key Auth + RBAC
AES-256-GCM Encryption
PBKDF2 key derivation (100K iterations). Authenticated encryption. HIPAA 2026 compliant.
HMAC Audit Chain
Every event gets an HMAC-SHA256 hash chained to the previous event. Modify anything — the chain breaks.
Compliance Exports
Policy-as-Code
Declarative YAML rules for organization-wide enforcement:
Import and export policies between projects. Share constraint templates across your organization.
REST API v2
Real-time constraint checking, patch review, and autonomous systems:
51 MCP Tools
Memory — goal, locks, decisions, notes, deploy facts
Enforcement — conflict detection, hard blocking, overrides
Tracking & Sessions — changes, events, session continuity
Intelligence — suggestions, health, templates, reports
Enterprise — audit, compliance, policy, telemetry
Typed Constraints — numerical, range, state, temporal (v5.0)
Spec Compiler & Code Graph — NL→constraints, dependency analysis (v5.0)
Patch Gateway & AI Patch Firewall — change review, diff analysis (v5.1/v5.2)
Universal Rules Sync & Incident Replay — cross-tool sync, session replay (v5.3)
CLI
Full command reference: npx speclock help
Auto-Guard
When you lock something, SpecLock finds related files and injects a warning the AI sees when it opens them:
The AI opens the file and sees:
Architecture
3 npm dependencies. Zero runtime dependencies for the semantic engine. Pure JavaScript.
Configuration
Tip: The heuristic engine alone scores 95%+ accuracy at ~250ms. The Gemini proxy adds cross-domain coverage but takes ~2s. For fastest response, set
SPECLOCK_NO_PROXY=true.
Test Results
Pre-publish gate runs all 24 suites before every npm publish. If any test fails, publish is blocked.
Reproducible project test gate: all 1,043 repository tests pass on v5.8.0. These are project-maintained automated scenarios, not third-party certification; run them yourself with npm test.
Tested across: fintech, e-commerce, IoT, healthcare, SaaS, gaming, biotech, aerospace, payments, payroll, robotics, autonomous systems, telecom, insurance, government. All 11 Indian payment gateways detected. Zero false positives on UI/cosmetic actions.
Simulated Developer Journeys
John scenario — Indie developer on Bolt.new
8 sessions building an ecommerce app. 5 locks (auth, Firebase, Supabase, shipping, Stripe). Every direct violation caught. Every euphemistic attack caught ("clean up auth", "modernize database", "streamline serverless"). Zero false positives on safe actions (product page, cart, dark mode). 86/86 tests passed.
Sam scenario — Senior engineer building a HIPAA hospital ERP
10 sessions with 8 HIPAA locks. Every violation caught — expose PHI, remove encryption, disable audit, downgrade MFA, bypass FHIR. Euphemistic HIPAA attacks caught ("simplify data flow", "modernize auth"). Full auth + RBAC + encryption + compliance export workflow verified. 124/124 tests passed.
Pricing
Changelog
Prior-version feature tours. The Quick Start and What's New sections above cover v5.7.0–v5.8.0 — this section preserves details on features shipped in v5.0–v5.5.
v5.4 — Drift Score, Lock Coverage, Lock Strengthener
Drift Score. How much has your AI-built project drifted from your original intent? Only SpecLock can answer this — because only SpecLock knows what was intended vs what was done.
Lock Coverage Audit. SpecLock scans your codebase and tells you what's unprotected:
Like a security scanner, but for AI constraint gaps.
Lock Strengthener. Your locks might be too vague. SpecLock grades each one and suggests improvements:
v5.3 — Universal Rules Sync, Incident Replay, Safety Templates
Universal Rules Sync. One command syncs your SpecLock constraints to every AI coding tool:
Define constraints once in SpecLock, sync everywhere. --format cursor for single format, --preview to dry-run, --list to see supported formats.
Incident Replay. Flight recorder for your AI coding sessions:
speclock replay --list lists sessions; --session <id> replays a specific one.
Safety Templates. Pre-built constraint packs:
Safe Defaults prevents the 5 most common AI disasters: database deletion, auth removal, secret exposure, error-handling removal, logging disablement.
v5.2 — AI Patch Firewall
Reviews actual diffs, not just descriptions. Catches things intent review misses:
Signal detection: interface breaks, protected symbol edits in locked zones, dependency drift, schema/migration destructive changes, public API route changes. Hard escalation: auto-BLOCK on destructive schema changes, removed API routes, protected symbol edits. Unified review: merges intent (35%) + diff (65%), takes the stronger verdict.
v5.1 — Patch Gateway
One API call gates every change. Takes a description + file list, returns ALLOW/WARN/BLOCK:
Combines semantic conflict detection + lock-to-file mapping + blast radius + typed constraint awareness into a single risk score (0-100).
v5.0 — Spec Compiler, Code Graph, Typed Constraints, Python SDK & ROS2
Spec Compiler. Paste a PRD, README, or architecture doc — SpecLock extracts all constraints automatically:
Uses Gemini Flash by default ($0.01 per 1000 compilations).
Code Graph. Live dependency graph of your codebase. Parses JS/TS/Python imports.
Lock-to-file mapping auto-maps locks to source files; module detection groups files into logical modules.
Typed Constraints. Real-time value and state checking for autonomous systems, IoT, robotics:
Python SDK & ROS2.
Uses the same .speclock/brain.json as the Node.js MCP server. ROS2 Guardian Node subscribes to /joint_states, /cmd_vel, /speclock/state_transition; publishes violations to /speclock/violations; triggers emergency stop via /speclock/emergency_stop.
Show your support
If SpecLock saves your project from a 3am incident, add this badge to your README:
Or run speclock badge in your terminal to see all variants. Full gallery: sgroy10.github.io/speclock/badge.html · Full docs: BADGES.md.
Every adoption helps another developer discover SpecLock and stop their AI from wrecking their project. Thank you.
Spread the word
Want to help SpecLock reach more developers? Everything you need to post — tweets, LinkedIn drafts, Reddit templates, Show HN copy, Discord messages, one-liners, elevator pitches — is pre-written and fact-checked in VIRAL-KIT.md. Copy, paste, send. Zero effort.
Contributing
Issues and PRs welcome on GitHub.
License
Author
SpecLock is created and maintained by Sandeep Roy.
Sandeep Roy is the sole developer of SpecLock — the AI Constraint Engine that enforces project rules across AI coding sessions. All 51 MCP tools, the semantic conflict detection engine, enterprise security features (SOC 2, HIPAA, RBAC, encryption), and the pre-publish test gate were designed and built by Sandeep Roy.
SpecLock v5.8.0 — Cross-platform action guardrails with native Claude Code enforcement, MCP integrations, 1,043 core tests, and 51 MCP tools. Developed by Sandeep Roy.
来源:README.md,提交 f0f0b2c
工具
0版本历史
1- v5.5.3最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分