Available in
Marketplaces, most starred first
Tags
Add to README
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
Marketplaces, most starred first
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
By erikdarlingdatav1.0.0MITIn 1 marketplace
Blocks Claude from running SQL writes or settings changes against SQL Server unless the command targets a copy server you name. Says it is a seatbelt, not a lock: a login with read-only permissions is the real protection. Requires Git Bash on Windows, since PowerShell alone is not supported.
Trending plugins
7-day copy clicks
Run automatically on Claude Code events. Claude doesn't decide.
Claude Code asks for these when you enable the plugin. Sensitive values are stored in your system keychain.
Copy serverscopy_servers
Host names of the SQL Servers that are a copy, where writes are allowed, separated by commas (for example DEV-SQL01,DEV-SQL02). Host names only: every instance and port on a named host counts as the copy. Leave empty to block writes on every server. A .claude/sqlserver-write-guard.json file in the project overrides this.
1 caution to review before installing
A hook runs when Claude uses the Bash tool
Static checks of hooks, mods, MCP servers and commands. Not a security audit.
1 marketplace, most starred first
sqlcmd, dbatools, safety, guardrails, read-only, database-safety, hook, mssql ·
Shows its components, always-on context cost and install status, kept current. Add ?tokens=0 to hide the cost.
stringdefault
A hook that stops Claude Code from running SQL that writes or changes settings, unless the command is aimed at a
copy server you name. It checks sqlcmd, osql, Invoke-Sqlcmd, dbatools commands, and MCP tools that take a
SQL query. It comes from Erik Darling's AI for Database Teams course.
/plugin install sqlserver-write-guard@erikdarling
It is a seatbelt. The login is the lock. A clever enough command can get past a regex: dynamic SQL built from pieces, a procedure that writes, SQL that a script builds and pipes in, a linked server. Nothing gets past a permission the login does not have. Run Claude with a login that can only read, and use this as the second layer.
Everywhere, the copy included:
SHUTDOWN, Stop-DbaService, Start-DbaService and Restart-DbaService, KILL and Stop-DbaProcessRECONFIGURE, sp_configure with a value (reading it is fine), and dbatools commands that change settingsxp_cmdshell and !! in a scriptDBCC SHRINK*, WRITEPAGE, TRACEON and TRACEOFF, and clearing caches (DBCC FREEPROCCACHE and friends)BACKUP and RESTOREGRANT, REVOKE and DENY, and creating, altering or dropping logins, users, roles, servers, databases,
credentials, endpoints and availability groupssa, however it is spelledOnly on the copy (blocked on every other server):
INSERT, UPDATE, DELETE, MERGE, TRUNCATE, CREATE, ALTER, DROP and SELECT INTOsp_recompile, sp_updatestats, sp_rename, plan guides, and Query Store changesGet-, Test-, Find- and similar read-only ones are fine anywhere)Fine anywhere: reads, and creating, filling, changing and dropping temp tables and table variables. An index or statistics on a temp table still counts as a write.
Each sqlcmd (or Invoke-Sqlcmd, or dbatools command) in a command needs its own server. One with no server goes
to whatever the default is, so it counts as not the copy. The hook reads the .sql files those commands point at
(-i, -InputFile, -File, <) and the :r files inside them. If it cannot read one, it blocks, unless the same
command writes that file from text in the command. It follows :connect too.
pyodbc, SqlConnection), bcp in, and anything else
that is not on the list above. The login is the lock.net stop or Stop-Service.UPDATE built in a variable, a DROP split in two
strings, or DISABLE TRIGGER, which no rule looks for.DROP gets blocked, and so does
LIKE N'%UPDATE dbo.Users%'. Stripping is how you get fooled by quotes. Rewrite the search
(LIKE N'%UPDATE%dbo.Users%' gets through) or run that one yourself.Out of the box no server counts as the copy, so writes are blocked on every server. That is the safe default. When a write is blocked, the message tells Claude that only a person names the copy, and Claude should not edit the file or the setting itself. You name it, one of two ways, and the project file wins.
1. A project file (recommended, it can be committed). Create .claude/sqlserver-write-guard.json in the
project directory:
{ "copy_servers": ["DEV-SQL01"] }
Save the file as UTF-8. In Windows PowerShell, > writes UTF-16, and the hook cannot read that.
The project directory is CLAUDE_PROJECT_DIR, or the working directory when that is not set. If the file exists it
decides, even when the list is empty. An empty list means writes are blocked on every server. A file that cannot be
read counts as an empty list, and the block message says so. The project file overrides your own plugin setting, so
read it when you clone a repository, the same as its .claude/settings.json.
2. The plugin setting copy_servers. It is used only when the project has no file. Set it with
/plugin configure sqlserver-write-guard@erikdarling. Claude Code does not show that dialog for
--plugin-dir or claude plugin install, so use the command in a session. It is one string of names separated by
commas, such as DEV-SQL01,DEV-SQL02.
7-day copy clicks
npx claudepluginhub erikdarlingdata/claude-plugins --plugin sqlserver-write-guardBuilt from public signals: copy clicks on this site, GitHub stars and activity, the README and the manifest. Not a security audit or an endorsement.
Plugins from other owners that cover similar ground