name: log description: Log this LLM session to .llm/log.jsonl. ONLY use when user explicitly asks to log the session with /log. argument-hint: [notes]
LLM Session Logging
Append a log entry to .llm/log.jsonl at the end of each session.
Log Schema
{
"timestamp": "2025-02-22T10:30:00Z",
"session_start": "2025-02-22T09:15:00Z",
"project_name": "Human-readable name",
"project_root": "folder-name",
"model": "claude-3-5-sonnet",
"tool": "claude-code | opencode | cursor | other",
"duration_min": 25,
"tokens_in": 15000,
"tokens_out": 8000,
"commits": ["e263c5e", "abc1234"],
"files": {
"read": ["PLAN.md"],
"created": ["README.md"],
"modified": ["src/index.ts"]
},
"summary": "Brief description of work done",
"user_notes": "Optional notes from user"
}
Required Fields
| Field | Type | Description |
|---|---|---|
timestamp |
string | When the log entry was created (ISO 8601, UTC) |
project_name |
string | Human-readable project name |
project_root |
string | Root folder name (for aggregation) |
model |
string | Model identifier |
tool |
string | Tool name (claude-code, opencode, cursor, etc.) |
summary |
string | Brief description of session work |
Optional Fields
| Field | Type | Description |
|---|---|---|
session_start |
string | When this work segment began (ISO 8601, UTC) |
duration_min |
number | Duration of this work segment in minutes |
tokens_in |
number | Input tokens used |
tokens_out |
number | Output tokens generated |
commits |
string[] | Git commit hashes made during this segment |
files |
object | File operations: read, created, modified arrays |
user_notes |
string | User-provided notes |
Data Accuracy
- Always precise:
timestamp(viadate -u),model,tool,commits,files,summary - Precise when valid session file:
session_start,duration_min - Estimated:
tokens_in/tokens_out— agents typically lack direct access to their own session metadata
/log Workflow
When user invokes /log:
Get current timestamp using bash:
date -u +"%Y-%m-%dT%H:%M:%SZ"Check for session file (
.llm/.session):If file does NOT exist:
- Ask user: "No session file found. Provide a session_start time? (YYYY-MM-DDTHH:MM:SSZ or 'skip')"
- If user provides time: use as
session_start, create.sessionfile - If user skips: leave
session_startandduration_minundefined
If file EXISTS:
- Read
startandtopicfrom.llm/.session
Calculate duration (if valid
session_start):start="2025-02-27T09:52:52Z" # from .llm/.session now=$(date -u +%s) start_epoch=$(TZ=UTC date -j -f "%Y-%m-%dT%H:%M:%SZ" "$start" +%s 2>/dev/null || TZ=UTC date -d "$start" +%s 2>/dev/null) echo $(( (now - start_epoch) / 60 ))Threshold check — if
duration_min > 120:- Prompt: "Session shows X hours duration. Adjust start time? [y/no/abort]"
y: Ask "Enter new start (YYYY-MM-DDTHH:MM:SSZ or 'now'):"now→ use current timestamp,duration_min= 0- timestamp → validate and use, recalculate duration
no: Proceed with current duration (legitimate long session)abort: Cancel/logcommand
Find commits for this segment:
# If session_start is known: git log --pretty=format:"%h" --since="<session_start>" # If no session_start, use last log timestamp: git log --pretty=format:"%h" --since="<last_log_timestamp>"- Remind user: "Found X commits since session start"
If no notes provided in arguments: Ask "Add any notes for this log entry? (press Enter to skip)"
Gather files data — track files read, created, modified during conversation
Append entry to
.llm/log.jsonl:mkdir -p .llm && printf '%s\n' '{"timestamp":"...","session_start":"..."}' >> .llm/log.jsonl- One JSON object per line
- No trailing commas, no array wrapper
Update
.session.startto the log entry timestamp:# After successful log append, update .session for next segment echo "{\"start\":\"$timestamp\",\"topic\":\"$topic\"}" > .llm/.session- This makes the next
/logcalculate duration since this log
- This makes the next
Confirm: "Logged session to .llm/log.jsonl"
Implementation Notes
- JSONL format: One JSON object per line, no trailing commas, no array wrapper
- Append only: Never modify existing log entries
- Always use Bash
>>: LLM tools' Write and Edit commands overwrite file contents. Always useprintf '%s\n' '{...}' >> .llm/log.jsonlvia Bash to append - Create if missing:
mkdir -p .llmbefore appending if the directory doesn't exist - User notes from arguments: If user typed
/log some notes, use "some notes" asuser_notes - Threshold for duration: 120 minutes — prompts user to adjust if exceeded (handles pause/resume)
- Update .session after log: Each log entry represents a work segment;
.session.startupdated to track next segment - No cleanup:
/logdoes not delete.llm/.session— it persists and gets updated
Arguments
$ARGUMENTS