Skip to content

Add Claude Code skills Memanto memory bridge example#618

Closed
auruminternum wants to merge 4 commits into
moorcheh-ai:mainfrom
auruminternum:bounty-508-decision-trail-memory
Closed

Add Claude Code skills Memanto memory bridge example#618
auruminternum wants to merge 4 commits into
moorcheh-ai:mainfrom
auruminternum:bounty-508-decision-trail-memory

Conversation

@auruminternum

@auruminternum auruminternum commented May 31, 2026

Copy link
Copy Markdown

Summary

  • add examples/claudecode-skills-memanto as a command-oriented developer skills memory bridge
  • include before-skill recall, mid-session decision/constraint/gotcha capture, and after-skill persistence
  • provide a credential-free JSONL backend for review plus optional Memanto CLI backend for live sessions
  • add tests proving a mid-session decision is recalled by a later skill

Bounty

Addresses #508.
BountyHub: https://www.bountyhub.dev/bounty/view/3a63800c-7c18-41d2-870f-c62344f8a3fe
Showcase: https://gist.github.com/auruminternum/abee535665f19ea8dccf4fabddf781e4

Validation

  • python -m ruff check examples/claudecode-skills-memanto
  • python -m pytest examples/claudecode-skills-memanto -q
  • python examples/claudecode-skills-memanto/demo.py
  • python -m py_compile examples/claudecode-skills-memanto/skill_memory_bridge.py examples/claudecode-skills-memanto/demo.py examples/claudecode-skills-memanto/test_skill_memory_bridge.py
  • git diff --check

/claim #508

Summary by CodeRabbit

  • New Features

    • Added a self-contained example that provides cross-session memory for Claude Code skills, including a runnable demo and both a local JSONL backend and an optional CLI-backed backend.
  • Documentation

    • New README describing the “decision trail” concept, demo usage, setup and activation instructions, and how to run the example and tests.
  • Tests

    • Added tests for the CLI-backed backend, including timeout handling and error conversion for recall and remember operations.

@coderabbitai

coderabbitai Bot commented May 31, 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: a4c1f0ce-46be-4eaf-b9fe-25162aa90860

📥 Commits

Reviewing files that changed from the base of the PR and between 4d700a9 and 8d57ed3.

📒 Files selected for processing (3)
  • examples/claudecode-skills-memanto/demo.py
  • 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 (3)
  • examples/claudecode-skills-memanto/demo.py
  • examples/claudecode-skills-memanto/test_skill_memory_bridge.py
  • examples/claudecode-skills-memanto/skill_memory_bridge.py

📝 Walkthrough

Walkthrough

Adds a Memanto-backed skill memory bridge (models and backend protocol), two backends (Local JSONL and memanto CLI with timeouts), orchestration (begin/record/end), a runnable demo, tests (including CLI timeout conversion), and README documentation.

Changes

Claude Code Skills Memory Bridge

Layer / File(s) Summary
Data Models and Backend Contract
examples/claudecode-skills-memanto/skill_memory_bridge.py
Constants (MEMORY_TYPES, DECISION_MARKERS), UTC/token helpers, MemoryRecord (validation), SkillEvent, SkillRun, and MemoryBackend protocol.
Backend Implementations
examples/claudecode-skills-memanto/skill_memory_bridge.py
LocalJsonlBackend (newline-delimited JSON store, token-overlap scoring) and MemantoCliBackend (subprocess wrapper adapting CLI output, timeout handling and TimeoutError conversion).
SkillMemoryBridge Orchestration
examples/claudecode-skills-memanto/skill_memory_bridge.py
SkillMemoryBridge with begin_skill, record_event, end_skill, context_block, plus helpers for event→memory conversion, classification, query/title building, and memory filtering.
Demo
examples/claudecode-skills-memanto/demo.py
Runnable demo: initializes LocalJsonlBackend at .memanto-demo/skills-memory.jsonl, runs two sequential skills, records events, prints context blocks, exposes main() entry.
Tests
examples/claudecode-skills-memanto/test_skill_memory_bridge.py
Tests for decision recall, low-signal tool-output filtering, empty-context message, and MemantoCliBackend timeout passthrough and conversion.
Example Documentation
examples/claudecode-skills-memanto/README.md
Describes the decision-trail-tap concept, demo goals, run/test instructions, and Memanto CLI/local backend setup and activation commands.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SkillMemoryBridge
  participant MemoryBackend
  Client->>SkillMemoryBridge: begin_skill(project, skill, prompt, cwd, files)
  SkillMemoryBridge->>MemoryBackend: recall(query, limit)
  MemoryBackend-->>SkillMemoryBridge: MemoryRecord[] (recalled)
  Client->>SkillMemoryBridge: record_event(event)
  Client->>SkillMemoryBridge: end_skill(summary)
  SkillMemoryBridge->>MemoryBackend: remember(memory) (persist classified events + artifact)
  MemoryBackend-->>SkillMemoryBridge: ack
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • het0814

Poem

🐰 I hop through code and tuck each choice away,

I nibble on decisions made through the day.
Two skills, some memories, context to find,
I bury the trails so the next run's aligned.
Hooray — small rabbit, keeping thoughts in mind!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and accurately describes the main change: adding a complete example for Claude Code skills integrated with Memanto memory bridge functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

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: 1

🤖 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`:
- Around line 157-189: The subprocess calls in MemantoCliBackend.remember and
MemantoCliBackend.recall can hang indefinitely; update both methods to pass a
bounded timeout argument to subprocess.run (e.g., timeout=10 or a configurable
constant/ENV like MEMANTO_TIMEOUT) and handle subprocess.TimeoutExpired (catch
it, log an error via the module logger/processLogger and either re-raise a
custom exception or return a safe failure value). Ensure you add the timeout
parameter to the subprocess.run call sites in remember() and recall() and add a
small try/except around them to handle TimeoutExpired cleanly.
🪄 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: 46b94dc8-447b-4d58-9b57-b90cfa4e009b

📥 Commits

Reviewing files that changed from the base of the PR and between a17ebc4 and b48607b.

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

Comment thread examples/claudecode-skills-memanto/skill_memory_bridge.py

@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.

🧹 Nitpick comments (1)
examples/claudecode-skills-memanto/test_skill_memory_bridge.py (1)

96-106: 💤 Low value

Add a matching test for remember timeouts (TimeoutExpired→TimeoutError)

The current test covers the timeout-to-TimeoutError conversion for recall, but MemantoCliBackend.remember uses the same subprocess.TimeoutExpiredTimeoutError wrapping (message: memanto remember timed out after {timeout:.1f}s), so adding a parallel test would lock in both behaviors.

🤖 Prompt for 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.

In `@examples/claudecode-skills-memanto/test_skill_memory_bridge.py` around lines
96 - 106, Add a new test mirroring test_memanto_cli_backend_converts_timeout but
targeting MemantoCliBackend.remember: monkeypatch subprocess.run to a fake_run
that raises subprocess.TimeoutExpired(command, kwargs["timeout"]), instantiate
MemantoCliBackend(timeout_seconds=1.0), call backend.remember(...) and assert it
raises TimeoutError with a match for the remember-specific message (e.g.
"memanto remember timed out after 1.0s" or an appropriate regex to match the
formatted timeout); reference MemantoCliBackend.remember and the existing
test_memanto_cli_backend_converts_timeout for structure.
🤖 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.

Nitpick comments:
In `@examples/claudecode-skills-memanto/test_skill_memory_bridge.py`:
- Around line 96-106: Add a new test mirroring
test_memanto_cli_backend_converts_timeout but targeting
MemantoCliBackend.remember: monkeypatch subprocess.run to a fake_run that raises
subprocess.TimeoutExpired(command, kwargs["timeout"]), instantiate
MemantoCliBackend(timeout_seconds=1.0), call backend.remember(...) and assert it
raises TimeoutError with a match for the remember-specific message (e.g.
"memanto remember timed out after 1.0s" or an appropriate regex to match the
formatted timeout); reference MemantoCliBackend.remember and the existing
test_memanto_cli_backend_converts_timeout for structure.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 70805170-9b82-43d4-94db-7ca3f146d06c

📥 Commits

Reviewing files that changed from the base of the PR and between b48607b and cb6fea4.

📒 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 (1)
  • examples/claudecode-skills-memanto/skill_memory_bridge.py

@auruminternum

Copy link
Copy Markdown
Author

Addressed the CodeRabbit timeout finding in commit cb6fea4:

  • added a bounded Memanto CLI timeout with MEMANTO_CLI_TIMEOUT_SECONDS override
  • pass timeout= to both memanto remember and memanto recall subprocess calls
  • convert subprocess.TimeoutExpired into explicit TimeoutError messages with logging
  • added tests proving timeout propagation and timeout conversion

Validation after the change:

  • python -m ruff check examples\claudecode-skills-memanto
  • python -m pytest examples\claudecode-skills-memanto -q (5 passed)
  • python -m py_compile examples\claudecode-skills-memanto\skill_memory_bridge.py examples\claudecode-skills-memanto\demo.py examples\claudecode-skills-memanto\test_skill_memory_bridge.py
  • git diff --check

@auruminternum

Copy link
Copy Markdown
Author

Added the matching remember-timeout coverage requested in the latest CodeRabbit nitpick in commit 4d700a9. Validation after the change: \python -m pytest examples\claudecode-skills-memanto -q\ (6 passed) and \python -m ruff check examples\claudecode-skills-memanto\ (all checks passed).

@auruminternum

Copy link
Copy Markdown
Author

Follow-up pushed to strengthen the review signal after the automated docstring note. The new example Python files now have docstrings on all function/class definitions in the added skill bridge/demo/tests by a local AST count (39/39, 100%).

Validation run locally:

  • python -m pytest examples\claudecode-skills-memanto -q
  • python -m ruff check examples\claudecode-skills-memanto
  • git diff --check

Latest head: 8d57ed3

@Xenogents

Copy link
Copy Markdown
Collaborator

We were blown away by the community's creativity and the sheer volume of high-quality submissions! After reviewing all the pull requests against the bounty's success matrix, we have decided to move forward with merging PR #692, which implemented a highly portable prompt-injection architecture via CLAUDE.md.

We are closing this PR because it falls into one of the architectural approaches that we ultimately decided against for the ecosystem:

  • High Friction (CLI Wrappers): Many submissions used Python or Bash wrappers (e.g., forcing the user to type memanto-wrap /tdd instead of the native claude /tdd). While effective at passing context, managing child PTY processes introduces terminal overhead and breaks the developer's native muscle memory
  • Incomplete Lifecycle (Manual Scripts): Some submissions successfully implemented the context extraction logic but failed to automate it, requiring the user to manually run pre and post scripts around every skill session.

We deeply appreciate the time and engineering effort you put into this submission. The codebase was fantastic to review, and we hope to see you in future Moorcheh bounties!

@Xenogents Xenogents closed this Jun 16, 2026
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.

2 participants