Wingman Memory Sync
Core Rule
memory-sync writes the smallest useful memory update after meaningful work, while promoting durable knowledge out of hot context when future agents would otherwise re-read old logs or re-debug the same issue.
- Current truth that future agents must obey belongs in
brief.md or domains/.
history/ is trace context only; it is not current truth.
- Small isolated changes may write nothing.
Gate
Apply these gates before reading or writing memory:
- If the user says "skip update", "不更新", "跳过记录", "这个不用记忆", "局部改动不记录", or equivalent, stop without reading or writing memory.
- If
.wingman/memory/ is missing, ordinary completion must not invoke memory-sync. If sync was explicitly requested, report that repository memory is disabled and memory-setup is the explicit enable path.
- If
.wingman/memory/ exists but .wingman/memory/brief.md or .wingman/memory/context.md is missing, stop before writing, report the missing core entry files, and suggest memory-setup repair. Do not repair from memory-sync.
- Continue only when both
brief.md and context.md exist.
Before reporting meaningful coding, documentation, configuration, product, or operational work as complete in a repository where memory is enabled, run this skill's thresholds. If the work passes a write threshold and memory has not been synced, sync memory before saying done, fixed, completed, or 已完成, unless the user explicitly opted out.
Promotion Check
Before writing a context log, check whether the new fact or existing same-feature context logs should be promoted to current truth or history.
Prefer promotion when any of these are true:
- The fact defines a stable API path, request body, response field, field meaning, schema, payload, state mapping, enum, route rule, permission rule, payment rule, money rule, quota rule, or lifecycle rule.
- The user corrected a business meaning, field meaning, or workflow interpretation.
- The work fixed a recurring debugging conclusion or a mistake future agents are likely to repeat.
- The behavior crosses files, modules, pages, APIs, or domains.
- The same feature, workflow, or domain already has multiple context logs and those logs now contain long-lived knowledge.
- Future agents would need the fact to avoid re-reading old logs, re-debugging, or choosing a semantically wrong field.
Promotion does not mean every promoted fact needs history. Current truth explains what is binding now; history explains important source events.
Routing
Route each fact to the destination matching its job:
| Route |
Destination |
Use When |
| IGNORE |
none |
Too small or too local to remember. |
| CONTEXT_LOG |
context.md |
Recent progress, changed files, debugging state, partial work, unresolved follow-ups, or near-term context. |
| DOMAIN_TRUTH |
domains/ |
Stable one-domain business rules, API contract, canonical field, state flow, permission rule, money rule, routing rule, or recurring debugging conclusion. |
| PROJECT_ADR |
brief.md |
Global or cross-domain architecture decision, repository convention, project-wide agent behavior, or policy. |
| HISTORY_EVENT |
history/ |
Past event with lasting trace value beyond hot context. |
A task may route to more than one destination, but each destination must have a concrete reason. Do not write memory just because this skill was invoked.
Thresholds
IGNORE for typo-only edits, rename-only cleanup, formatting, small copy edits, isolated visual or style tweaks with no behavior/state/data/contract/business impact, behavior-preserving movement or extraction, and one-off failed attempts with no reusable lesson.
CONTEXT_LOG when the work may matter in the next few sessions: meaningful progress, changed files and what each one now does, partial work, pending follow-ups, debugging state, recent conclusions, or non-trivial implementation details that are not durable rules.
DOMAIN_TRUTH or PROJECT_ADR when future agents must obey the result or would otherwise need old logs to avoid re-debugging: stable field meaning, API path/body/response contract, schema, event, config, data model, state or enum mapping, permission, routing, money, quota, lifecycle, product or business invariant, cross-file behavior contract, recurring debugging conclusion with a clear trigger, repository-wide convention, or architecture decision.
HISTORY_EVENT defaults to no for small local changes. It defaults to yes when a non-trivial DOMAIN_TRUTH or PROJECT_ADR was written for a feature milestone, contract decision, field decision, state-flow correction, recurring debugging conclusion, migration, incident, important bug or regression fix, or user-requested historical memory, unless the event has no trace value beyond the current rule.
Value Funnel
Before writing memory, classify the change by future value:
- Record when it changes behavior, contracts, data meaning, workflow, architecture, shared implementation, or a durable debugging conclusion.
- Skip when it is local, obvious from the diff, purely mechanical, or has no reusable lesson.
- Promote to
domains/ or brief.md when it becomes a rule future work must follow.
Every recorded entry must explain why the change was needed and what future mistake it prevents.
Workflow
- Apply the Gate.
- Run Promotion Check before deciding to write a context log.
- Route facts using the Thresholds.
- If every fact is IGNORE, write nothing and say which threshold blocked the update.
- For DOMAIN_TRUTH or PROJECT_ADR, pass the Evidence Gate before writing current truth.
- Write current truth before history when both are needed.
- Decide HISTORY_EVENT after current truth routing. Write history when the History threshold passes.
- Write CONTEXT_LOG only for hot context. When current truth or history already carries the durable detail, write a short pointer instead of repeating the full event.
- Report changed memory files, projection indexes, or the threshold that blocked writing.
Current truth comes before history. If a future agent must follow a rule, write it to brief.md or domains/ before writing any history event about it. Do not write history just because context.md was updated. Do not create a history event just to fill a History backlink. Do not promote guessed thresholds, temporary constants, local workarounds, or one-off implementation details into current rules.
Write Rules
Context Log
Open .wingman/memory/context.md. Find the recent log section, commonly ## Recent Logs, ## Current Sprint Logs, or ## 短期活跃日志 (CURRENT SPRINT LOGS).
- Prepend the new log directly below the section heading.
- Update pending tasks only when the task changes pending work.
- If this update corrects a same-day, same-feature, or same-bug log that is now wrong, remove only that obsolete log and keep the corrected truth.
- Do not merge, rewrite, reorder, or delete unrelated history.
- Before using the default context log shape, read
references/templates.md.
- If DOMAIN_TRUTH, PROJECT_ADR, or HISTORY_EVENT was written for the same fact, use the Context Pointer Template from
references/templates.md instead of duplicating durable detail in context.md.
Before writing a log, internally verify that:
- The implementation used canonical memory fields and did not substitute proxy or heuristic fields for semantic fields.
- The implementation reused an existing component/helper/pattern when the repository already had one.
- Any tiny but high-impact local behavior has an inline invariant comment when code alone would invite accidental cleanup.
- The context log includes the reason for the change and the mistake it prevents.
If this proof fails, report the conflict or missing invariant instead of claiming completion.
Inline invariant comments are for local constraints, not full change history. Use them only when a tiny or odd-looking line would be easy to "simplify" but changing it would alter behavior, data meaning, contract, security, money, routing, permissions, or state flow:
// @invariant: <constraint>; <why changing it breaks semantics>.
Reason Gate
Do not write a context log that only says what changed. Include the reason in one sentence:
Changed X because Y; prevents Z.
If the reason is trivial, meaningless, or obvious from the diff, prefer IGNORE unless the task is hot context for the next session.
Current Truth
Before writing DOMAIN_TRUTH or PROJECT_ADR, verify at least one evidence source:
- The user explicitly stated the rule or decision.
- Existing Wingman memory already implies the rule.
- Product docs, API docs, schema, tests, or accepted specs confirm it.
- The implementation intentionally changed a stable contract or business behavior, not just an incidental implementation detail.
If evidence is weak and the proposed durable rule would constrain future work, ask the user before writing durable memory.
Write current truth with these rules:
- Read
.wingman/memory/brief.md and use the Domain Registry to route the rule.
- Route one-domain rules to
.wingman/memory/domains/<domain>.md or that domain folder's focused topic file.
- Route global or cross-domain rules to the architecture decisions section in
brief.md.
- Create new domain files only for stable business, technical, product, or operational domains. Do not create one domain file per small feature.
- Write new durable truth to the best existing location. If the target already mixes unrelated knowledge clusters, prefer the most specific existing domain or topic file instead of adding another broad entry.
- Write durable rules under
## Current Truths for English memory or ## 当前业务真理 for Chinese memory.
- Update the Domain Registry when creating, renaming, deprecating, or superseding a domain route. New registry rows use
Domain | Read When | Current File | History Domain Index | History Topics | Aliases | Related Domains | Status.
- When creating a new domain, choose
.wingman/memory/domains/<domain>.md for a small domain or .wingman/memory/domains/<domain>/index.md plus focused topic files for a large domain.
- Use stable, generic topic names for domain subfiles and history topics. Avoid customer names, project code names, and one-off business labels.
- When replacing a rule, decision, or domain route, mark the old current entry as
superseded or deprecated and point to the replacement. Do not leave conflicting current truths alive.
Before using the default durable truth shape, read references/templates.md when the existing memory file has no stronger local format. History is optional; write None when there is no specific history event. Do not invent a history event just to fill the field. For PROJECT_ADR, use ADR lifecycle status values: proposed | accepted | deprecated | superseded.
History Event
Run this section only when HISTORY_EVENT passes the threshold.
- Read
references/history-events.md before writing history.
- Write one event body under
.wingman/memory/history/events/YYYY/MM/YYYY-MM-DD-<event-slug>.md.
- Update
.wingman/memory/history/index.md, .wingman/memory/history/domains/<domain>.md, .wingman/memory/history/topics/<topic>.md, and .wingman/memory/history/months/YYYY-MM.md.
- Choose topics from the task's feature, workflow, or problem cluster. Use generic names such as
checkout-flow, payment-selection, order-status, product-detail, upload-retry, or quota-display.
- Include
Promoted Truths links when brief.md or domains/ was updated. Use None when no current truth was promoted.
- Do not copy full event bodies into projection indexes.
- Do not treat projection indexes as current rules.
- Projection indexes can be rebuilt from events; do not rewrite event bodies just because an index changes.
Language And Completion
Memory language: brief.md setting when not auto; otherwise existing memory language, then user's language, then English. Keep code symbols, paths, API names, config names, and field names unchanged.
Finish by reporting changed memory files, including context, domain truth, history event bodies, and projection indexes. If no history event was written, name the threshold or reason that blocked history. If nothing was written, name the blocking gate or threshold.
1---2name: memory-sync3description: Use when progress, decisions, business logic, API contracts, state flow, field mappings, or durable project knowledge should be recorded in Wingman memory.4---56# Wingman Memory Sync78## Core Rule910`memory-sync` writes the smallest useful memory update after meaningful work, while promoting durable knowledge out of hot context when future agents would otherwise re-read old logs or re-debug the same issue.1112- Current truth that future agents must obey belongs in `brief.md` or `domains/`.13- `history/` is trace context only; it is not current truth.14- Small isolated changes may write nothing.1516## Gate1718Apply these gates before reading or writing memory:19201. If the user says "skip update", "不更新", "跳过记录", "这个不用记忆", "局部改动不记录", or equivalent, stop without reading or writing memory.212. If `.wingman/memory/` is missing, ordinary completion must not invoke `memory-sync`. If sync was explicitly requested, report that repository memory is disabled and `memory-setup` is the explicit enable path.223. If `.wingman/memory/` exists but `.wingman/memory/brief.md` or `.wingman/memory/context.md` is missing, stop before writing, report the missing core entry files, and suggest `memory-setup` repair. Do not repair from `memory-sync`.234. Continue only when both `brief.md` and `context.md` exist.2425Before reporting meaningful coding, documentation, configuration, product, or operational work as complete in a repository where memory is enabled, run this skill's thresholds. If the work passes a write threshold and memory has not been synced, sync memory before saying done, fixed, completed, or 已完成, unless the user explicitly opted out.2627## Promotion Check2829Before writing a context log, check whether the new fact or existing same-feature context logs should be promoted to current truth or history.3031Prefer promotion when any of these are true:3233- The fact defines a stable API path, request body, response field, field meaning, schema, payload, state mapping, enum, route rule, permission rule, payment rule, money rule, quota rule, or lifecycle rule.34- The user corrected a business meaning, field meaning, or workflow interpretation.35- The work fixed a recurring debugging conclusion or a mistake future agents are likely to repeat.36- The behavior crosses files, modules, pages, APIs, or domains.37- The same feature, workflow, or domain already has multiple context logs and those logs now contain long-lived knowledge.38- Future agents would need the fact to avoid re-reading old logs, re-debugging, or choosing a semantically wrong field.3940Promotion does not mean every promoted fact needs history. Current truth explains what is binding now; history explains important source events.4142## Routing4344Route each fact to the destination matching its job:4546| Route | Destination | Use When |47| ----------------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |48| **IGNORE** | none | Too small or too local to remember. |49| **CONTEXT_LOG** | `context.md` | Recent progress, changed files, debugging state, partial work, unresolved follow-ups, or near-term context. |50| **DOMAIN_TRUTH** | `domains/` | Stable one-domain business rules, API contract, canonical field, state flow, permission rule, money rule, routing rule, or recurring debugging conclusion. |51| **PROJECT_ADR** | `brief.md` | Global or cross-domain architecture decision, repository convention, project-wide agent behavior, or policy. |52| **HISTORY_EVENT** | `history/` | Past event with lasting trace value beyond hot context. |5354A task may route to more than one destination, but each destination must have a concrete reason. Do not write memory just because this skill was invoked.5556## Thresholds5758**IGNORE** for typo-only edits, rename-only cleanup, formatting, small copy edits, isolated visual or style tweaks with no behavior/state/data/contract/business impact, behavior-preserving movement or extraction, and one-off failed attempts with no reusable lesson.5960**CONTEXT_LOG** when the work may matter in the next few sessions: meaningful progress, changed files and what each one now does, partial work, pending follow-ups, debugging state, recent conclusions, or non-trivial implementation details that are not durable rules.6162**DOMAIN_TRUTH** or **PROJECT_ADR** when future agents must obey the result or would otherwise need old logs to avoid re-debugging: stable field meaning, API path/body/response contract, schema, event, config, data model, state or enum mapping, permission, routing, money, quota, lifecycle, product or business invariant, cross-file behavior contract, recurring debugging conclusion with a clear trigger, repository-wide convention, or architecture decision.6364**HISTORY_EVENT** defaults to no for small local changes. It defaults to yes when a non-trivial **DOMAIN_TRUTH** or **PROJECT_ADR** was written for a feature milestone, contract decision, field decision, state-flow correction, recurring debugging conclusion, migration, incident, important bug or regression fix, or user-requested historical memory, unless the event has no trace value beyond the current rule.6566## Value Funnel6768Before writing memory, classify the change by future value:6970- **Record** when it changes behavior, contracts, data meaning, workflow, architecture, shared implementation, or a durable debugging conclusion.71- **Skip** when it is local, obvious from the diff, purely mechanical, or has no reusable lesson.72- **Promote** to `domains/` or `brief.md` when it becomes a rule future work must follow.7374Every recorded entry must explain why the change was needed and what future mistake it prevents.7576## Workflow77781. Apply the Gate.792. Run Promotion Check before deciding to write a context log.803. Route facts using the Thresholds.814. If every fact is **IGNORE**, write nothing and say which threshold blocked the update.825. For **DOMAIN_TRUTH** or **PROJECT_ADR**, pass the Evidence Gate before writing current truth.836. Write current truth before history when both are needed.847. Decide **HISTORY_EVENT** after current truth routing. Write history when the History threshold passes.858. Write **CONTEXT_LOG** only for hot context. When current truth or history already carries the durable detail, write a short pointer instead of repeating the full event.869. Report changed memory files, projection indexes, or the threshold that blocked writing.8788Current truth comes before history. If a future agent must follow a rule, write it to `brief.md` or `domains/` before writing any history event about it. Do not write history just because `context.md` was updated. Do not create a history event just to fill a `History` backlink. Do not promote guessed thresholds, temporary constants, local workarounds, or one-off implementation details into current rules.8990## Write Rules9192### Context Log9394Open `.wingman/memory/context.md`. Find the recent log section, commonly `## Recent Logs`, `## Current Sprint Logs`, or `## 短期活跃日志 (CURRENT SPRINT LOGS)`.9596- Prepend the new log directly below the section heading.97- Update pending tasks only when the task changes pending work.98- If this update corrects a same-day, same-feature, or same-bug log that is now wrong, remove only that obsolete log and keep the corrected truth.99- Do not merge, rewrite, reorder, or delete unrelated history.100- Before using the default context log shape, read `references/templates.md`.101- If **DOMAIN_TRUTH**, **PROJECT_ADR**, or **HISTORY_EVENT** was written for the same fact, use the Context Pointer Template from `references/templates.md` instead of duplicating durable detail in `context.md`.102103Before writing a log, internally verify that:104105- The implementation used canonical memory fields and did not substitute proxy or heuristic fields for semantic fields.106- The implementation reused an existing component/helper/pattern when the repository already had one.107- Any tiny but high-impact local behavior has an inline invariant comment when code alone would invite accidental cleanup.108- The context log includes the reason for the change and the mistake it prevents.109110If this proof fails, report the conflict or missing invariant instead of claiming completion.111112Inline invariant comments are for local constraints, not full change history. Use them only when a tiny or odd-looking line would be easy to "simplify" but changing it would alter behavior, data meaning, contract, security, money, routing, permissions, or state flow:113114`// @invariant: <constraint>; <why changing it breaks semantics>.`115116### Reason Gate117118Do not write a context log that only says what changed. Include the reason in one sentence:119120`Changed X because Y; prevents Z.`121122If the reason is trivial, meaningless, or obvious from the diff, prefer `IGNORE` unless the task is hot context for the next session.123124### Current Truth125126Before writing **DOMAIN_TRUTH** or **PROJECT_ADR**, verify at least one evidence source:127128- The user explicitly stated the rule or decision.129- Existing Wingman memory already implies the rule.130- Product docs, API docs, schema, tests, or accepted specs confirm it.131- The implementation intentionally changed a stable contract or business behavior, not just an incidental implementation detail.132133If evidence is weak and the proposed durable rule would constrain future work, ask the user before writing durable memory.134135Write current truth with these rules:136137- Read `.wingman/memory/brief.md` and use the Domain Registry to route the rule.138- Route one-domain rules to `.wingman/memory/domains/<domain>.md` or that domain folder's focused topic file.139- Route global or cross-domain rules to the architecture decisions section in `brief.md`.140- Create new domain files only for stable business, technical, product, or operational domains. Do not create one domain file per small feature.141- Write new durable truth to the best existing location. If the target already mixes unrelated knowledge clusters, prefer the most specific existing domain or topic file instead of adding another broad entry.142- Write durable rules under `## Current Truths` for English memory or `## 当前业务真理` for Chinese memory.143- Update the Domain Registry when creating, renaming, deprecating, or superseding a domain route. New registry rows use `Domain | Read When | Current File | History Domain Index | History Topics | Aliases | Related Domains | Status`.144- When creating a new domain, choose `.wingman/memory/domains/<domain>.md` for a small domain or `.wingman/memory/domains/<domain>/index.md` plus focused topic files for a large domain.145- Use stable, generic topic names for domain subfiles and history topics. Avoid customer names, project code names, and one-off business labels.146- When replacing a rule, decision, or domain route, mark the old current entry as `superseded` or `deprecated` and point to the replacement. Do not leave conflicting current truths alive.147148Before using the default durable truth shape, read `references/templates.md` when the existing memory file has no stronger local format. `History` is optional; write `None` when there is no specific history event. Do not invent a history event just to fill the field. For **PROJECT_ADR**, use ADR lifecycle status values: `proposed | accepted | deprecated | superseded`.149150### History Event151152Run this section only when **HISTORY_EVENT** passes the threshold.153154- Read `references/history-events.md` before writing history.155- Write one event body under `.wingman/memory/history/events/YYYY/MM/YYYY-MM-DD-<event-slug>.md`.156- Update `.wingman/memory/history/index.md`, `.wingman/memory/history/domains/<domain>.md`, `.wingman/memory/history/topics/<topic>.md`, and `.wingman/memory/history/months/YYYY-MM.md`.157- Choose topics from the task's feature, workflow, or problem cluster. Use generic names such as `checkout-flow`, `payment-selection`, `order-status`, `product-detail`, `upload-retry`, or `quota-display`.158- Include `Promoted Truths` links when `brief.md` or `domains/` was updated. Use `None` when no current truth was promoted.159- Do not copy full event bodies into projection indexes.160- Do not treat projection indexes as current rules.161- Projection indexes can be rebuilt from events; do not rewrite event bodies just because an index changes.162163## Language And Completion164165Memory language: `brief.md` setting when not `auto`; otherwise existing memory language, then user's language, then English. Keep code symbols, paths, API names, config names, and field names unchanged.166167Finish by reporting changed memory files, including context, domain truth, history event bodies, and projection indexes. If no history event was written, name the threshold or reason that blocked history. If nothing was written, name the blocking gate or threshold.