Skip to content
Development
Hook

Hooks

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

From plugin
permafrost
234 commands1 hook
Install
> /plugin marketplace add jianzhichun/permafrost
> /plugin install permafrost@permafrost

Ships with permafrost. 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 hook: ensure the Permafrost proxy is running — but only when this
    # session is actually routed through it. We never start a background server for
    # users who installed the plugin but aren't pointing Claude Code at the proxy.
    #
    # Opt-in is automatic: if ANTHROPIC_BASE_URL points at the Permafrost port (or
    # PERMAFROST_AUTOSTART=1 is set), we start the proxy in the background. Otherwise
    # this is a silent no-op.
    set -euo pipefail
    
    PORT="${PERMAFROST_PORT:-8787}"
    HOST="${PERMAFROST_HOST:-127.0.0.1}"
    BASE="http://${HOST}:${PORT}"
    
    routed=0
    case "${ANTHROPIC_BASE_URL:-}" in
      *"${HOST}:${PORT}"*) routed=1 ;;
    esac
    [[ "${PERMAFROST_AUTOSTART:-0}" == "1" ]] && routed=1
    
    [[ "$routed" == "1" ]] || exit 0
    
    # Already up?
    if curl -fsS "${BASE}/permafrost/health" >/dev/null 2>&1; then
      exit 0
    fi
    
    # Start it detached and return immediately so we don't delay the session.
    LOGDIR="${PERMAFROST_HOME:-$HOME/.permafrost}"
    mkdir -p "$LOGDIR"
    nohup python3 "${CLAUDE_PLUGIN_ROOT}/proxy/permafrost_proxy.py" \
      >>"$LOGDIR/proxy.log" 2>&1 &
    echo $! > "$LOGDIR/proxy.pid"
    
    echo "permafrost: started cache proxy at ${BASE} (mode=${PERMAFROST_MODE:-aggressive})" >&2
    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 withpermafrost

Freeze Claude Code's prompt prefix so DeepSeek's automatic cache always hits — alignment proxy + coalescing + keepalive, installable as a CC plugin. Measured 64% cheaper on real Claude Code traffic.

Get the whole plugin
Stats
23
Stars
3
Forks
Maintained
Maintenance
Python
Language
MIT
License
2mo ago
Last commit
3mo ago
Created

Repo: jianzhichun/permafrost