
Speclock
io.github.sgroy10Published by GitHub account sgroy10v5.5.3Updated Oct 24, 2026
AI Constraint Engine — enforces CLAUDE.md and .cursorrules as laws. 51 MCP tools.
Overview
SpecLock enforces project rules from CLAUDE.md, AGENTS.md and .cursorrules as constraints, checking AI edits, shell commands and commits before they run.
- What you can do
- SpecLock reads existing AI rule files and turns them into locks that are checked before actions. Its MCP server exposes 51 tools covering constraint management, semantic conflict checks, enforcement modes, session tracking, audit verification, compliance exports, policy rules, typed constraints, patch review and code graph analysis. It also provides a CLI for setup, pre-commit hooks, drift scoring and syncing rules to other coding tools.
- When to use it
- Worth adding when an assistant edits a codebase where certain files, systems or data must not be touched, and you want those constraints checked rather than merely remembered. Advisory mode is a low-risk way to see what would be flagged; strict mode is for constraints that must block an action.
- Requirements
- Runs locally as an npm package (npx speclock) over stdio, with no account required. Optional environment variables include SPECLOCK_API_KEY, SPECLOCK_ENCRYPTION_KEY, SPECLOCK_LLM_KEY, GEMINI_API_KEY and SPECLOCK_TELEMETRY. A remote HTTP endpoint is also offered for some hosts. Enforcement strength depends on the host client's hooks.
Installation
In SourceWeft
- Open Speclock in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
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.
Source: README.md at commit f0f0b2c
Tools
0Version history
1- v5.5.3LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts