Session Recovery & Project Memory
Use this skill to make the repository the durable source of project context.
Run it before planning, implementation, analysis, or review whenever session
continuity matters.
Hard Rules
- Resolve the current repository before reading sessions.
- Never mix sessions from different repositories.
- Load
.codex/ project memory before inferring history from transcripts.
- Prefer current repository state over saved memory when they conflict.
- Never expose full conversation transcripts; show concise previews only.
- Never invent unsupported Codex terminal commands. Detect installed commands
from local help output before telling the user what to run.
- Append session history; do not overwrite previous entries.
- Update only affected memory sections. Preserve valid older context.
- Never store assumptions as facts. Cross-check against the current repo.
Startup Workflow
- Detect the repository root.
- Initialize
.codex/ memory files if missing.
- Read project memory files in this order:
project-memory.md, architecture.md, coding-decisions.md,
pending-work.md, session-history.md.
- Search local Codex sessions belonging to the detected repository.
- Sort candidates by most recent activity, highest activity, then most
complete status.
- Recommend the most recent relevant session.
- Display additional recent sessions with concise previews.
- Ask:
Which session would you like me to summarize and restore?
- Accept session number, session name, or session ID.
- After selection, detect supported local Codex resume/history commands and
instruct the user to run only commands verified by local help output.
- When a summary becomes available, recover project goals, architecture,
code changes, security work, technical decisions, and remaining work.
- At the end of the session, update
.codex/ incrementally.
Repository Detection
Find the repository root using .git first, then walk upward looking for
project indicators such as package.json, pyproject.toml, Cargo.toml,
go.mod, pom.xml, build.gradle, composer.json, *.sln, or workspace
configuration.
Use the helper when useful:
python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py root
If no root can be resolved, use the current working directory as a temporary
root and state that repository identity is uncertain.
Project Memory
The repository memory directory is:
<repo>/.codex/
Required files:
.codex/
├── project-memory.md
├── architecture.md
├── coding-decisions.md
├── session-history.md
├── pending-work.md
└── references/
Initialize missing files with:
python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py init
Read references/project-memory-files.md before creating or updating these
files.
Session Discovery
Search only sessions that belong to the detected repository. Check memory
summaries first if available, then raw local Codex storage:
~/.codex/session_index.jsonl
~/.codex/history.jsonl
~/.codex/sessions/
~/.codex/archived_sessions/
~/.codex/memories/rollout_summaries/
The index can lag; raw JSONL session files and archive files are often more
reliable for latest-session recovery.
Use the helper for an initial inventory:
python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/session_inventory.py --repo "$(python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py root)"
Read references/session-recovery-workflow.md for the exact display fields,
preview rules, conflict handling, and command-detection process.
What To Display
Recommended session:
- Session name.
- Session ID.
- Last activity.
- Files modified.
- Brief summary.
- Current status.
Additional recent sessions:
- Name.
- Date.
- Repository.
- Branch.
- Number of interactions.
- Conversation preview.
- Brief description.
Conversation previews must include only the primary objective, major features,
bugs fixed, architecture changes, and remaining work. Do not paste the full
conversation.
Context Recovery
When a selected session summary is available, recover:
- Project goals and current milestone.
- Architecture, folder structure, patterns, and design decisions.
- Files created, modified, removed, APIs added, and database changes.
- Security work: authentication, authorization, validation, secrets, and
infrastructure.
- Technical decisions: libraries introduced, dependencies removed, refactors,
and performance improvements.
- Remaining work: TODOs, known bugs, planned refactors, open questions, and
next tasks.
Merge multiple selected sessions chronologically and highlight conflicts.
Conflict priority:
- Current repository state.
- Explicit user instructions.
- Most recent session.
- Existing project memory.
- Older sessions.
End-Of-Session Update
Before finishing a session that changed understanding or code, update .codex/
incrementally:
project-memory.md: concise overview, milestone, architecture, technologies,
conventions, and constraints.
architecture.md: diagrams in Markdown, folder structure, module
responsibilities, service relationships, and design principles.
coding-decisions.md: append or update ADR-style decisions with date,
context, decision, justification, alternatives, and consequences.
pending-work.md: TODOs, bugs, refactors, technical debt, and planned
features grouped by priority.
session-history.md: append one entry with session title, date, goal, files
modified, summary, decisions, and remaining work.
Use the append helper when useful:
python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py append-session --title "Session title" --goal "Goal" --summary "Summary"
Missing History
If no previous sessions exist, initialize .codex/, create the memory files
from the current repository state, and state that no prior local Codex history
was found for the detected repository.
1---2name: session-recovery-project-memory3description: Use this skill at the beginning of a Codex session, and whenever the user asks to resume, continue, recover context, inspect previous sessions, restore a Codex conversation, initialize project memory, update project memory, or preserve architectural decisions and pending work across sessions. It detects the current repository, loads repository-local `.codex/` memory first, searches only relevant local Codex sessions for that repository, recommends the most recent session, supports user-selected session recovery, and updates persistent project memory files without mixing unrelated repositories.4---56# Session Recovery & Project Memory78Use this skill to make the repository the durable source of project context.9Run it before planning, implementation, analysis, or review whenever session10continuity matters.1112## Hard Rules1314- Resolve the current repository before reading sessions.15- Never mix sessions from different repositories.16- Load `.codex/` project memory before inferring history from transcripts.17- Prefer current repository state over saved memory when they conflict.18- Never expose full conversation transcripts; show concise previews only.19- Never invent unsupported Codex terminal commands. Detect installed commands20 from local help output before telling the user what to run.21- Append session history; do not overwrite previous entries.22- Update only affected memory sections. Preserve valid older context.23- Never store assumptions as facts. Cross-check against the current repo.2425## Startup Workflow26271. Detect the repository root.282. Initialize `.codex/` memory files if missing.293. Read project memory files in this order:30 `project-memory.md`, `architecture.md`, `coding-decisions.md`,31 `pending-work.md`, `session-history.md`.324. Search local Codex sessions belonging to the detected repository.335. Sort candidates by most recent activity, highest activity, then most34 complete status.356. Recommend the most recent relevant session.367. Display additional recent sessions with concise previews.378. Ask: `Which session would you like me to summarize and restore?`389. Accept session number, session name, or session ID.3910. After selection, detect supported local Codex resume/history commands and40 instruct the user to run only commands verified by local help output.4111. When a summary becomes available, recover project goals, architecture,42 code changes, security work, technical decisions, and remaining work.4312. At the end of the session, update `.codex/` incrementally.4445## Repository Detection4647Find the repository root using `.git` first, then walk upward looking for48project indicators such as `package.json`, `pyproject.toml`, `Cargo.toml`,49`go.mod`, `pom.xml`, `build.gradle`, `composer.json`, `*.sln`, or workspace50configuration.5152Use the helper when useful:5354```bash55python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py root56```5758If no root can be resolved, use the current working directory as a temporary59root and state that repository identity is uncertain.6061## Project Memory6263The repository memory directory is:6465```text66<repo>/.codex/67```6869Required files:7071```text72.codex/73├── project-memory.md74├── architecture.md75├── coding-decisions.md76├── session-history.md77├── pending-work.md78└── references/79```8081Initialize missing files with:8283```bash84python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py init85```8687Read `references/project-memory-files.md` before creating or updating these88files.8990## Session Discovery9192Search only sessions that belong to the detected repository. Check memory93summaries first if available, then raw local Codex storage:9495- `~/.codex/session_index.jsonl`96- `~/.codex/history.jsonl`97- `~/.codex/sessions/`98- `~/.codex/archived_sessions/`99- `~/.codex/memories/rollout_summaries/`100101The index can lag; raw JSONL session files and archive files are often more102reliable for latest-session recovery.103104Use the helper for an initial inventory:105106```bash107python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/session_inventory.py --repo "$(python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py root)"108```109110Read `references/session-recovery-workflow.md` for the exact display fields,111preview rules, conflict handling, and command-detection process.112113## What To Display114115Recommended session:116117- Session name.118- Session ID.119- Last activity.120- Files modified.121- Brief summary.122- Current status.123124Additional recent sessions:125126- Name.127- Date.128- Repository.129- Branch.130- Number of interactions.131- Conversation preview.132- Brief description.133134Conversation previews must include only the primary objective, major features,135bugs fixed, architecture changes, and remaining work. Do not paste the full136conversation.137138## Context Recovery139140When a selected session summary is available, recover:141142- Project goals and current milestone.143- Architecture, folder structure, patterns, and design decisions.144- Files created, modified, removed, APIs added, and database changes.145- Security work: authentication, authorization, validation, secrets, and146 infrastructure.147- Technical decisions: libraries introduced, dependencies removed, refactors,148 and performance improvements.149- Remaining work: TODOs, known bugs, planned refactors, open questions, and150 next tasks.151152Merge multiple selected sessions chronologically and highlight conflicts.153154Conflict priority:1551561. Current repository state.1572. Explicit user instructions.1583. Most recent session.1594. Existing project memory.1605. Older sessions.161162## End-Of-Session Update163164Before finishing a session that changed understanding or code, update `.codex/`165incrementally:166167- `project-memory.md`: concise overview, milestone, architecture, technologies,168 conventions, and constraints.169- `architecture.md`: diagrams in Markdown, folder structure, module170 responsibilities, service relationships, and design principles.171- `coding-decisions.md`: append or update ADR-style decisions with date,172 context, decision, justification, alternatives, and consequences.173- `pending-work.md`: TODOs, bugs, refactors, technical debt, and planned174 features grouped by priority.175- `session-history.md`: append one entry with session title, date, goal, files176 modified, summary, decisions, and remaining work.177178Use the append helper when useful:179180```bash181python3 /home/tintas/.codex/skills/session-recovery-project-memory/scripts/project_memory.py append-session --title "Session title" --goal "Goal" --summary "Summary"182```183184## Missing History185186If no previous sessions exist, initialize `.codex/`, create the memory files187from the current repository state, and state that no prior local Codex history188was found for the detected repository.