dream
The dream command consolidates project memory by deduplicating, resolving contradictions, and pruning stale entries from MEMORY.md and the Project Learnings section of CLAUDE.md. Use this slash command after major refactors or significant development sessions to maintain a clean, accurate knowledge base that mirrors the current project state without modifying source code.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/solanabr/solana-ai-kit/HEAD/.claude/commands/dream.md -o ~/.claude/commands/dream.mddream.md
<!-- Schema adapted from the learn skill (gstack via sendaifun/solana-new), MIT © 2026 SendAI and Superteam. Local-only — no sync, no telemetry. -->
You are consolidating this project's memory. Like sleep, this pass doesn't add new knowledge — it merges duplicates, resolves contradictions, discards what's stale, and strengthens what's proven. Touch ONLY `MEMORY.md` and (with confirmation) the `## Project Learnings` section of `CLAUDE.md`. Never modify project code.
## Learning Schema
Every entry in `MEMORY.md` is typed and structured. Sections: `## Patterns`, `## Pitfalls`, `## Preferences`, `## Architecture`, `## Tools`.
```markdown
### kebab-case-key
- **Insight:** One clear sentence
- **Confidence:** N/10
- **Source:** command/agent/session that produced it (e.g. debug-user-tx, manual)
- **Files:** relative/path.rs, other/path.ts (optional)
- **Date:** YYYY-MM-DD
```
Entries missing fields get them backfilled during consolidation (unknown source → `legacy`, missing date → today, missing confidence → 5/10).
## Pipeline
### 1. Collect
- Read `MEMORY.md`. If missing, create it with the five section headers above and report "fresh memory initialized" — then skip to step 6.
- Read the `## Project Learnings` section of `CLAUDE.md` if present (subsections like Recurring Issues / Fix Patterns / Config Conventions). These are the already-exported, always-loaded learnings — treat them as the authoritative set when checking contradictions.
- Inventory: total entries, entries per section, malformed entries.
### 2. Dedupe / Merge
- Same key appearing more than once → keep the latest dated entry, fold any extra detail from older ones into its Insight, take the max confidence. Older duplicates are deleted (consolidation is the one place append-only history gets compacted).
- Different keys, same meaning (read the insights, don't just string-match) → merge under the clearer key, note the alias in the Insight if useful.
### 3. Contradiction Check
- Same topic, opposing advice ("use X" vs "avoid X") — within MEMORY.md, or between MEMORY.md and CLAUDE.md Project Learnings.
- Resolution order: (a) higher confidence + newer date wins; (b) if the referenced files reveal which is currently true, verify against the code; (c) genuinely ambiguous → ask the user, presenting both entries.
- The losing entry is deleted, and the winner's Insight gains a one-line "supersedes: <old-key>" note.
### 4. Prune
Flag for removal:
- **Dead references** — any entry whose Files no longer exist (check with Glob; if some files survive, just trim the Files list)
- **Stale** — confidence ≤ 4 AND older than 90 days with no re-confirmation
- **Transient leftovers** — entries describing in-progress work, old branch state, or one-off incidents that can't recur
- **Redundant** — restates something already in README/CLAUDE.md verbatim
Auto-remove dead references and transient leftovers. For stale-but-plausible entries, ask the user: remove / keep (re-date to today) / update insight.
### 5. Re-rank
Within each section, order entries by confidence descending, then date descending. Highest-signal knowledge reads first.
### 6. Write Back (cap enforcement)
`MEMORY.md` loads every session start — hard cap **200 lines / 25KB**, index-pointer style (one-line insights pointing at files, not essays). The richer typed fields (confidence, dates, insight) used during steps 2–5 are processing-only — the written `MEMORY.md` keeps the index-pointer format, with that metadata living in the linked detail files, not the index.
- If over cap after steps 2–5: compress Insights to one line, drop optional Files where obvious, then remove lowest-confidence entries until under cap (tell the user what was cut).
- Write the consolidated file. Show a before/after diff summary, not the full file.
### 7. Export to CLAUDE.md (optional, confirm first)
An entry graduates from MEMORY.md to CLAUDE.md `## Project Learnings` when ALL hold:
- Confidence ≥ 8/10
- Survived at least one prior consolidation (≥ 30 days old or re-confirmed)
- General — applies to the whole project, not one file's quirk
- Short — exports as a single bullet: `- **key:** insight (N/10)`
Propose the export list; on confirmation append bullets under the matching subsection and remove the originals from MEMORY.md (CLAUDE.md is always loaded — keeping both wastes tokens).
## Write / Don't-Write Rules
| Write | Never write |
|-------|-------------|
| Reusable patterns, pitfalls that cost > 10 min, user preferences, architecture decisions with trade-offs, tool choices with reasons | Secrets, keys, tokens, wallet addresses tied to the user, or anything resembling credential material |
| One-line insights + file pointers | File contents, code blocks > 3 lines, command transcripts |
| Confirmed, dated knowledge | Transient state: current branch, in-flight tasks, TODO lists, session-specific context |
| | Anything already stated in README or CLAUDE.md |
If a candidate entry contains something from the "never" column, strip it or drop the entry — there is no exception path.
## Output
```
## Dream Report — <date>
| Stage | Result |
|-------|--------|
| Collected | N entries (P pat / Q pit / R pref / S arch / T tool), M malformed fixed |
| Merged | N duplicates folded |
| Contradictions | N resolved (list keys), N escalated to user |
| Pruned | N removed (dead refs: n, stale: n, transient: n) |
| Exported | N promoted to CLAUDE.md (or "none proposed") |
| Size | X lines / Y KB (cap: 200 / 25KB) ✓ |
```
## Checklist
- [ ] MEMORY.md read (or initialized) and CLAUDE.md Project Learnings collected
- [ ] Duplicates merged — latest wins, max confidence kept
- [ ] Contradictions resolved or escalated, never left side by side
- [ ] Every Files reference existence-checked before keeping
- [ ] No secrets / transient state / CLAUDE.md duplicates written
- [ ] Final MEMORY.md ≤ 200 lines and ≤ 25KB
- [ ] Exports confirmed with the user before touching CLAUDE.md
- [ ] Dream report printeAnchor framework specialist for rapid Solana program development. Use for building programs with Anchor macros, IDL generation, account validation, and standardized patterns. Prioritizes developer experience while maintaining security.\\n\\nUse when: Building new programs quickly, team projects needing standardization, projects requiring IDL for client generation, or when developer experience is prioritized over maximum CU optimization.
DeFi integration specialist for composing with Solana protocols including Jupiter, Drift, Kamino, Raydium, Orca, Meteora, Marginfi, and Sanctum. Handles swap routing, lending/borrowing, staking, liquidity provision, and oracle price feeds.\n\nUse when: Integrating DeFi protocols, building swap interfaces, implementing lending/borrowing, setting up yield strategies, working with Pyth/Switchboard oracles, or composing multi-protocol transactions.
CI/CD, infrastructure, and deployment specialist for Solana projects. Handles GitHub Actions, Docker, monitoring, RPC management, and Cloudflare Workers edge deployment.\n\nUse when: Setting up CI/CD pipelines, containerizing Solana validators or programs, configuring monitoring and alerting, managing RPC infrastructure, deploying edge workers, or automating build and deploy workflows.
Senior Solana game architect for game system design, Unity/C# architecture, on-chain game state, player progression, NFT integration, and PlaySolana ecosystem. Use for high-level game design decisions, architecture reviews, and planning complex game systems.\n\nUse when: Designing new Solana games from scratch, planning game state on-chain, Unity project architecture, integrating with PlaySolana/PSG1, or deciding between implementation approaches.
React Native and Expo specialist for building Solana mobile dApps. Handles mobile wallet adapter integration, transaction signing UX, deep linking, and mobile-specific performance optimization.\n\nUse when: Building React Native or Expo mobile apps with Solana integration, implementing mobile wallet adapter flows, setting up deep links for transaction signing, or optimizing mobile dApp performance.
CU optimization specialist using Pinocchio framework. Use for performance-critical programs requiring 80-95% CU reduction vs Anchor. Specializes in zero-copy access, manual validation, and minimal binary size.\\n\\nUse when: CU limits are being hit, transaction costs are significant at scale, binary size must be minimized, or maximum throughput is required.
Rust backend specialist for building async services that interact with Solana blockchain. Builds APIs, indexing services, and off-chain processing using Axum, Tokio, and modern async patterns.\n\nUse when: Building REST/WebSocket APIs for Solana dApps, implementing transaction indexers, creating webhook services, or any Rust backend that interacts with Solana.
Senior Solana program architect for system design, account structures, PDA schemes, token economics, and cross-program composability. Use for high-level design decisions, architecture reviews, and planning complex multi-program systems.\n\nUse when: Designing new programs from scratch, planning account structures, optimizing PDA schemes, reviewing architecture for security, or deciding between implementation approaches.