Skip to content

Add Claude Code skills memory bridge example#734

Open
wcj007 wants to merge 6 commits into
moorcheh-ai:mainfrom
wcj007:improve/claudecode-skills-memory-508
Open

Add Claude Code skills memory bridge example#734
wcj007 wants to merge 6 commits into
moorcheh-ai:mainfrom
wcj007:improve/claudecode-skills-memory-508

Conversation

@wcj007

@wcj007 wcj007 commented Jun 13, 2026

Copy link
Copy Markdown

Refs #508

BountyHub: https://www.bountyhub.dev/bounty/view/3a63800c-7c18-41d2-870f-c62344f8a3fe

Summary

  • Adds examples/claudecode-skills-memanto, a credential-free Claude Code skills memory bridge.
  • Implements before, after, and wrap lifecycle hooks that distill skill summaries into typed engineering memories and inject relevant context before later skills run.
  • Provides a deterministic local JSONL backend for review plus an optional MEMANTO_SKILLS_BACKEND=cli path for live Memanto CLI recall/writeback.
  • Includes demo, validation, and unittest coverage for cross-session recall, path-tagged memories, malformed JSON recovery, and typed extraction.

Verification

  • py -3.12 demo.py
  • py -3.12 validate.py
  • py -3.12 -m unittest test_skill_memory_bridge.py
  • py -3.12 -m py_compile examples\claudecode-skills-memanto\skill_memory_bridge.py examples\claudecode-skills-memanto\demo.py examples\claudecode-skills-memanto\validate.py examples\claudecode-skills-memanto\test_skill_memory_bridge.py
  • git diff --check

Showcase

The README includes the full credential-free demo flow and commands. I have not posted an external social-media showcase yet; per the maintainer clarification in #508 (comment), technical review can proceed without an external social post, and social engagement only affects the leaderboard scoring.

Summary by CodeRabbit

  • New Features

    • Added a complete Memanto example demonstrating persistent cross-skill and cross-session memory storage with local JSONL backend support and optional CLI integration.
  • Documentation

    • Added comprehensive guide for the Memanto example, including quick-start instructions and integration patterns.
  • Tests

    • Added validation suite covering memory recall correctness, malformed data handling, and memory type extraction.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 00829727-6b10-4cf6-8e85-28ff992afb6c

📥 Commits

Reviewing files that changed from the base of the PR and between 0f4431d and 6b01865.

📒 Files selected for processing (2)
  • examples/claudecode-skills-memanto/skill_memory_bridge.py
  • examples/claudecode-skills-memanto/test_skill_memory_bridge.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/claudecode-skills-memanto/test_skill_memory_bridge.py
  • examples/claudecode-skills-memanto/skill_memory_bridge.py

📝 Walkthrough

Walkthrough

This PR adds a complete Memanto example that demonstrates cross-skill and cross-session memory persistence for Claude Code. It includes a core implementation (skill_memory_bridge.py) with typed memory storage, two backend implementations (file-based and CLI-based), memory extraction utilities, and both a public API and command-line interface, plus documentation, a demo script, and comprehensive test coverage.

Changes

Skills Memory Bridge Example

Layer / File(s) Summary
Memory Types and Backend Contract
examples/claudecode-skills-memanto/skill_memory_bridge.py
MemoryRecord dataclass with fields for content, type, confidence, tags, and provenance; MemoryBackend protocol defining remember() and recall() operations; shared utilities for tokenization, stable ID generation, and timestamp handling.
Memory Storage Backends
examples/claudecode-skills-memanto/skill_memory_bridge.py
LocalJsonlBackend persists memories to a JSONL file and tolerates malformed rows; MemantoCliBackend shells out to the installed memanto CLI. score_memory() ranks recalled memories using token overlap, tag bonuses, memory type bonuses, and confidence.
Memory Extraction and Context Rendering
examples/claudecode-skills-memanto/skill_memory_bridge.py
extract_memories() distills skill output into typed memories using prefix patterns and keyword heuristics; normalize_tags() and expand_path_tags() generate tag sets from skill names and file paths; render_context() formats recalled memories into an injectable context block.
SkillMemoryBridge Orchestration
examples/claudecode-skills-memanto/skill_memory_bridge.py
SkillMemoryBridge class orchestrates the recall-inject-store lifecycle: before_skill() queries the backend and returns rendered context; after_skill() extracts memories from skill output and stores them.
CLI Interface and Backend Factory
examples/claudecode-skills-memanto/skill_memory_bridge.py
create_backend() factory selects between local and CLI backends via MEMANTO_SKILLS_BACKEND environment variable; argument parsing utilities for reading files and paths; main() dispatches three subcommands (before, after, wrap) with appropriate output formatting and exit codes.
Documentation
examples/claudecode-skills-memanto/README.md
Complete example README explaining the purpose, demonstrated capabilities (cross-skill recall, JSONL persistence, typed memories, local execution, optional CLI backend), quick-start workflow, CLI usage patterns with examples, backend configuration, integration patterns with code snippets, bounty mapping, and validation coverage.
Demo Script and Dependencies
examples/claudecode-skills-memanto/demo.py, examples/claudecode-skills-memanto/requirements.txt
Credential-free demo showing two-session memory flow using SkillMemoryBridge with local JSONL storage, plus pinned dependencies for memanto, pyjwt, and python-multipart.
Tests and Validation
examples/claudecode-skills-memanto/test_skill_memory_bridge.py, examples/claudecode-skills-memanto/validate.py
Unit tests validating backend recall by tags, bridge persistence across instances, path-tagged recall, CLI wrap execution, memory type extraction, and malformed JSONL resilience. Lightweight validation script verifies cross-session recall, bad JSON recovery, and typed memory extraction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A bridge of memories, across the sessions we bound,
Typed wisdom persists where Claude Code skills are found,
From JSONL to CLI, the flow runs so clean,
Cross-skill recall made swift—the best bridge I've seen!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a complete Claude Code skills memory bridge example with multiple supporting files (bridge implementation, demo, tests, validation, README, and requirements).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@examples/claudecode-skills-memanto/skill_memory_bridge.py`:
- Line 117: The default confidence values are inconsistent between the class
__init__ (default 0.82) and the from_dict() factory (uses 0.72); update
from_dict() to use the same default as __init__ by changing
payload.get("confidence", 0.72) to payload.get("confidence", 0.82) (or
alternatively update __init__ to 0.72 if you prefer that default) so both Record
construction paths use the same default confidence.
- Around line 233-241: MemantoCliBackend.recall() currently collapses all CLI
stdout into one MemoryRecord; change it to return one MemoryRecord per returned
memory preserving its memory_type, confidence, title and tags instead of a
single record. Preferably replace the CLI invocation with the SDK client call to
retrieve the structured list of memories (use the SDK method that returns the
memories list) and map each memory -> MemoryRecord(content=..., memory_type=...,
title=..., confidence=..., tags=...). If you must keep the CLI path, parse the
memanto recall stdout panels into discrete memory entries and construct a
MemoryRecord per entry (filling memory_type/confidence/tags from the parsed
fields) rather than concatenating everything into a single MemoryRecord.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 63ea2839-fabd-43d3-8810-5940115e7edc

📥 Commits

Reviewing files that changed from the base of the PR and between 262db90 and 0f4431d.

📒 Files selected for processing (6)
  • examples/claudecode-skills-memanto/README.md
  • examples/claudecode-skills-memanto/demo.py
  • examples/claudecode-skills-memanto/requirements.txt
  • examples/claudecode-skills-memanto/skill_memory_bridge.py
  • examples/claudecode-skills-memanto/test_skill_memory_bridge.py
  • examples/claudecode-skills-memanto/validate.py

Comment thread examples/claudecode-skills-memanto/skill_memory_bridge.py Outdated
Comment thread examples/claudecode-skills-memanto/skill_memory_bridge.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant