SessionStart

SessionStart is a hook for coding agents from JeongJaeSoon/agent-guard. Its token cost is not measured, scanned A, a copy of PreToolUse, MIT.

A session-start hook that runs a shell check when an agent session starts, resumes, is cleared, or is compacted. It checks which installed version of agent-guard should be used and reports missing infrastructure.

In plain words
What is it for?
Use it to prepare agent-guard whenever a session begins or resumes and to warn about setup failures. The exact guard checks are not shown.
Why use it?
It helps detect when the session's guard tool is unavailable or when its version link needs updating.

Hook

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

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add hooks/jeongjaesoon/agent-guard/session-start
Clone the repo
git clone --depth 1 https://github.com/JeongJaeSoon/agent-guard

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 SessionStart

README.md
[![agentmods](https://agentmods.dev/badge/hooks/jeongjaesoon/agent-guard/session-start.svg)](https://agentmods.dev/hooks/jeongjaesoon/agent-guard/session-start)
Your own site
<a href="https://agentmods.dev/hooks/jeongjaesoon/agent-guard/session-start"><img src="https://agentmods.dev/badge/hooks/jeongjaesoon/agent-guard/session-start.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 91% copy Near-identical to another mod in the catalogue.
Security

Grade A, and why

SessionStart 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 3d ago.

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

91% identical to PreToolUse — 8 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.

{
  "SessionStart": [
    {
      "matcher": "startup|resume|clear|compact",
      "hooks": [
        {
          "type": "command",
          "command": "sh -c 'r=${CLAUDE_PLUGIN_ROOT:-}; b=${r%/*}; s=\"$b/current/bin/agent-guard\"; x=; if [ -n \"$r\" ]; then x=$(for c in \"$b\"/*/bin/agent-guard; do [ -x \"$c\" ] || continue; v=${c%/bin/agent-guard}; printf \"%s\\\\t%s\\\\n\" \"${v##*/}\" \"$c\"; done | awk -F \"\\\\t\" \"\\$1 ~ /^[0-9]+\\\\.[0-9]+\\\\.[0-9]+$/\" | sort -t. -k1,1n -k2,2n -k3,3n | tail -n 1 | cut -f 2-); fi; if [ -x \"$x\" ]; then v=${x%/bin/agent-guard}; v=${v##*/}; if [ ! -e \"$b/current\" ] || [ -L \"$b/current\" ]; then ln -sfn \"$v\" \"$b/current\" 2>/dev/null || :; fi; [ -L \"$b/current\" ] && [ -x \"$s\" ] && x=\"$s\"; fi; if [ ! -x \"$x\" ] && [ -x \"$r/bin/agent-guard\" ]; then x=\"$r/bin/agent-guard\"; 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); else i=ppid-${PPID:-0}; fi; k=\"$d/manifest-claude-$i-$mode\"; warn=1; if mkdir -p \"$d\" 2>/dev/null; then (umask 077; set -C; : >\"$k\") 2>/dev/null || warn=0; fi; [ \"$warn\" -eq 0 ] || echo \"agent-guard: CLAUDE_PLUGIN_ROOT env not set or no installed binary was found; $action because AGENT_GUARD_INFRA_FAILURE_MODE=$mode\" >&2; [ \"$mode\" = closed ] && exit 2; exit 0; fi; AGENT_GUARD_HOOK_HOST=claude \"$x\" hook-session-start'",
          "timeout"

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. 3d ago First seen · 14 lines scan A 971b39d81dab

Subscribe to this mod's changes

SessionStart is a hook published in the GitHub repository JeongJaeSoon/agent-guard (24 stars, last pushed 3d ago), 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 91% identical to PreToolUse, differing in 8 lines, and is treated as a copy.