--- name: log description: > End-of-session logging. Captures key decisions, gotchas, open questions, and discussion points into memory/log/ for later reflection. Run before ending a session to preserve context. Fast and low-friction — just run /log. allowed-tools: Read, Write, Glob, Bash(date *), Bash(ls *), Bash(cat *), Bash(find *), Bash(rm *), Bash(mkdir *) --- # Session Log Skill You are capturing key points from the current session into a structured log file. ## Pre-gathered context ### Current date and session timestamp !`date +%Y-%m-%d` !`date +%Y%m%d-%H%M%S` ### Existing log files !`ls -1 memory/log/ 2>/dev/null || echo "No log directory yet"` ### Settings !`cat settings.yaml 2>/dev/null || cat ../claude-foundations/settings.yaml 2>/dev/null || echo "No settings file found — using defaults: retention_days=7, warn_unreflected_days=14"` ### Reflection state (to check what has been reflected) !`cat .reflection-state.json 2>/dev/null || echo "No reflection state yet"` ### Current MEMORY.md index !`cat MEMORY.md 2>/dev/null || echo "No MEMORY.md found"` ## Instructions Review the **full conversation history** in your context window and extract the key points worth preserving. Not every session needs a log — if the session was trivial (a typo fix, a quick question), say so and skip. ### Step 1: Create the log directory if needed If `memory/log/` does not exist, create it with `mkdir -p memory/log/`. ### Step 2: Write the log file Generate the filename as `memory/log/YYYY-MM-DD..md` using the pre-gathered date and timestamp values. Write the file using this format: ```markdown # Session Log — YYYY-MM-DD ## Summary ## Decisions - Decision: — Rationale: ## Gotchas Discovered - **[topic]** Symptom: — Fix: ## Open Questions - ## Key Context - ## Process Notes - ``` **Guidelines:** - Omit empty sections entirely rather than leaving them blank - The `[topic]` tag on gotchas should match existing memory topic names where possible (e.g., `[k8s]`, `[cilium]`, `[ansible]`, `[sops]`, `[helm]`). Use new tags for new topics. - Keep entries concise — this is raw material for `/reflect-logs`, not a polished document - Include enough context that each entry makes sense on its own without the full conversation ### Step 3: Prune old logs After writing the log file, check for old logs that should be pruned: 1. Read `retention_days` and `warn_unreflected_days` from the settings (defaults: 7 and 14) 2. Read `.reflection-state.json` to know which logs have been reflected on 3. For each file in `memory/log/`: - Parse the date from the filename (first 10 characters: `YYYY-MM-DD`) - If **older than `retention_days`** AND **present in `.reflection-state.json`** → delete it and note the deletion - If **older than `warn_unreflected_days`** AND **NOT in `.reflection-state.json`** → print a warning: `WARNING: is N days old and has NOT been reflected on. Run /reflect-logs.` - Otherwise → leave it alone ### Step 4: Summary Print a brief summary: - Log file created (with path) - Number of entries by section - Any files pruned or warnings issued