---
name: context-save
description: Save a compact project context snapshot for later resumption. Use only when explicitly invoked via $context-save, /skill:context-save, or manual selection.
metadata:
  short-description: Persist project context snapshot
compatibility: Codex, Claude Code, Pi, Qwen
disable-model-invocation: true
---

# Context Save

Run this skill only on explicit invocation:
- `$context-save` in Codex
- `/skill:context-save` in Pi
- or direct/manual skill selection

Do not trigger implicitly from natural-language phrases.

## Goal

Create or overwrite context files in **all three** tool directories so any tool can restore. All paths are relative to the **current working directory**, not the home directory:

1. `.pi/context.md` (primary)
2. `.claude/context.md` (mirror)
3. `.codex/context.md` (mirror)

Always write all three. Create directories if they don't exist. Do **not** write to `~/.pi/context.md` or any home-directory path.

## Steps

### 1. Capture Current State

Run:

```bash
git branch --show-current
git status --short
git log --oneline -5
```

If the folder is not a git repo, continue without git details.

### 2. Summarize Session

Extract from conversation and current files:
- Main objective
- What is done vs not done
- Where we stopped exactly
- Decisions and tradeoffs already agreed
- Risks, open questions, pending approvals
- Next 1-3 concrete actions

### 3. Write Context Files

Write the **same content** to all three paths (relative to current working directory):
- `.pi/context.md`
- `.claude/context.md`
- `.codex/context.md`

Create parent directories (`mkdir -p`) if they don't exist. Overwrite, do not append.

Use this template:

```markdown
# Session Context
<!-- Auto-generated by context-save -->
<!-- Last saved: YYYY-MM-DD HH:MM local -->

## Project Anchor
- Project: [name]
- Goal: [one sentence]
- Current phase: [phase/status]

## Git Snapshot
- Branch: [branch or N/A]
- Recent commits:
  - [hash] [message]
- Working tree changes:
  - [file] [status] [short note]

## What We Were Doing
- Task: [specific task]
- Progress:
  - [x] done item
  - [ ] next item
- Stop point: [exact point where work paused]

## Decisions
- [decision] -> [why]

## Open Items
- [question/risk/dependency]

## Resume Plan
1. [first action]
2. [second action]
3. [third action]

## Notes
- Preferences, constraints, or gotchas that matter for continuation.
```

### 4. Confirm Back

Return a short confirmation including:
- all file paths written
- one-line summary of task/status
- recommended first action when resuming

## Rules

- **Always write all three files** — `.pi/context.md`, `.claude/context.md`, `.codex/context.md`.
- Prefer facts over vague summaries.
- Include uncommitted changes if present.
- Keep it compact but operationally complete.
- If uncertain, mark uncertainty explicitly.
