Memory: Install, Source and Security | FunnelSlayer

Memory

Published by yonatangross in orchestkit

Review recommended769 installs

What this skill does

Memory in three verbs: remember (store a decision or pattern), search (search, load, history, viz, status) and dream (consolidate stale memory files). Use when storing, finding or cleaning up what was learned or decided.

Add Memory to your agent

Review the source and files first. When you are ready, copy the prompt instruction or use the CLI command supported by your environment.

Install with a prompt

Paste this into a compatible coding agent:

add this skill "memory" from https://github.com/yonatangross/orchestkit

Install with the CLI

Run this command in a controlled environment after reviewing the repository:

npx skills add https://github.com/yonatangross/orchestkit --skill memory

Skill instructions

Memory - Remember, Search, Dream

Three verbs: remember (store, "Verb: remember" below), search (read, the subcommands below), dream (consolidate, Read("references/verb-dream.md")). Formerly the skills remember and dream: /ork:remember is now /ork:memory remember.

Cross-session read strategy (Opus 5.5 / CC 2.1.111+): Opus 5.5 reads filesystem memory reliably across sessions. When loading context at session start, prefer the layered read order:

  1. ~/.claude/projects/<slug>/memory/MEMORY.md (durable index — load first, always)
  2. .claude/chain/state.json + most recent NN-*.json handoff (session continuation)
  3. MCP mcp__memory__search_nodes for anything the filesystem index doesn't answer (typed graph traversal)

Layer 1 is cheap (small index file), Layer 2 is scoped (session-specific), Layer 3 is selective (only when needed). Avoid dumping the full knowledge graph into context — use the index to narrow the search first.

Argument Resolution

SUBCOMMAND = "$ARGUMENTS[0]"  # First token: remember, dream, or search, load, history, viz, status
QUERY = "$ARGUMENTS[1]"       # Second token onward: search query, text to remember, or flags
# $ARGUMENTS is the full string (CC 2.1.59 indexed access)

remember: follow "Verb: remember" below. dream: Read("references/verb-dream.md") (flag --dry-run). Anything else is a search subcommand.

Usage

memory remember <text> # Store a decision or pattern (flags below)
memory dream            # Consolidate memory files (--dry-run)
memory search <query>  # Search knowledge graph
memory load             # Load context at session start
memory history          # View decision timeline
memory viz              # Visualize knowledge graph
memory status           # Show memory system health

When No Subcommand Is Given

With no verb, ask which one (remember, search, dream). For search, ask which subcommand:

AskUserQuestion(
  questions=[{
    "question": "What memory operation do you need?",
    "header": "Operation",
    "options": [
      {"label": "search", "description": "Search decisions and patterns in knowledge graph"},
      {"label": "load", "description": "Load relevant context for this session"},
      {"label": "history", "description": "Decision timeline + knowledge-graph viz (--mermaid)"},
      {"label": "status", "description": "Check memory system health"}
    ],
    "multiSelect": false
  }]
)

Subcommands

Load details: Read("references/memory-commands.md") for full usage, flags, output formats, and context-aware result limits for each subcommand.

SubcommandPurpose
searchSearch past decisions, patterns, entities. Supports --category (maps to metadata.category), --limit, --agent (scopes by agent_id), --global filter flags
loadAuto-load relevant memories at session start. Supports --project, --global
historyDecision timeline with table, Mermaid, or JSON output. Supports --since, --mermaid
vizRender knowledge graph as Mermaid diagram. See also Read("references/mermaid-patterns.md")
statusMemory system health check

Scheduled Sweeps (cron)

Nightly KG staleness report

Cron job in .github/workflows/memory-staleness.yml runs nightly at 04:00 UTC. Calls scripts/staleness_cron.py to scan ALL memory MCP entities, flag those whose latest observation timestamp is older than 30 days, and write a Markdown report to docs/reports/memory-staleness-YYYY-MM-DD.md.

python3 ${CLAUDE_SKILL_DIR}/scripts/staleness_cron.py docs/reports/ \
    --threshold-days 30 --limit 50

Auto-skip conditions (exit 0 and WARN-logged on a local run; with --require-read, which the nightly workflow passes, exit 3 and status unknown). An unreadable search_nodes answer exits 2 in both modes:

Skip reasonTrigger
yg-mcp-core not importableyg-mcp-core>=0.3.0 not installed (orchestkit is public; yg-mcp-core lives on private pypi.yonyon.ai — HQ-only)
memory MCP unreachablememory MCP server down OR .mcp.json doesn't define memory

Report contents:

  • Total / stale / fresh entity counts
  • Top N stale entries sorted by staleness (no-timestamp first, then oldest → newest)
  • Each row: name, entityType, age in days, observations count
  • Suggested actions per age bucket (>90d review, >180d archive candidate)

Treats entities with no parsable timestamp as stale — operator intervention is the right outcome (backfill last_read observation OR prune).

Pure helpers (parse_iso_timestamp, latest_observation_timestamp, is_stale, build_report_payload, render_markdown) live in sibling staleness_lib.py for unit-testability.

Mirrors Yonatan-HQ/hq-ext-plugin#194 (audio_podcast) and orchestkit#1886 (post-synth podcast) + #1887 (memory writeback) pattern. Unblocked by Yonatan-HQ/core#993 (yg-mcp-core 0.3.0).


Workflow

1. Parse Subcommand

Extract first argument as subcommand
If no subcommand -> AskUserQuestion
Validate subcommand is one of: remember, dream, search, load, history, viz, status
Parse remaining flags
Check for --agent <agent-id> flag → agent_id: "ork:{agent-id}"

2. Execute Subcommand

Route to appropriate handler based on subcommand.

3. Report Results

Format output appropriate to the operation.


Rules Quick Reference

RuleImpactWhat It Covers
entity-extraction-patterns (load rules/entity-extraction-patterns.md)HIGHEntity types, relation types, graph query semantics
deduplication-strategy (load rules/deduplication-strategy.md)HIGHEdit-over-Write pattern, anchor-based insertion, verification
remember rules (load rules/duplicate-entity-detection.md, entity-relationship-validation.md, observation-quality-gate.md)HIGHSearch before create, allowed entity and relation types, observations need a metric or condition

Session Resume

Load details: Read("references/session-resume-patterns.md") for CC 2.1.31 resume hints, context capture before ending, and resume workflows for PRs, issues, and implementations.


Verb: remember (store decisions and patterns)

Filesystem vs MCP memory (Opus 5.5 guidance, CC 2.1.111+): Opus 5.5 reads filesystem memory reliably across multi-session work. Use that to your advantage:

  • Short-lived handoff state (current phase, task in-progress, pending approvals) → .claude/chain/*.json files. Small, structured, session-scoped.
  • Durable auto-memory (user facts, feedback, project conventions) → ~/.claude/projects/<slug>/memory/*.md files with a one-line index in MEMORY.md. Read on every session start.
  • Cross-session knowledge graph (typed entities + relations for query traversal) → MCP memory server (this skill's default path). Best when future sessions will search for patterns.

The three are complementary, not alternatives. Prefer fs for anything you'd want to grep; prefer MCP for anything you'd want to traverse.

Store important decisions, patterns, or context in the knowledge graph for future sessions. Supports tracking success/failure outcomes for building a Best Practice Library.

Argument Resolution

TEXT = "$ARGUMENTS"        # Full argument string; drop the leading `remember` token, e.g., "We use cursor pagination"
FLAG = "$ARGUMENTS[1]"     # Token after `remember` — check for --success, --failed, --category, --agent
# $ARGUMENTS[0] is the verb; flags start at $ARGUMENTS[1] (CC 2.1.59 indexed access)
# Remaining tokens after flags = the text to remember

Architecture

The remember verb uses knowledge graph as storage:

  1. Knowledge Graph: Entity and relationship storage via mcp__memory__create_entities and mcp__memory__create_relations. These tools come from a memory MCP server that OrchestKit does not bundle: configure one in the user or project scope first (for example @modelcontextprotocol/server-memory) and confirm it with claude mcp list. Without it, every graph step here does nothing.

Benefits:

  • Free and local once the memory server is configured
  • Explicit relationship queries (e.g., "what does X use?")
  • Cross-referencing between entities
  • No cloud dependency

Automatic Entity Extraction:

  • Extracts capitalized terms as potential entities (PostgreSQL, React, pgvector)
  • Detects agent names (database-engineer, backend-system-architect)
  • Identifies pattern names (cursor-pagination, connection-pooling)
  • Recognizes "X uses Y", "X recommends Y", "X requires Y" relationship patterns

Usage

Store Decisions (Default)

remember <text>
remember --category <category> <text>
remember --success <text>     # Mark as successful pattern
remember --failed <text>      # Mark as anti-pattern
remember --success --category <category> <text>

# Agent-scoped memory
remember --agent <agent-id> <text>         # Store in agent-specific scope
remember --global <text>                   # Store as cross-project best practice

Flags

FlagBehavior
(default)Write to graph
--successMark as successful pattern
--failedMark as anti-pattern
--category <cat>Set category
--agent <agent-id>Scope memory to a specific agent
--globalStore as cross-project best practice

Categories

  • decision - Why we chose X over Y (default)
  • architecture - System design and patterns
  • pattern - Code conventions and standards
  • blocker - Known issues and workarounds
  • constraint - Limitations and requirements
  • preference - User/team preferences
  • pagination - Pagination strategies
  • database - Database patterns
  • authentication - Auth approaches
  • api - API design patterns
  • frontend - Frontend patterns
  • performance - Performance optimizations

Outcome Flags

  • --success - Pattern that worked well (positive outcome)
  • --failed - Pattern that caused problems (anti-pattern)

If neither flag is provided, the memory is stored as neutral (informational).

Workflow

1. Parse Input

Check for --success flag → outcome: success
Check for --failed flag → outcome: failed
Check for --category <category> flag
Check for --agent <agent-id> flag → agent_id: "ork:{agent-id}"
Check for --global flag → use global user_id
Extract the text to remember
If no category specified, auto-detect from content

2. Auto-Detect Category

KeywordsCategory
chose, decided, selecteddecision
architecture, design, systemarchitecture
pattern, convention, stylepattern
blocked, issue, bug, workaroundblocker
must, cannot, required, constraintconstraint
pagination, cursor, offset, pagepagination
database, sql, postgres, querydatabase
auth, jwt, oauth, token, sessionauthentication
api, endpoint, rest, graphqlapi
react, component, frontend, uifrontend
performance, slow, fast, cacheperformance

3. Extract Lesson (for anti-patterns)

If outcome is "failed", look for:

  • "should have", "instead use", "better to"
  • If not found, prompt user: "What should be done instead?"

4-6. Extract Entities and Create Graph

Extract entities (Technology, Agent, Pattern, Project, AntiPattern) from the text, detect relationship patterns ("X uses Y", "chose X over Y", etc.), then create entities and relations in the knowledge graph.

7. Confirm Type + Scope (AskUserQuestion — M118 #1466)

Auto-classification is best-effort. Before writing, ask the user to confirm both the memory type and the persistence scope. Pre-select the auto-detected type as the default option when the classifier is confident (≥0.9):

# Skip when the invocation already specifies type and scope:
#   remember --type=preference --global  → skip, use those values
#   remember --session  → skip, no persistence
#
# Otherwise, ask both:
AskUserQuestion(questions=[
  {"question": "What type of memory?",
   "header": "Type",
   "options": [
     {"label": "Preference", "description": "How I like to work (style, format, tooling)"},
     {"label": "Project fact", "description": "State of THIS codebase (decisions, constraints)"},
     {"label": "Reference", "description": "External system pointer (URL, doc, dashboard)"},
     {"label": "Feedback", "description": "Correction to future behavior — applied as a rule"}
   ]},
  {"question": "Apply to?",
   "header": "Scope",
   "options": [
     {"label": "This project (default)", "description": "Scoped to .claude/projects/<this-project>/memory/"},
     {"label": "All projects (global)", "description": "User-level memory at ~/.claude/memory/"},
     {"label": "This session only", "description": "Print to context but don't persist"}
   ]}
])

Default selection rules:

  • If auto-detected category maps to one of the 4 type options with confidence ≥0.9, that option is pre-selected (the user can still override).
  • "This project" is always the scope default.
  • "This session only" returns immediately without writing — useful when the user wants to surface a fact for the conversation but not commit it.

Global memory writes route to ~/.claude/memory/<filename>.md instead of the project-local memory directory. The MEMORY.md index is updated in whichever scope was selected (project- or user-level).

Load entity extraction rules, type assignment, relationship patterns, and graph creation examples: Read("references/graph-operations.md")

7. Confirm Storage

Display confirmation using the appropriate template (success, anti-pattern, or neutral) showing created entities, relations, and graph stats.

Load output templates and examples: Read("references/confirmation-templates.md")

File-Based Memory Updates

When updating .claude/memory/MEMORY.md or project memory files:

  • PREFER Edit over Write to preserve existing content and avoid overwriting
  • Use stable anchor lines: ## Recent Decisions, ## Patterns, ## Preferences
  • See rules/deduplication-strategy.md (Edit over Write) for the full Edit pattern
  • This applies to the calling agent's file operations, not to the knowledge graph operations above

References

Load on demand with Read("references/<file>"):

FileContent
verb-dream.md, housekeeping.md, index-budget.md, safe-deletes.mdDream: the full verb, housekeeping, MEMORY.md budget, safe deletes
category-detection.md, graph-operations.md, confirmation-templates.md, entity-extraction-workflow.md, examples.mdRemember: category rules, graph operations, output templates, extraction, examples
memory-commands.md, mermaid-patterns.md, session-resume-patterns.mdSearch: subcommands, Mermaid, resume

Error Handling

  • If graph empty for viz: Show helpful message about using the remember verb
  • If subcommand invalid: Show usage help
  • If memory files corrupt: Report and offer repair
  • If search query empty: Show recent entities instead
  • If no search results: Suggest alternatives
  • Remember: knowledge graph unavailable -> show configuration instructions
  • Remember: empty text -> ask user for content; text >2000 chars -> truncate with notice
  • Remember: both --success and --failed -> ask user to clarify
  • Remember: entity extraction fails -> create generic Decision entity; relation fails -> create entities first, retry

Files included

  • references/category-detection.md
  • references/confirmation-templates.md
  • references/entity-extraction-workflow.md
  • references/examples.md
  • references/graph-operations.md
  • references/housekeeping.md
  • references/index-budget.md
  • references/memory-commands.md
  • references/mermaid-patterns.md
  • references/safe-deletes.md
  • references/session-resume-patterns.md
  • references/verb-dream.md
  • rules/_sections.md
  • rules/deduplication-strategy.md
  • rules/duplicate-entity-detection.md
  • rules/entity-extraction-patterns.md
  • rules/entity-relationship-validation.md
  • rules/observation-quality-gate.md
  • scripts/graph-utils.mjs
  • scripts/index-budget.mjs
  • scripts/playground-template.html
  • scripts/render-graph.mjs
  • scripts/render-playground.mjs
  • scripts/staleness_cron.py
  • scripts/staleness_lib.py
  • SKILL.md
  • test-cases.json

More skills