Add Claude Code skills Memanto bridge example#581
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR adds an example project that bridges Claude Code skills and Memanto: a SkillMemory model, pluggable backends (local JSONL and Memanto SDK), API functions to recall and persist memories (pre/post hooks), a CLI, example session scripts, configuration files, and tests. ChangesClaude Code Skills Memanto Memory Bridge
Sequence DiagramsequenceDiagram
participant Skill
participant pre_skill_context
participant Backend
participant post_skill_capture
participant distill_engineering_memory
Skill->>pre_skill_context: (skill, prompt, path_hint)
pre_skill_context->>Backend: recall(query, limit=3)
Backend-->>pre_skill_context: list[SkillMemory]
pre_skill_context-->>Skill: formatted_context
Skill->>post_skill_capture: (skill, prompt, transcript, path_hint)
post_skill_capture->>distill_engineering_memory: (skill, prompt, transcript, path_hint)
distill_engineering_memory-->>post_skill_capture: SkillMemory
post_skill_capture->>Backend: remember(memory)
Backend-->>post_skill_capture: persisted
post_skill_capture-->>Skill: SkillMemory
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (6)
examples/claudecode-skills-memanto/run_session_b.py (2)
6-6: Consider adding a docstring.A brief docstring would clarify what this example demonstrates and how it relates to Session A.
📝 Suggested docstring
def main() -> None: + """Demonstrate pre-skill context retrieval (Session B). + + Retrieves the Stripe webhook architecture decision stored by + Session A when working on a related /tdd task in the same path. + """ backend = build_backend()🤖 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/run_session_b.py` at line 6, Add a one- or two-line docstring to the top of the main() function explaining what this example demonstrates (e.g., what the script does, how it relates to Session A, and any expected inputs/outputs or behaviors) so readers quickly understand the purpose of run_session_b.py; locate the top of the main() function and insert the docstring immediately after def main() -> None: (referencing the main function) following standard Python triple-quoted string conventions.
6-15: ⚡ Quick winConsider adding error handling for robustness.
Like Session A, this script would benefit from try-except blocks around
build_backend()andpre_skill_context()to handle potential failures gracefully and demonstrate best practices.🛡️ Suggested error handling pattern
def main() -> None: - backend = build_backend() - context = pre_skill_context( - backend=backend, - skill="/tdd", - prompt="Add tests for Stripe webhook retries.", - path_hint="services/payments", - ) - print("Session B injected context:") - print(context or "No relevant engineering memory found.") + try: + backend = build_backend() + context = pre_skill_context( + backend=backend, + skill="/tdd", + prompt="Add tests for Stripe webhook retries.", + path_hint="services/payments", + ) + print("Session B injected context:") + print(context or "No relevant engineering memory found.") + except Exception as e: + print(f"Error retrieving context: {e}") + raise🤖 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/run_session_b.py` around lines 6 - 15, Wrap the backend creation and context injection in try/except blocks inside main to handle failures from build_backend() and pre_skill_context(); specifically, catch exceptions raised by build_backend() and log/print a clear error message including exception details and exit or return early, then similarly wrap pre_skill_context() to report errors and avoid printing an invalid context; ensure you reference the existing main, build_backend, and pre_skill_context symbols and keep behavior consistent with Session A (graceful failure, informative error output).examples/claudecode-skills-memanto/run_session_a.py (2)
6-6: Consider adding a docstring.Adding a brief docstring would help users understand what this example demonstrates.
📝 Suggested docstring
def main() -> None: + """Demonstrate post-skill memory capture (Session A). + + Stores a Stripe webhook architecture decision that will be + retrieved by Session B when working on related tasks. + """ backend = build_backend()🤖 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/run_session_a.py` at line 6, Add a concise docstring to the main function to explain what this example demonstrates and how to run it; specifically, update the def main() function by inserting a short triple-quoted docstring immediately under the signature (e.g., one- to three-line description of the example's purpose, inputs/outputs if any, and usage) so readers understand the example without inspecting the implementation.
6-20: ⚡ Quick winConsider adding error handling for robustness.
The script lacks try-except blocks around
build_backend()andpost_skill_capture(). For example code, wrapping these calls in error handling would make the script more robust and educational by demonstrating proper error management patterns.🛡️ Suggested error handling pattern
def main() -> None: - backend = build_backend() - memory = post_skill_capture( - backend=backend, - skill="/grill-with-docs", - prompt="Review the payments service architecture.", - transcript=( - "Decision: use a repository layer for Stripe webhook persistence. " - "Keep webhook signature verification at the HTTP boundary and store " - "only normalized event records under services/payments." - ), - path_hint="services/payments", - ) - print("Session A stored memory:") - print(f"- {memory.title}: {memory.content}") + try: + backend = build_backend() + memory = post_skill_capture( + backend=backend, + skill="/grill-with-docs", + prompt="Review the payments service architecture.", + transcript=( + "Decision: use a repository layer for Stripe webhook persistence. " + "Keep webhook signature verification at the HTTP boundary and store " + "only normalized event records under services/payments." + ), + path_hint="services/payments", + ) + print("Session A stored memory:") + print(f"- {memory.title}: {memory.content}") + except Exception as e: + print(f"Error capturing memory: {e}") + raise🤖 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/run_session_a.py` around lines 6 - 20, The script calls build_backend() and post_skill_capture() in main() without error handling; wrap those calls in a try/except block inside main (or separate try/except around each call) to catch exceptions, log or print a concise error message, and exit or re-raise as appropriate; locate the calls to build_backend and post_skill_capture in the main function and ensure exceptions include context (e.g., "failed to build backend" or "failed to store memory") so failures are handled cleanly for this example script.examples/claudecode-skills-memanto/README.md (2)
16-27: 💤 Low valueConsider adding
.gitignoreto the file listing.The directory structure omits
.gitignore, which is part of this PR and helps reviewers understand the complete project layout.📝 Suggested addition
examples/claudecode-skills-memanto/ ├── README.md ├── requirements.txt ├── .env.example +├── .gitignore ├── memanto_skills.py🤖 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/README.md` around lines 16 - 27, Update the examples/claudecode-skills-memanto/ README.md tree to include the .gitignore entry so the project layout matches the PR; edit the code block in README.md (the directory listing) to add a line for ".gitignore" (e.g., between .env.example and memanto_skills.py) and ensure the actual .gitignore file is present in the repo so the README and repository contents stay in sync.
83-89: 💤 Low valueConsider documenting ruff validation mentioned in PR description.
The PR description lists "ruff check/format" as validation commands, but the README only mentions pytest and py_compile. Including ruff commands would provide complete validation coverage.
📝 Suggested addition
```bash cd examples/claudecode-skills-memanto python -m pytest tests -q python -m py_compile memanto_skills.py run_session_a.py run_session_b.py +ruff check . +ruff format --check .</details> <details> <summary>🤖 Prompt for AI Agents</summary>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/README.mdaround lines 83 - 89,
Validation section in README.md omits the ruff lint/format checks referenced in
the PR description; update the Validation block in
examples/claudecode-skills-memanto/README.md to include the ruff commands (e.g.,
add "ruff check ." and "ruff format --check .") alongside the existing pytest
and python -m py_compile commands that target memanto_skills.py,
run_session_a.py and run_session_b.py so the README reflects full validation
steps.</details> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary>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/memanto_skills.py:
- Around line 55-57: The current recall logic treats any single shared token as
a match (score = len(query_terms & _tokens(haystack))) which allows common words
to trigger unrelated memories; update the matching in both places where this
appears (the score calculation and append to scored involving query_terms,
_tokens(haystack), score, and memory) to require a stricter threshold (e.g.,
require score >= 2 or score >= max(1, int(len(query_terms) * 0.3))) before
appending to scored so that at least multiple or a meaningful proportion of
query tokens must overlap to qualify as a memory match.- Around line 65-68: The JSONL parsing in the loop that builds memories (using
self.path.read_text, json.loads and SkillMemory(**...)) should be guarded so a
single corrupted/truncated line doesn't raise and abort recall; wrap the
per-line parsing and dataclass construction in a try/except (catch
json.JSONDecodeError and ValueError/TypeError from SkillMemory construction),
skip the bad line on exception (optionally log a warning with the offending
line), and continue appending only successfully parsed SkillMemory instances to
memories.- Around line 170-172: Explicit decision extraction currently concatenates
prompt and transcript (text = f"{prompt}\n{transcript}") before calling
_find_explicit_decision, which can surface prompt phrasing as a decision; change
the call to run _find_explicit_decision against the transcript only (e.g., pass
transcript or set text = transcript) so that only session output is analyzed;
update references to text/explicit accordingly (look for variable text, the
function _find_explicit_decision, and the prompt/transcript variables) and
ensure no prompt content is included in the explicit decision check.
Nitpick comments:
In@examples/claudecode-skills-memanto/README.md:
- Around line 16-27: Update the examples/claudecode-skills-memanto/ README.md
tree to include the .gitignore entry so the project layout matches the PR; edit
the code block in README.md (the directory listing) to add a line for
".gitignore" (e.g., between .env.example and memanto_skills.py) and ensure the
actual .gitignore file is present in the repo so the README and repository
contents stay in sync.- Around line 83-89: Validation section in README.md omits the ruff lint/format
checks referenced in the PR description; update the Validation block in
examples/claudecode-skills-memanto/README.md to include the ruff commands (e.g.,
add "ruff check ." and "ruff format --check .") alongside the existing pytest
and python -m py_compile commands that target memanto_skills.py,
run_session_a.py and run_session_b.py so the README reflects full validation
steps.In
@examples/claudecode-skills-memanto/run_session_a.py:
- Line 6: Add a concise docstring to the main function to explain what this
example demonstrates and how to run it; specifically, update the def main()
function by inserting a short triple-quoted docstring immediately under the
signature (e.g., one- to three-line description of the example's purpose,
inputs/outputs if any, and usage) so readers understand the example without
inspecting the implementation.- Around line 6-20: The script calls build_backend() and post_skill_capture() in
main() without error handling; wrap those calls in a try/except block inside
main (or separate try/except around each call) to catch exceptions, log or print
a concise error message, and exit or re-raise as appropriate; locate the calls
to build_backend and post_skill_capture in the main function and ensure
exceptions include context (e.g., "failed to build backend" or "failed to store
memory") so failures are handled cleanly for this example script.In
@examples/claudecode-skills-memanto/run_session_b.py:
- Line 6: Add a one- or two-line docstring to the top of the main() function
explaining what this example demonstrates (e.g., what the script does, how it
relates to Session A, and any expected inputs/outputs or behaviors) so readers
quickly understand the purpose of run_session_b.py; locate the top of the main()
function and insert the docstring immediately after def main() -> None:
(referencing the main function) following standard Python triple-quoted string
conventions.- Around line 6-15: Wrap the backend creation and context injection in
try/except blocks inside main to handle failures from build_backend() and
pre_skill_context(); specifically, catch exceptions raised by build_backend()
and log/print a clear error message including exception details and exit or
return early, then similarly wrap pre_skill_context() to report errors and avoid
printing an invalid context; ensure you reference the existing main,
build_backend, and pre_skill_context symbols and keep behavior consistent with
Session A (graceful failure, informative error output).</details> <details> <summary>🪄 Autofix (Beta)</summary> Fix all unresolved CodeRabbit comments on this PR: - [ ] <!-- {"checkboxId": "4b0d0e0a-96d7-4f10-b296-3a18ea78f0b9"} --> Push a commit to this branch (recommended) - [ ] <!-- {"checkboxId": "ff5b1114-7d8c-49e6-8ac1-43f82af23a33"} --> Create a new PR with the fixes </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro Plus **Run ID**: `ec059a79-e3ec-4ddd-b633-0e94ac48398b` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 01b8b24151e7efa9f56fe9979fa8e8dd54c9c455 and a4a606f8c557d20903e8a8a9cbfe58386822e9b3. </details> <details> <summary>📒 Files selected for processing (9)</summary> * `examples/claudecode-skills-memanto/.env.example` * `examples/claudecode-skills-memanto/.gitignore` * `examples/claudecode-skills-memanto/README.md` * `examples/claudecode-skills-memanto/memanto_skills.py` * `examples/claudecode-skills-memanto/requirements.txt` * `examples/claudecode-skills-memanto/run_session_a.py` * `examples/claudecode-skills-memanto/run_session_b.py` * `examples/claudecode-skills-memanto/tests/conftest.py` * `examples/claudecode-skills-memanto/tests/test_memanto_skills.py` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
|
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:
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! |
/claim #508
Bounty: https://www.bountyhub.dev/bounty/view/3a63800c-7c18-41d2-870f-c62344f8a3fe
What it adds:
examples/claudecode-skills-memanto, a Claude Code Skills-style memory bridge for Memanto.prehook: recalls task/path-relevant engineering memory before a skill starts.posthook: distills completed skill output into durable project memory.MEMANTO_SKILLS_BACKEND=memanto./tddsession receiving it as injected context.Social showcase:
Validation run locally:
uv run python -m py_compile examples/claudecode-skills-memanto/memanto_skills.py examples/claudecode-skills-memanto/run_session_a.py examples/claudecode-skills-memanto/run_session_b.pyuv run pytest examples/claudecode-skills-memanto/tests -quv run ruff check examples/claudecode-skills-memantouv run ruff format --check examples/claudecode-skills-memantouv run python examples/claudecode-skills-memanto/run_session_a.py && uv run python examples/claudecode-skills-memanto/run_session_b.pySummary by CodeRabbit
New Features
Documentation
Tests
Chores