Skip to content
Development
Hook

Hooks

What cprof runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.

From plugin
cprof
51 command1 hook
Install
> /plugin marketplace add dcotelo/cprof
> /plugin install cprof@dcotelo

Ships with cprof. Installing the plugin gets these hooks.

What fires, and when

SessionStart

Fires once when a session begins, and again after a context compaction. It is where a plugin sets up its environment, or restores state the compaction dropped.

  • ${CLAUDE_PLUGIN_ROOT}/hooks/session-start.sh
Read hooks/hooks.json

Where it lives

  • hooks/session-start.shRunsGitHub
    Read the script
    #!/usr/bin/env bash
    # SessionStart: warn when the live session's account no longer matches what this
    # directory resolves to. Never fails a session.
    set -u
    
    root="${CLAUDE_PLUGIN_ROOT:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)}"
    cli="$root/scripts/cprof"
    [ -x "$cli" ] || exit 0
    
    want="$("$cli" env 2>/dev/null)"
    have="${CLAUDE_CONFIG_DIR:+export CLAUDE_CONFIG_DIR=$(printf "'%s'" "$CLAUDE_CONFIG_DIR")}"
    [ -n "$have" ] || have='unset CLAUDE_CONFIG_DIR'
    
    if [ "$want" = "$have" ]; then
      exit 0
    fi
    
    detail="$("$cli" which 2>/dev/null | head -1)"
    printf 'cprof: this session does not match this directory. Expected: %s. Relaunch claude here to switch.\n' \
      "${detail:-unknown}"
    exit 0
    

Read the script before you install anything that runs on your machine. This is the one part of a plugin that acts without being asked.

Ships withcprof

Per-repository Claude account switching: keep personal and work subscriptions separate.

Get the whole plugin
Stats
5
Stars
1
Forks
Active
Maintenance
Shell
Language
MIT
License
5d ago
Last commit
1mo ago
Created

Repo: dcotelo/cprof