/pai:Reconstructfrom PAI Knowledge OS
Retroactively creates session notes from JSONL transcripts and git history when automatic capture failed or was incomplete. Useful for backfilling missing notes.
Ships in PAI Knowledge OS. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
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., ~/Cloud/Development/PAI and ~/dev/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/PAI, also check ~/Cloud/Development/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"
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
6 skills in this plugin
/BrainstormRun a round table: one moderator and several cloud participants discuss a goal on a shared board and return a ranked synthesis. USE WHEN user says 'brainstorm', 'round table', 'let us think this through with several views', OR /brainstorm./PAIHow to use the pai MCP server (memory, projects, sessions, code graph, workers, queue, plans, config). USE WHEN a task touches past work or decisions, project status, session handover, delegating code changes to workers, or PAI configuration./setupInstall, configure and verify PAI Knowledge OS, including workers, the router and the cockpit. USE WHEN user says "set up PAI", "install PAI", "configure PAI", "give Claude a memory", "set up workers", "set up the cockpit", or asks whether their PAI install is healthy. Phase-based and idempotent: every phase checks its state first and only does what is missing.
/TasksRun the task bus — read cross-session work from the tracker, dispatch it to the sessions that own it, and file new findings. USE WHEN user says 'morning routine', 'what needs doing', 'run the routine', 'check my tasks', 'dispatch tasks', 'file a finding', 'add this to todoist', 'what did we find', OR /tasks./TestsClean up a project's tests down to the governed core and keep suites from growing again (tests/KEPT.md: fix evidence, security guard, external contract; unit, UI/simulator, snapshot and run outputs). USE WHEN user says 'clean up tests', 'prune tests', 'test cleanup', 'too many tests', 'test governance', 'clean up testing', OR a notice says a project's suite outgrew its core.npx claudepluginhub mnott/pai --plugin paiOther plugins' skills for the same job