Rekal save

From janbjorge/rekal · View interactive version

Rekal save is an AI agent skill from the GitHub repository janbjorge/rekal. End-of-session memory capture with deduplication. Extracts durable knowledge, checks for duplicates, stores or replaces as appropriate. Use whenever a session wraps up, a task finishes, or the user says goodbye/thanks/done. Also use when significant preferences, decisions, or discoveries emerge mid-

How to use this skill

Skill file

Save durable knowledge from this session into rekal. Goal: user never repeats themselves across sessions.

Step 1: Extract candidates

Review the conversation. Per item, apply this filter:

Would a fresh agent in a new session benefit from knowing this?
├── YES → candidate
└── NO  → skip

Candidate types:

| What | Example |

|------|---------|

| Preference with reasoning | "User prefers dataclasses over hand-written __init__ for less boilerplate" |

| Architecture/convention | "Auth service uses JWT, lives in services/auth, 15-min token expiry" |

| Decision + why | "Chose PostgreSQL over MySQL for JSONB support and better partial indexes" |

| Procedure | "Deploy: 1) git tag vX.Y.Z 2) git push --tags 3) wait CI 4) merge to main" |

| Bug with non-obvious cause | "OOM from unbounded LRU cache in parser, fixed with maxsize=1000" |

| Behavior correction | "Never use grep/find. Use rg/fd. Strict, no exceptions." |

Skip (do not store):

If zero candidates survive, stop here. Do not force-store.

Step 2: Deduplicate each candidate

For EVERY candidate, before storing:

memory_build_context(query="<candidate topic in natural language>")

Read results. Apply:

Recall returned results?
├── NO match at all
│   └── Proceed to step 3 (store new)
│
├── Same topic, same info (duplicate)
│   └── SKIP. Do not store.
│
├── Same topic, new/updated info
│   └── memory_store(content="<updated content>", replaces="<matched memory id>")
│
└── Same topic, contradictory info
    └── memory_store(content="<corrected content>", replaces="<matched memory id>")
        Include what changed and why in the content.

Critical rule: Two memories about the same topic must never coexist.

replaces supersedes the older memory so it stops surfacing. "User's

preferred formatter" appears exactly once in the database.

Step 3: Store surviving candidates

Per candidate that passed dedup with no match:

memory_store(
    content="<self-contained content: what AND why>",
    tags=["<tag1>", "<tag2>"],  # 2-4 specific tags. Not "code", "project", "general".
    project="<name>",  # Set if project-specific. Omit for global knowledge.
)

Content must be self-contained

A fresh agent with zero conversation context reads this content. It must make complete sense alone.

Good: "User prefers Ruff over Black for formatting because it's faster
       and handles import sorting in a single tool"
Bad:  "User prefers Ruff"               (missing the why)
Bad:  "As discussed, switch to Ruff"     (references conversation)
Bad:  "The formatter preference"         (meaningless alone)

Code claims must carry inline anchors

Every claim about code embeds (relative/path.py:LINE symbol) with line

numbers verified in THIS session. Anchored memories are trusted by future

sessions and displace file reads; bare claims get re-verified, which wastes

the memory.

Good: "Dep cache key is (call, scopes, computed_scope)
       (fastapi/dependencies/models.py:63 cache_key); same callable at
       different scopes caches separately"
Bad:  "The dependency cache key includes the scope"   (no anchor — will be re-derived)

For a whole subsystem mapped this session, prefer ONE brief (350-500 words:

headline + 8-12 search keywords, mechanism narrative, final "Deviations:"

section for where this codebase differs from public/upstream behavior),

tagged brief, over many fragments.

Tags must be specific

Good: ["ruff", "formatting", "linting"]
Bad:  ["code", "tools", "project"]

Step 4: Summary

Summarize what was saved:

"Saved 3 memories: Ruff preference, deploy procedure, auth architecture. Replaced 1 outdated API endpoint memory."

If nothing was saved (all skipped as duplicates), say so:

"Reviewed session, no new knowledge to capture. Existing memories already cover it."

Boundaries

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.