jpskill.com
🛠️ 開発・MCP コミュニティ 🔴 エンジニア向け 👤 エンジニア・AI開発者

🛠️ Memoryシステム

memory-systems

AIエージェントが過去のやり取りや

⏱ コードレビュー 1時間 → 10分

📺 まず動画で見る(YouTube)

▶ 【衝撃】最強のAIエージェント「Claude Code」の最新機能・使い方・プログラミングをAIで効率化する超実践術を解説! ↗

※ jpskill.com 編集部が参考用に選んだ動画です。動画の内容と Skill の挙動は厳密には一致しないことがあります。

📜 元の英語説明(参考)

Design short-term, long-term, and graph-based memory architectures. Use when building agents that must persist across sessions, needing to maintain entity consistency across conversations, or implementing reasoning over accumulated knowledge.

🇯🇵 日本人クリエイター向け解説

一言でいうと

AIエージェントが過去のやり取りや

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o memory-systems.zip https://jpskill.com/download/3151.zip && unzip -o memory-systems.zip && rm memory-systems.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/3151.zip -OutFile "$d\memory-systems.zip"; Expand-Archive "$d\memory-systems.zip" -DestinationPath $d -Force; ri "$d\memory-systems.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して memory-systems.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → memory-systems フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-17
取得日時
2026-05-17
同梱ファイル
1

💬 こう話しかけるだけ — サンプルプロンプト

  • Memory Systems を使って、最小構成のサンプルコードを示して
  • Memory Systems の主な使い方と注意点を教えて
  • Memory Systems を既存プロジェクトに組み込む方法を教えて

これをClaude Code に貼るだけで、このSkillが自動発動します。

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

このスキルを使用する場面

短期、長期、およびグラフベースのメモリ・アーキテクチャを設計する

短期、長期、およびグラフベースのメモリ・アーキテクチャの設計に取り組む際に、このスキルを使用してください。

メモリ・システム設計

メモリは、エージェントがセッション間で継続性を維持し、蓄積された知識に基づいて推論することを可能にする永続化レイヤーを提供します。単純なエージェントは、メモリを完全にコンテキストに依存し、セッションが終了するとすべての状態を失います。洗練されたエージェントは、即時のコンテキスト要件と長期的な知識保持のバランスを取る、階層化されたメモリ・アーキテクチャを実装します。ベクトル・ストアからナレッジ・グラフ、そして時系列ナレッジ・グラフへの進化は、検索と推論を改善するための構造化メモリへの投資の増加を表しています。

使用する場面

以下の状況でこのスキルをアクティブ化してください。

  • セッション間で永続化する必要があるエージェントを構築する場合
  • 会話間でエンティティの一貫性を維持する必要がある場合
  • 蓄積された知識に基づいて推論を実装する場合
  • 過去のインタラクションから学習するシステムを設計する場合
  • 時間とともに成長するナレッジ・ベースを作成する場合
  • 状態変化を追跡する時間認識システムを構築する場合

コア・コンセプト

メモリは、即時のコンテキストから永続的なストレージまで、連続したスペクトル上に存在します。一方の極では、コンテキスト・ウィンドウ内のワーキング・メモリはゼロ・レイテンシーでアクセスできますが、セッションが終了すると消滅します。もう一方の極では、永続ストレージは無期限に永続しますが、コンテキストに入るには検索が必要です。

単純なベクトル・ストアは、関係と時間構造を欠いています。ナレッジ・グラフは、推論のための関係を保持します。時系列ナレッジ・グラフは、時間認識クエリのために有効期間を追加します。実装の選択は、クエリの複雑さ、インフラストラクチャの制約、および精度要件によって異なります。

詳細なトピック

メモリ・アーキテクチャの基礎

コンテキスト-メモリ・スペクトル メモリは、即時のコンテキストから永続的なストレージまで、連続したスペクトル上に存在します。一方の極では、コンテキスト・ウィンドウ内のワーキング・メモリはゼロ・レイテンシーでアクセスできますが、セッションが終了すると消滅します。もう一方の極では、永続ストレージは無期限に永続しますが、コンテキストに入るには検索が必要です。効果的なアーキテクチャは、このスペクトルに沿って複数のレイヤーを使用します。

このスペクトルには、ワーキング・メモリ(コンテキスト・ウィンドウ、ゼロ・レイテンシー、揮発性)、短期メモリ(セッション永続性、検索可能、揮発性)、長期メモリ(セッション間永続性、構造化、半永続性)、および永続メモリ(アーカイブ、クエリ可能、永続性)が含まれます。各レイヤーは、異なるレイテンシー、容量、および永続性特性を持っています。

単純なベクトル・ストアが不十分な理由 ベクトル RAG は、クエリとドキュメントを共有の埋め込み空間に埋め込むことで、セマンティック検索を提供します。類似性検索は、最もセマンティックに類似したドキュメントを検索します。これはドキュメント検索には適していますが、エージェント・メモリの構造を欠いています。

ベクトル・ストアは関係情報を失います。エージェントが「顧客 X が日付 Z に製品 Y を購入した」という事実を学習した場合、ベクトル・ストアは直接尋ねられればこの事実を検索できます。しかし、「製品 Y を購入した顧客が他に購入した製品は何か?」という質問には答えられません。なぜなら、関係構造が保持されていないからです。

ベクトル・ストアは、時間的有効性にも苦労します。事実は時間とともに変化しますが、ベクトル・ストアは、明示的なメタデータとフィルタリングを除いて、「現在の事実」と「古い事実」を区別するメカニズムを提供しません。

グラフベース・メモリへの移行 ナレッジ・グラフは、エンティティ間の関係を保持します。孤立したドキュメント・チャンクではなく、グラフはエンティティ A がエンティティ B と関係 R を持つことをエンコードします。これにより、類似性だけでなく関係をたどるクエリが可能になります。

時系列ナレッジ・グラフは、事実に有効期間を追加します。各事実には「有効開始」と、オプションで「有効終了」のタイムスタンプがあります。これにより、特定の時点での知識を再構築するタイムトラベル・クエリが可能になります。

ベンチマーク性能比較 Deep Memory Retrieval (DMR) ベンチマークは、メモリ・アーキテクチャ全体の具体的な性能データを提供します。

メモリ・システム DMR 精度 検索レイテンシー 備考
Zep (Temporal KG) 94.8% 2.58秒 最高の精度、高速検索
MemGPT 93.4% 可変 優れた全体的な性能
GraphRAG 約75-85% 可変 ベースライン RAG から20-35%の向上
Vector RAG 約60-70% 高速 関係構造を失う
Recursive Summarization 35.3% 深刻な情報損失

Zep は、フルコンテキストのベースラインと比較して、検索レイテンシーを90%削減しました(GPT-5.2 で2.58秒対28.9秒)。この効率は、コンテキスト履歴全体ではなく、関連するサブグラフのみを検索することによって実現されます。

GraphRAG は、複雑な推論タスクにおいてベースライン RAG と比較して約20-35%の精度向上を達成し、コミュニティベースの要約を通じて幻覚を最大30%削減します。

メモリ・レイヤー・アーキテクチャ

レイヤー 1: ワーキング・メモリ ワーキング・メモリは、コンテキスト・ウィンドウそのものです。現在処理中の情報に即座にアクセスできますが、容量が限られており、セッションが終了すると消滅します。

ワーキング・メモリの使用パターンには、エージェントが中間結果を追跡するスクラッチパッド計算、現在のタスクの対話を保持する会話履歴、アクティブな目標の進捗を追跡する現在のタスク状態、および現在使用されている情報を保持するアクティブな検索ドキュメントが含まれます。

ワーキング・メモリを最適化するには、アクティブな情報のみを保持し、完了した作業が注意から外れる前に要約し、重要な情報には注意が向けられやすい位置を使用します。

レイヤー 2: 短期メモリ 短期メモリは現在のセッション全体で永続しますが、セッション間では永続しません。永続ストレージのレイテンシーなしで検索および取得機能を提供します。

一般的な実装には、セッション終了まで永続するセッション・スコープのデータベース、指定されたセッション・ディレクトリ内のファイル・システム・ストレージ、およびセッション ID でキー付けされたインメモリ・キャッシュが含まれます。

短期メモリのユースケースには、会話を詰め込むことなく、ターン間で会話の状態を追跡することが含まれます。

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

When to Use This Skill

Design short-term, long-term, and graph-based memory architectures

Use this skill when working with design short-term, long-term, and graph-based memory architectures.

Memory System Design

Memory provides the persistence layer that allows agents to maintain continuity across sessions and reason over accumulated knowledge. Simple agents rely entirely on context for memory, losing all state when sessions end. Sophisticated agents implement layered memory architectures that balance immediate context needs with long-term knowledge retention. The evolution from vector stores to knowledge graphs to temporal knowledge graphs represents increasing investment in structured memory for improved retrieval and reasoning.

When to Use

Activate this skill when:

  • Building agents that must persist across sessions
  • Needing to maintain entity consistency across conversations
  • Implementing reasoning over accumulated knowledge
  • Designing systems that learn from past interactions
  • Creating knowledge bases that grow over time
  • Building temporal-aware systems that track state changes

Core Concepts

Memory exists on a spectrum from immediate context to permanent storage. At one extreme, working memory in the context window provides zero-latency access but vanishes when sessions end. At the other extreme, permanent storage persists indefinitely but requires retrieval to enter context.

Simple vector stores lack relationship and temporal structure. Knowledge graphs preserve relationships for reasoning. Temporal knowledge graphs add validity periods for time-aware queries. Implementation choices depend on query complexity, infrastructure constraints, and accuracy requirements.

Detailed Topics

Memory Architecture Fundamentals

The Context-Memory Spectrum Memory exists on a spectrum from immediate context to permanent storage. At one extreme, working memory in the context window provides zero-latency access but vanishes when sessions end. At the other extreme, permanent storage persists indefinitely but requires retrieval to enter context. Effective architectures use multiple layers along this spectrum.

The spectrum includes working memory (context window, zero latency, volatile), short-term memory (session-persistent, searchable, volatile), long-term memory (cross-session persistent, structured, semi-permanent), and permanent memory (archival, queryable, permanent). Each layer has different latency, capacity, and persistence characteristics.

Why Simple Vector Stores Fall Short Vector RAG provides semantic retrieval by embedding queries and documents in a shared embedding space. Similarity search retrieves the most semantically similar documents. This works well for document retrieval but lacks structure for agent memory.

Vector stores lose relationship information. If an agent learns that "Customer X purchased Product Y on Date Z," a vector store can retrieve this fact if asked directly. But it cannot answer "What products did customers who purchased Product Y also buy?" because relationship structure is not preserved.

Vector stores also struggle with temporal validity. Facts change over time, but vector stores provide no mechanism to distinguish "current fact" from "outdated fact" except through explicit metadata and filtering.

The Move to Graph-Based Memory Knowledge graphs preserve relationships between entities. Instead of isolated document chunks, graphs encode that Entity A has Relationship R to Entity B. This enables queries that traverse relationships rather than just similarity.

Temporal knowledge graphs add validity periods to facts. Each fact has a "valid from" and optionally "valid until" timestamp. This enables time-travel queries that reconstruct knowledge at specific points in time.

Benchmark Performance Comparison The Deep Memory Retrieval (DMR) benchmark provides concrete performance data across memory architectures:

Memory System DMR Accuracy Retrieval Latency Notes
Zep (Temporal KG) 94.8% 2.58s Best accuracy, fast retrieval
MemGPT 93.4% Variable Good general performance
GraphRAG ~75-85% Variable 20-35% gains over baseline RAG
Vector RAG ~60-70% Fast Loses relationship structure
Recursive Summarization 35.3% Low Severe information loss

Zep demonstrated 90% reduction in retrieval latency compared to full-context baselines (2.58s vs 28.9s for GPT-5.2). This efficiency comes from retrieving only relevant subgraphs rather than entire context history.

GraphRAG achieves approximately 20-35% accuracy gains over baseline RAG in complex reasoning tasks and reduces hallucination by up to 30% through community-based summarization.

Memory Layer Architecture

Layer 1: Working Memory Working memory is the context window itself. It provides immediate access to information currently being processed but has limited capacity and vanishes when sessions end.

Working memory usage patterns include scratchpad calculations where agents track intermediate results, conversation history that preserves dialogue for current task, current task state that tracks progress on active objectives, and active retrieved documents that hold information currently being used.

Optimize working memory by keeping only active information, summarizing completed work before it falls out of attention, and using attention-favored positions for critical information.

Layer 2: Short-Term Memory Short-term memory persists across the current session but not across sessions. It provides search and retrieval capabilities without the latency of permanent storage.

Common implementations include session-scoped databases that persist until session end, file-system storage in designated session directories, and in-memory caches keyed by session ID.

Short-term memory use cases include tracking conversation state across turns without stuffing context, storing intermediate results from tool calls that may be needed later, maintaining task checklists and progress tracking, and caching retrieved information within sessions.

Layer 3: Long-Term Memory Long-term memory persists across sessions indefinitely. It enables agents to learn from past interactions and build knowledge over time.

Long-term memory implementations range from simple key-value stores to sophisticated graph databases. The choice depends on complexity of relationships to model, query patterns required, and acceptable infrastructure complexity.

Long-term memory use cases include learning user preferences across sessions, building domain knowledge bases that grow over time, maintaining entity registries with relationship history, and storing successful patterns that can be reused.

Layer 4: Entity Memory Entity memory specifically tracks information about entities (people, places, concepts, objects) to maintain consistency. This creates a rudimentary knowledge graph where entities are recognized across multiple interactions.

Entity memory maintains entity identity by tracking that "John Doe" mentioned in one conversation is the same person in another. It maintains entity properties by storing facts discovered about entities over time. It maintains entity relationships by tracking relationships between entities as they are discovered.

Layer 5: Temporal Knowledge Graphs Temporal knowledge graphs extend entity memory with explicit validity periods. Facts are not just true or false but true during specific time ranges.

This enables queries like "What was the user's address on Date X?" by retrieving facts valid during that date range. It prevents context clash when outdated information contradicts new data. It enables temporal reasoning about how entities changed over time.

Memory Implementation Patterns

Pattern 1: File-System-as-Memory The file system itself can serve as a memory layer. This pattern is simple, requires no additional infrastructure, and enables the same just-in-time loading that makes file-system-based context effective.

Implementation uses the file system hierarchy for organization. Use naming conventions that convey meaning. Store facts in structured formats (JSON, YAML). Use timestamps in filenames or metadata for temporal tracking.

Advantages: Simplicity, transparency, portability. Disadvantages: No semantic search, no relationship tracking, manual organization required.

Pattern 2: Vector RAG with Metadata Vector stores enhanced with rich metadata provide semantic search with filtering capabilities.

Implementation embeds facts or documents and stores with metadata including entity tags, temporal validity, source attribution, and confidence scores. Query includes metadata filters alongside semantic search.

Pattern 3: Knowledge Graph Knowledge graphs explicitly model entities and relationships. Implementation defines entity types and relationship types, uses graph database or property graph storage, and maintains indexes for common query patterns.

Pattern 4: Temporal Knowledge Graph Temporal knowledge graphs add validity periods to facts, enabling time-travel queries and preventing context clash from outdated information.

Memory Retrieval Patterns

Semantic Retrieval Retrieve memories semantically similar to current query using embedding similarity search.

Entity-Based Retrieval Retrieve all memories related to specific entities by traversing graph relationships.

Temporal Retrieval Retrieve memories valid at specific time or within time range using validity period filters.

Memory Consolidation

Memories accumulate over time and require consolidation to prevent unbounded growth and remove outdated information.

Consolidation Triggers Trigger consolidation after significant memory accumulation, when retrieval returns too many outdated results, periodically on a schedule, or when explicit consolidation is requested.

Consolidation Process Identify outdated facts, merge related facts, update validity periods, archive or delete obsolete facts, and rebuild indexes.

Practical Guidance

Integration with Context

Memories must integrate with context systems to be useful. Use just-in-time memory loading to retrieve relevant memories when needed. Use strategic injection to place memories in attention-favored positions.

Memory System Selection

Choose memory architecture based on requirements:

  • Simple persistence needs: File-system memory
  • Semantic search needs: Vector RAG with metadata
  • Relationship reasoning needs: Knowledge graph
  • Temporal validity needs: Temporal knowledge graph

Examples

Example 1: Entity Tracking

# Track entity across conversations
def remember_entity(entity_id, properties):
    memory.store({
        "type": "entity",
        "id": entity_id,
        "properties": properties,
        "last_updated": now()
    })

def get_entity(entity_id):
    return memory.retrieve_entity(entity_id)

Example 2: Temporal Query

# What was the user's address on January 15, 2024?
def query_address_at_time(user_id, query_time):
    return temporal_graph.query("""
        MATCH (user)-[r:LIVES_AT]->(address)
        WHERE user.id = $user_id
        AND r.valid_from <= $query_time
        AND (r.valid_until IS NULL OR r.valid_until > $query_time)
        RETURN address
    """, {"user_id": user_id, "query_time": query_time})

Guidelines

  1. Match memory architecture to query requirements
  2. Implement progressive disclosure for memory access
  3. Use temporal validity to prevent outdated information conflicts
  4. Consolidate memories periodically to prevent unbounded growth
  5. Design for memory retrieval failures gracefully
  6. Consider privacy implications of persistent memory
  7. Implement backup and recovery for critical memories
  8. Monitor memory growth and performance over time

Integration

This skill builds on context-fundamentals. It connects to:

  • multi-agent-patterns - Shared memory across agents
  • context-optimization - Memory-based context loading
  • evaluation - Evaluating memory quality

References

Internal reference:

  • Implementation Reference - Detailed implementation patterns

Related skills in this collection:

  • context-fundamentals - Context basics
  • multi-agent-patterns - Cross-agent memory

External resources:

  • Graph database documentation (Neo4j, etc.)
  • Vector store documentation (Pinecone, Weaviate, etc.)
  • Research on knowledge graphs and reasoning

Skill Metadata

Created: 2025-12-20 Last Updated: 2025-12-20 Author: Agent Skills for Context Engineering Contributors Version: 1.0.0

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.