Memory Sweep - find memory-only rules that should be in copilot-instructions.md
When to use this skill
Trigger this skill whenever the user asks any of:
- "audit my memories"
- "sweep my memories"
- "any memory-only rules?"
- "review my Copilot memories"
- "what memories should be promoted to instructions"
- "is anything in memory that should be in the file?"
Also proactively offer to run this skill if you notice during a session that a user-stated rule lives only in memory and not in the instructions file (e.g., when a recent multi-model PR review flags a "smuggled rule" finding like the gratitude-first case).
Why this matters
Memories are great for capturing preferences mid-conversation, but they have downsides:
- They're personal to one user account and don't transfer to teammates.
- They can be down-voted into oblivion accidentally.
- They're invisible during code review or onboarding.
- They can drift out of sync with the canonical instructions file.
Rules that the user wants to apply consistently belong in
copilot-instructions.md, where they're visible, source-controlled,
and survive any memory churn. The memory remains useful as a quick
reference but the file is authoritative.
How to run the sweep
Follow these steps in order:
Step 1: Dump the current memories block
You have the user's stored memories in your prompt context inside a
<memories> block. Write that block verbatim to a tempfile in a
private per-invocation directory. Memories can contain personal
preferences and context you do not want on a predictable shared path.
SWEEP_DIR=$(mktemp -d -t memory-sweep.XXXXXX)
chmod 700 "$SWEEP_DIR"
Then use your file-write tool to create
"$SWEEP_DIR/memories.md" containing only the memory entries
from the <memories> block - one entry per memory, in this exact
markdown format:
**subject heading**
- Fact: <fact text>
- Citations: <citations text>
**next subject**
- Fact: <fact text>
- Citations: <citations text>
Do not include the surrounding instructional prose ("Be sure to consider these stored facts carefully...", "If you come across a memory you can verify...", etc.). Only the memory entries themselves.
Step 2: Run the classifier
python3 ~/.copilot/skills/memory-sweep/sweep.py \
"$SWEEP_DIR/memories.md" \
~/repos/dotfiles/.github/copilot-instructions.md
To focus on only the promotion candidates:
python3 ~/.copilot/skills/memory-sweep/sweep.py \
"$SWEEP_DIR/memories.md" \
~/repos/dotfiles/.github/copilot-instructions.md \
--only PROMOTE
When the review is finished, clean up the temp directory:
rm -rf "$SWEEP_DIR"
Step 3: Review the output with the user
The output sorts findings by score (lowest first), so the strongest PROMOTE candidates appear at the top. For each candidate:
- Read the fact text aloud (or summarize it).
- Confirm with the user whether it's a rule they want documented in the instructions file.
- If yes, ask which section of the file it belongs under (e.g., Writing Style, Pull Requests, GitHub Actions).
- If the user says "skip" or "leave in memory only", move on.
Do not silently file a PR for everything flagged as PROMOTE. The classifier is a heuristic and the user gets the final say on what becomes documented policy.
Step 4: Promote agreed-upon rules
For each rule the user approves for promotion:
- Draft the change to
~/repos/dotfiles/.github/copilot-instructions.md. Match the surrounding section's tone and structure. - Self-lint with the validate-style skill before opening a PR.
- Follow the user's PR workflow from their personal instructions: multi-model review, draft PR, sign-off, Co-authored-by Copilot trailer, full repo PR template.
Verdict guide
| Verdict | Score range | What it means |
|---|---|---|
| PROMOTE | < 0.30 | Almost no overlap with the file. Strong candidate for promotion. |
| AMBIGUOUS | 0.30 to <0.70 | Partial overlap. Eyeball the matched/missing tokens to decide. |
| PRESENT | >= 0.70 | Significant token overlap with the file. Likely already documented. Exact quoted-phrase matches add weight (up to +0.3) but cannot reach PRESENT on their own. |
PRESENT findings are not always perfect matches. If the user has recently added a rule to the file and the memory was already there, the two should agree. If they don't, that's a different problem (drift) worth surfacing.
Caveats
- This is a keyword and phrase classifier, not a semantic one. False positives and false negatives both happen. Treat output as a triage aid, not as gospel.
- The classifier only checks the instructions file passed as the second
argument. Repo-level
.github/copilot-instructions.mdfiles are not considered. - The
<memories>block in your prompt context already excludes memories outside the current scope. Whatever you dump is the working set.
Source: zkoppert/dotfiles — distributed by TomeVault.