# Compound Memory

> Extract session patterns via transcript analysis to project memory

- **Type:** Skill
- **Install:** `agentstack add skill-qgolem-orc-compound-memory`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [qGolem](https://agentstack.voostack.com/s/qgolem)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [qGolem](https://github.com/qGolem)
- **Source:** https://github.com/qGolem/orc/tree/main/skills/compound-memory

## Install

```sh
agentstack add skill-qgolem-orc-compound-memory
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Compound Memory

Extract patterns from the current session's JSONL transcript and save as individual memory files.

- [ ] Step 1: Extract current session transcript
- [ ] Step 2: Analyze for pattern candidates
- [ ] Step 3: Draft as memory file
- [ ] Step 4: Dedup check
- [ ] Step 5: Self-evaluate
- [ ] Step 6: Present to user
- [ ] Step 7: Write to memory

Pattern crystallizer, not note-taker. You programmatically extract the current session's tool calls and results from JSONL, identify non-trivial patterns, and save them as individual memory files with frontmatter.

**Your role:**
- Extract current session from JSONL via jq
- Identify debugging paths, architecture seams, workaround branches
- Draft decision trees and self-evaluate against rubric
- Present and get user confirmation before writing

**Not your role:**
- Saving trivial fixes or language basics
- Writing without user confirmation
- Overwriting existing memory entries

**When to use:**
- End of session with non-trivial debugging, workarounds, architecture decisions, or integration patterns

**What NOT to extract:**
- Trivial fixes, one-time issues, language basics, things already in CLAUDE.md

**Avoid:**
- Saving prose summaries instead of decision trees
- Skipping the dedup check against existing memory files
- Lowering the quality threshold (all 5 dimensions must be >= 4/5)
- Writing to memory without user confirmation
- Analyzing from in-context memory instead of programmatic JSONL extraction

## Process

### Step 1: Extract Current Session Transcript

Write the jq filter to a file first (avoids zsh `!=` history expansion and nested quoting issues), then run it:

```bash
# Write jq filter to file to avoid shell quoting issues
cat > /tmp/memory-palace-filter.jq /dev/null | head -1)

jq -r -f /tmp/memory-palace-filter.jq "$CURRENT" > /tmp/memory-palace-session.txt 2>/tmp/memory-palace-debug.log

wc -l /tmp/memory-palace-session.txt
```

Read the extracted transcript.

### Step 2: Analyze for Pattern Candidates

Review the extracted content for:
- **Error resolution paths** — root cause → diagnosis → fix
- **Debugging decision trees** — symptom → checks → outcomes
- **Architecture/integration seams** — where components meet, why boundaries exist
- **Workaround branches** — what works, what doesn't, why

If nothing qualifies → stop, tell user "nothing worth saving in this session."

### Step 3: Draft as Memory File

Format each pattern as an individual file with frontmatter:

Filename convention: `{type}_{kebab-topic}.md` (e.g., `feedback_shell-quoting.md`)

Types: `user`, `feedback`, `project`, `reference`

```markdown
---
name: [Pattern Name]
description: [when to recall + what it solves — one line, specific enough to judge relevance]
type: feedback
---

├── [trigger or entry point]
│   ├── [condition A]
│   │   ├── [outcome] → [action]
│   │   └── [alternative] → [action]
│   └── [condition B]
│       └── [outcome] → [action]
├── seam: [component] ↔ [component]
│   └── decision: [why the boundary is here]
└── pitfall: [what goes wrong if you ignore this]
```

### Step 4: Dedup Check

Glob `$MEMORY_DIR/*.md` and read filenames + descriptions. If a file already covers this pattern (by filename or description overlap), either skip or propose updating the existing file.

### Step 5: Self-Evaluate

Score each candidate on this rubric (threshold: all >= 4/5):

| Dimension | 1 | 3 | 5 |
|-----------|---|---|---|
| Specificity | Abstract, no code | Has code example | Code + edge cases |
| Actionability | Unclear what to do | Main steps clear | Immediately executable |
| Scope Fit | Too broad/narrow | Mostly appropriate | Trigger + content aligned |
| Non-redundancy | Duplicate of existing | Partial overlap | Completely unique |
| Coverage | Fraction of target | Main cases covered | Main + edge + pitfalls |

**Pass: all dimensions >= 4.** One re-draft pass allowed; if still fails on any dimension, discard that entry.

### Step 6: Present to User

Present **one AskUserQuestion per pattern** so the user can approve/reject each individually. Each question uses a `preview` showing the full file as it'll be written.

```
For each candidate pattern:

AskUserQuestion:
  question: "Save as {type}_{kebab-topic}.md?"
  header: "Pattern N"
  options:
    - label: "Save"
      description: "[one-line summary of the pattern]"
      preview: |
        [Full file content including frontmatter]
    - label: "Skip"
      description: "Don't save this pattern"
```

Only write patterns the user explicitly approved. Do NOT proceed to Step 7 for skipped patterns.

### Step 7: Write to Memory

Write each approved pattern to its own file in `$MEMORY_DIR/` using the filename from Step 3.

Then update `$MEMORY_DIR/MEMORY.md` index — one line per file with description.

If `MEMORY.md` doesn't exist, create it. Format:

```markdown
# Memory Index

## Patterns
- `feedback_shell-quoting.md` — Shell quoting traps in zsh/awk
- `project_auth-rewrite.md` — Auth middleware rewrite context
```

- One line per file: filename + description
- Don't duplicate — match by filename
- Keep under 200 lines (only first 200 load into sessions)

## File Ownership

| File | Access | Purpose |
|------|--------|---------|
| `~/.claude/projects/-$PROJECT/*.jsonl` | Read only | Current session log |
| `$MEMORY_DIR/*.md` | Read only | Dedup check |
| `$MEMORY_DIR/MEMORY.md` | Read/Write | Index of memory files |
| `$MEMORY_DIR/{type}_{topic}.md` | Read/Write | Individual pattern files |
| `/tmp/memory-palace-session.txt` | Write | Extracted transcript |
| `/tmp/memory-palace-debug.log` | Write | jq error log |

## Skip Conditions

Skip if:
- No JSONL files found in project directory
- Session is trivial (no debugging, no architecture decisions, no workarounds)
- All candidate patterns already exist in memory files

Report "Nothing worth saving in this session." and exit.

## Completion Criteria

- [ ] Current session extracted via jq (not from in-context memory)
- [ ] Pattern candidates identified (or "nothing worth saving" reported)
- [ ] Decision trees drafted with branches, seams, and pitfalls
- [ ] Dedup check completed against existing memory files
- [ ] All 5 rubric dimensions scored >= 4/5
- [ ] User confirmed before writing
- [ ] Pattern written to individual file in $MEMORY_DIR/
- [ ] MEMORY.md index updated with file pointer

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [qGolem](https://github.com/qGolem)
- **Source:** [qGolem/orc](https://github.com/qGolem/orc)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-qgolem-orc-compound-memory
- Seller: https://agentstack.voostack.com/s/qgolem
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
