$npx -y skills add tody-agent/codymaster --skill cm-continuityWorking memory protocol — maintains context across sessions via CONTINUITY.md. Inspired by Loki Mode. Read at turn start, update at turn end. Captures mistakes and learnings to prevent repeating errors.
| 1 | # Continuity — Working Memory Protocol |
| 2 | |
| 3 | ## TL;DR |
| 4 | - **Use at** session start (read) and end (update) |
| 5 | - **File**: .cm/CONTINUITY.md (working memory) |
| 6 | - **Auto-loads**: recent learnings from .cm/learnings.jsonl |
| 7 | - **Loki Mode**: prevents repeating past mistakes |
| 8 | |
| 9 | > **Context persistence across sessions. Mistakes captured. Learnings applied.** |
| 10 | > Inspired by Loki Mode's CONTINUITY.md protocol (Autonomi). |
| 11 | |
| 12 | ## When to Use |
| 13 | |
| 14 | **ALWAYS** — This is a background protocol, not an explicit invocation. |
| 15 | |
| 16 | - **Start of every session:** Read `.cm/CONTINUITY.md` to orient yourself |
| 17 | - **End of every session:** Update `.cm/CONTINUITY.md` with progress |
| 18 | - **On error:** Record in Mistakes & Learnings section |
| 19 | - **On key decision:** Record in Key Decisions section |
| 20 | |
| 21 | ## Setup |
| 22 | |
| 23 | > **Prerequisite:** The `cm` CLI is the CodyMaster command-line tool. If not installed, you can |
| 24 | > manage `.cm/CONTINUITY.md` directly with your editor or the AI agent without the CLI commands. |
| 25 | |
| 26 | ```bash |
| 27 | # Initialize working memory for current project |
| 28 | cm continuity init |
| 29 | |
| 30 | # Check current state |
| 31 | cm continuity status |
| 32 | |
| 33 | # View captured learnings / decisions |
| 34 | cm continuity learnings |
| 35 | cm continuity decisions |
| 36 | |
| 37 | # ── Smart Spine v5 commands ────────────────────────────── |
| 38 | # Regenerate L0 compact indexes (learnings-index.md, skeleton-index.md) |
| 39 | cm continuity index |
| 40 | |
| 41 | # Show token budget allocation + usage per category |
| 42 | cm continuity budget |
| 43 | |
| 44 | # Pretty-print current context bus state (active skill chain) |
| 45 | cm continuity bus |
| 46 | |
| 47 | # Print Codex Desktop MCP config snippet for cm-context server |
| 48 | cm continuity mcp |
| 49 | |
| 50 | # Migrate learnings.json + decisions.json → SQLite (one-time) |
| 51 | cm continuity migrate |
| 52 | |
| 53 | # Export SQLite back to JSON (backup) |
| 54 | cm continuity export |
| 55 | |
| 56 | # ── Legacy config note ──────────────────────────────────── |
| 57 | # CodyMaster's supported default path is SQLite + FTS5. |
| 58 | # Older configs may still say `storage.backend: viking`; CodyMaster now warns and falls back to SQLite. |
| 59 | ``` |
| 60 | |
| 61 | ## The Protocol |
| 62 | |
| 63 | ### AT THE START OF EVERY SESSION: |
| 64 | |
| 65 | ``` |
| 66 | 1. Read .cm/CONTINUITY.md to understand current state |
| 67 | 2. Read "Mistakes & Learnings" to avoid past errors |
| 68 | 3. Check "Next Actions" to determine what to do |
| 69 | 4. Reference Active Goal throughout your work |
| 70 | ``` |
| 71 | |
| 72 | ### DURING WORK: |
| 73 | |
| 74 | ``` |
| 75 | PRE-ACT ATTENTION CHECK (before every significant action): |
| 76 | - Re-read Active Goal |
| 77 | - Ask: "Does my planned action serve this goal?" |
| 78 | - Ask: "Am I solving the original problem, not a tangent?" |
| 79 | - If DRIFT detected → log it → return to goal |
| 80 | ``` |
| 81 | |
| 82 | ### AT THE END OF EVERY SESSION: |
| 83 | |
| 84 | ``` |
| 85 | 1. Update "Just Completed" with accomplishments |
| 86 | 2. Update "Next Actions" with remaining work |
| 87 | 3. Record any new "Mistakes & Learnings" |
| 88 | 4. Record any "Key Decisions" made |
| 89 | 5. Update "Files Modified" list |
| 90 | 6. Set currentPhase and timestamp |
| 91 | ``` |
| 92 | |
| 93 | ### ON ERROR (Self-Correction Loop): |
| 94 | |
| 95 | ``` |
| 96 | ON_ERROR: |
| 97 | 1. Capture error details (stack trace, context) |
| 98 | 2. Analyze root cause (not just symptoms) |
| 99 | 3. Write learning to CONTINUITY.md "Mistakes & Learnings" |
| 100 | 4. Update approach based on learning |
| 101 | 5. Retry with corrected approach |
| 102 | 6. Max 3 retries per error pattern before ESCALATE |
| 103 | ``` |
| 104 | |
| 105 | ## CONTINUITY.md Template |
| 106 | |
| 107 | ```markdown |
| 108 | # CodyMaster Working Memory |
| 109 | Last Updated: [ISO timestamp] |
| 110 | Current Phase: [planning|executing|testing|deploying|reviewing] |
| 111 | Current Iteration: [number] |
| 112 | Project: [project name] |
| 113 | |
| 114 | ## Active Goal |
| 115 | [What we're currently trying to accomplish — 1-2 sentences max] |
| 116 | |
| 117 | ## Current Task |
| 118 | - ID: [task-id from dashboard] |
| 119 | - Title: [task title] |
| 120 | - Status: [in-progress|blocked|reviewing] |
| 121 | - Skill: [cm-skill being used] |
| 122 | - Started: [timestamp] |
| 123 | |
| 124 | ## Just Completed |
| 125 | - [Most recent accomplishment with file:line references] |
| 126 | - [Previous accomplishment] |
| 127 | - [etc — last 5 items] |
| 128 | |
| 129 | ## Next Actions (Priority Order) |
| 130 | 1. [Immediate next step] |
| 131 | 2. [Following step] |
| 132 | 3. [etc] |
| 133 | |
| 134 | ## Active Blockers |
| 135 | - [Any current blockers or waiting items] |
| 136 | |
| 137 | ## Key Decisions This Session |
| 138 | - [Decision]: [Rationale] — [timestamp] |
| 139 | |
| 140 | ## Mistakes & Learnings |
| 141 | |
| 142 | ### Pattern: Error → Learning → Prevention |
| 143 | - **What Failed:** [Specific error that occurred] |
| 144 | - **Why It Failed:** [Root cause analysis] |
| 145 | - **How to Prevent:** [Concrete action to avoid this in future] |
| 146 | - **Timestamp:** [When learned] |
| 147 | - **Agent:** [Which agent] |
| 148 | - **Task:** [Which task ID] |
| 149 | |
| 150 | ## Working Context |
| 151 | [Critical information for current work — architecture decisions, patterns being followed. |
| 152 | ⚠️ NEVER store API keys, secrets, or credentials here — use .env or a secrets manager instead] |
| 153 | |
| 154 | ## Files Currently Being Modified |
| 155 | - [file path]: [what we're changing] |
| 156 | ``` |
| 157 | |
| 158 | ## Memory Architecture (v5 — Smart Spine) |
| 159 | |
| 160 | ``` |
| 161 | Tier 1: SENSORY MEMORY (seconds — within current tool call) |
| 162 | → Internal variables, intermediate results |
| 163 | → NEVER written to file — discarded when action completes |
| 164 | |
| 165 | Tier 2: WORKING MEMO |