Skip to content

About

Interactive examples for the Extending Claude Code workshop — hooks, plugins, status line, and more

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Extending Claude Code Workshop

Interactive examples for the "Extending Claude Code" workshop .

Clone this repo and try things yourself!

What's Included

hooks/ - Hook Script Examples

Copy these to ~/.claude/hooks/ and reference them in your settings.json:

Script Hook Type What it does
commit-validator.sh PreToolUse Validates git commits (conventional commits, max length, blocks -f)
auto-format.sh PostToolUse Auto-formats TS/JS (prettier) and PHP (phpcbf) after Write/Edit
notify.sh Notification Sends macOS desktop notification when Claude needs attention
save-summary SessionEnd AI-powered session summary using Claude Agent SDK (writes to ~/.claude/session-logs/)
save-summary-basic.sh SessionEnd Simple session logging (no AI, just metadata)
session-context.sh SessionStart Injects git status and recent commits at session start

statusline/ - Status Line Examples

Copy to ~/.claude/ and enable in your settings:

Script Description
basic-statusline.sh Shows: Model, context %, git branch
full-statusline.sh Full-featured: directory, git, model, context %, MCP status

settings-examples/ - Configuration Examples

Reference snippets showing how to configure hooks:

File Description
hooks-in-settings.json How to add hooks to your settings.json
prompt-stop-hook.json Prompt-based hooks (LLM-powered decisions)

plugin-example/ - Plugin Structure Reference

Complete plugin directory structure showing how plugins organize their components.

Prerequisites

For the hooks to work, you'll need:

  • jq - JSON processor (all hooks use this)
  • prettier - For auto-format.sh (TS/JS formatting): npm install -g prettier
  • phpcbf - For auto-format.sh (PHP formatting): composer global require squizlabs/php_codesniffer
  • terminal-notifier - For macOS notifications: brew install terminal-notifier
  • Python 3 + Claude Agent SDK - For save-summary.py (auto-creates venv on first run)

Quick Start

First, copy all hooks to your Claude hooks directory:

mkdir -p ~/.claude/hooks
cp hooks/* ~/.claude/hooks/

You may need to restart Claude Code after adding hooks.


Commit Validator (PreToolUse)

Validates git commits before they run and enforces conventional commits, max length, blocks force push.

Add to ~/.claude/settings.json:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/commit-validator.sh" }
        ]
      }
    ]
  }
}

Test it: Ask Claude to git commit -m "bad". It should be blocked for not using conventional commit format.


Auto-Format (PostToolUse)

Automatically formats code after Claude writes or edits files.

Add to ~/.claude/settings.json:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/auto-format.sh" }
        ]
      }
    ]
  }
}

Test it: Ask Claude to create a messy .ts or .js file and it should be auto-formatted after writing.


Notifications (Notification)

Sends macOS desktop notifications when Claude needs attention.

Add to ~/.claude/settings.json:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "permission_prompt|idle_prompt",
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/notify.sh" }
        ]
      }
    ]
  }
}

Test it: Wait 60+ seconds without responding and you'll get a notification for idle_prompt.


Session Context (SessionStart)

Injects git status and recent commits when a session starts.

Add to ~/.claude/settings.json:

{
  "hooks": {
    "SessionStart": [
      {
        "matcher": "startup|resume",
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/session-context.sh" }
        ]
      }
    ]
  }
}

Test it: Start a new Claude session in a git repo and Claude will see additional git info in the context.


Session Summary (SessionEnd)

Saves an AI-generated summary when sessions end. Uses the Claude Agent SDK.

Add to ~/.claude/settings.json:

{
  "hooks": {
    "SessionEnd": [
      {
        "hooks": [
          { "type": "command", "command": "~/.claude/hooks/save-summary" }
        ]
      }
    ]
  }
}

Test it: End a session with /exit and check ~/.claude/session-logs/ for the summary.

(Or use save-summary-basic.sh for simple logging without AI.)


Status Line

Shows model, context %, git branch, and more at the bottom of Claude Code.

cp statusline/basic-statusline.sh ~/.claude/statusline.sh

Add to ~/.claude/settings.json (user level only!):

{
  "statusLine": {
    "type": "command",
    "command": "bash ~/.claude/statusline.sh"
  }
}

Test it: Restart Claude Code and you'll see the status line at the bottom.


Example Plugin

A complete plugin showing slash commands, subagents, skills, hooks, and MCP config.

# Add this repo as a marketplace
/plugin marketplace add /path/to/ai-workshop-extending-claude-code

# Install the example plugin
/plugin install workshop-example@workshop-examples

The plugin includes:

  • /greet - A slash command
  • researcher - A subagent for codebase search
  • example-skill - A minimal skill
  • SessionStart hook - Prints "Workshop plugin loaded!"
  • .mcp.json - MCP server config (disabled placeholder)

Test it: Run /greet to see the slash command in action. Run /skills to see the example Skill is loaded. Run /agents to see the researcher is loaded.

Resources

About

Interactive examples for the Extending Claude Code workshop — hooks, plugins, status line, and more

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages