From @tekmidian/pai
Retroactively reconstructs session notes from JSONL transcripts and git commit history for PAI-registered projects when automatic capture fails or is incomplete.
npx claudepluginhub mnott/paiThis skill uses the workspace's default tool permissions.
USE WHEN user says 'reconstruct sessions', 'rebuild session notes', 'recover session notes', 'retroactively create notes', 'create notes from git history', 'notes are missing', 'backfill session notes', 'reconstruct what we did', OR /reconstruct.
Generates markdown diary entries for coding sessions, capturing accomplishments, files changed, git commits, decisions, next steps, and handoffs. Triggers on 'save diary', 'log session', or 'wrapping up'.
Generates and saves Markdown session logs capturing objectives, file changes, referenced materials, technical notes, future plans, open items, and metrics to resume project work across conversations.
Logs factual progress from git work sessions (detected via 3-day gaps) to a global markdown file after sprints, phases, or milestones. Useful for 'document my progress' or post-repo work.
Share bugs, ideas, or general feedback.
USE WHEN user says 'reconstruct sessions', 'rebuild session notes', 'recover session notes', 'retroactively create notes', 'create notes from git history', 'notes are missing', 'backfill session notes', 'reconstruct what we did', OR /reconstruct.
Reconstructs session notes for a PAI-registered project by reading:
Generates one session note per day (or per logical session if multiple sessions existed in a day), numbered sequentially from the highest existing note number.
ONLY include what can be verified from git log and JSONL. Never invent or embellish content.
| Argument | Default | Description |
|---|---|---|
--days N | 7 | Reconstruct notes for the last N days |
--since YYYY-MM-DD | — | Reconstruct from this date forward |
--until YYYY-MM-DD | today | Reconstruct up to this date |
--dry-run | false | Show what would be created without writing files |
--commit | false | Git commit the created notes after writing |
Before starting, verify:
pai project detect (or pai project list) to confirm the current project is known to PAI and get its Notes directory path.Notes/YYYY/MM/. Create it if absent.Notes/**/*.md files for the pattern ^NNNN to find max note number. New notes continue from there.Claude Code encodes project paths lossily: /, spaces, dots, hyphens all become -. A project may have been accessed from multiple base directories (e.g., ~/Daten/Cloud/Development/ai/PAI and ~/dev/ai/PAI both encode to different paths).
Search strategy — use glob patterns, not exact paths:
# Find all encoded project directories that might match this project
ls ~/.claude/projects/ | grep -i "<project-slug-fragment>"
# For each candidate, look for JSONL files
ls ~/.claude/projects/<encoded-path>/*.jsonl 2>/dev/null
# Also check the dev copy if the project has one
# Example: if cwd is ~/dev/ai/PAI, also check ~/Daten/Cloud/Development/ai/PAI encoding
Collect ALL JSONL files from ALL matching encoded paths. A session may have been started from either location.
Calculate the date range from arguments:
--days 7 → from (today - 7 days) to today--since 2026-03-01 → from that date to today (or --until date)For each day in the range:
git -C <project-dir> log \
--after="YYYY-MM-DD 00:00:00" \
--before="YYYY-MM-DD 23:59:59" \
--format="%H|%ad|%s" \
--date=short \
--stat
Group commits by day. If no commits on a day, skip that day (no note to reconstruct).
Also capture:
--stat)For each JSONL file, parse messages where type == "user" AND message.role == "user":
Each line is a JSON object. Look for:
{
"type": "user",
"message": {
"role": "user",
"content": "..." | [{"type": "text", "text": "..."}]
},
"timestamp": "2026-03-15T10:23:45.000Z"
}
Filter messages by timestamp to match the day being reconstructed.
Extract:
sessionId field) to group messages per sessionSKIP messages that are:
content is array with type: "tool_result")KEEP messages that reveal:
A "logical session" is a continuous work block. Use these signals to split a day into multiple sessions:
If only one logical session exists for a day, create one note. If multiple exist, create one note per session with a suffix: NNNN - YYYY-MM-DD - Title.md, NNNN+1 - YYYY-MM-DD - Title (2).md.
The note title comes from synthesizing git commits for that session:
Note filename format: NNNN - YYYY-MM-DD - Title.md
Path: Notes/YYYY/MM/NNNN - YYYY-MM-DD - Title.md
Content template:
# Session: [Title]
**Date:** YYYY-MM-DD
**Status:** Completed
**Reconstructed:** true (from JSONL + git history)
---
## Work Done
[Group related commits into logical sections by theme/component, not by commit order.
Each section describes WHAT was built and WHY, derived from commit messages and user messages.
Use present-tense descriptions: "Add X", "Fix Y", "Refactor Z".]
## Key Decisions
[Architectural choices, technology selections, approach changes.
ONLY include decisions that are explicitly stated in user messages or strongly implied by commit message changes (e.g., a series of "revert" commits followed by a new approach).
Format as bullet points.]
## Known Issues at End of Session
[Bugs discovered, things left unfinished.
Derive from: last commits in session (if they add TODOs or fix-me comments), user messages mentioning problems, or explicit "not done yet" statements.
Omit this section if nothing can be verified.]
---
**Tags:** #[project-slug] #reconstructed
Filling rules:
pai project detectAfter writing (or dry-run preview):
Reconstructed N session notes:
0042 - 2026-03-13 - Implement Reranker → Notes/2026/03/
0043 - 2026-03-14 - Add Recency Boost → Notes/2026/03/
0044 - 2026-03-15 - Zettelkasten Schema Update → Notes/2026/03/
Skipped: 2026-03-12 (no commits)
Skipped: 2026-03-16 (note already exists: 0041 - 2026-03-16 - ...)
If --commit was passed:
git add Notes/
git commit -m "docs: reconstruct session notes for YYYY-MM-DD to YYYY-MM-DD"