SuperAPI AI Directory

session-memory

Office & productivity

View repository

Updated 10-15 17:33

About this skill

Session Memory Skill

A skill for managing learning and memory between sessions. It records and references past work content, decisions, and learned patterns.


Trigger phrases

This skill is automatically activated by the following phrases:

  • "What did I do last time?" "Continue from last time"
  • "Show me the history" "Past work"
  • "Tell me about this project"
  • "what did we do last time?", "continue from before"

Overview

This skill stores work history in .claude/memory/ and enables continuity of knowledge between sessions.

At the same time, it clarifies "where important information should be kept" (details: docs/MEMORY_POLICY.md)。


Memory structure

.claude/
├── memory/
│   ├── session-log.md      # セッションごとのログ
│   ├── decisions.md        # 重要な決定事項
│   ├── patterns.md         # 学んだパターン
│   └── context.json        # プロジェクトコンテキスト
└── state/
    └── agent-trace.jsonl   # Agent Trace(ツール実行履歴)

Recommended operation (SSOT/local separation)

  • SSOT (sharing recommended): decisions.md / patterns.md
    • Consolidate "decisions (Why)" and "reusable solutions (How)"
    • Each entry is given a title + tags(e.g. #decision #db) and places Index at the beginning
  • Local recommended: session-log.md / context.json / .claude/state/
    • Because it tends to become noisy/bloated, in principle do not manage it with Git (if necessary, decide individually)

Automatically recorded information

session-log.md

Each session record is given a session ID obtainable from the execution environment. In Claude Code, ${CLAUDE_SESSION_ID} is prioritized, and in Codex, the session / thread ID passed by the Codex runtime is prioritized. If neither can be obtained, .claude/state/session.json の .session_id is read, and as the last fallback, a datetime-based ID is generated. This improves traceability between sessions.

## セッション: 2024-01-15 14:30 (session: abc123def)

### 実行したタスク
- [x] ユーザー認証機能の実装
- [x] ログインページの作成

### 生成したファイル
- src/lib/auth.ts
- src/app/login/page.tsx

### 重要な決定
- 認証方式: Supabase Auth を採用

### 次回への引き継ぎ
- ログアウト機能が未実装
- パスワードリセットも必要

Note: ${CLAUDE_SESSION_ID} is an environment variable automatically set by Claude Code. On the Codex side, this variable may not exist, so do not assume it is fixed, and use the Codex runtime's session / thread ID or .claude/state/session.json .

decisions.md

## 技術選定

| 日付 | 決定事項 | 理由 |
|------|---------|------|
| 2024-01-15 | Supabase Auth | 無料枠あり、セットアップ簡単 |
| 2024-01-14 | Next.js App Router | 最新のベストプラクティス |

## アーキテクチャ

- コンポーネント: `src/components/`
- ユーティリティ: `src/lib/`
- 型定義: `src/types/`

patterns.md

## このプロジェクトのパターン

### コンポーネント命名
- PascalCase
- 例: `UserProfile.tsx`, `LoginForm.tsx`

### API エンドポイント
- `/api/v1/` プレフィックス
- RESTful 設計

### エラーハンドリング
- try-catch で囲む
- エラーメッセージは日本語

context.json

{
  "project_name": "my-blog",
  "created_at": "2024-01-14",
  "stack": {
    "frontend": "next.js",
    "backend": "next-api",
    "database": "supabase",
    "styling": "tailwind"
  },
  "current_phase": "フェーズ2: コア機能",
  "last_session": "2024-01-15T14:30:00Z"
}

Processing flow

At session start

  1. .claude/memory/context.json Load
  2. Check the previous session log
  3. Get the most recent edit history from Agent Trace
  4. Identify incomplete tasks
  5. Generate a context summary

Utilizing Agent Trace:

# 前回の編集ファイル一覧を取得
tail -50 .claude/state/agent-trace.jsonl | jq -r '.files[].path' | sort -u

# プロジェクト情報を取得
tail -1 .claude/state/agent-trace.jsonl | jq '.metadata'

During the session

  1. Record important decisions in decisions.md .
  2. Add new patterns to patterns.md .
  3. Record file generation in session-log.md .

At session end

  1. Generate a session summary
  2. context.json Update
  3. Record handover items for next time

Memory optimization (CC 2.1.49+)

From Claude Code 2.1.49 onward, memory usage when resuming a session is reduced by 68% .

Recommended workflow

# 長時間作業は --resume を活用
claude --resume

# 大規模タスクは分割してセッション再開
claude --resume "続きから"
Scenario Recommended
Long implementation Resume the session every 1-2 hours
Large-scale refactoring Split sessions by functional unit
Out of memory warning immediately --resume resume with

Since memory efficiency has improved significantly, please actively make use of session resumption.

/recap — Check the status within a session (CC 2.1.108+)

Added in CC 2.1.108, the /recap command (an alias for/rewind ) is used to quickly review what has been done so far within the current session. --resume It is effective when combined with checking before returning to another session with , or for mid-progress checks during long work.

Recommended timing:

Timing Usage
--resume Just before resuming with /recap After organizing the context with claude --resume
Before resuming a Breezing Worker Check the progress within the session with /recap then move to the next task
Midpoint of a long implementation (over 1 hour) /recap Check the status with session-log.md manually add to
# 典型的な使用フロー
# 1. 現在の作業状況を確認
/recap

# 2. 必要に応じて session-log.md に手動追記後、セッションを再開
claude --resume

/recap is only for reviewing within a session. The contents of the previous session should be checked with session-log.md or claude --resume by inheriting context with


Usage example

Start from where you left off

ユーザー: 「前回の続きから」

Claude Code:
📋 前回のセッション(2024-01-15)

完了したタスク:
- ユーザー認証機能
- ログインページ

未完了:
- ログアウト機能
- パスワードリセット

「ログアウト機能を作って」と言えば続きを実装します。

Check project status

ユーザー: 「このプロジェクトについて教えて」

Claude Code:
📁 プロジェクト: my-blog

技術スタック:
- Next.js + Tailwind CSS + Supabase

現在のフェーズ: コア機能開発
進捗: 40% 完了

最近の決定:
- Supabase Auth を採用
- App Router を使用

Relationship with Claude Code automatic memory (D22)

Claude Code 2.1.32+ has an "automatic memory" feature that automatically saves learning across sessions to~/.claude/projects/<project>/memory/MEMORY.md .

Harness memory system3-layer architecturecoexists as:

Layer System Content Management
Layer 1 Claude Code automatic memory General-purpose learning (mistake avoidance, tool usage) Implicit/automatic
Layer 2 Harness SSOT Project-specific decisions and patterns Explicit/manual
Layer 3 Agent Memory Task learning per agent Agent definitions

How to use them separately:

  • If Layer 1 knowledge is important for the entire project → /memory ssot promote to Layer 2 with
  • Leave everyday learning to Layer 1 (do not disable it)
  • Be careful about parallel writes when using Agent Teams

Details: D22: 3-layer memory architecture


Notes

  • Automatic saving: hooks/Stop It is recommended to automatically append a summary to session-log.md at session end with (manual operation is fine if not introduced)
  • Privacy: Do not record confidential information
  • Git policy: decisions.md/patterns.mdis recommended to be shared,session-log.md/context.json/.claude/state/is recommended to be local (details: docs/MEMORY_POLICY.md)
  • Capacity management: When the log gets large, "Organize session logs" is recommended