Memory System
Maintains persistent memory across sessions via tiered markdown files.
This skill must be run via a runtime-appropriate background subagent mechanism. For Claude, use the Task tool (subagent_type: general-purpose, model: sonnet, run_in_background: true). For Codex, prefer the session's native subagent tools spawn_agent/wait_agent (host session tools — they do not appear in codex --help) with a Codex-supported model; do not hardcode sonnet.
Architecture
~/zylos/memory/
├── identity.md # Bot soul + digital assets (always loaded)
├── state.md # Active working state (always loaded)
├── references.md # Pointers to config files (always loaded)
├── users/
│ └── <id>/profile.md # Per-user preferences
├── reference/
│ ├── decisions.md # Key decisions with rationale
│ ├── projects.md # Active/planned projects
│ ├── preferences.md # Shared team preferences
│ └── ideas.md # Uncommitted plans and ideas
├── sessions/
│ ├── current.md # Today's session log
│ └── YYYY-MM-DD.md # Past session logs
└── archive/ # Cold storage
Memory Sync
Priority
Memory Sync is the highest-priority internal maintenance task.
When triggered, run it before handling queued user messages.
Memory Sync is maintenance-only. A sync subagent must not reply through C4,
process user-facing tasks, modify business/project repositories, install or
upgrade components, restart services, or apply runtime changes outside the
sync flow below.
Trigger Paths
- Session init: if C4 unsummarized count is over threshold, launch memory sync.
- Scheduled context check: if context usage is high, launch memory sync.
Both launch a background subagent using the current runtime's supported subagent mechanism with this file's Sync Flow as the prompt.
Codex Background Execution
In Codex, use the session's native subagent tools: spawn_agent to
launch the sync subagent and wait_agent to collect its result. These are
host session tools — they do not appear in codex --help. For a single
long-running command, an async exec session (exec_command +
write_stdin) also works. Bare nohup ... & does NOT survive the
tool-call boundary and must never be used for sync. Never use PM2 for
sync — do not create PM2 services, run pm2 start ... codex exec ..., or
fork an extra codex exec sidecar: one-shot sync processes leave stopped
services piling up in the PM2 list. If the session exposes no native
background-agent capability, run the sync inline as a last resort and note
that in the handoff/status.
Before starting Memory Sync, check for existing in-flight sync work: if the
runtime exposes background-agent status, check it for a running sync subagent
and do not start another sync writer while one is in flight.
Sync Flow
- Rotate session log if needed:
node ~/zylos/.claude/skills/zylos-memory/scripts/rotate-session.js
- Fetch unsummarized conversations from C4:
node ~/zylos/.claude/skills/comm-bridge/scripts/c4-fetch.js --unsummarized
If output says "No unsummarized conversations.", skip to step 5
(still save current state). Otherwise, note the end_id from the
[Unsummarized Range] line.
- Read memory files (
identity.md, state.md, references.md, user profiles, reference/*, sessions/current.md).
- Extract and classify updates from conversations into the correct files.
- Write memory updates (always — even without new conversations,
update
state.md and sessions/current.md with current context).
- Audit
references.md against its content rules
(references/references-file-format.md): relocate rule-violating
entries to their routed destination (reference/decisions.md,
archive/, or a pointer to the config file) instead of leaving or
appending them. If the file exceeds the 8KB warn threshold
(memory-status.js reports WARN), trim until it is back under.
- Audit
state.md against its content rules
(references/state-format.md): relocate rule-violating content to its
routed destination (reference/projects.md, reference/decisions.md,
archive/, or a pointer to the on-demand file that already holds it)
instead of leaving or appending it. If the file exceeds the 10KB warn
threshold (memory-status.js reports WARN), trim until it is back
under.
- Create checkpoint (only if conversations were fetched in step 2):
node ~/zylos/.claude/skills/comm-bridge/scripts/c4-checkpoint.js create <end_id> --summary "SUMMARY"
- Confirm completion.
Classification Rules
reference/decisions.md: committed choices that close alternatives.
reference/projects.md: scoped work efforts with status.
reference/preferences.md: standing team-wide preferences.
reference/ideas.md: uncommitted proposals.
users/<id>/profile.md: user-specific preferences.
state.md: active focus, pending items, and blockers only, per the
content rules in references/state-format.md; completed-task narrative,
decisions, and run history are routed out, never accumulated.
references.md: pointers and stable identifiers only, per the content
rules in references/references-file-format.md; never duplicate config
values, never accumulate narrative history.
File Formats and Examples
Each memory file type has a format definition in references/ and a
worked example in examples/:
| File |
Format |
Example |
identity.md |
references/identity-format.md |
examples/identity.md |
state.md |
references/state-format.md |
examples/state.md |
references.md |
references/references-file-format.md |
examples/references.md |
users/<id>/profile.md |
references/user-profile-format.md |
examples/user-profile.md |
reference/decisions.md |
references/decisions-format.md |
examples/decisions.md |
reference/projects.md |
references/projects-format.md |
examples/projects.md |
reference/preferences.md |
references/preferences-format.md |
examples/preferences.md |
reference/ideas.md |
references/ideas-format.md |
examples/ideas.md |
sessions/current.md |
references/session-log-format.md |
examples/session-log.md |
Supporting Scripts
session-start-inject.js: prints core memory context blocks for hooks.
rotate-session.js: rotates sessions/current.md at day boundary.
daily-commit.js: local git snapshot for memory/ if changed.
consolidate.js: JSON consolidation report (sizes, age, budget checks).
Use for deliberate memory maintenance, or for scheduler-triggered
consolidation when such a task is configured. Review the report and apply
the Consolidation Review rules below.
memory-status.js: quick health summary.
Use when you need a fast manual check of core file sizes and budget status.
If it reports OVER, run consolidate.js and perform the needed cleanup.
C4 scripts used by sync flow (provided by comm-bridge skill):
c4-fetch.js --unsummarized: fetch unsummarized conversations and range.
c4-checkpoint.js create <end_id> --summary "...": create sync checkpoint.
Consolidation Review
The weekly consolidation task runs consolidate.js and outputs a JSON report.
Review the report and apply these rules:
Core File Budgets
- Files over 100% budget: summarize and trim older entries.
Move historical content to
reference/ or archive/.
identity.md, state.md, and references.md must stay under 16KB.
- Apply file-specific cleanup:
identity.md: keep only stable identity traits, principles, durable
collaboration style, and digital asset references. Move operational state
and one-off lessons elsewhere.
state.md: keep active focus, pending tasks, and recent completions.
Move completed or historical detail to sessions/current.md or
reference/. Apply the content rules in references/state-format.md;
the sync-time audit (Sync Flow step 7) should keep it under the 10KB
warn threshold.
references.md: keep pointers and lookup facts only. Move prose,
project history, and detailed decisions to reference/. Apply the
content rules in references/references-file-format.md; the sync-time
audit (Sync Flow step 6) should keep it under the 8KB warn threshold.
Session Logs
- Logs in
archiveCandidatesOlderThan30Days: move from sessions/ to archive/.
Reference Files (reference/*.md)
These files have no size cap. Maintenance is at the entry level.
Freshness is reported by file mtime (Phase 1 limitation):
- active (< 7 days): no action.
- aging (7–30 days): no action.
- fading (30–90 days): open the file. Review entries by their dates
and status fields. Update or confirm still-relevant entries; move
obsolete entries (superseded/completed/abandoned/dropped) to
archive/.
- stale (> 90 days): same as fading, but prioritize review.
Entries that are clearly still critical may remain.
Immunity: Entries with importance 1-2 (defined in entry metadata) are
immune to automatic fading suggestions. They may still be reviewed but
should not be archived based on age alone.
User Profiles
- Profiles over ~1KB: summarize older notes.
General Rules
- Never delete — always move to
archive/. Content is recoverable
from archive/ or git history.
- Log consolidation actions in
sessions/current.md.
Best Practices
- Keep
state.md lean (tight context budget).
- Prefer updates over duplication.
- Use explicit dates/timestamps for entries.
- Archive instead of deleting historical data.
- Route user data to user profiles.
- Keep configuration values in config files; use
references.md as an index.
1---2name: zylos-memory3description: Core memory system. Maintains persistent memory across sessions via tiered markdown files following the Inside Out model. Handles Memory Sync (processing conversations into structured memory), session rotation, consolidation, and context-aware state saving. Must be launched via a runtime-appropriate background subagent mechanism — do not invoke with the Skill tool.4---56# Memory System78Maintains persistent memory across sessions via tiered markdown files.9This skill must be run via a runtime-appropriate background subagent mechanism. For Claude, use the Task tool (`subagent_type: general-purpose`, `model: sonnet`, `run_in_background: true`). For Codex, prefer the session's native subagent tools `spawn_agent`/`wait_agent` (host session tools — they do not appear in `codex --help`) with a Codex-supported model; do not hardcode `sonnet`.1011## Architecture1213```text14~/zylos/memory/15├── identity.md # Bot soul + digital assets (always loaded)16├── state.md # Active working state (always loaded)17├── references.md # Pointers to config files (always loaded)18├── users/19│ └── <id>/profile.md # Per-user preferences20├── reference/21│ ├── decisions.md # Key decisions with rationale22│ ├── projects.md # Active/planned projects23│ ├── preferences.md # Shared team preferences24│ └── ideas.md # Uncommitted plans and ideas25├── sessions/26│ ├── current.md # Today's session log27│ └── YYYY-MM-DD.md # Past session logs28└── archive/ # Cold storage29```3031## Memory Sync3233### Priority3435Memory Sync is the highest-priority internal maintenance task.36When triggered, run it before handling queued user messages.3738Memory Sync is maintenance-only. A sync subagent must not reply through C4,39process user-facing tasks, modify business/project repositories, install or40upgrade components, restart services, or apply runtime changes outside the41sync flow below.4243### Trigger Paths44451. Session init: if C4 unsummarized count is over threshold, launch memory sync.462. Scheduled context check: if context usage is high, launch memory sync.4748Both launch a background subagent using the current runtime's supported subagent mechanism with this file's Sync Flow as the prompt.4950### Codex Background Execution5152In Codex, use the session's native subagent tools: `spawn_agent` to53launch the sync subagent and `wait_agent` to collect its result. These are54host session tools — they do not appear in `codex --help`. For a single55long-running command, an async exec session (`exec_command` +56`write_stdin`) also works. Bare `nohup ... &` does NOT survive the57tool-call boundary and must never be used for sync. Never use PM2 for58sync — do not create PM2 services, run `pm2 start ... codex exec ...`, or59fork an extra `codex exec` sidecar: one-shot sync processes leave stopped60services piling up in the PM2 list. If the session exposes no native61background-agent capability, run the sync inline as a last resort and note62that in the handoff/status.6364Before starting Memory Sync, check for existing in-flight sync work: if the65runtime exposes background-agent status, check it for a running sync subagent66and do not start another sync writer while one is in flight.6768### Sync Flow69701. Rotate session log if needed:71 `node ~/zylos/.claude/skills/zylos-memory/scripts/rotate-session.js`722. Fetch unsummarized conversations from C4:73 `node ~/zylos/.claude/skills/comm-bridge/scripts/c4-fetch.js --unsummarized`74 If output says "No unsummarized conversations.", skip to step 575 (still save current state). Otherwise, note the `end_id` from the76 `[Unsummarized Range]` line.773. Read memory files (`identity.md`, `state.md`, `references.md`, user profiles, `reference/*`, `sessions/current.md`).784. Extract and classify updates from conversations into the correct files.795. Write memory updates (always — even without new conversations,80 update `state.md` and `sessions/current.md` with current context).816. Audit `references.md` against its content rules82 (`references/references-file-format.md`): relocate rule-violating83 entries to their routed destination (`reference/decisions.md`,84 `archive/`, or a pointer to the config file) instead of leaving or85 appending them. If the file exceeds the 8KB warn threshold86 (`memory-status.js` reports WARN), trim until it is back under.877. Audit `state.md` against its content rules88 (`references/state-format.md`): relocate rule-violating content to its89 routed destination (`reference/projects.md`, `reference/decisions.md`,90 `archive/`, or a pointer to the on-demand file that already holds it)91 instead of leaving or appending it. If the file exceeds the 10KB warn92 threshold (`memory-status.js` reports WARN), trim until it is back93 under.948. Create checkpoint (only if conversations were fetched in step 2):95 `node ~/zylos/.claude/skills/comm-bridge/scripts/c4-checkpoint.js create <end_id> --summary "SUMMARY"`969. Confirm completion.9798## Classification Rules99100- `reference/decisions.md`: committed choices that close alternatives.101- `reference/projects.md`: scoped work efforts with status.102- `reference/preferences.md`: standing team-wide preferences.103- `reference/ideas.md`: uncommitted proposals.104- `users/<id>/profile.md`: user-specific preferences.105- `state.md`: active focus, pending items, and blockers only, per the106 content rules in `references/state-format.md`; completed-task narrative,107 decisions, and run history are routed out, never accumulated.108- `references.md`: pointers and stable identifiers only, per the content109 rules in `references/references-file-format.md`; never duplicate config110 values, never accumulate narrative history.111112## File Formats and Examples113114Each memory file type has a format definition in `references/` and a115worked example in `examples/`:116117| File | Format | Example |118|------|--------|---------|119| `identity.md` | `references/identity-format.md` | `examples/identity.md` |120| `state.md` | `references/state-format.md` | `examples/state.md` |121| `references.md` | `references/references-file-format.md` | `examples/references.md` |122| `users/<id>/profile.md` | `references/user-profile-format.md` | `examples/user-profile.md` |123| `reference/decisions.md` | `references/decisions-format.md` | `examples/decisions.md` |124| `reference/projects.md` | `references/projects-format.md` | `examples/projects.md` |125| `reference/preferences.md` | `references/preferences-format.md` | `examples/preferences.md` |126| `reference/ideas.md` | `references/ideas-format.md` | `examples/ideas.md` |127| `sessions/current.md` | `references/session-log-format.md` | `examples/session-log.md` |128129## Supporting Scripts130131- `session-start-inject.js`: prints core memory context blocks for hooks.132- `rotate-session.js`: rotates `sessions/current.md` at day boundary.133- `daily-commit.js`: local git snapshot for `memory/` if changed.134- `consolidate.js`: JSON consolidation report (sizes, age, budget checks).135 Use for deliberate memory maintenance, or for scheduler-triggered136 consolidation when such a task is configured. Review the report and apply137 the Consolidation Review rules below.138- `memory-status.js`: quick health summary.139 Use when you need a fast manual check of core file sizes and budget status.140 If it reports `OVER`, run `consolidate.js` and perform the needed cleanup.141142C4 scripts used by sync flow (provided by comm-bridge skill):143- `c4-fetch.js --unsummarized`: fetch unsummarized conversations and range.144- `c4-checkpoint.js create <end_id> --summary "..."`: create sync checkpoint.145146## Consolidation Review147148The weekly consolidation task runs `consolidate.js` and outputs a JSON report.149Review the report and apply these rules:150151### Core File Budgets152- Files over 100% budget: summarize and trim older entries.153 Move historical content to `reference/` or `archive/`.154- `identity.md`, `state.md`, and `references.md` must stay under 16KB.155- Apply file-specific cleanup:156 - `identity.md`: keep only stable identity traits, principles, durable157 collaboration style, and digital asset references. Move operational state158 and one-off lessons elsewhere.159 - `state.md`: keep active focus, pending tasks, and recent completions.160 Move completed or historical detail to `sessions/current.md` or161 `reference/`. Apply the content rules in `references/state-format.md`;162 the sync-time audit (Sync Flow step 7) should keep it under the 10KB163 warn threshold.164 - `references.md`: keep pointers and lookup facts only. Move prose,165 project history, and detailed decisions to `reference/`. Apply the166 content rules in `references/references-file-format.md`; the sync-time167 audit (Sync Flow step 6) should keep it under the 8KB warn threshold.168169### Session Logs170- Logs in `archiveCandidatesOlderThan30Days`: move from `sessions/` to `archive/`.171172### Reference Files (`reference/*.md`)173These files have no size cap. Maintenance is at the entry level.174Freshness is reported by file mtime (Phase 1 limitation):175- **active** (< 7 days): no action.176- **aging** (7–30 days): no action.177- **fading** (30–90 days): open the file. Review entries by their dates178 and status fields. Update or confirm still-relevant entries; move179 obsolete entries (superseded/completed/abandoned/dropped) to `archive/`.180- **stale** (> 90 days): same as fading, but prioritize review.181 Entries that are clearly still critical may remain.182183**Immunity:** Entries with importance 1-2 (defined in entry metadata) are184immune to automatic fading suggestions. They may still be reviewed but185should not be archived based on age alone.186187### User Profiles188- Profiles over ~1KB: summarize older notes.189190### General Rules1911. Never delete — always move to `archive/`. Content is recoverable192 from `archive/` or git history.1932. Log consolidation actions in `sessions/current.md`.194195## Best Practices1961971. Keep `state.md` lean (tight context budget).1982. Prefer updates over duplication.1993. Use explicit dates/timestamps for entries.2004. Archive instead of deleting historical data.2015. Route user data to user profiles.2026. Keep configuration values in config files; use `references.md` as an index.