---
name: engram-memory-safety
description: "Trigger: Engram, mem_save, cloud sync, missing title. Reduce malformed-save risk and guide version-matched legacy repair."
license: Apache-2.0
compatibility: "Requires Engram CLI or MCP. Portable across Agent Skills-compatible clients."
metadata:
  author: "EmilZapata"
  version: "1.0"
---

## Activation Contract

Activate before any Engram `mem_save`, Cloud migration, sync preparation, or recovery from a legacy missing-title blocker.

This prompt-level guidance applies to future agent calls. It does not enforce Engram's write boundary, and existing malformed observations require explicit repair.

## Hard Rules

- Require non-empty content and a concise, factual, non-empty title before every `mem_save`.
- Explicitly pass `title` in every `mem_save` call; never rely on schema-required metadata alone.
- If the caller omitted a title, derive it from the first meaningful fact in the supplied content without inventing facts.
- Stop when the supplied content cannot support an accurate title.
- Preserve normal Engram conflict handling and surface every `judgment_required` response.
- Never claim this skill fixes the underlying Engram product defect.
- Never expose credentials, tokens, private memory content, or unrelated project data.

## Decision Gates

| Condition | Action |
| --- | --- |
| Title and content are valid | Call `mem_save` with both fields explicitly. |
| Title is missing | Derive a concise title only from supplied facts. |
| Content is missing or insufficient | Stop without saving. |
| Cloud migration is requested | Run project-scoped upgrade doctor before sync. |
| Doctor reports a supported missing-title blocker | Use the official version-matched repair helper. |
| Blocker is unsupported or data cannot be inferred | Stop and report the blocker. |

## Execution Steps

1. Trim and validate the proposed title and content before calling `mem_save`.
2. Derive a missing title only from the first meaningful factual statement in the content.
3. Call `mem_save` with explicit `title` and `content`.
4. Process conflicts and `judgment_required` responses through the normal Engram workflow.
5. Before Cloud migration or synchronization, run:

   ```sh
   engram cloud upgrade doctor --project <project>
   ```

6. Stop when doctor reports a blocker.
7. For a supported legacy missing-title blocker:
   - verify that the official helper matches the installed Engram version;
   - run a dry-run before applying changes;
   - derive replacement titles only from authoritative content displayed by the helper;
   - ensure a backup exists and preserve every helper-created backup;
   - bound loop mode with `--max`;
   - apply changes only to the explicit project.
8. Rerun doctor after repair and before synchronization.

## Prohibited Actions

Never:

- delete `sync_mutations`;
- manually edit the Engram SQLite database;
- modify `last_acked_seq`;
- use `--all` for Cloud synchronization;
- invent observation titles;
- synchronize while doctor reports blockers;
- expose tokens or credentials;
- silently continue after an unsupported repair condition.

## Output Contract

Report:

- the validation outcome;
- the explicit title used;
- any `judgment_required` response;
- doctor status;
- repair mode and backup status;
- unresolved blockers.

Never print credentials, tokens, or private memory content.

## References

None.
