AgentSkillsCN

mnemonic-format

MIF 3级规范、记忆模板与格式化指南

SKILL.md
--- frontmatter
allowed-tools:
- Read
- Write
- Glob
- Bash
- Grep
description: MIF Level 3 specification, memory templates, and formatting guidelines
name: mnemonic-format
user-invocable: true
<!-- 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 -->

Mnemonic Format Skill

MIF Level 3 specification, templates, and formatting guidelines.

Trigger Phrases

  • "memory format"
  • "MIF format"
  • "frontmatter template"
  • "memory template"
  • "mnemonic schema"

Overview

MIF Level 3 specification. Start minimal, add fields as needed.


Quick Start: Minimal Memory

Only 4 fields are required. Everything else is optional.

yaml
---
id: 550e8400-e29b-41d4-a716-446655440000
title: "Human-readable title"
type: semantic
created: 2026-01-23T10:30:00Z
---

# Title

Content here.

That's it. Add optional fields only when you need them.


File Naming

code
{uuid}-{slug}.memory.md
  • uuid: Lowercase UUID v4
  • slug: URL-safe title, max 50 chars

Optional Fields Reference

Add these when relevant:

yaml
---
# REQUIRED (always include these 4)
id: 550e8400-e29b-41d4-a716-446655440000
title: "Human-readable title"
type: semantic
created: 2026-01-23T10:30:00Z

# COMMON (add when useful)
modified: 2026-01-23T14:22:00Z
namespace: _semantic/decisions/project
tags:
  - architecture
  - database

# === PROGRESSIVE DISCLOSURE ===
summary: "PostgreSQL chosen for ACID compliance and JSON support"
detail_level: comprehensive  # minimal | standard | comprehensive
related_memories: []  # UUIDs of related memories
supersedes: []  # UUIDs of memories this one replaces

# === BI-TEMPORAL TRACKING ===
temporal:
  valid_from: 2026-01-23T00:00:00Z    # When fact became true
  valid_until: null                    # When fact expired (null = current)
  recorded_at: 2026-01-23T10:30:00Z   # When captured in system
  ttl: P90D                            # ISO 8601 duration until expiry
  decay:
    model: exponential                 # Decay algorithm
    half_life: P7D                     # Time to 50% relevance
    strength: 0.85                     # Current relevance score 0-1
  access_count: 5                      # Times recalled
  last_accessed: 2026-01-23T14:22:00Z # Last recall timestamp

# === PROVENANCE ===
provenance:
  source_type: conversation            # user_explicit | inferred | conversation
  source_ref: file:///path/to/source.ts:42
  agent: claude-opus-4                 # Capturing agent
  confidence: 0.95                     # Certainty score 0-1
  session_id: abc123                   # Claude session ID

# === CODE STRUCTURE AWARENESS ===
code_refs:
  - file: src/auth/handler.ts
    line: 42
    symbol: authenticateUser
    type: function                     # function | class | method | variable | type

# === CITATIONS ===
citations:
  - type: documentation                # paper | documentation | blog | github | stackoverflow | article
    title: "Source Title"
    url: https://example.com/source
    author: "Author Name"              # optional
    date: 2026-01-23                   # publication date, optional
    accessed: 2026-01-23T10:30:00Z     # when accessed, optional
    relevance: 0.90                    # how relevant to memory 0.0-1.0, optional
    note: "Brief description"          # optional context

# === CONFLICT TRACKING ===
conflicts:
  - memory_id: xyz789
    resolution: merged                 # merged | invalidated | skipped
    resolved_at: 2026-01-23T12:00:00Z

# === COMPRESSION (Auto-generated) ===
summary: "Concise 2-3 sentence summary (max 500 chars)"  # Auto-generated by gc --compress
compressed_at: 2026-01-24T10:00:00Z                      # When compression occurred
---

# Memory Title

Main content in markdown format.

## Section 1

Detailed information...

## Rationale

Why this decision/pattern/learning matters.

## Relationships

- relates-to [[other-memory-id]]
- supersedes [[old-memory-id]]
- derived-from [[source-memory-id]]

## Entities

- mentions @[[PostgreSQL]]
- uses @[[JWT Authentication]]

Field Reference

Required Fields

FieldTypeDescription
idUUIDUnique identifier (v4, lowercase)
typeenumCognitive type: semantic, episodic, procedural
namespacestringCategory/scope: _semantic/decisions, _semantic/knowledge, _procedural/patterns, etc.
createdISO 8601Creation timestamp with timezone
titlestringHuman-readable title in quotes

Recommended Fields

FieldTypeDescription
modifiedISO 8601Last modification timestamp
tagslistCategorization tags (lowercase, hyphenated)

Progressive Disclosure Fields

FieldTypeDescription
summarystring1-2 sentence summary for Level 1 recall (max 200 chars)
detail_levelenumminimal, standard, comprehensive
related_memorieslistUUIDs of related memories for cross-reference
supersedeslistUUIDs of memories this one replaces

Temporal Fields

FieldTypeDescription
valid_fromISO 8601When the fact actually became true
valid_untilISO 8601When the fact became outdated (null if current)
recorded_atISO 8601When captured in the system
ttlISO 8601 durationTime-to-live (e.g., P90D = 90 days)
decay.modelstringexponential, linear, step
decay.half_lifeISO 8601 durationTime to 50% relevance
decay.strengthfloatCurrent relevance 0.0-1.0
access_countintegerNumber of recalls
last_accessedISO 8601Most recent recall

Provenance Fields

FieldTypeDescription
source_typeenumuser_explicit, inferred, conversation
source_refURISource location (file, URL, etc.)
agentstringAgent that captured (e.g., claude-opus-4)
confidencefloatCertainty score 0.0-1.0
session_idstringSession identifier

Code Reference Fields

FieldTypeDescription
filestringRelative file path
lineintegerLine number
symbolstringSymbol name
typeenumfunction, class, method, variable, type, module

Citation Fields

FieldTypeDescription
typeenumpaper, documentation, blog, github, stackoverflow, article (required)
titlestringHuman-readable title of source (required)
urlstringFull URL to source material (required)
authorstringAuthor name (optional)
datedatePublication date YYYY-MM-DD (optional)
accessedISO 8601When source was accessed (optional)
relevancefloatHow relevant to memory 0.0-1.0 (optional)
notestringBrief description of what this citation provides (optional)

Compression Fields (Auto-generated)

These fields are added automatically by /mnemonic:gc --compress:

FieldTypeDescription
summarystringConcise 2-3 sentence summary (max 500 chars)
compressed_atISO 8601When compression was performed

Compression is applied to memories that:

  • Are older than 30 days AND have > 100 lines, OR
  • Have strength < 0.3 AND have > 100 lines

The summary field enables quick scanning without reading full content. Original content is preserved.


Cognitive Memory Types

Semantic (Facts & Concepts)

Use for: API documentation, technical specifications, definitions, configurations

Indicators:

  • "X is Y"
  • Definitions
  • Documentation
  • Specifications
  • Configuration values

Example:

yaml
---
id: abc123
type: semantic
namespace: _semantic/knowledge/project
title: "REST API Authentication Endpoint"
tags:
  - api
  - authentication
---

# REST API Authentication Endpoint

POST /api/v1/auth/login

## Request
- email: string (required)
- password: string (required)

## Response
- token: JWT access token
- expires_in: seconds until expiry

Episodic (Events & Experiences)

Use for: Debug sessions, incidents, deployments, meetings, discoveries

Indicators:

  • "On [date], we..."
  • "When we tried..."
  • Timestamps
  • Narratives
  • Incident reports

Example:

yaml
---
id: def456
type: episodic
namespace: _episodic/sessions/blockers/project
title: "Database connection timeout incident"
tags:
  - incident
  - database
  - resolved
temporal:
  valid_from: 2026-01-20T14:30:00Z
  recorded_at: 2026-01-20T16:00:00Z
---

# Database Connection Timeout Incident

## What Happened
On 2026-01-20 at 14:30 UTC, production database connections started timing out.

## Root Cause
Connection pool exhaustion due to unclosed connections in the batch processor.

## Resolution
Added connection.close() in finally block. Deployed fix at 15:45 UTC.

## Prevention
- Added connection pool monitoring
- Set max connection lifetime to 5 minutes

Procedural (Processes & Workflows)

Use for: Deployment steps, configuration procedures, how-to guides, workflows

Indicators:

  • "To do X, first..."
  • Step-by-step instructions
  • Sequences
  • Procedures
  • Runbooks

Example:

yaml
---
id: ghi789
type: procedural
namespace: _procedural/patterns/project
title: "Database migration procedure"
tags:
  - database
  - deployment
  - procedure
---

# Database Migration Procedure

## Prerequisites
- Database backup completed
- Maintenance window scheduled
- Rollback script prepared

## Steps

1. Enable maintenance mode
   ```bash
   ./scripts/maintenance.sh enable
  1. Run migrations

    bash
    npm run db:migrate
    
  2. Verify migrations

    bash
    npm run db:verify
    
  3. Disable maintenance mode

    bash
    ./scripts/maintenance.sh disable
    

Rollback

If step 3 fails:

bash
npm run db:rollback
code

---

## Namespace Reference

| Namespace | Purpose | Memory Type |
|-----------|---------|-------------|
| `_semantic/decisions/` | Architectural choices, rationale | semantic |
| `_semantic/knowledge/` | APIs, context, learnings, security | semantic |
| `_semantic/entities/` | Entity definitions (technologies, components) | semantic |
| `_episodic/incidents/` | Production issues, postmortems | episodic |
| `_episodic/sessions/` | Debug sessions, work sessions | episodic |
| `_episodic/blockers/` | Impediments, issues | episodic |
| `_procedural/runbooks/` | Operational procedures | procedural |
| `_procedural/patterns/` | Code conventions, testing strategies | procedural |
| `_procedural/migrations/` | Migration steps, upgrade procedures | procedural |

### Memory Scope

- **Project**: `{org}/{project}/{namespace}/` - Specific to current codebase
- **Organization**: `{org}/{namespace}/` - Shared across projects in org

---

## Progressive Disclosure Structure

Every comprehensive memory should include three disclosure levels in the body:

### Level 1: Quick Answer (Default Recall)

The `## Quick Answer` section provides a 1-3 sentence summary. This is what Claude returns first when recalling a memory.

**Triggers for Level 1:** "What is X?", "Which X do we use?", basic recall

### Level 2: Context (Expanded Recall)

The `## Context` section provides:
- Decision date/timeframe
- Alternatives considered
- Key decision drivers
- Trade-offs made

**Triggers for Level 2:** "Why?", "Tell me more", "Explain the reasoning"

### Level 3: Comprehensive (Full Detail)

The `## Full Detail` section includes:
- Complete alternatives analysis
- Implementation notes
- Related decisions/patterns
- Code references
- Citations

**Triggers for Level 3:** "All details", "Full context", implementation work, debugging

### Progressive Disclosure Template

```markdown
# {Title}

## Quick Answer
{1-3 sentence summary answering "what" and "why briefly"}

## Context
- **Decision date:** {date}
- **Alternatives considered:** {list}
- **Key drivers:** {factors that led to decision}
- **Trade-offs:** {what was sacrificed}

## Full Detail

### Alternatives Analysis
1. **{Option 1}**: {pros/cons, why rejected or chosen}
2. **{Option 2}**: {pros/cons, why rejected or chosen}

### Implementation Notes
- {Specific implementation details}
- {Configuration requirements}
- {File locations}

### Related Decisions
- See: [[{related-memory-id}]] for {context}

### Code References
- {file:line} - {description}

### Citations
- {source title} - {url}

Relationship Syntax

Memory Links

markdown
## Relationships

- relates-to [[550e8400-e29b-41d4-a716-446655440000]]
- supersedes [[old-memory-id]]
- derived-from [[source-memory-id]]
- contradicts [[conflicting-memory-id]]
- implements [[design-memory-id]]

Relationship Types

TypeMeaning
relates-toGeneral association
supersedesReplaces older memory
derived-fromBuilt upon another memory
contradictsConflicts with another memory
implementsRealizes a design/decision
blocksDependency relationship
blocked-byInverse dependency

Entity Syntax

Entity Mentions

markdown
## Entities

- mentions @[[PostgreSQL]]
- uses @[[JWT Authentication]]
- authored-by @[[John Smith]]
- located-in @[[src/auth/]]

Entity Types

TypeExamples
TechnologyPostgreSQL, Redis, Kubernetes
PatternFactory Pattern, Singleton
PersonTeam members, authors
LocationFile paths, directories
ConceptMicroservices, REST, GraphQL

Validation Rules

Required Checks

  1. id must be valid UUID v4 format
  2. type must be one of: semantic, episodic, procedural
  3. namespace must follow pattern: {namespace}/{scope}
  4. created must be valid ISO 8601 timestamp
  5. title must be non-empty string

Recommended Checks

  1. confidence should be between 0.0 and 1.0
  2. valid_from should be before or equal to recorded_at
  3. tags should be lowercase with hyphens
  4. code_refs.file paths should be relative

Citation Checks

Required if citations array exists:

  1. citations[].type must be one of: paper, documentation, blog, github, stackoverflow, article
  2. citations[].title must be non-empty string
  3. citations[].url must be valid URL format (https:// or http://)

Optional field validations: 4. citations[].relevance if present, should be between 0.0 and 1.0 5. citations[].date if present, should be valid YYYY-MM-DD format 6. citations[].accessed if present, should be valid ISO 8601 timestamp

File Naming

bash
# Generate compliant filename
UUID=$(uuidgen | tr '[:upper:]' '[:lower:]')
TITLE="My Memory Title"
SLUG=$(echo "$TITLE" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-' | head -c 50)
FILENAME="${UUID}-${SLUG}.memory.md"

Quick Templates

Minimal Memory

yaml
---
id: {uuid}
type: semantic
namespace: _semantic/knowledge/project
created: {timestamp}
title: "{title}"
summary: "{Brief summary for quick recall}"
detail_level: minimal
---

# {Title}

## Quick Answer
{Content - serves as both summary and full content for minimal memories}

Detail Level Guidelines

LevelWhen to UseTypical Content
minimalSimple facts, quick TILs, single-point learningsQuick Answer only
standardMost decisions, patterns with some rationaleQuick Answer + Context
comprehensiveArchitectural decisions, complex patterns, researchAll three levels

Decision Memory (with Progressive Disclosure)

yaml
---
id: {uuid}
type: semantic
namespace: _semantic/decisions/project
created: {timestamp}
title: "Decision: {what}"
tags:
  - architecture
summary: "{Brief 1-sentence summary of decision and key reason}"
detail_level: comprehensive
related_memories: []
supersedes: []
provenance:
  confidence: 0.95
---

# Decision: {What}

## Quick Answer
{What} was chosen for {primary reason}. This enables {key benefit}.

## Context
- **Decision date:** {date}
- **Alternatives considered:** {Option A}, {Option B}, {Option C}
- **Key drivers:**
  - {Driver 1}
  - {Driver 2}
- **Trade-offs:** {What was sacrificed for this choice}

## Full Detail

### Alternatives Analysis
1. **{Option A}**: {Description}
   - Pros: {pros}
   - Cons: {cons}
   - Verdict: {Chosen/Rejected because...}

2. **{Option B}**: {Description}
   - Pros: {pros}
   - Cons: {cons}
   - Verdict: {Rejected because...}

### Implementation Notes
- {Specific implementation details}
- {Configuration requirements}

### Related Decisions
- relates-to [[{related-decision-id}]]

## Relationships
- supersedes [[{old-decision-id}]] (if applicable)

Incident Memory

yaml
---
id: {uuid}
type: episodic
namespace: _episodic/sessions/blockers/project
created: {timestamp}
title: "Incident: {summary}"
tags:
  - incident
temporal:
  valid_from: {when_it_happened}
---

# Incident: {Summary}

## Timeline
- {time}: {event}

## Root Cause
{Why it happened}

## Resolution
{How it was fixed}

## Prevention
{How to prevent recurrence}

Research Memory with Citations

yaml
---
id: {uuid}
type: semantic
namespace: _semantic/knowledge/project
created: {timestamp}
title: "Learning: {topic}"
tags:
  - research
citations:
  - type: paper
    title: "Research Paper Title"
    url: https://arxiv.org/abs/...
    author: "Smith et al."
    date: 2025-11-15
    accessed: {timestamp}
    relevance: 0.95
    note: "Key finding about X"
  - type: documentation
    title: "Official Documentation"
    url: https://docs.example.com/...
    accessed: {timestamp}
    relevance: 0.85
---

# Learning: {Topic}

## Summary
{What you learned}

## Key Points
- {Point 1 from citation 1}
- {Point 2 from citation 2}

## Application
{How this applies to our project}