The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the Speclock listing page.
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.
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.
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.
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.
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.
SpecLock is packaged for multiple agent ecosystems, but the enforcement level depends on what each host exposes:
| Platform | Install/discovery path | Protection level |
|---|---|---|
| Claude Code | Native marketplace plugin above | Native pre-action checks for Write, Edit, and Bash |
| Gemini CLI | Install this repository as a Gemini extension | MCP-assisted checks plus project context |
| Cursor | Agent Plugin / Cursor marketplace package | MCP-assisted checks plus rules |
| Codex | Repository Codex plugin in plugins/speclock | MCP-assisted checks plus $speclock-guardrails skill |
| GitHub Copilot CLI | Add this repository as a plugin marketplace | MCP-assisted checks plus bundled plugin context |
| Cline | MCP server; curated marketplace submission in progress | MCP-assisted checks |
| Windsurf | speclock mcp install windsurf | MCP-assisted checks plus rules |
| Any Git client or CI | speclock protect | Commit/CI enforcement independent of the coding agent |
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:
| Capability | What it does |
|---|---|
| Pre-action checks | Reviews Claude Code writes, edits, and shell commands before they run |
| Semantic constraints | Detects synonyms, euphemisms, compound requests, and indirect violations |
| Git enforcement | Adds a second guard at commit time |
| Advisory and strict modes | Start with warnings; opt in to hard blocking when ready |
| Audit trail | Records decisions in a tamper-evident HMAC chain |
| MCP integration | Exposes 51 tools to Claude Code, Cursor, Codex, Windsurf, and Cline |
| Shareable save receipts | Shows what SpecLock prevented with speclock wins |
Full reference: npx speclock@latest help
$speclock-guardrails skill and pinned MCP server.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.
You set constraints. SpecLock enforces them — across sessions, across tools, across teams.
The semantic engine doesn't do keyword matching. It understands:
And it knows what's safe:
Creates SPECLOCK.md, injects rules into package.json, generates .speclock/context/latest.md. The AI reads these automatically.
Install the plugin using the commands above. For MCP-only setup without the
plugin hooks, add this to .mcp.json:
Same config — add to .cursor/mcp.json or equivalent.
https://speclock-mcp-production.up.railway.app/mcp| Claude Memory | Mem0 | .cursorrules | SpecLock | |
|---|---|---|---|---|
| Remembers context | Yes | Yes | Manual | Yes |
| Blocks the AI from breaking things | No | No | No | Yes |
| Semantic conflict detection | No | No | No | Yes — covered by adversarial tests |
| Tamper-proof audit trail | No | No | No | HMAC-SHA256 chain |
| Hard enforcement (AI cannot proceed) | No | No | No | Yes |
| SOC 2 / HIPAA compliance exports | No | No | No | Yes |
| Encrypted storage (AES-256-GCM) | No | No | No | Yes |
| RBAC + API key auth | No | No | No | 4 roles |
| Policy-as-Code DSL | No | No | No | YAML rules |
| Works on Bolt.new, Lovable, etc. | No | No | No | Yes |
Other tools remember. SpecLock enforces.
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.
| Category | Detection | Example |
| Direct violations | 100% | "Delete the auth module" vs lock "Never modify auth" |
| Euphemistic attacks | 100% | "Clean up old patient data" = deletion |
| Temporal evasion | 100% | "Temporarily disable MFA" = disable MFA |
| Dilution attacks | 100% | Violation buried in multi-part request |
| Compound sentences | 100% | "Update UI and also drop users table" |
| Synonym substitution | 100% | "Sunset the API" = remove the API |
| Payment brand names (11 gateways) | 100% | "Add Razorpay" / "Implement PayU" vs "Must use Stripe" |
| Salary/payroll cross-vocab | 100% | "Optimize salary" vs "Payroll records locked" |
| Safety system bypass | 100% | "Disable safety interlock" = bypass safety |
| Unknown domains (via Gemini) | 100% | Gaming, biotech, aerospace, music, legal |
| Safe actions (true negatives) | 0% FP | "Change the font" correctly passes auth locks |
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).
Two modes:
speclock override <lockId> "JIRA-1234: approved by CTO" (logged to audit trail)| Role | Read | Write Locks | Override | Admin |
|---|---|---|---|---|
viewer | Yes | — | — | — |
developer | Yes | — | With reason | — |
architect | Yes | Yes | Yes | — |
admin | Yes | Yes | Yes | Yes |
PBKDF2 key derivation (100K iterations). Authenticated encryption. HIPAA 2026 compliant.
Every event gets an HMAC-SHA256 hash chained to the previous event. Modify anything — the chain breaks.
Declarative YAML rules for organization-wide enforcement:
Import and export policies between projects. Share constraint templates across your organization.
Real-time constraint checking, patch review, and autonomous systems:
| Tool | What it does |
|---|---|
speclock_init | Initialize SpecLock in project |
speclock_get_context | Full context pack (the key tool) |
speclock_set_goal | Set project goal |
speclock_add_lock | Add constraint + auto-guard files |
speclock_remove_lock | Soft-delete a lock |
speclock_add_decision | Record architectural decision |
speclock_add_note | Add pinned note |
speclock_set_deploy_facts | Record deploy config |
| Tool | What it does |
|---|---|
speclock_check_conflict | Semantic conflict check against all locks |
speclock_set_enforcement | Switch advisory/hard mode |
speclock_override_lock | Override with reason (audit logged) |
speclock_override_history | View override audit trail |
speclock_semantic_audit | Analyze git diff against locks |
speclock_detect_drift | Scan for constraint violations |
speclock_audit | Audit staged files pre-commit |
| Tool | What it does |
|---|---|
speclock_session_briefing | Start session + full briefing |
speclock_session_summary | End session + record summary |
speclock_log_change | Log a change with files |
speclock_get_changes | Recent tracked changes |
speclock_get_events | Full event log (filterable) |
speclock_checkpoint | Git tag for rollback |
speclock_repo_status | Branch, commit, diff summary |
| Tool | What it does |
|---|---|
speclock_suggest_locks | AI-powered lock suggestions |
speclock_health | Health score + multi-agent timeline |
speclock_apply_template | Apply constraint template |
speclock_report | Violation stats + most tested locks |
| Tool | What it does |
|---|---|
speclock_verify_audit | Verify HMAC chain integrity |
speclock_export_compliance | SOC 2 / HIPAA / CSV reports |
speclock_policy_evaluate | Evaluate policy rules |
speclock_policy_manage | CRUD for policy rules |
speclock_telemetry | Opt-in usage analytics |
| Tool | What it does |
|---|---|
speclock_add_typed_lock | Add typed constraint (numerical/range/state/temporal) |
speclock_check_typed | Check proposed values against typed constraints |
speclock_list_typed_locks | List all typed constraints |
speclock_update_threshold | Update typed lock thresholds |
| Tool | What it does |
|---|---|
speclock_compile_spec | Compile natural language into structured constraints |
speclock_build_graph | Build/refresh code dependency graph |
speclock_blast_radius | Calculate blast radius of file changes |
speclock_map_locks | Map locks to actual code files |
| Tool | What it does |
|---|---|
speclock_review_patch | ALLOW/WARN/BLOCK verdict for proposed changes |
speclock_review_patch_diff | Diff-native review with signal scoring + unified verdict |
speclock_parse_diff | Parse unified diff into structured changes (debug/inspect) |
| Tool | What it does |
|---|---|
speclock_sync_rules | Sync constraints to Cursor, Claude, Copilot, Windsurf, Gemini, Aider, AGENTS.md |
speclock_list_sync_formats | List all available sync formats |
speclock_replay | Replay a session's activity — what AI tried and what was caught |
speclock_list_sessions | List available sessions for replay |
speclock_drift_score | 0-100 project integrity metric — how much AI deviated from intent |
speclock_coverage | Lock Coverage Audit — find unprotected code areas |
speclock_strengthen | Grade locks and suggest stronger versions |
Full command reference: npx speclock help
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:
3 npm dependencies. Zero runtime dependencies for the semantic engine. Pure JavaScript.
| Variable | Default | Description |
|---|---|---|
SPECLOCK_API_KEY | — | API key for authenticated access |
SPECLOCK_ENCRYPTION_KEY | — | Enables AES-256-GCM encryption at rest |
SPECLOCK_NO_PROXY | false | Set true for heuristic-only mode (~250ms). Skips the Gemini proxy (~2s) |
SPECLOCK_LLM_KEY | — | Your own LLM API key (Gemini/OpenAI/Anthropic) |
GEMINI_API_KEY | — | Google Gemini API key for hybrid conflict detection |
SPECLOCK_TELEMETRY | false | Opt-in anonymous usage analytics |
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.
Pre-publish gate runs all 24 suites before every npm publish. If any test fails, publish is blocked.
| Suite | Tests | Pass Rate | What it covers |
|---|---|---|---|
| Real-World Testers | 111 | 100% | 5 developers, 30+ locks, diverse domains |
| Adversarial Conflict | 46 | 100% | Euphemisms, temporal evasion, compound sentences |
| Phase 4 (Multi-domain) | 91 | 100% | Fintech, e-commerce, IoT, healthcare, SaaS |
| Sam (Enterprise HIPAA) | 124 | 100% | HIPAA locks, PHI, encryption, RBAC |
| Auth & Crypto | 114 | 100% | API keys, RBAC, AES-256 encryption |
| John (Indie Dev Journey) | 86 | 100% | 8-session Bolt.new build with 5 locks |
| Diff-Native Review | 76 | 100% | Interface breaks, schema changes, API impact |
| Patch Gateway | 57 | 100% | ALLOW/WARN/BLOCK verdicts, blast radius |
| Compliance Export | 50 | 100% | SOC 2, HIPAA, CSV formats |
| Enforcement | 40 | 100% | Hard/advisory mode, overrides |
| Audit Chain | 35 | 100% | HMAC-SHA256 chain integrity |
| Code Graph | 33 | 100% | Import parsing, blast radius, lock mapping |
| Spec Compiler | 24 | 100% | NL→constraints parsing, auto-apply |
| Typed Constraints | 13 | 100% | Numerical, range, state, temporal validation |
| Claude Regression | 9 | 100% | Vue detection, safe-intent, patch gateway |
| Question Framing | 9 | 100% | "What if we..." and "How hard would it be..." |
| REST API v2 | 9 | 100% | Typed constraint endpoints, SSE |
| PII/Export Detection | 8 | 100% | SSN, email export, data access violations |
| Guardian (Protect) | 47 | 100% | Zero-config rule file extraction |
| Total | 1043 | 100% | 24 suites, 15+ domains |
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.
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.
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.
| Tier | Price | What you get |
|---|---|---|
| Free | $0 | 10 locks, conflict detection, MCP, CLI |
| Pro | $19/mo | Unlimited locks, HMAC audit, compliance exports |
| Enterprise | $99/mo | + RBAC, encryption, SSO, policy-as-code |
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.
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:
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.
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.
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).
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.
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.
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.
Issues and PRs welcome on GitHub.
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.