Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

pact-memory契约记忆

Agent Skill

pact-memory 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

594

周安装

25

GitHub Stars

62

下载量

208
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:pact-memory(契约记忆)
来源仓库:https://github.com/profsynapse/pact-plugin
仓库路径:skills/pact-memory
安装命令:
npx skills add https://github.com/profsynapse/pact-plugin --skill pact-memory
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/profsynapse/pact-plugin --skill pact-memory

简介

pact-memory 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。

  • 它适用于研究检索类任务,可结合来源仓库和原始 README 核验具体用法。
  • 安装方式:通过 npx skills add 命令从 GitHub 仓库安装。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

PACT Memory Skill

Persistent memory system for PACT framework agents. Store and retrieve context, goals, lessons learned, decisions, and entities across sessions with semantic search.

Overview

The PACT Memory skill provides:

  • Rich Memory Objects: Store context, goals, tasks, lessons, decisions, and entities
  • Semantic Search: Find relevant memories using natural language queries
  • Graph-Enhanced Retrieval: Memories linked to files are boosted when working on related files
  • Session Tracking: Automatic file tracking and session context
  • Cross-Session Learning: Memories persist across sessions for cumulative knowledge

Quick Start

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 (scalar fields replace; list fields merge additively)
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

Memory Structure

Each memory can contain:

FieldTypeDescription
contextstringCurrent working context description
goalstringWhat you're trying to achieve
active_taskslistTasks with status and priority
lessons_learnedlistWhat worked or didn't work
decisionslistDecisions with rationale and alternatives
entitieslistReferenced components, services, modules
reasoning_chainslistHow key decisions connect — "X because Y, which required Z"
agreements_reachedlistWhat was verified via teachback or agreement check
disagreements_resolvedlistWhere agents disagreed and how it was settled
fileslistAssociated file paths (auto-linked)
project_idstringAuto-detected from environment
session_idstringAuto-detected from environment

Task Format

{"task": "Implement token refresh", "status": "in_progress", "priority": "high"}

Decision Format

{
    "decision": "Use Redis for caching",
    "rationale": "Fast, supports TTL natively",
    "alternatives": ["Memcached", "In-memory LRU"]
}

Entity Format

{"name": "AuthService", "type": "component", "notes": "Handles all auth flows"}

CLI Reference

Commands

CommandDescriptionOutput
save <json>Save a memory object{"memory_id": "<hex>"}
save --stdinSave from piped JSON{"memory_id": "<hex>"}
search <query>Semantic search[{"id": "...", "context": "...",...},...]
search <query> --limit NSearch with limit[...] (default: 5)
search <query> --current-file <path>Search with graph boosting[...] (boosts file-related memories)
listList recent memories[{"id": "...", "context": "...",...},...]
list --limit NList with limit[...] (default: 20)
get <id>Get memory by ID{"id": "...", "context": "...",...}
update <id> <json>Update memory fields (list fields merge additively){"memory_id": "<hex>"}
update <id> --stdinUpdate from piped JSON{"memory_id": "<hex>"}
update <id> <json> --replaceReplace list fields wholesale instead of merging{"memory_id": "<hex>"}
delete <id>Delete a memory{"deleted": true, "memory_id": "<hex>"}
statusSystem status{"memory_count": N, "db_path": "...",...}
setupInitialize system{"status": "ready", "message": "..."}

Exit Codes

CodeMeaning
0Success
1User error (bad args, invalid JSON, not found)
2Validation error (unknown field name, unknown sub-object key) — the error envelope includes an allowed_fields list

Update Semantics

update uses additive merge with content-hash dedup for list-valued fields (lessons_learned, reasoning_chains, agreements_reached, disagreements_resolved, active_tasks, decisions, entities). Scalar fields (context, goal, etc.) still replace on update.

  • Passing {"lessons_learned": ["new lesson"]} appends to the existing list; duplicate items (by content hash) are silently deduplicated, so repeated saves are idempotent.
  • Pass --replace when you intentionally want to remove items from a list by overwriting it wholesale.
  • Unknown top-level fields (e.g. {"foo": 1}) raise ValueError with exit code 2 instead of silently disappearing. Likewise, unknown sub-object keys (e.g. {"entities": [{"description": "…"}]} — the field is notes, not description) raise ValueError.

This prevents partial-list updates from silently clobbering the entire column.

Examples

# 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 — additive list merge (default)
# This APPENDS "New lesson" to the existing lessons_learned list; any
# existing lessons are preserved. Scalar fields like "goal" still replace.
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" update abc123 \
  '{"goal": "Updated goal", "lessons_learned": ["New lesson"]}'

# Update with wholesale list replacement (--replace)
# Use this ONLY when you intentionally want to remove items from a list.
# After this call, lessons_learned contains exactly ["Only lesson that matters"]
# and nothing else.
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" update abc123 \
  '{"lessons_learned": ["Only lesson that matters"]}' --replace

# Delete a memory
python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" delete abc123

Search Capabilities

Semantic Search

Uses embeddings to find semantically similar memories. Requires either:

  • sqlite-lembed with GGUF model (preferred)
  • sentence-transformers (fallback)

Graph-Enhanced Search

When searching while working on a file, memories linked to:

  • The current file
  • Files imported by/importing the current file
  • Files modified in the same session

...are boosted in ranking.

Keyword Fallback

If embeddings are unavailable, falls back to substring matching across context, goal, lessons_learned, and decisions fields.

Setup

Dependencies

# Required for database
pip install sqlite-vec

# For local embeddings (recommended)
pip install sqlite-lembed

# Alternative embedding backend
pip install sentence-transformers

Initialize and Check Status

# 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

Storage

Memories are stored in ~/.claude/pact-memory/memory.db using SQLite with:

  • WAL mode for crash safety
  • Vector extensions for semantic search
  • Graph tables for file relationships

Command Line Usage

When invoked via /pact-memory <command> "<args>":

Save Command

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:

FieldMinimum LengthWhat to Include
context3-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
goal1-2 sentencesThe specific objective, including success criteria if applicable
lessons_learned3-5 itemsSpecific, 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 rejected
  • entities: 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"}
    ]
}

Search Command

python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" search "<query>"

Returns semantically similar memories. Use natural language queries.

List Command

python3 "${CLAUDE_SKILL_DIR}/scripts/cli.py" list --limit 10

Shows recent memories (default: 20).

Best Practices

  1. Save at Phase Completion: Save memories after completing PACT phases
  2. Include Lessons: Always capture what worked and what didn't
  3. Document Decisions: Record rationale and alternatives considered
  4. Link Entities: Reference components for better graph connectivity
  5. Search Before Acting: Check for relevant past context before starting work
  6. Write Complete Sentences: Context should be a full description, not a fragment
  7. Be Specific in Lessons: "X didn't work because Y" is better than "X didn't work"
  8. Check Save Results: The 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 status

Memory Layers: pact-memory vs Auto-Memory

The PACT framework operates with multiple memory layers. Understanding their distinct roles prevents duplication and ensures the right tool is used for the right purpose.

LayerStorageContentWho WritesAuto-Loaded
Auto-memory (MEMORY.md)~/.claude/projects/{hash}/memory/Free-form session learnings, user preferences, general patternsPlatform (automatic)Yes (first 200 lines)
pact-memory (SQLite)~/.claude/pact-memory/memory.dbStructured institutional knowledge: context, goals, decisions, lessons, entitiesAgents via this skillVia Working Memory sync to CLAUDE.md
Agent persistent memory~/.claude/agent-memory/<name>/Per-agent domain expertise accumulated across sessionsIndividual 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.

Integration with PACT

The memory skill integrates with PACT phases:

  • Prepare: Search for relevant past context before starting
  • Architect: Record design decisions with rationale
  • Code: Save lessons learned during implementation
  • Test: Document test strategies and findings

See references/memory-patterns.md for detailed usage patterns.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.36%
按下载量换算74

Claude

31.45%
按下载量换算65

Cursor

20.37%
按下载量换算42

Gemini CLI

9.8%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills