From mnemonic
Integrates mnemonic memory capture and recall into existing Claude Code plugins using sentinel markers for updates, removal, and git rollback. Triggers on integrate/wire/add memory requests.
How this skill is triggered — by the user, by Claude, or both
Slash command
/mnemonic:integrateThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Wire mnemonic memory operations into other Claude Code plugins.
Wire mnemonic memory operations into other Claude Code plugins.
Use this skill when you want to:
Don't use this skill if:
/mnemonic:search and /mnemonic:capture)This skill enables integrating mnemonic memory capture and recall into other Claude Code plugins. Integration happens through two mechanisms:
Both mechanisms work together: Markdown provides explicit workflow guidance, hooks provide automatic event detection.
# Integrate a plugin (adds mnemonic protocol to all components)
/mnemonic:integrate {plugin_path}
# Preview changes without applying
/mnemonic:integrate {plugin_path} --dry-run
# Remove integration
/mnemonic:integrate {plugin_path} --remove
# Rollback last integration (git required)
/mnemonic:integrate {plugin_path} --rollback
For detailed options, see "How to Use This Skill" below.
[CRITICAL] PROTOCOL CONTENT MUST BE VERBATIM
For the mnemonic protocol section (## Memory), you MUST:
- Read
templates/mnemonic-protocol.md- this is the single source of truth- Insert its content EXACTLY as-is, including sentinel markers
- Never abbreviate, modify, or "improve" the protocol text
Exception: Event-driven hooks (Pattern D) are optional and use the provided template code.
All integrations use sentinel markers for clean updates and removal:
<!-- BEGIN MNEMONIC PROTOCOL -->
## Memory
Search first: `/mnemonic:search {relevant_keywords}`
Capture after: `/mnemonic:capture {namespace} "{title}"`
Run `/mnemonic:list --namespaces` to see available namespaces from loaded ontologies.
<!-- END MNEMONIC PROTOCOL -->
Benefits:
Template Source: templates/mnemonic-protocol.md is the single source of truth.
For most users: Skip to "How to Use This Skill" below for command-line usage. This section details the internal steps the skill performs.
# Read plugin manifest
cat {plugin_path}/.claude-plugin/plugin.json
# List all components
ls -la {plugin_path}/commands/ {plugin_path}/skills/ {plugin_path}/agents/ 2>/dev/null
For each component, determine:
| Component Type | Integration Pattern |
|---|---|
| Command that creates files | Add capture section at end |
| Agent that makes decisions | Add recall before, capture after |
| Skill with workflows | Add memory search step |
| Hook on tool use | Add capture trigger |
Use the template verbatim - do not modify the protocol content.
# Read the template - this is the ONLY content to insert
cat "${CLAUDE_PLUGIN_ROOT}/templates/mnemonic-protocol.md"
The template already contains:
<!-- BEGIN MNEMONIC PROTOCOL --> start marker<!-- END MNEMONIC PROTOCOL --> end markerFor each target file:
Check for existing markers:
grep -l "BEGIN MNEMONIC PROTOCOL" {file}
If markers exist: Replace content BETWEEN markers with template content
If no markers: Insert the COMPLETE template (including markers) after frontmatter
NEVER insert content without the sentinel markers.
Mnemonic operations require certain tools. Add them to target component's allowed-tools:
Required tools for mnemonic integration:
Bash - For git operations and memory file creationGlob - For finding memory filesGrep - For searching memory contentRead - For reading memory filesWrite - For creating memory filesHow to update:
For agents/skills with frontmatter:
---
name: some-agent
allowed-tools:
- Bash # Add if missing
- Glob # Add if missing
- Grep # Add if missing
- Read # Add if missing
- Write # Add if missing
# ... existing tools
---
Check existing allowed-tools and add only what's missing.
MANDATORY RULES (Non-negotiable):
templates/mnemonic-protocol.md and insert exactly as-is<!-- BEGIN/END MNEMONIC PROTOCOL --> markersRead and insert template content with markers:
# Read template content
PROTOCOL=$(cat "${CLAUDE_PLUGIN_ROOT}/templates/mnemonic-protocol.md")
# Insert after frontmatter with markers
See template content in "Sentinel Markers" section above.
Namespaces: Run /mnemonic:list --namespaces to see available namespaces from loaded ontologies. Base namespaces include _semantic/*, _episodic/*, and _procedural/* from mif-base ontology.
The template uses /mnemonic:search and /mnemonic:capture skills which:
Applies to: Plugins that need automatic capture signals
Note: Hooks provide signals only. The markdown patterns above are primary.
Create hooks/mnemonic-signal.py:
#!/usr/bin/env python3
import json, os
def main():
tool_input = json.loads(os.environ.get("CLAUDE_TOOL_INPUT", "{}"))
file_path = tool_input.get("file_path", "")
# Detect capture-worthy files
namespace = None
if "/adr/" in file_path: namespace = "_semantic/decisions"
elif "/docs/" in file_path: namespace = "_semantic/knowledge"
if namespace:
print(json.dumps({
"continue": True,
"hookSpecificOutput": {
"hookEventName": "PostToolUse",
"additionalContext": f"**CAPTURE:** `/mnemonic:capture {namespace}`"
}
}))
else:
print(json.dumps({"continue": True}))
if __name__ == "__main__":
main()
All integrations use the standard template from templates/mnemonic-protocol.md with sentinel markers.
Files to modify: commands/adr-new.md, agents/adr-author.md
Insert template after frontmatter. Replace {relevant_keywords} with {decision_topic} if needed.
Files to modify: commands/doc-create.md, commands/doc-review.md
Insert template after frontmatter. Use generic keywords.
Files to modify: agents/*.md, skills/*.md
Insert template after frontmatter. Replace {relevant_keywords} with {feature} if needed.
/mnemonic:integrate {plugin_path}
Inserts or updates mnemonic protocol with sentinel markers. If markers already exist, updates content between them.
/mnemonic:integrate {plugin_path} --remove
Cleanly removes mnemonic protocol by deleting everything between sentinel markers.
/mnemonic:integrate {plugin_path} --migrate
Finds old marker-less integrations and replaces them with marker-wrapped version from template.
Detection patterns for migration:
## Memory Operations or ## Memory section without markersrg -i, /mnemonic:capture, ${MNEMONIC_ROOT}//mnemonic:integrate {plugin_path} --analyze
Outputs proposed modifications without making changes.
/mnemonic:integrate {plugin_path} --dry-run
Shows exactly what changes would be made without applying them. Useful for reviewing integration before committing.
Dry run output includes:
Example output:
DRY RUN - No changes will be made
Plugin: ~/.claude/plugins/cache/zircote/adr/0.2.0/
Git repo: ✓ Found
Changes that would be made:
1. MODIFY: commands/adr-new.md
+ ## Post-Creation: Capture to Mnemonic
+ After creating the file, capture the key details...
(15 lines added)
2. MODIFY: agents/adr-author.md
+ ## Before Starting: Check Related Memories
+ Use mnemonic recall workflow...
(12 lines added)
TOOLS: Would add [Bash, Glob, Grep, Read, Write] to allowed-tools
3. CREATE: hooks/mnemonic-suggest.py
(45 lines, template from mnemonic/templates/plugin-hooks/)
4. CREATE/MERGE: hooks/hooks.json
+ PostToolUse matcher for Write tool
Git commit that would be created:
feat(mnemonic): integrate memory capture and recall
To apply these changes, run without --dry-run flag.
/mnemonic:integrate {plugin_path}
Analyzes plugin and applies all integration modifications.
/mnemonic:integrate {plugin_path}/commands/adr-new.md
Integrates mnemonic into a specific command/skill file.
/mnemonic:integrate {plugin_path} --rollback
Reverts the last mnemonic integration commit. Only works if plugin has git.
Rollback workflow:
git revert to cleanly undo changesExample:
/mnemonic:integrate ~/.claude/plugins/cache/zircote/adr/ --rollback
Output:
Found mnemonic integration commit:
abc1234 feat(mnemonic): integrate memory capture and recall
Date: 2026-01-24 15:30
Files: 4 changed
This will revert:
- commands/adr-new.md (remove capture section)
- agents/adr-author.md (remove recall section)
- hooks/mnemonic-suggest.py (delete file)
- hooks/hooks.json (remove PostToolUse entry)
Proceed with rollback? [y/N]
Rollback implementation:
cd {plugin_path}
# Find the mnemonic integration commit
COMMIT=$(git log --oneline --grep="feat(mnemonic)" -1 | cut -d' ' -f1)
if [ -z "$COMMIT" ]; then
echo "No mnemonic integration commit found"
exit 1
fi
# Show what will be reverted
echo "Will revert commit: $COMMIT"
git show --stat $COMMIT
# Revert the commit (creates a new revert commit)
git revert --no-edit $COMMIT
echo "✓ Rollback complete"
git log -1 --oneline
Note: Rollback creates a new revert commit, preserving history. To completely remove the integration commit, use git reset --hard HEAD~1 instead (destructive).
Safety Considerations:
git status and resolve manuallyNote: This section describes internal mechanics. For usage instructions, see "How to Use This Skill" above.
When invoked, this skill:
Standard Mode (Insert/Update):
templates/mnemonic-protocol.md as source of truth.claude-plugin/plugin.jsonRemove Mode (--remove):
<!-- BEGIN/END MNEMONIC PROTOCOL -->)Migrate Mode (--migrate):
## Memory Operations or ## Memory without markersrg -i, /mnemonic:capture, ${MNEMONIC_ROOT}/Dry Run Mode (--dry-run):
Rollback Mode (--rollback):
git revert on integration commitAfter integration, verify by:
# Verify memory was created
/mnemonic:status
# Search for content
/mnemonic:search {topic}
--analyze to preview changesWhen integrating mnemonic into a plugin, track changes with git for clean rollback.
cd {plugin_path}
# Check if git repo exists
if [ -d .git ]; then
echo "✓ Git repository found"
else
echo "⚠ No git repository - changes will not be committed"
echo " Consider: git init"
fi
If git repository exists, create single atomic commit with all integration changes:
cd {plugin_path}
# Stage only the specific modified files (not git add -A for security)
git add SKILL.md README.md hooks/*.py # Example - list actual modified files
# Create descriptive commit
git commit -m "feat(mnemonic): integrate memory capture and recall" \
-m "Added mnemonic integration via integrate skill" \
-m "Enables persistent memory across Claude sessions"
Or for more detailed commit messages, use a heredoc:
git commit -F - << 'EOF'
feat(mnemonic): integrate memory capture and recall
Added mnemonic integration:
- Capture workflow for [list components]
- Recall pattern for [list components]
- Event hooks for [list triggers]
Enables persistent memory across Claude sessions.
Integration by: mnemonic integrate skill
EOF
If target plugin has no git repository:
Example output:
⚠ Warning: Plugin has no git repository
Integration complete but changes are not tracked.
Files modified:
- commands/adr-new.md
- agents/adr-author.md
- hooks/mnemonic-suggest.py
Consider: cd {plugin_path} && git init
If integration needs to be undone:
cd {plugin_path}
# View what was changed
git show HEAD
# Undo the integration commit
git revert HEAD
# Or reset completely (discards commit)
git reset --hard HEAD~1
After commit, verify integration:
# Show commit details
git log -1 --stat
# Show what changed
git diff HEAD~1
The integrate skill is backed by a Python library located at skills/integrate/lib/.
| Module | Purpose |
|---|---|
integrator.py | Main orchestrator - handles full integration workflow |
marker_parser.py | Sentinel marker detection, extraction, replacement |
template_validator.py | Template validation and content verification |
frontmatter_updater.py | YAML frontmatter manipulation for tools |
The library can be invoked directly via command line:
# Integrate a plugin
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode integrate
# Verify integration
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode verify
# Remove integration
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode remove
# Dry run (preview changes)
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode integrate --dry-run
# JSON output
python3 skills/integrate/lib/integrator.py /path/to/plugin --json
# Check for markers
python3 skills/integrate/lib/marker_parser.py /path/to/file.md --check
# Extract content between markers
python3 skills/integrate/lib/marker_parser.py /path/to/file.md --extract
# Validate template
python3 skills/integrate/lib/template_validator.py /path/to/template.md
# List tools in frontmatter
python3 skills/integrate/lib/frontmatter_updater.py /path/to/file.md --list
After successful integration, a .mnemonic-integration-manifest.json file is created in the plugin root:
{
"version": "1.0.0",
"integrated_at": "2026-01-27T10:30:00Z",
"template_path": "templates/mnemonic-protocol.md",
"files": [
{"path": "commands/example.md", "action": "inserted", "success": true}
],
"tools_required": ["Bash", "Glob", "Grep", "Read", "Write"]
}
The library includes several security measures:
npx claudepluginhub zircote/mnemonicProvides stable principles, keyword registry, and navigation for Claude Code memory system (CLAUDE.md, static memory, hierarchy, imports). Delegates details to docs-management skill.
Explains how claude-mem captures observations, injects context, and where data is stored locally.
Manages persistent AI memory across coding sessions: remember decisions/patterns, recall context, learn from bugs/mistakes. Auto-triggers on memory prompts, key events like decisions/fixes via Claude Code hooks.