Hooks

8 lifecycle hooks that run automatically during your session.

Overview

Hooks are lifecycle functions that execute automatically at specific points in your Coding Friend session. They handle security, formatting, reminders, and context management without requiring manual invocation.

Hook Reference

HookTriggerPurpose
session-initSessionStartInitialize session state and load configuration
rules-reminderUserPromptSubmitRemind developers of project rules (every 4th prompt)
privacy-blockPreToolUseBlock access to sensitive files (.env, .pem, SSH keys)
scout-blockPreToolUseBlock access to files matching .coding-friend/ignore patterns
auto-approvePreToolUseAuto-approve safe tool calls, block destructive ones (opt-in)
statuslineSessionStartConfigure editor statusline with project info, account, rate limits, task/agent progress
session-logStopAppend turn log (JSONL) for richer memory capture
task-trackerTaskCreated/TaskCompletedTrack task progress for statusline display
agent-trackerSubagentStart/SubagentStopTrack active agent for statusline display
memory-capturePreCompactAuto-capture session memory before context compaction

How Hooks Work

Hooks are executed automatically by the Coding Friend plugin at specific lifecycle events. You don't invoke them manually — they run in the background to support your workflow.

Controlling Hooks

Enable or disable hooks in .coding-friend/config.json:

{
  "hooks": {
    "privacyBlock": true,
    "scoutBlock": true,
    "rulesReminder": true
  }
}

All hooks default to enabled. Set to false to disable specific hooks for your project.

Statusline Hook

The statusline hook configures your editor's status bar with live project information. It supports the following components:

ComponentDescription
versionPlugin version from plugin.json
folderCurrent working directory name
modelActive Claude model
branchCurrent git branch
accountAccount email and display name from ~/.claude.json
contextContext window usage percentage
rate_limitAPI rate limit usage for 5-hour and 7-day windows

Component Configuration

Toggle individual components in .coding-friend/config.json:

{
  "statusline": {
    "components": {
      "version": true,
      "folder": true,
      "model": true,
      "branch": true,
      "account": true,
      "context": true,
      "rate_limit": true
    }
  }
}

All components default to enabled. The rate_limit component caches API responses for 5 minutes to avoid excessive requests.

Security Hooks

privacy-block and scout-block form Coding Friend's first line of defense against accidental credential exposure and inappropriate file access. See the security reference for the full defense-in-depth model.

Auto-Approve Hook

The auto-approve hook reduces permission prompts by automatically approving safe tool calls and blocking destructive ones. See the dedicated auto-approve reference for details on classification tiers, rules, and configuration.