npx claudepluginhub synaptic-labs-ai/pact-plugin --plugin PACTThis skill uses the workspace's default tool permissions.
Persistent memory system for PACT framework agents. Store and retrieve context,
references/memory-patterns.mdscripts/__init__.pyscripts/cli.pyscripts/config.pyscripts/database.pyscripts/embedding_catchup.pyscripts/embeddings.pyscripts/graph.pyscripts/memory_api.pyscripts/memory_init.pyscripts/models.pyscripts/pact_session.pyscripts/search.pyscripts/setup_memory.pyscripts/working_memory.pyIntegrates sage-memory for persistent knowledge across sessions via MCP tools or file fallback. Automates recall at session/task starts and storage during work.
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
Persistent memory system for PACT framework agents. Store and retrieve context, goals, lessons learned, decisions, and entities across sessions with semantic search.
The PACT Memory skill provides:
All commands use the CLI entry point via ${CLAUDE_SKILL_DIR}:
# Save a memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" save '{
"context": "Implementing user authentication",
"goal": "Add JWT refresh token support",
"lessons_learned": [
"Redis INCR is atomic - perfect for rate limiting",
"Always validate refresh token rotation"
],
"decisions": [
{
"decision": "Use Redis for token blacklist",
"rationale": "Fast TTL support, distributed access"
}
],
"reasoning_chains": [
"Redis chosen because TTL support → needed for token expiry → simpler than DB cleanup"
],
"entities": [
{"name": "AuthService", "type": "component"},
{"name": "TokenManager", "type": "class"}
]
}'
# See Memory Structure table below for all available fields
# including agreements_reached and disagreements_resolved
# Search memories
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" search "rate limiting tokens"
# Search with graph-enhanced boosting for current file
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" search "auth tokens" --current-file src/auth/refresh.ts
# List recent memories
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" list --limit 10
# Get a specific memory by ID
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" get <memory_id>
# Update an existing memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" update <memory_id> '{"goal": "Updated goal"}'
# Delete a memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" delete <memory_id>
# Check system status
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" status
# Initialize/verify the memory system
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" setup
All commands output JSON to stdout: {"ok": true, "result": ...}.
Errors output JSON to stderr: {"ok": false, "error": "...", "message": "..."}.
For large JSON payloads (to avoid shell escaping issues), use --stdin:
echo '{"context": "...", "goal": "..."}' | python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" save --stdin
Each memory can contain:
| Field | Type | Description |
|---|---|---|
context | string | Current working context description |
goal | string | What you're trying to achieve |
active_tasks | list | Tasks with status and priority |
lessons_learned | list | What worked or didn't work |
decisions | list | Decisions with rationale and alternatives |
entities | list | Referenced components, services, modules |
reasoning_chains | list | How key decisions connect — "X because Y, which required Z" |
agreements_reached | list | What was verified via teachback or agreement check |
disagreements_resolved | list | Where agents disagreed and how it was settled |
files | list | Associated file paths (auto-linked) |
project_id | string | Auto-detected from environment |
session_id | string | Auto-detected from environment |
{"task": "Implement token refresh", "status": "in_progress", "priority": "high"}
{
"decision": "Use Redis for caching",
"rationale": "Fast, supports TTL natively",
"alternatives": ["Memcached", "In-memory LRU"]
}
{"name": "AuthService", "type": "component", "notes": "Handles all auth flows"}
| Command | Description | Output |
|---|---|---|
save <json> | Save a memory object | {"memory_id": "<hex>"} |
save --stdin | Save from piped JSON | {"memory_id": "<hex>"} |
search <query> | Semantic search | [{"id": "...", "context": "...", ...}, ...] |
search <query> --limit N | Search with limit | [...] (default: 5) |
search <query> --current-file <path> | Search with graph boosting | [...] (boosts file-related memories) |
list | List recent memories | [{"id": "...", "context": "...", ...}, ...] |
list --limit N | List with limit | [...] (default: 20) |
get <id> | Get memory by ID | {"id": "...", "context": "...", ...} |
update <id> <json> | Update memory fields | {"memory_id": "<hex>"} |
update <id> --stdin | Update from piped JSON | {"memory_id": "<hex>"} |
delete <id> | Delete a memory | {"deleted": true, "memory_id": "<hex>"} |
status | System status | {"memory_count": N, "db_path": "...", ...} |
setup | Initialize system | {"status": "ready", "message": "..."} |
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | User error (bad args, invalid JSON) |
| 2 | System error (DB failure, missing deps) |
# Save a memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" save '{"context": "Bug fix", "lessons_learned": ["Check null values first"]}'
# Search memories
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" search "authentication"
# Search with file context for graph-enhanced results
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" search "auth patterns" --current-file src/auth/service.py
# List recent memories
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" list --limit 5
# Update an existing memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" update abc123 '{"goal": "Updated goal", "lessons_learned": ["New lesson"]}'
# Delete a memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" delete abc123
Uses embeddings to find semantically similar memories. Requires either:
When searching while working on a file, memories linked to:
...are boosted in ranking.
If embeddings are unavailable, falls back to substring matching across context, goal, lessons_learned, and decisions fields.
# Required for database
pip install sqlite-vec
# For local embeddings (recommended)
pip install sqlite-lembed
# Alternative embedding backend
pip install sentence-transformers
# Initialize the memory system (creates directories, database schema)
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" setup
# Check system status (memory count, capabilities, db path)
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" status
Memories are stored in ~/.claude/pact-memory/memory.db using SQLite with:
When invoked via /pact-memory <command> "<args>":
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" save '<json>'
IMPORTANT: The argument is just a hint. You MUST construct a comprehensive memory object with ALL relevant fields. Never just save the raw string. Think of each memory as a detailed journal entry that your future self (or another agent) needs to fully understand what happened, why it mattered, and what was learned.
Required fields for every save:
| Field | Minimum Length | What to Include |
|---|---|---|
context | 3-5 sentences (paragraph) | Full background: what you were working on, why, what led to this point, relevant history, the state of things when this memory was created |
goal | 1-2 sentences | The specific objective, including success criteria if applicable |
lessons_learned | 3-5 items | Specific, actionable insights with enough detail to be useful months later. Each lesson should explain the "why" not just the "what" |
Recommended fields:
decisions: Key decisions made with full rationale, alternatives considered, and why they were rejectedentities: Components, files, services, APIs involved (enables graph-based retrieval)Writing comprehensive context:
BAD (too sparse):
"Debugging auth bug"
STILL BAD (single sentence):
"Debugging authentication failure in the login flow where users were getting 401 errors."
GOOD (comprehensive):
"Working on the fix/auth-refresh branch to resolve issue #234 where users reported intermittent 401 errors after being logged in for extended periods. The bug was reported by 3 enterprise customers last week and is blocking the v2.1 release. Initial investigation pointed to the token refresh mechanism, specifically a race condition between concurrent API requests. The authentication system uses JWT tokens with 15-minute expiry and a refresh token rotation pattern. This session focused on reproducing the bug locally by simulating high-latency conditions."
Example transformation:
# Agent is asked to save "figured out the auth bug"
# Construct the full memory object and save:
{
"context": "Working on the fix/auth-refresh branch to resolve issue #234 where users reported intermittent 401 errors after being logged in for extended periods. The bug was reported by 3 enterprise customers last week and is blocking the v2.1 release. Initial investigation pointed to the token refresh mechanism, specifically a race condition between concurrent API requests. The authentication system uses JWT tokens with 15-minute expiry and a refresh token rotation pattern. This session focused on reproducing the bug locally by simulating high-latency conditions and tracing through the token refresh flow.",
"goal": "Identify and fix the root cause of intermittent authentication failures that occur after extended user sessions, ensuring the fix doesn't introduce performance regressions.",
"lessons_learned": [
"The token refresh mechanism had a race condition: when multiple API requests detected an expired token simultaneously, each would trigger its own refresh, causing token rotation conflicts where subsequent requests used invalidated tokens",
"Adding a mutex/lock around the token refresh operation prevents concurrent refresh attempts - the first request refreshes while others wait and then use the new token",
"The bug only manifests under high latency conditions (>500ms API response time) because faster responses complete before the token expiry window, making it hard to reproduce in development",
"Our existing retry logic actually made the problem worse by immediately retrying with the same stale token instead of waiting for the refresh to complete",
"Integration tests should include latency simulation to catch timing-dependent bugs like this"
],
"decisions": [
{
"decision": "Use mutex pattern for token refresh instead of request queuing",
"rationale": "Simpler implementation with less state to manage. A mutex ensures only one refresh happens at a time while other requests wait. Our concurrency level (typically <10 concurrent requests) doesn't warrant the complexity of a full request queue.",
"alternatives": ["Request queue with single refresh - more complex, better for high concurrency", "Optimistic token prefetch - would require predicting refresh timing", "Retry with backoff - doesn't solve the root cause, just masks it"]
}
],
"entities": [
{"name": "AuthService", "type": "service", "notes": "Central authentication service handling login, logout, and token management"},
{"name": "TokenManager", "type": "class", "notes": "Manages JWT token lifecycle including refresh logic"},
{"name": "src/auth/refresh.ts", "type": "file", "notes": "Contains the token refresh implementation where the bug was fixed"}
]
}
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" search "<query>"
Returns semantically similar memories. Use natural language queries.
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" list --limit 10
Shows recent memories (default: 20).
save command verifies persistence by reading back the saved memory. If verification fails (exit code 2, error type SYSTEM_ERROR), the save silently failed — retry or check system statusThe PACT framework operates with multiple memory layers. Understanding their distinct roles prevents duplication and ensures the right tool is used for the right purpose.
| Layer | Storage | Content | Who Writes | Auto-Loaded |
|---|---|---|---|---|
| Auto-memory (MEMORY.md) | ~/.claude/projects/{hash}/memory/ | Free-form session learnings, user preferences, general patterns | Platform (automatic) | Yes (first 200 lines) |
| pact-memory (SQLite) | ~/.claude/pact-memory/memory.db | Structured institutional knowledge: context, goals, decisions, lessons, entities | Agents via this skill | Via Working Memory sync to CLAUDE.md |
| Agent persistent memory | ~/.claude/agent-memory/<name>/ | Per-agent domain expertise accumulated across sessions | Individual agents (automatic) | Yes (first 200 lines, per agent) |
pact-memory's unique value: Structured fields (context, goal, decisions, lessons_learned, entities) enable semantic search, graph-enhanced retrieval, and cross-agent knowledge sharing -- capabilities that auto-memory's free-form markdown does not provide.
Coexistence model: Auto-memory captures broad session context automatically. pact-memory captures deliberate, structured knowledge at PACT phase boundaries. The Working Memory section in CLAUDE.md shows the 3 most recent pact-memory entries, providing structured context that complements auto-memory's general learnings.
The memory skill integrates with PACT phases:
See references/memory-patterns.md for detailed usage patterns.