Skip to content
Back to skills

Session Context

ASecurity

Session context persistence for project goals, decisions, progress, and gotchas; use when restoring project state, managing session notes, or checking whether context was injected at startup.

  • 26 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 4, 2026
ai-agentsgosql

Security analysis

A100/100

Scanned October 4, 2026

npx -y skills add RohiRIK/OpenLtm --skill session-context --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Session Context?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Session Context
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rohirik-session-context/badge)](https://www.skillsdirectory.com/skills/rohirik-session-context)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: session-context
description: "Session context persistence for project goals, decisions, progress, and gotchas; use when restoring project state, managing session notes, or checking whether context was injected at startup."
user-invocable: false
version: 1.0.0
---

# Session Context Persistence

## Overview

Per-project context lives in `$CLAUDE_PLUGIN_DATA/openltm.db` (SQLite). Hooks manage it automatically.
Project names come from `~/.claude/projects/registry.json` — run `/openltm:project register` to see yours.

**Claude does NOT manually write context files.** Hooks handle all reads and writes.

## The 4 Context Types

| Type | Purpose | Managed by |
|------|---------|-----------|
| `goal` | Current objective (1-3 lines) | `/openltm:project init` to seed; auto-replaced on change |
| `decision` | Architectural / key choices | Permanent — never trimmed |
| `progress` | Session log — what was done | `UpdateContext` hook at session end; trimmed to last 20 |
| `gotcha` | Warnings, pitfalls, blockers | Permanent — never trimmed |

## What Happens at Session Start

The `SessionStart` hook:
1. Resolves project from `registry.json`
2. Regenerates `context-summary.md` from DB
3. Injects up to 60 lines of context into your session
4. If DB has LTM memories: also injects importance-5 globals + top-15 project memories

You'll see `## Restored Project Context` at session start when this fires. Acknowledge it briefly and confirm you're ready to continue.

## LTM Commands (store and search learned insights)

| Command | When to use |
|---------|------------|
| `/openltm:memory learn` | After discovering a non-obvious pattern, gotcha, or decision |
| `/openltm:memory recall [query]` | Before starting work on a topic — surface past decisions |
| `/openltm:memory forget <id>` | When a memory is wrong or stale |
| `/openltm:memory relate <src> <tgt> <type>` | Link two related memories |

Recall before a non-trivial problem to check for prior knowledge; skip it for trivial one-liners.

## What PreCompact Does

When compaction fires, `PreCompact` hook:
1. Reads DB for all 4 context types for this project
2. Writes `context-summary.md` (max ~60 lines) as a human-readable fallback
3. This file is injected at the next `SessionStart`

You do not manage `context-summary.md` — the hook overwrites it each compaction.

## Short-Term vs Long-Term Memory

| Question | Answer | Store as |
|----------|--------|----------|
| Specific to the current project? | Yes | context_item (hooks auto-manage) |
| Useful in ALL future projects? | Yes | `/openltm:memory learn` (global memories table) |
| Temporary note / work log? | Yes | context_item `progress` |
| Permanent rule, gotcha, or decision? | Yes | `/openltm:memory learn --importance 5` |

**Short-term** = `context_items`. Auto-managed by hooks. Expires after 14 days inactivity.
**Long-term** = `memories`. Persist forever. Inject into every session via SessionStart.

**When to promote:** If a project-level gotcha has burned you twice, promote it to global LTM with `/openltm:memory learn --importance 5`.

## Promoting Patterns to Durable LTM

Gotchas and decisions in `context_items` survive until the project is stale (14 days inactive).
For lessons that must persist across all projects permanently, use `/openltm:memory learn` with `importance=5`:

```
/openltm:memory learn "Supabase RLS must be enabled before production" --category gotcha --importance 5
```

These appear in the `memories` table and inject into every session regardless of project.

## Rules

- Never manually write to `context-goals.md`, `context-decisions.md`, `context-progress.md`, or `context-gotchas.md`
- Never manually edit `context-summary.md` — it is auto-generated
- Use `/openltm:memory learn` to persist important insights to global LTM
- Use `/openltm:memory recall` before starting non-trivial tasks
- Use `/openltm:project init` to seed a new project goal (not to create .md files)
- If context wasn't injected at session start, run `/openltm:health` to diagnose

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.