| name | integrate |
| description | This skill should be used when the user asks to "integrate mnemonic", "wire plugin",
"add memory to plugin", "enable memory capture in plugin", "integrate memory operations",
"add mnemonic protocol", "remove mnemonic integration", "rollback plugin integration",
or "migrate legacy memory sections". It wires mnemonic memory capture and recall
workflows into other Claude Code plugins using sentinel markers.
|
| allowed-tools | ["Bash","Read","Write","Glob","Grep","Edit"] |
Integrate Skill
Wire mnemonic memory operations into other Claude Code plugins.
When to Use
Use this skill when you want to:
- Add memory to an existing plugin - Make any plugin mnemonic-aware
- Enable cross-session learning - Let plugins recall past decisions and learnings
- Automate capture triggers - Set up hooks that suggest memory capture at the right time
- Migrate legacy integrations - Convert old marker-less integrations to the new format
Don't use this skill if:
- You're building a new plugin from scratch (use the core skill directly)
- You only need to search/capture memories (use
/mnemonic:search and /mnemonic:capture)
Overview
This skill enables integrating mnemonic memory capture and recall into other Claude Code plugins. Integration happens through two mechanisms:
- Markdown Workflow Edits - Add explicit workflow steps to command/skill/agent markdown files
- Event-Driven Hooks - Add hooks that detect events and inject memory context
Both mechanisms work together: Markdown provides explicit workflow guidance, hooks provide automatic event detection.
Quick Start
/mnemonic:integrate {plugin_path}
/mnemonic:integrate {plugin_path} --dry-run
/mnemonic:integrate {plugin_path} --remove
/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.
Sentinel Markers
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:
- Updates: Replace content between markers without affecting rest of file
- Removal: Delete everything between markers cleanly
- Detection: Identify already-integrated files
- Migration: Convert old integrations to marker-wrapped format
Template Source: templates/mnemonic-protocol.md is the single source of truth.
Integration Workflow
For most users: Skip to "How to Use This Skill" below for command-line usage. This section details the internal steps the skill performs.
Phase 1: Analyze Target Plugin
cat {plugin_path}/.claude-plugin/plugin.json
ls -la {plugin_path}/commands/ {plugin_path}/skills/ {plugin_path}/agents/ 2>/dev/null
For each component, determine:
- Does it CREATE something? ā Candidate for capture after
- Does it MAKE DECISIONS? ā Candidate for capture after
- Does it RESEARCH something? ā Candidate for recall before
Phase 2: Identify Integration Points
| 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 |
Phase 3: Read Template (MANDATORY)
Use the template verbatim - do not modify the protocol content.
cat "${CLAUDE_PLUGIN_ROOT}/templates/mnemonic-protocol.md"
The template already contains:
<!-- BEGIN MNEMONIC PROTOCOL --> start marker
<!-- END MNEMONIC PROTOCOL --> end marker
- Complete protocol content between markers (see "Sentinel Markers" section above)
Phase 4: Insert Template With Markers
For 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.
Phase 5: Update Tool Access
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 creation
Glob - For finding memory files
Grep - For searching memory content
Read - For reading memory files
Write - For creating memory files
How to update:
For agents/skills with frontmatter:
---
name: some-agent
allowed-tools:
- Bash
- Glob
- Grep
- Read
- Write
---
Check existing allowed-tools and add only what's missing.
Integration Patterns
MANDATORY RULES (Non-negotiable):
- Use template verbatim - Read
templates/mnemonic-protocol.md and insert exactly as-is
- Keep sentinel markers - Template content must stay within
<!-- BEGIN/END MNEMONIC PROTOCOL --> markers
- Insert at TOP - Immediately after frontmatter, before any other content
- Don't modify protocol - The protocol text is standardized; only hooks (Pattern D) may be customized
Standard Protocol (From Template)
Read and insert template content with markers:
PROTOCOL=$(cat "${CLAUDE_PLUGIN_ROOT}/templates/mnemonic-protocol.md")
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.
Graceful Fallthrough
The template uses /mnemonic:search and /mnemonic:capture skills which:
- Fail gracefully if mnemonic plugin is uninstalled (skills simply won't be available)
- No errors or crashes in integrated plugins
- Seamless degradation - agent continues without memory operations
Pattern D: Event-Driven Hooks (Optional)
Applies to: Plugins that need automatic capture signals
Note: Hooks provide signals only. The markdown patterns above are primary.
Create hooks/mnemonic-signal.py:
import json, os
def main():
tool_input = json.loads(os.environ.get("CLAUDE_TOOL_INPUT", "{}"))
file_path = tool_input.get("file_path", "")
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()
Target Plugin Examples
All integrations use the standard template from templates/mnemonic-protocol.md with sentinel markers.
ADR Plugin
Files to modify: commands/adr-new.md, agents/adr-author.md
Insert template after frontmatter. Replace {relevant_keywords} with {decision_topic} if needed.
Documentation Review Plugin
Files to modify: commands/doc-create.md, commands/doc-review.md
Insert template after frontmatter. Use generic keywords.
Feature Dev Plugin
Files to modify: agents/*.md, skills/*.md
Insert template after frontmatter. Replace {relevant_keywords} with {feature} if needed.
How to Use This Skill
Insert/Update Mode (Default)
/mnemonic:integrate {plugin_path}
Inserts or updates mnemonic protocol with sentinel markers. If markers already exist, updates content between them.
Remove Mode
/mnemonic:integrate {plugin_path} --remove
Cleanly removes mnemonic protocol by deleting everything between sentinel markers.
Migrate Mode
/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 markers
- Content containing
rg -i, /mnemonic:capture, ${MNEMONIC_ROOT}/
Analyze Only Mode
/mnemonic:integrate {plugin_path} --analyze
Outputs proposed modifications without making changes.
Dry Run Mode
/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:
- Files that would be created
- Files that would be modified (with diff preview)
- Tools that would be added to allowed-tools
- Git commit that would be created
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.
Full Integration Mode
/mnemonic:integrate {plugin_path}
Analyzes plugin and applies all integration modifications.
Specific Component
/mnemonic:integrate {plugin_path}/commands/adr-new.md
Integrates mnemonic into a specific command/skill file.
Rollback Mode
/mnemonic:integrate {plugin_path} --rollback
Reverts the last mnemonic integration commit. Only works if plugin has git.
Rollback workflow:
- Find integration commit - Search for commits with "feat(mnemonic)" message
- Show what will be reverted - Display the commit diff
- Confirm with user - Ask before reverting
- Revert commit - Use
git revert to cleanly undo changes
- Report - Show reverted files and new commit hash
Example:
/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}
COMMIT=$(git log --oneline --grep="feat(mnemonic)" -1 | cut -d' ' -f1)
if [ -z "$COMMIT" ]; then
echo "No mnemonic integration commit found"
exit 1
fi
echo "Will revert commit: $COMMIT"
git show --stat $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:
- ā ļø Rollback only works if plugin has git (non-git plugins warn at integration time)
- ā ļø If you've made manual changes since integration, rollback will revert those too
- ā ļø Failed rollbacks leave partial state - check
git status and resolve manually
- ā
Rollback is non-destructive by default (creates revert commit)
- ā
Original integration is preserved in git history for reference
Workflow Steps
Note: This section describes internal mechanics. For usage instructions, see "How to Use This Skill" above.
When invoked, this skill:
Standard Mode (Insert/Update):
- Read template - Load
templates/mnemonic-protocol.md as source of truth
- Read plugin manifest - Parse
.claude-plugin/plugin.json
- List components - Find all commands, skills, agents, hooks
- For each component:
- Check for existing sentinel markers
- If markers exist: Update content between them
- If no markers: Insert after frontmatter with markers
- Update tool access - Add required tools (Bash, Glob, Grep, Read, Write)
- Commit changes - Create atomic git commit for rollback
- Report results - Summarize what was integrated and commit hash
Remove Mode (--remove):
- List components - Find all commands, skills, agents, hooks
- For each component:
- Find sentinel markers (
<!-- BEGIN/END MNEMONIC PROTOCOL -->)
- Delete everything between markers (inclusive)
- Commit changes - Create git commit for the removal
- Report results - Summarize what was removed
Migrate Mode (--migrate):
- List components - Find all commands, skills, agents, hooks
- For each component:
- Detect old patterns:
## Memory Operations or ## Memory without markers
- Detect content indicators:
rg -i, /mnemonic:capture, ${MNEMONIC_ROOT}/
- Replace old section with marker-wrapped version from template
- Commit changes - Create git commit
- Report results - Summarize migrated files
Dry Run Mode (--dry-run):
- Perform analysis - Same as standard/remove/migrate mode
- Display changes - Show what WOULD be modified (with diffs)
- Exit - No changes applied
Rollback Mode (--rollback):
- Check git repository - Verify plugin has git
- Find integration commit - Search for "feat(mnemonic)" commit
- Display changes - Show what will be reverted
- Confirm - Ask user to confirm rollback
- Revert commit - Run
git revert on integration commit
- Report - Show reverted files and new commit hash
Verification
After integration, verify by:
- Run integrated command - Execute the modified command
- Check for capture prompt - Verify Claude suggests memory capture
- Create a memory - Confirm memory is created correctly
- Test recall - Search for the new memory
# Verify memory was created
/mnemonic:status
# Search for content
/mnemonic:search {topic}
Best Practices
- Always analyze first - Use
--analyze to preview changes
- Test integration - Run modified commands to verify
- Keep sections minimal - Integration text should be concise
- Use consistent patterns - All capture sections should follow same format
- Don't duplicate - Check if integration already exists
- Document changes - Note which files were modified
Git Workflow for Plugin Modifications
When integrating mnemonic into a plugin, track changes with git for clean rollback.
Check for Git Repository
cd {plugin_path}
if [ -d .git ]; then
echo "ā Git repository found"
else
echo "ā No git repository - changes will not be committed"
echo " Consider: git init"
fi
Atomic Commit Pattern
If git repository exists, create single atomic commit with all integration changes:
cd {plugin_path}
git add SKILL.md README.md hooks/*.py
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
Non-Git Plugins
If target plugin has no git repository:
- Warn user but proceed with integration
- List changes made for manual review
- Suggest initializing git for future modifications
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
Rollback
If integration needs to be undone:
cd {plugin_path}
git show HEAD
git revert HEAD
git reset --hard HEAD~1
Verification
After commit, verify integration:
git log -1 --stat
git diff HEAD~1
Implementation Library
The integrate skill is backed by a Python library located at skills/integrate/lib/.
Library Components
| 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 |
Using the Library
The library can be invoked directly via command line:
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode integrate
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode verify
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode remove
python3 skills/integrate/lib/integrator.py /path/to/plugin --mode integrate --dry-run
python3 skills/integrate/lib/integrator.py /path/to/plugin --json
Individual Tool Usage
python3 skills/integrate/lib/marker_parser.py /path/to/file.md --check
python3 skills/integrate/lib/marker_parser.py /path/to/file.md --extract
python3 skills/integrate/lib/template_validator.py /path/to/template.md
python3 skills/integrate/lib/frontmatter_updater.py /path/to/file.md --list
Integration Manifest
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"]
}
Security Features
The library includes several security measures:
- Path validation - All file paths are validated to be within plugin root
- Symlink protection - Symlinks pointing outside plugin root are rejected
- Rollback support - Failed integrations can be automatically rolled back
- Template validation - Templates are checked for executable code patterns