Patterns

Patterns are reusable knowledge snippets that MUR learns from your coding sessions and injects into your AI tools.

What Are Patterns?

When you work with AI coding assistants, you teach them things:

  • "Always use @Test macro instead of func test...()"
  • "Our API responses follow this JSON structure"
  • "We use Result types for error handling"

These learnings are patterns. MUR captures them so you don't repeat yourself — and all your AI tools benefit.

Pattern Format (v2)

Patterns are YAML files stored in ~/.mur/patterns/:

schema: 2
name: swift-testing-macro
description: Prefer Swift Testing over XCTest
content:
  technical: |
    Use @Test macro instead of func test...()
    Use #expect() instead of XCTAssert
    Use @Suite for test organization
  principle: |
    Swift Testing is more expressive and supports async natively.
    It's the future of testing in Swift.
tier: project
importance: 0.8
confidence: 0.7
maturity: stable
tags:
  languages: [swift]
  topics: [testing]
applies:
  languages: [swift]

Dual-Layer Content

v2 patterns have two content layers:

  • technical — Specific instructions, code examples, concrete rules
  • principle — The reasoning behind the pattern, when to apply it

This helps AI tools understand both what to do and why.

Pattern Tiers

Tiers control how long a pattern persists before decay:

TierHalf-LifeUse Case
Session14 daysQuick notes, experimental patterns
Project90 daysProject-specific conventions
Core365 daysUniversal knowledge, always relevant

Promote patterns as they prove their value:

mur promote swift-testing-macro --tier mur

Maturity Lifecycle

Patterns progress through maturity stages based on real usage:

Draft → Emerging → Stable → Canonical
StageMeaning
DraftNewly created, unvalidated
EmergingHas some positive feedback
StableConsistently helpful, well-tested
CanonicalEstablished best practice

Run mur evolve to evaluate and promote/demote patterns based on usage data.

Automatic Decay

MUR uses an exponential half-life system — unused patterns gradually fade:

  • Patterns that get injected and receive positive feedback stay strong
  • Patterns that are never used slowly lose importance
  • Pinned patterns skip decay entirely: mur pin <name>
  • Muted patterns are skipped during injection: mur mute <name>

Run mur gc to garbage collect patterns that have decayed below the threshold.

Pattern Management

# Create interactively
mur new

# Create with a diagram attachment
mur new --diagram architecture.mmd

# View details
mur pattern show swift-testing-macro

# Search by meaning
mur search "how to handle authentication"

# Boost importance
mur boost swift-testing-macro

# See connections
mur links swift-testing-macro

# Deprecate
mur deprecate old-pattern

Confidence & Importance

  • Importance (0.0–1.0) — How critical the pattern is. Higher = injected more often.
  • Confidence (0.0–1.0) — How reliable the pattern is. Increases with positive feedback.

Pattern Linking

Patterns can have bidirectional links (Zettelkasten-style), allowing you to build a knowledge graph:

mur links swift-testing-macro
# Shows: related-to: swift-async-testing, error-handling-swift

Diagram Attachments

Attach Mermaid or PlantUML diagrams to patterns:

mur new --diagram auth-flow.mmd

Diagrams are inline-injected with the pattern content during injection.

See Also