SessionEnd

SessionEnd is a hook for Claude Code from Fmarzochi/EGC. Its token cost is not measured, scanned A, a copy of PreCompact, Apache-2.0.

A session-end hook that runs Node.js commands when a coding-agent session finishes.

In plain words
What is it for?
Use it to trigger the referenced scripts and utilities when a session ends.
Why use it?
It automates end-of-session tasks that would otherwise need to be run manually.

Hook for Claude Code

Written for Claude Code: SessionEnd hook event.

One of 8 entries in hooks.json upstream. Installing this one merges just its entry into your config; the other 7 are separate, each on its own page.

Good fit Use it to trigger the referenced scripts and utilities when a session ends.

Compare 6 hooks from other repositories ↓
Install with agentmods
npx agentmods add hooks/fmarzochi/egc/session-end
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.

Clone the repo
git clone --depth 1 https://github.com/Fmarzochi/EGC

Made for: Claude Code.

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 SessionEnd

README.md
[![agentmods](https://agentmods.dev/badge/hooks/fmarzochi/egc/session-end/github.svg)](https://agentmods.dev/hooks/fmarzochi/egc/session-end)
Your own site
<a href="https://agentmods.dev/hooks/fmarzochi/egc/session-end"><img src="https://agentmods.dev/badge/hooks/fmarzochi/egc/session-end/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for SessionEnd

Your own site · 80×15
<a href="https://agentmods.dev/hooks/fmarzochi/egc/session-end"><img src="https://agentmods.dev/badge/hooks/fmarzochi/egc/session-end.svg" alt="Reviewed on agentmods" width="80" 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 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin 92% copy Near-identical to another mod in the catalogue.
Security

Grade A, and why

SessionEnd scanned grade A with 1 finding 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 1mo 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.

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

"command": "node -e \"const fs=require('fs');const path=require('path');const {spawnSync}=require('child_process');const raw=fs.readFileSync(0,'utf8');const rel=path.join('scripts','hooks','run-with-flags.js');const hasR
Origin

This is a copy

92% identical to PreCompact — 28 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.

hooks/hooks.json · 52 lines

How it starts

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

{
  "SessionEnd": [
    {
      "matcher": "*",
      "hooks": [
        {
          "type": "command",
          "command": "node -e \"const fs=require('fs');const path=require('path');const {spawnSync}=require('child_process');const raw=fs.readFileSync(0,'utf8');const rel=path.join('scripts','hooks','run-with-flags.js');const hasRunnerRoot=candidate=>{const value=typeof candidate==='string'?candidate.trim():'';return value.length>0&&fs.existsSync(path.join(path.resolve(value),rel));};const root=(()=>{const envRoot=process.env.EGC_PLUGIN_ROOT||process.env.ECC_PLUGIN_ROOT||process.env.GEMINI_PLUGIN_ROOT||'';if(hasRunnerRoot(envRoot))return path.resolve(envRoot.trim());const home=require('os').homedir();const claudeDir=path.join(home,'.gemini');if(hasRunnerRoot(claudeDir))return claudeDir;for(const candidate of [path.join(claudeDir,'plugins','egc'),path.join(claudeDir,'plugins','egc@egc'),path.join(claudeDir,'plugins','marketplace','egc'),path.join(claudeDir,'plugins','everything-gemini'),path.join(claudeDir,'plugins','everything-gemini@everything-gemini'),path.join(claudeDir,'plugins','marketplace','everything-gemini')]){if(hasRunnerRoot(candidate))return candidate;}try{for(const slug of ['egc','everything-gemini']){const cacheBase=path.join(claudeDir,'plugins','cache',slug);for(const org of fs.readdirSync(cacheBase,{withFileTypes:true})){if(!org.isDirectory())continue;for(const version of fs.readdirSync(path.join(cacheBase,org.name),{withFileTypes:true})){if(!version.isDirectory())continue;const candidate=path.join(cacheBase,org.name,version.name);if(fs.existsSync(path.join(candidate,rel)))return candidate;}}}}catch{}return claudeDir;})();const script=path.join(root,rel);if(fs.existsSync(script)){const result=spawnSync(process.execPath,[script,'session:end:marker','scripts/hooks/session-end-marker.js','minimal,standard,strict'],{input:raw,encoding:'utf8',env:process.env,cwd:process.cwd(),timeout:30000});const stdout=typeof result.stdout==='string'?result.stdout:'';

Read the full file on GitHub · 52 lines

Same file

What else hooks.json configures

This page is one entry in a file that holds 8. 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. 1mo ago First seen · 52 lines scan A d94f927519f9

Subscribe to this mod's changes

SessionEnd is a hook published in the GitHub repository Fmarzochi/EGC (68 stars, last pushed yesterday), licensed Apache-2.0. Its token cost is not measured: a hook is shell that never enters the context. A static security scan graded it A with 1 finding (runs shell commands). It is 92% identical to PreCompact, differing in 28 lines, and is treated as a copy.