ModsCode / Claude Code Mods / Build / Deny a tool call
Deny a tool call (tool.call and deny)
A PreToolUse settings hook blocks with a shell script; in a mod you handle on('tool.call', { tool: 'Bash' }, ...) and return { deny: 'reason' } without calling next. Claude reads the reason and tries something else. Let a call through with next(e), or change it with next({ ...e, command }).
The smallest form
export function register(on) {
on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
if (/\brm\s+-[a-zA-Z]*(rf|fr)\b/.test(e.command)) {
// no call to next: the command never runs, and Claude reads this
return { deny: 'rm -rf is blocked in this project. Delete the files one by one instead.' }
}
return next(e)
})
}
Written by ModsCode with the API of the official docs. Free to use.
Real mods' code (6)
Quoted as is from public mods on GitHub, at the commit ModsCode read. The heading leads to the mod's page (what it does, its good points, what its code reaches); the file name leads to the lines on GitHub.
Check the code yourself before you copy or install it. Mods run unsandboxed, with your permissions. ModsCode does not vouch for what the code does.
blast-radius deepseek-ai · Terminal + desktop · ★ 247,289
See what a risky command would change before it runs.
on("tool.call", { tool: "Bash" }, async ($, e, next) => {
const risk = classify(String(e.command ?? ""));
if (risk === null) return next(e); // everything else runs as normal
const report = await measure($, risk, await $.session.cwd()); // git status, git clean -n, du, ...
held = { command: e.command, risk, report, decision: null };
const opened = await $.ui.open({ id: "blast-radius", title: "Blast Radius", focus: true });
if (!opened.isPlaced) held.where = "band"; // too narrow for a pane: draw above the prompt
while (held.decision === null && !next.signal.aborted) {
await $.process.run(waitArgv); // time inside $ calls doesn't count against the hook's time limit
}
if (held.decision === "proceed") return next(e); // let it run
return { deny: `Blast Radius held this command: the user pressed Cancel. It would have: ${report.summary}.` };
});MIT licence. Keep its notice when you copy the code. Its code
Licence text (MIT)
MIT License Copyright (c) 2026 DeepSeek Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ruflo-security-audit ruvnet · Draws nothing · ★ 74,323
Security review, dependency scanning, policy gates, and CVE monitoring
on('tool.call', async ($, e, next) => {
const label = watched(e.tool, e)
if (label === undefined) return next(e)
s.stats.checked++
s.stats.seen[label] = (s.stats.seen[label] ?? 0) + 1
const reason = s.opts.guard ? verdict(e.tool, e) : undefined
if (reason !== undefined) {
s.stats.blocked++
s.stats.lastReason = reason.slice(0, 160)
}
await flush($, s)
return reason === undefined ? next(e) : { deny: reason }
})MIT licence. Keep its notice when you copy the code. Its code
Licence text (MIT)
MIT License Copyright (c) 2024-2026 ruvnet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ruflo-testgen ruvnet · Draws nothing · ★ 74,323
Test gap detection, coverage analysis, and automated test generation — drives the testgaps background worker via hooks_worker-dispatch; SPARC Refinement-phase canonical owner
on('tool.call', async ($, e, next) => {
const label = watched(e.tool, e)
if (label === undefined) return next(e)
s.stats.checked++
s.stats.seen[label] = (s.stats.seen[label] ?? 0) + 1
const reason = s.opts.guard ? verdict(e.tool, e) : undefined
if (reason !== undefined) {
s.stats.blocked++
s.stats.lastReason = reason.slice(0, 160)
}
await flush($, s)
return reason === undefined ? next(e) : { deny: reason }
})MIT licence. Keep its notice when you copy the code. Its code
Licence text (MIT)
MIT License Copyright (c) 2024-2026 ruvnet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ruflo-workflows ruvnet · Draws nothing · ★ 74,323
Workflow automation across two surfaces: the 10 workflow_* MCP tools (create/run/execute/status/list/pause/resume/cancel/delete/template) with full state-machine lifecycle (created → running ↔ paused → completed/cancelled), and native Clau…
on('tool.call', async ($, e, next) => {
const label = watched(e.tool, e)
if (label === undefined) return next(e)
s.stats.checked++
s.stats.seen[label] = (s.stats.seen[label] ?? 0) + 1
const reason = s.opts.guard ? verdict(e.tool, e) : undefined
if (reason !== undefined) {
s.stats.blocked++
s.stats.lastReason = reason.slice(0, 160)
}
await flush($, s)
return reason === undefined ? next(e) : { deny: reason }
})MIT licence. Keep its notice when you copy the code. Its code
Licence text (MIT)
MIT License Copyright (c) 2024-2026 ruvnet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ruflo-x-gateway ruvnet · Draws nothing · ★ 74,323
Coordinate AI-agent swarms through signed federation messages, channels, and work claims. The remote Claude connector exposes a directory-safe Streamable HTTP MCP surface with OAuth-protected publishing and five ruv:// reference resources.
on('tool.call', async ($, e, next) => {
const label = watched(e.tool, e)
if (label === undefined) return next(e)
s.stats.checked++
s.stats.seen[label] = (s.stats.seen[label] ?? 0) + 1
const reason = s.opts.guard ? verdict(e.tool, e) : undefined
if (reason !== undefined) {
s.stats.blocked++
s.stats.lastReason = reason.slice(0, 160)
}
await flush($, s)
return reason === undefined ? next(e) : { deny: reason }
})MIT licence. Keep its notice when you copy the code. Its code
Licence text (MIT)
MIT License Copyright (c) 2024-2026 ruvnet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
crit-tui Tomasz Tomczyk · Terminal + desktop · ★ 1,196
Early: crit inside Claude Code. Comment on the conversation, your diff or a file in a pane, send the review to Claude, and read Claude's replies in threads.
on('tool.call', { tool: 'mcp__crit-tui__reply' }, async ($, e) => {
const input = e as unknown as { id?: string; body?: string }
const thread = input.id ? await findThread($, input.id) : undefined
if (!thread || !input.body) {
return { deny: `No crit thread with id ${input.id ?? '(none)'}. Call ${TOOL_PREFIX}threads to list them.` }
}
try {
await addReply($, thread, input.body, 'claude', false)
} catch (error) {
return { deny: `crit could not save the reply: ${String(error)}` }
}
$.ui.toast(`Claude replied on ${whereOf(thread, await read($, chatIndexA))}`)
await sync($)
return { result: 'Reply saved. The user sees it in the crit pane.' }
})MIT licence. Keep its notice when you copy the code. Its code
Licence text (MIT)
MIT License Copyright (c) 2026 Tomasz Tomczyk Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Start building
Put a .claude-plugin/plugin.json ({"name": "my-mod"}) and a hooks/hooks.json ({"modules": ["register.js"]}) in a folder, save the code above as hooks/register.js, and run claude --plugin-dir . to load it for one session. claude plugin validate . lists the events it hooks and the APIs it calls.