---
name: memory-rules
description: Rules for what to store in persistent memory and how to format it. Load this skill whenever working with the memory tool.
---

# Memory Rules

Activate these rules whenever saving or updating memory (`memory` tool).

## Always remember
- **Project status changes** — what moved, what got blocked, what shipped
- **Decisions made + reason** — why you chose option A over B
- **Infrastructure changes** — ports, services, domains, configs
- **Errors solved** — symptom + root cause + fix
- **User preferences revealed in conversation** — especially corrections and pet peeves

## Never remember
- ❌ Temporary debug output
- ❌ Speculative ideas not confirmed by user
- ❌ Sensitive credentials or tokens (use environment variables or secret store)
- ❌ Task progress, session outcomes, completed-work logs (use `session_search` to recall past sessions)
- ❌ Temporary TODO state

## Memory format

Use the **subject -> relation -> object** triple format where possible:

```
GoClaw -> RUNS_ON -> port 18790
Valentin -> PREFERS -> free tools over paid
Sailor.bar -> STACK -> Vite + React + Tailwind
```

This makes memories compact, queryable, and easy to maintain.

## Priority
1. User preferences and corrections (highest priority — prevents repeated steering)
2. Environment facts (OS, tools, project structure)
3. Procedural knowledge (non-obvious workflows, pitfalls)

## When to save
- User corrects you or says "remember this" / "don't do that again"
- User shares a preference, habit, or personal detail
- You discover something about the environment
- You learn a convention, API quirk, or workflow specific to this setup
- A stable fact surfaces that will be useful in future sessions

## When NOT to save (redundant or obvious)
- Trivial/obvious info easily re-discovered
- Raw data dumps
- Temporary task state
- Things the user can quickly re-explain

---

# Memory Workflow (practical)

## Known limits (discovered experimentally)
- **User profile** (`target='user'`): max **1,375 chars**
- **Memory** (`target='memory'`): max **2,200 chars**
- No `list` action exists — you cannot enumerate entries. Track what you've stored via `remove`/`replace` result messages.

## Chunking strategy for large content

When content exceeds the limit, split into **multiple entries** with clear `## Section` headings:

```
### Good — 3 entries fitting within limits:
1. ## Identity & Work style
2. ## Communication & Principles
3. ## Projects & Ecosystem
```

Each chunk independently compresses into the available space.

## Error recovery: "would exceed limit"

If `replace` fails with `"Replacement would put memory at N/M chars"`:

1. First `remove` old entries matching a substring to free space
2. Then `add` the new content in chunks
3. Or: shorten the replacement content aggressively (trim adjectives, merge sections)

## Best compression (fits more)
- **Triple format** (`Subject -> VERB -> Object`) compresses ~2-3x vs prose
- Pipe-separated lists for multiple items: `Free before paid | Existing before new | v1 before v2`
- One-liner per fact, no full sentences where possible
