forked from FlorianBruniaux/claude-code-ultimate-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearning-capture.sh
More file actions
executable file
·58 lines (46 loc) · 1.46 KB
/
learning-capture.sh
File metadata and controls
executable file
·58 lines (46 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# Hook: Stop - Capture one learning insight at session end
# Event: Stop (when user ends session or interrupts)
# Purpose: Build a learning journal with minimal friction
#
# Exit codes:
# 0 = success (always returns 0 to not block session end)
#
# Output: Appends to ~/claude-learnings.md
#
# Configuration:
# CLAUDE_LEARNING_LOG - Custom log path (default: ~/claude-learnings.md)
# CLAUDE_LEARNING_SKIP - Set to 1 to skip prompt
set -e
# Configuration
LOG_FILE="${CLAUDE_LEARNING_LOG:-$HOME/claude-learnings.md}"
SKIP_PROMPT="${CLAUDE_LEARNING_SKIP:-0}"
# Skip if disabled
if [[ "$SKIP_PROMPT" == "1" ]]; then
exit 0
fi
# Read hook input (not used but consumed to avoid errors)
INPUT=$(cat)
# Get project context
PROJECT_NAME=$(basename "${CLAUDE_PROJECT_DIR:-$(pwd)}")
DATE=$(date +%Y-%m-%d)
TIME=$(date +%H:%M)
# Ensure log file directory exists
mkdir -p "$(dirname "$LOG_FILE")"
# Create log file with header if it doesn't exist
if [[ ! -f "$LOG_FILE" ]]; then
cat > "$LOG_FILE" << 'HEADER'
# Claude Learning Journal
A record of insights captured during coding sessions.
---
HEADER
fi
# Return system message prompting for learning capture
# The user's response will be logged by the next invocation
# (This is a non-blocking prompt approach)
cat << EOF
{
"systemMessage": "Session ending. Quick reflection:\n\nWhat's ONE thing you learned this session?\n\n(Type your answer, or 'skip' to end without logging)\n\nLogging to: $LOG_FILE"
}
EOF
exit 0