Skip to content

Instantly share code, notes, and snippets.

@roelven
Last active January 11, 2026 13:44
Show Gist options
  • Select an option

  • Save roelven/6e2599be7e2dac225239860f426a6331 to your computer and use it in GitHub Desktop.

Select an option

Save roelven/6e2599be7e2dac225239860f426a6331 to your computer and use it in GitHub Desktop.
Claude Code SessionEnd hook for generating Obsidian project summaries

Claude Code Obsidian Summary Command

A UserPromptSubmit hook for Claude Code that generates concise project summaries in your Obsidian vault when you type obsidian-summary.

What It Does

When you type obsidian-summary during a Claude Code session, Claude will:

  • Analyze the session to extract project details
  • Determine the project/tool name
  • Summarize what was built in bullet points
  • Find the project location and git repository
  • Create a formatted markdown file in your Obsidian vault

Installation

Step 1: Create the hook script

Create the file ~/.claude/hooks/obsidian-summary.py:

#!/usr/bin/env python3
"""
Claude Code hook for creating Obsidian project summaries.
Triggers when user types 'obsidian-summary'.
"""
import json
import sys

try:
    input_data = json.load(sys.stdin)
except json.JSONDecodeError:
    sys.exit(0)

prompt = input_data.get("prompt", "").strip().lower()

if prompt == "obsidian-summary":
    context = """
The user wants to create an Obsidian summary for this session.

IMPORTANT: You must use the Sonnet model for this task. If you are not currently using Sonnet, use the Task tool with model="sonnet" to delegate this work to a Sonnet agent.

Please analyze what was worked on in this conversation and create a markdown file at:
~/Documents/Obsidian/YOUR-VAULT/Projects/[ToolName].md

Replace [ToolName] with the actual name of the tool/project.

Use this exact format:

---
created: [YYYY-MM-DD HH:MM]
tags: [project, tool, code, ai-written]
status: completed
---

[1-2 sentence description of what the tool does]

## What it does

- [Key functionality bullet point]
- [Another functionality]
- [etc.]

## Tech

[Comma-separated list of technologies used]

## Links

**Repo:** [GitHub URL, or "Gist only", or "Local only"]
**Gist:** [Gist URL if one was created in this session]

---
*Generated by Claude Code on [YYYY-MM-DD]*

Important: Use the Write tool to create the file. Get the current date/time for the timestamps.
"""
    print(context)

sys.exit(0)

Make it executable:

chmod +x ~/.claude/hooks/obsidian-summary.py

Step 2: Configure the hook

Add this to your ~/.claude/settings.json:

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/obsidian-summary.py",
            "timeout": 30
          }
        ]
      }
    ]
  }
}

Step 3: Customize

Edit the Python script to change:

  • The Obsidian vault path (~/Documents/Obsidian/YOUR-VAULT/Projects/)
  • The template format if desired

Step 4: Restart Claude Code

The hook configuration is loaded at startup.

How It Works

  1. Every prompt you submit passes through the hook script
  2. The script checks if the prompt is exactly obsidian-summary
  3. If yes, it outputs context that tells Claude what to do
  4. Claude receives this context and creates the summary file

Output Format

---
created: 2026-01-09 22:30
tags: [project, tool, code, ai-written]
status: completed
---

A Python script that automates routine Home Assistant tasks.

## What it does

- Generates YAML config for common automation patterns
- Validates entity IDs against your HA instance
- Creates device groups based on naming patterns

## Tech

Python, Home Assistant API, YAML, Click CLI

## Links

**Repo:** https://github.com/username/ha-helper
**Gist:** https://gist.github.com/username/abc123

---
*Generated by Claude Code on 2026-01-09*

Usage

Type obsidian-summary during your Claude Code session when you're ready to document your project.

Key Points

  • Hook type must be command - not agent (which doesn't exist)
  • No matcher for UserPromptSubmit - the script checks the prompt itself
  • The script receives JSON via stdin with the user's prompt
  • Plain text output from the script becomes context for Claude
  • Always uses Sonnet model - The hook instructs Claude to use Sonnet for generating summaries, ensuring consistent quality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment