Update /log skill to use transcript backups via Sonnet subagent; add switch-mode
- skills/log/SKILL.md: pre-gathers unprocessed transcript metadata (compact JSON via list-transcripts-here.sh) rather than full content; spawns a Sonnet subagent (not Haiku — gotcha detection requires judgment) to read JSONL backups, write a companion -transcripts.md log, and mark backups processed in tracking.json; adds Agent and Bash(bash|pwd|python3) to allowed-tools - skills/switch-mode/SKILL.md: add previously untracked skill to repo Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ 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 *)
|
||||
allowed-tools: Read, Write, Glob, Agent, Bash(date *), Bash(pwd), Bash(ls *), Bash(cat *), Bash(find *), Bash(rm *), Bash(mkdir *), Bash(python3 *), Bash(bash *)
|
||||
---
|
||||
|
||||
# Session Log Skill
|
||||
@@ -17,6 +17,9 @@ You are capturing key points from the current session into a structured log file
|
||||
!`date +%Y-%m-%d`
|
||||
!`date +%Y%m%d-%H%M%S`
|
||||
|
||||
### Current project directory
|
||||
!`pwd`
|
||||
|
||||
### Existing log files
|
||||
!`ls -1 memory/log/ 2>/dev/null || echo "No log directory yet"`
|
||||
|
||||
@@ -29,16 +32,19 @@ You are capturing key points from the current session into a structured log file
|
||||
### Current MEMORY.md index
|
||||
!`cat MEMORY.md 2>/dev/null || echo "No MEMORY.md found"`
|
||||
|
||||
### Unprocessed transcript backups for this project (metadata only)
|
||||
!`bash ~/.claude/scripts/list-transcripts-here.sh 2>/dev/null || echo "[]"`
|
||||
|
||||
## 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.
|
||||
Review the **full conversation history** in your context window and extract 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
|
||||
The "Unprocessed transcript backups" above shows metadata (filenames, timestamps) for any pre-compaction snapshots not yet captured in a log. **Do NOT read the transcript content yourself** — that is handled by a subagent in Step 2 to avoid context overflow.
|
||||
|
||||
### Step 1: Create the log directory and write the in-context log
|
||||
|
||||
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.<HHMMSS>.md` using the pre-gathered date and timestamp values.
|
||||
|
||||
Write the file using this format:
|
||||
@@ -72,9 +78,82 @@ Write the file using this format:
|
||||
|
||||
**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.
|
||||
- The `[topic]` tag on gotchas should match existing memory topic names where possible (e.g., `[k8s]`, `[cilium]`, `[ansible]`, `[sops]`, `[helm]`)
|
||||
- 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
|
||||
- Include enough context that each entry makes sense without the full conversation
|
||||
|
||||
### Step 2: Dispatch transcript analysis subagent (if unprocessed transcripts exist)
|
||||
|
||||
If the pre-gathered transcript list is non-empty and contains backup files that `exists: true`:
|
||||
|
||||
Spawn a **Sonnet** subagent (model: sonnet) with the following prompt. Sonnet is used (not Haiku) because gotcha detection requires judgment about backtracking, failed attempts, and domain-specific failure modes — Haiku tends to miss these. Fill in the bracketed values from the pre-gathered data:
|
||||
|
||||
---
|
||||
**Subagent prompt template:**
|
||||
|
||||
You are processing pre-compaction transcript backups into a structured session log.
|
||||
|
||||
**Project directory:** [CWD from pre-gathered context]
|
||||
**Log directory:** memory/log/ (relative to project dir — write files there using absolute path)
|
||||
**Log filename:** [SAME HHMMSS timestamp as Step 1, but with suffix -transcripts, e.g. memory/log/YYYY-MM-DD.HHMMSS-transcripts.md]
|
||||
**Transcripts to process:** [paste the JSON array from the pre-gathered list]
|
||||
|
||||
## Your task
|
||||
|
||||
For each backup file listed above (where `exists: true`):
|
||||
|
||||
1. Extract the conversation using:
|
||||
```
|
||||
python3 ~/.claude/scripts/extract-transcripts.py --extract <backup_name>
|
||||
```
|
||||
Run this as a Bash command and read the output.
|
||||
|
||||
2. If the transcript has >40 turns, process it in two passes:
|
||||
- First half of turns in one read
|
||||
- Second half in a second run (re-run --extract and skip to turn N)
|
||||
Note: the --extract command outputs all turns; read the full output but focus analysis on substance.
|
||||
|
||||
3. After reading all transcripts, write a single log file at the absolute path:
|
||||
`[PROJECT_ABS_PATH]/memory/log/YYYY-MM-DD.HHMMSS-transcripts.md`
|
||||
|
||||
Use this format:
|
||||
```markdown
|
||||
# Transcript Log — YYYY-MM-DD (pre-compaction backups)
|
||||
|
||||
## Sources
|
||||
- <backup_name> (session <session_id>, saved <saved_at>)
|
||||
|
||||
## Summary
|
||||
<!-- What was worked on across the captured sessions -->
|
||||
|
||||
## Decisions
|
||||
- Decision: <what> — Rationale: <why>
|
||||
|
||||
## Gotchas Discovered
|
||||
- **[topic]** Symptom: <what happened> — Fix: <what resolved it>
|
||||
|
||||
## Open Questions
|
||||
- <question>
|
||||
|
||||
## Key Context
|
||||
- <fact>
|
||||
|
||||
## Process Notes
|
||||
- <note>
|
||||
```
|
||||
|
||||
4. After writing the log, mark all processed transcripts:
|
||||
```
|
||||
python3 ~/.claude/scripts/extract-transcripts.py --mark-all-processed "[CWD]" --log-file "memory/log/YYYY-MM-DD.HHMMSS-transcripts.md"
|
||||
```
|
||||
|
||||
5. Report: transcript(s) processed, log file written, any issues encountered.
|
||||
|
||||
**Allowed tools for the subagent:** Read, Write, Bash(python3 *), Bash(mkdir *)
|
||||
|
||||
---
|
||||
|
||||
Spawn this subagent with `model: sonnet` and wait for it to complete before continuing.
|
||||
|
||||
### Step 3: Prune old logs
|
||||
|
||||
@@ -91,6 +170,6 @@ After writing the log file, check for old logs that should be pruned:
|
||||
### Step 4: Summary
|
||||
|
||||
Print a brief summary:
|
||||
- Log file created (with path)
|
||||
- Number of entries by section
|
||||
- In-context log file created (with path)
|
||||
- Whether a transcript analysis subagent was dispatched (and which backups it processed)
|
||||
- Any files pruned or warnings issued
|
||||
|
||||
Reference in New Issue
Block a user