-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonthly-summary.sh
More file actions
executable file
·96 lines (74 loc) · 3.2 KB
/
Copy pathmonthly-summary.sh
File metadata and controls
executable file
·96 lines (74 loc) · 3.2 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/zsh
# Task 3 — Monthly Summary
# Schedule: Every Saturday at 11:30pm PST
# Writes to: Current month's parent page (e.g. "March 2026")
CONFIG_FILE="$(dirname "$0")/config.sh"
[ -f "$CONFIG_FILE" ] || { echo "Run setup.sh first — config.sh not found at $CONFIG_FILE"; exit 1; }
source "$CONFIG_FILE"
export TZ="$AUDIT_TZ"
TODAY=$(date "+%b %-d, %Y")
YEAR=$(date "+%Y")
MONTH=$(date "+%B %Y") # e.g. "March 2026"
MONTH_NAME=$(date "+%B") # e.g. "March"
MONTH_NUM=$(date "+%m")
QUARTER_NUM=$(( ($(date "+%-m") - 1) / 3 + 1 ))
QUARTER="Q${QUARTER_NUM} ${YEAR}"
# Last day of current month
LAST_DAY=$(date -v1d -v+1m -v-1d "+%B %-d, %Y")
# Is this the last Saturday of the month?
# Check if next Saturday would be in the next month
NEXT_SATURDAY=$(date -v+7d "+%m")
CURRENT_MONTH_NUM=$(date "+%m")
IS_LAST_SATURDAY=$( [ "$NEXT_SATURDAY" != "$CURRENT_MONTH_NUM" ] && echo "yes" || echo "no" )
LOG_FILE="$HOME/.claude/automations/logs/monthly-$(date '+%Y-%m').log"
echo "=== Monthly Summary run at $(date) ===" >> "$LOG_FILE"
claude --dangerously-skip-permissions -p "$(cat <<PROMPT
Today is ${TODAY} (Saturday). PST = UTC-8.
Current month: ${MONTH}
Current quarter: ${QUARTER}
Last day of month: ${LAST_DAY}
Is this the final Saturday of the month? ${IS_LAST_SATURDAY}
The Notion hierarchy is: Audit Log → ${YEAR} → ${QUARTER} → ${MONTH}
STEP 1 — IDENTIFY ALL WEEK PAGES FOR THIS MONTH
Navigate: Audit Log → ${YEAR} → ${QUARTER} → ${MONTH}
Use notion-fetch on the ${MONTH} page to list all child week pages (titled "Week of ...").
Collect all week pages whose date range falls within ${MONTH_NAME} ${YEAR}.
STEP 2 — FETCH ALL WEEKLY SUMMARIES
For each week page found:
- Fetch the page
- Extract the ## Weekly Summary section
- Note the week range and key themes
STEP 3 — FIND OR CREATE THE MONTH PAGE
Use notion-search to find the page titled "${MONTH}".
If it doesn't exist, create it under the ${QUARTER} page with title "${MONTH}" and skeleton:
Monthly audit log: ${MONTH}. Summarized from weekly logs.
## Monthly Summary
*Updated through Week of [date] — finalizes ${LAST_DAY}.*
STEP 4 — REWRITE ## MONTHLY SUMMARY
Generate a comprehensive monthly summary covering:
- Major initiatives started and/or completed this month (with outcomes)
- Cross-week patterns and recurring themes
- What closed vs. still in progress at this point in the month
- Key relationships and collaborations (people + teams)
- One retrospective paragraph on the month so far
Format:
## Monthly Summary
[in-progress marker if not final Saturday]
### Major Initiatives
[bullet points — started, in progress, completed]
### Cross-Week Patterns
[bullet points]
### Closed vs. In Progress
[two sub-sections]
### Key Collaborators & Teams
[bullet points]
### Month in Review
[one retrospective paragraph]
In-progress marker logic:
- If IS_LAST_SATURDAY = "no": include *Updated through Week of [current week] — finalizes ${LAST_DAY}.*
- If IS_LAST_SATURDAY = "yes": OMIT the marker (this is the final run for the month)
STEP 5 — WRITE TO NOTION
Use notion-update-page with replace_content_range to rewrite the ## Monthly Summary section.
PROMPT
)" 2>&1 | tee -a "$LOG_FILE"
echo "=== Done at $(date) ===" >> "$LOG_FILE"