with one click
diary
// Use when the user says 'save diary', 'log session', 'wrapping up', or at end of a productive session.
// Use when the user says 'save diary', 'log session', 'wrapping up', or at end of a productive session.
Use this skill when the user says 'SEO audit', 'site audit', 'check SEO', 'audit my site', 'SEO check', 'technical SEO', or is evaluating a website's search engine optimization health, meta tags, performance, or structured data. Do NOT use for keyword research or schema markup generation alone.
Use this skill when the user says 'AI search', 'AI visibility', 'ChatGPT ranking', 'Perplexity optimization', 'GEO', 'generative engine optimization', or needs to optimize content for AI-powered search engines and LLM citations. Do NOT use for traditional SEO audits or Google Ads.
Use this skill when the user says 'add schema', 'schema markup', 'JSON-LD', 'structured data', 'rich results', 'rich snippets', or is adding or fixing schema.org structured data for better search result appearance. Do NOT use for meta tag optimization or full SEO audits.
Use this skill when the user says 'GDPR', 'data protection', 'privacy compliance', 'DPA', 'DSAR', 'data subject request', 'cookie consent', 'privacy audit', 'CCPA', or asks 'do I need GDPR for this repo'. Scans the repository to detect what personal data is collected, classifies sensitivity, determines whether GDPR applies and how critical it is, then reports required roles, obligations, and remediation. Do NOT use for general security audits (use owasp-top10) or contract drafting (use contract-template).
Use this skill when the user says 'licensing', 'license audit', 'can I use this commercially', 'OSS license check', 'license compatibility', 'GPL', 'MIT', 'AGPL', 'copyleft'. Scans the repository for every dependency and asset license, then produces a per-package verdict table: ready for commercial use, citation/attribution required, more information needed, or commercial use not allowed. Do NOT use for vulnerability scanning (use dependency-audit) or contract drafting (use contract-template).
Use when the user says 'teach me', 'explain as you go', 'mentor mode', 'walk me through', 'help me learn', 'explain why', 'learning mode', or wants real-time plain language narration of decisions and tradeoffs while building. Do NOT use for code review or debugging.
| name | diary |
| description | Use when the user says 'save diary', 'log session', 'wrapping up', or at end of a productive session. |
| version | 1.0.0 |
Document what was accomplished in each CC session for future recall.
When this skill activates, output:
š Diary ā Logging session...
Then execute the protocol below.
| Context | Status | Priority |
|---|---|---|
| User says "save diary", "log session", "write diary" | ACTIVE ā write diary | P1 |
| User explicitly says they're done ("that's it", "wrapping up") | ACTIVE ā suggest diary if work was done | P2 |
| Multi-agent session (Builder/Reviewer role) | DORMANT ā Manager handles diary | ā |
| Mid-session, user is actively coding | DORMANT ā don't interrupt flow | ā |
| Casual conversation, no code changes made | DORMANT ā nothing to log | ā |
| User asks to recall past sessions ("what did we do") | DORMANT ā Echo handles recall, not Diary | ā |
| User says "save project" or "handoff" | DORMANT ā Project skill handles this | ā |
| Session just started, no work yet | DORMANT ā nothing to log | ā |
When the user asks to save a diary, keep these in mind:
| Temptation | Why it matters |
|---|---|
| "Nothing important happened" | Even small decisions have context worth capturing. |
| "Commits capture everything" | Commits don't capture decisions, blockers, or next steps. |
| "Skip the handoff section" | Handoffs are the most valuable part for session continuity. |
Always use Bash for all memstack-db.py commands. Do not use PowerShell or CMD -- PowerShell mangles JSON arguments.
All JSON field values must be plain strings. Never pass arrays or objects. If multiple items (files, commits, decisions), join them as a comma-separated string.
Summarize the session:
Check git log for commits:
git log --oneline -10
Format the diary entry:
# Session Diary ā {project} ā {date}
## Accomplished
- Item 1...
## Files Changed
- path/to/file.ts ā description
## Commits
- abc1234 Message
## Decisions
- Decision: reason
## Next Steps
- What to do next
## Session Handoff
**In Progress:** [what was actively being worked on when session ended]
**Uncommitted Changes:** [list any unstaged/uncommitted work, or "None"]
**Pick Up Here:** [exact instruction for next session ā specific enough to start cold]
**Session Context:** [anything important that isn't captured elsewhere ā temp decisions, debugging state, gotchas discovered]
Save to SQLite database (primary storage):
python "$MEMSTACK_PATH/db/memstack-db.py" add-session '{"project":"<name>","date":"<YYYY-MM-DD>","accomplished":"<bullets>","files_changed":"<bullets>","commits":"<bullets>","decisions":"<bullets>","problems":"<bullets>","next_steps":"<bullets>","duration":"<estimate>","raw_markdown":"<full text>"}'
Also save decisions as insights for cross-project search:
python "$MEMSTACK_PATH/db/memstack-db.py" add-insight '{"project":"<name>","type":"decision","content":"<decision>","context":"Session <date>","tags":"<project>"}'
CRITICAL: The field name is "content", NOT "insight". Using "insight" will fail with a missing required field error.
Update project context with last session date:
python "$MEMSTACK_PATH/db/memstack-db.py" set-context '{"project":"<name>","last_session_date":"<YYYY-MM-DD>"}'
Also save markdown copy to memory/sessions/{date}-{project}.md (export format, human-readable backup)
The 500-line limit on markdown files is no longer a concern since SQLite is the source of truth.
Markdown files in memory/sessions/ are now just human-readable exports.
Old markdown files are preserved but not the primary storage.
User: "save diary"
š Diary ā Logging session...
Saved: memory/sessions/2026-02-18-adminstack.md
Project: AdminStack | Duration: ~2 hours
Accomplished: Built CC Monitor page, API routes, setup guide
Commits: 4 (45b4c42, d1c7e11, f6c8e18, f0e793f)
Files changed: 8
This session is now searchable via Echo.
The diary system includes an automatic PreCompact hook that fires before Claude Code compresses the context window. This closes the gap where session context could be lost during long conversations.
.claude/diary/{date}-compaction.md ā one file per day, appends on multiple compactionsCOMPACTION_INTERRUPTED so the next session knows context was cut| Data | Source |
|---|---|
| Uncommitted changes | git status --short |
| Recent commits | git log --oneline -5 |
| Recent shell commands | Shell history (last 5) |
| Recently modified files | Files modified since last git operation |
| Branch and project | Git branch + directory name |
| Manual Diary | PreCompact Diary | |
|---|---|---|
| Trigger | User says "save diary" | Automatic before compaction |
| Content | Full narrative with decisions, handoff | Snapshot of working state |
| Storage | SQLite + memory/sessions/ | .claude/diary/ only |
| Purpose | Session documentation | Context recovery after compaction |
When resuming after compaction, check .claude/diary/ for entries with today's date. The COMPACTION_INTERRUPTED flag signals that the previous context was truncated and these files contain the lost state.
Hook is registered in .claude/settings.json under PreCompact. Script lives at .claude/hooks/pre-compact.sh. Always exits 0 ā must never block compaction.
The Diary skill is part of a broader hook system that automates session lifecycle, security, and observability. All hooks follow the same defensive pattern: set -uo pipefail, SCRIPT_DIR resolution, all external commands wrapped with fallbacks, guaranteed exit 0.
| Event | Script | Matcher | Timeout | Purpose |
|---|---|---|---|---|
| PreToolUse | pre-tool-notify.sh | Write|Edit|MultiEdit|Bash | 10s | TTS voice alert before approval prompts |
| PreToolUse | pre-push.sh | Bash (git push) | 60s | Build verification + secrets scan before push |
| PostToolUse | post-commit.sh | Bash (git commit) | 10s | Debug artifact + secrets scan after commit |
| PostToolUse | post-tool-monitor.sh | Write|Edit|MultiEdit|Bash | 10s | Observation capture ā logs tool calls to .claude/observations/ |
| SessionStart | session-start.sh | (all) | 10s | Headroom proxy start, CLAUDE.md indexing, monitoring ping |
| SessionStart | session-context-load.sh | (all) | 15s | Context injection ā last 3 diary + observation summaries ā .claude/session-context.md |
| Stop | session-end.sh | (all) | 10s | Monitoring API session-complete ping |
| PreCompact | pre-compact.sh | (all) | 15s | Auto-save diary snapshot before context compaction |
settings.json, giving it its own timeout budget.claude/observations/YYYY-MM-DD.md ā daily files, append-only.claude/session-context.md on each new session.claude/observations/ and .claude/session-context.md are in .gitignore (ephemeral runtime output).claude/hooks/ and use ${CLAUDE_PROJECT_DIR} for portable path resolution.claude/rules/diary.md), always-on session logging awareness without skill file read. (Origin: MemStack v3.0-beta, Feb 2026)