Skip to content
Back to skills

Compound Memory

ASecurity

Extract session patterns via transcript analysis to project memory

  • 5 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added May 27, 2026
developmentgoshellbashdebugging

Security analysis

A100/100

Scanned May 27, 2026

npx -y skills add qGolem/orc --skill compound-memory --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Compound Memory?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Compound Memory
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/qgolem-compound-memory/badge)](https://www.skillsdirectory.com/skills/qgolem-compound-memory)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
description: Extract session patterns via transcript analysis to project memory
argument-hint: (no arguments)
allowed-tools:
  - Bash(ls:*)
  - Bash(jq:*)
  - Bash(wc:*)
  - Bash(cat:*)
  - Bash(date:*)
  - Bash(mkdir:*)
  - Read
  - Write
  - Edit
  - Glob
model: inherit
context: inherit
hooks: {}
user-invocable: true
disable-model-invocation: true
---

# Compound Memory

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

<progress>
- [ ] 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
</progress>

<purpose>
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.
</purpose>

<constraints>
**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
</constraints>

<antipatterns>
**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
</antipatterns>

## 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 << 'JQEOF'
if .type == "user" then
  .message.content |
  if type == "string" then
    "USER: " + .
  elif type == "array" then
    [ .[] |
      if .type == "text" then .text
      elif .type == "tool_result" then
        (.content |
          if type == "string" then .[0:100]
          elif type == "array" then
            [.[] | select(.type == "text") | .text[0:100]] | join(" ")
          else "" end
        ) | if . != "" then "RESULT: " + . else empty end
      else empty end
    ] | map(select(. != "")) | join("\n") |
    if . != "" then "USER:\n" + . else empty end
  else empty end
elif .type == "assistant" then
  [ .message.content // [] | .[] |
    if .type == "text" then .text
    elif .type == "tool_use" then
      "TOOL: " + .name + "(" + (.input | tostring | .[0:100]) + ")"
    else empty end
  ] | map(select(. != "")) | join("\n") |
  if . != "" then "ASSISTANT:\n" + . else empty end
else empty end
JQEOF
```

```bash
PROJECT_PATH=$(pwd | sed 's|/|-|g' | sed 's|^-||')
CONVO_DIR=~/.claude/projects/-${PROJECT_PATH}
MEMORY_DIR=~/.claude/projects/-${PROJECT_PATH}/memory

# Get the MOST RECENT file (current session)
CURRENT=$(ls -t "$CONVO_DIR"/*.jsonl 2>/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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.