Parse memory.yaml and consolidate recurring patterns into skills. Use when memory.yaml grows large, when patterns recur 3+ times, or during RSID Ideate stage. Automates the memory-to-skill pipeline.
Turn accumulated learnings into durable skill improvements.
memory.yaml exceeds ~10 tasksβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. PARSE: Read memory.yaml, extract all learnings β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. GROUP: Cluster similar learnings by topic/domain β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. THRESHOLD: Identify clusters with 3+ learnings β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 4. MAP: Determine which skill each cluster should update β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 5. GENERATE: Create skill updates (new sections, anti-patterns) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 6. ARCHIVE: Move consolidated memories to memory-archive.yaml β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Read instructions/improvements/memory.yaml and extract structured data:
# Expected structure
memories:
- task: string # Task identifier
date: string # YYYY-MM-DD
context: string # Background
learnings:
- type: string # command-correction|q-and-a|misconception|pattern|insight
summary: string # One-line
detail: string # Full explanation
Extract into flat list:
interface Learning {
task: string;
date: string;
type: 'command-correction' | 'q-and-a' | 'misconception' | 'pattern' | 'insight';
summary: string;
detail: string;
context: string; // From parent task
}
Cluster learnings using these heuristics:
Look for shared keywords in summaries:
| Keywords | Likely Domain |
|---|---|
sandbox, permission, operation not permitted |
Environment/Sandbox |
contract, port, deps, interface |
Architecture/Coding-patterns |
PR, merge, commit, branch |
Git/Workflow |
skill, SKILL.md, description |
Skill-writing |
RSID, loop, memory, reflection |
Meta/RSID |
| Type | Typical Destination |
|---|---|
command-correction |
coding-loop (commands section) or specific skill |
q-and-a |
Relevant skill's FAQ or quick reference |
misconception |
Anti-patterns section of relevant skill |
pattern |
Core patterns of relevant skill |
insight |
Context or principles section |
The Rule: 3+ similar learnings β consolidation candidate.
For each cluster:
If learnings.length >= 3:
β Ready for consolidation
Else if learnings.length == 2:
β Watch list (note but don't consolidate yet)
Else:
β Keep in memory.yaml, not yet a pattern
| Topic/Keywords | Target Skill | Section to Update |
|---|---|---|
| Sandbox, permissions, heredocs | devcontainer-sandboxing |
Workarounds |
| Contracts, ports, deps, architecture | coding-patterns |
Core Principles or Anti-Patterns |
| Plans, alternatives, experts | plan-writing |
Self-Check or Anti-Patterns |
| Commits, branches, git | effective-git |
Phase guidance |
| PRs, merging, review workflow | pull-request |
PR workflow |
| RSID, loops, reflection | rsid |
Loop guidance |
| Skills, descriptions, triggers | writing-claude-skills |
Best Practices |
| Memory, consolidation | memory-consolidation |
This skill |
Is it about how code should be structured?
βββ YES β coding-patterns
βββ NO β Is it about git/commits/PRs?
βββ YES β Is it about commit messages?
β βββ YES β effective-git
β βββ NO β pull-request or coding-loop
βββ NO β Is it about environment/sandbox?
βββ YES β devcontainer-sandboxing
βββ NO β Is it about planning?
βββ YES β plan-writing
βββ NO β Is it about skills themselves?
βββ YES β writing-claude-skills
βββ NO β rsid (meta-level)
### [Pattern Number]. [Pattern Name]
**The Problem**: [What goes wrong without this pattern]
**The Pattern**:
[Extracted and generalized from the learnings]
**Examples**:
[Concrete examples from the memory entries]
### The "[Misconception Name]" Anti-Pattern
**Wrong:**
> [The incorrect belief, quoted from memories]
**Right:**
> [The correction, synthesized from learnings]
**Why it matters:**
[Consequences of the misconception]
### [Command/Approach]
**Fails with:** `[error message]`
**Use instead:**
```bash
[corrected command]
Why: [Root cause explanation]
### For Q&A β Add to Quick Reference
```markdown
| Question | Answer |
|----------|--------|
| [Q from memory] | [A from memory] |
**Key Insight:** [Insight summary]
[Detailed explanation from memory, generalized]
After updating skills, move consolidated memories to memory-archive.yaml:
# instructions/improvements/memory-archive.yaml
archived:
- consolidated_date: "2024-12-15"
consolidated_into: "coding-patterns"
pattern_name: "No Fake Defaults"
memories:
- task: "add-rsid-skill"
date: "2024-12-15"
type: "pattern"
summary: "No fake defaults for required dependencies"
# ... full original entry
- consolidated_date: "2024-12-15"
consolidated_into: "devcontainer-sandboxing"
pattern_name: "Heredoc Sandbox Restriction"
memories:
- task: "add-plan-writing-skill"
# ... full original entry
Archive Entry Structure:
archived:
- consolidated_date: string # When consolidation happened
consolidated_into: string # Which skill was updated
pattern_name: string # Name given to the pattern
memories: Learning[] # Original memory entries
Before consolidating, verify:
# From memory.yaml
- task: "add-plan-writing-skill"
learnings:
- type: "command-correction"
summary: "Heredocs fail in sandbox"
detail: "git commit with heredoc fails..."
- task: "feature-x"
learnings:
- type: "command-correction"
summary: "Temp files blocked in sandbox"
detail: "mktemp fails with operation not permitted..."
- task: "feature-y"
learnings:
- type: "insight"
summary: "Sandbox restricts /tmp writes"
detail: "Only /tmp/claude/ is writable..."
Target: devcontainer-sandboxing or coding-loop
### Sandbox File System Restrictions
The Claude Code sandbox restricts file system writes:
| Location | Writable | Notes |
|----------|----------|-------|
| `/tmp/` | NO | Use `/tmp/claude/` instead |
| `/tmp/claude/` | YES | TMPDIR is set here |
| Heredocs | NO | Can't create temp files for here-documents |
**Workarounds:**
1. **Heredocs**: Use inline multiline strings instead
```bash
# Instead of: git commit -m "$(cat <<'EOF' ... EOF)"
git commit -m "message line 1
line 2"
/tmp/claude/ or set TMPDIR explicitlyexport TMPDIR=/tmp/claude
mktemp # Now works
### Output: Archive Entry
```yaml
archived:
- consolidated_date: "2024-12-15"
consolidated_into: "coding-loop"
pattern_name: "Sandbox File System Restrictions"
section_added: "## Sandbox File System Restrictions"
memories:
- task: "add-plan-writing-skill"
type: "command-correction"
summary: "Heredocs fail in sandbox"
# ... full entry
- task: "feature-x"
type: "command-correction"
summary: "Temp files blocked in sandbox"
# ... full entry
- task: "feature-y"
type: "insight"
summary: "Sandbox restricts /tmp writes"
# ... full entry
This skill is invoked during the Ideate stage of RSID:
USER-DRIVEN: Listen β Execute β Reflect
β (memories recorded)
AUTONOMOUS: Ideate β INVOKE memory-consolidation HERE β Execute β Reflect
(patterns consolidated, skills updated)
When Ideate finds consolidation candidates:
Parse β Group β Threshold (3+) β Map β Generate β Archive
| Step | Action |
|---|---|
| Parse | Read memory.yaml, extract flat learning list |
| Group | Cluster by keywords and type |
| Threshold | 3+ similar β consolidate |
| Map | Determine target skill and section |
| Generate | Create update following templates |
| Archive | Move to memory-archive.yaml |