A UserPromptSubmit hook for Claude Code that generates concise project summaries in your Obsidian vault when you type obsidian-summary.
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
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.pyAdd this to your ~/.claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/obsidian-summary.py",
"timeout": 30
}
]
}
]
}
}Edit the Python script to change:
- The Obsidian vault path (
~/Documents/Obsidian/YOUR-VAULT/Projects/) - The template format if desired
The hook configuration is loaded at startup.
- Every prompt you submit passes through the hook script
- The script checks if the prompt is exactly
obsidian-summary - If yes, it outputs context that tells Claude what to do
- Claude receives this context and creates the summary file
---
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*Type obsidian-summary during your Claude Code session when you're ready to document your project.
- Hook type must be
command- notagent(which doesn't exist) - No
matcherfor 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