UserPromptSubmit

UserPromptSubmit is a hook for Claude Code from JeongJaeSoon/agent-guard. Its token cost is not measured, scanned A, a copy of PreToolUse, MIT.

A prompt-time hook that runs a shell check before the coding agent sees a submitted prompt. It locates the available agent-guard version and handles missing-tool failures.

In plain words
What is it for?
Use it to run agent-guard before every prompt. The input does not describe what the guard itself checks.
Why use it?
It checks the guard before work begins, making setup problems visible early in the session.

Hook for Claude Code

Written for Claude Code: ${CLAUDE_PLUGIN_ROOT variable. Also seen: positional $N argument.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the agent-guard plugin — 2 skills, 2 commands, 5 hooks shipped together

One of 5 entries in hooks.json — they are configured in one file and arrive together.

Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add JeongJaeSoon/agent-guard
Claude Code
/plugin install agent-guard

Made for: Claude Code.

Or install agent-guard, the plugin that ships this one along with the rest of its 2 skills, 2 commands, 5 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for UserPromptSubmit

README.md
[![agentmods](https://agentmods.dev/badge/hooks/jeongjaesoon/agent-guard/user-prompt-submit.svg)](https://agentmods.dev/hooks/jeongjaesoon/agent-guard/user-prompt-submit)
Your own site
<a href="https://agentmods.dev/hooks/jeongjaesoon/agent-guard/user-prompt-submit"><img src="https://agentmods.dev/badge/hooks/jeongjaesoon/agent-guard/user-prompt-submit.svg" alt="Measured on agentmods" height="20"></a>
Per session not measured What this adds to a session before it is invoked.
When invoked not measured Not applicable: nothing here is loaded into a session.
Security scan A 0 findings. Scan, not verified.
Origin 84% copy Near-identical to another mod in the catalogue.
Security

Grade A, and why

UserPromptSubmit scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the commands this hook runs, not an audit. A hook is shell that executes on your machine at the event it names, which is why every command in it is printed with what was found.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

84% identical to PreToolUse — 6 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

plugins/agent-guard/hooks/hooks.json · 14 lines

How it starts

The opening of the file, as written. The whole thing — 14 lines — stays where its author put it; the contents beside it link to each section on GitHub.

{
  "UserPromptSubmit": [
    {
      "matcher": "",
      "hooks": [
        {
          "type": "command",
          "command": "sh -c 'r=${CLAUDE_PLUGIN_ROOT:-}; b=${r%/*}; x=; semver() { case ${1:-} in \"\"|*[!0-9.]*) return 1 ;; esac; o=$IFS; IFS=.; set -- $1; IFS=$o; [ \"$#\" -eq 3 ] && [ -n \"$1\" ] && [ -n \"$2\" ] && [ -n \"$3\" ]; }; root_ok() { q=$1; e=${2:-}; z=\"$q/bin/agent-guard\"; [ -x \"$z\" ] && [ -r \"$q/config/gitleaks.toml\" ] && [ -r \"$q/config/deny-read-paths.txt\" ] && [ -r \"$q/config/deny-bash-patterns.txt\" ] || return 1; u=; while IFS= read -r l; do case \"$l\" in VERSION=*) u=${l#VERSION=}; break ;; esac; done <\"$z\"; [ -n \"$u\" ] && { [ -z \"$e\" ] || [ \"$u\" = \"$e\" ]; }; }; if [ -n \"$r\" ]; then v=${r##*/}; semver \"$v\" || v=; if root_ok \"$r\" \"$v\"; then x=\"$r/bin/agent-guard\"; elif [ ! -e \"$r\" ]; then c=\"$b/current\"; t=; [ -L \"$c\" ] && t=$(readlink \"$c\" 2>/dev/null) || :; if semver \"$t\" && root_ok \"$c\" \"$t\"; then x=\"$c/bin/agent-guard\"; else x=$(for z in \"$b\"/*/bin/agent-guard; do [ -x \"$z\" ] || continue; q=${z%/bin/agent-guard}; v=${q##*/}; semver \"$v\" || continue; root_ok \"$q\" \"$v\" || continue; printf \"%s\\\\t%s\\\\n\" \"$v\" \"$z\"; done | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1 | cut -f 2-); fi; fi; fi; if [ ! -x \"$x\" ]; then mode=${AGENT_GUARD_INFRA_FAILURE_MODE:-open}; case \"$mode\" in closed) action=blocking ;; *) mode=open; action=continuing ;; esac; d=${AGENT_GUARD_WARNING_DIR:-${TMPDIR:-/tmp}/agent-guard-warnings-${UID:-user}}; p=; while IFS= read -r line || [ -n \"$line\" ]; do p=$p$line; done; i=${AGENT_GUARD_SESSION_ID:-}; if [ -z \"$i\" ] && command -v jq >/dev/null 2>&1; then i=$(printf %s \"$p\" | jq -r \".session_id // empty\" 2>/dev/null); fi; if [ -z \"$i\" ]; then case \"$p\" in *\\\"session_id\\\":\\\"*) i=${p#*\\\"session_id\\\":\\\"}; i=${i%%\\\"*}; case \"$i\" in \"\"|*[!A-Za-z0-9._:-]*) i= ;; esac ;; esac; fi; if [ -n \"$i\" ]; then i=$(printf %s \"$i\" | cksum); el

Read the full file on GitHub · 14 lines

Same file

What else hooks.json configures

This page is one entry in a file that holds 5. Installing the file brings all of them; each is measured and scanned on its own page.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed 17fcb7ed9e37
  2. 6d ago First seen · 14 lines scan A d3c8ac0ffa51

Subscribe to this mod's changes

UserPromptSubmit is a hook published in the GitHub repository JeongJaeSoon/agent-guard (25 stars, last pushed yesterday), licensed MIT. Its token cost is not measured: a hook is shell that never enters the context. A static security scan graded it A with 0 findings. It is 84% identical to PreToolUse, differing in 6 lines, and is treated as a copy.