PLUGIN brewdoc / Skills

memory-sync-setup opus generator

A generic memory sweep cannot tell an intentional Russian trigger alias from a language violation, or a stale lint-rule claim from a correct one. /brewdoc:memory-sync-setup analyzes your repo and writes a project-local .claude/skills/memory-sync/ that knows its batches, invariants, verification commands, agent roster and language policy. That emitted skill syncs everything auto-loaded against the code.

Quick reference

FieldValue
Command/brewdoc:memory-sync-setup [prompt] [status|install|upgrade|enable|disable|uninstall|purge] [fine-tune-prompt] [--unattended]
Canonical modesstatus · install · upgrade · enable · disable · uninstall · purge
No argumentstatus when .claude/skills/memory-sync/ exists, install when not
Invocationuser-invoked only (disable-model-invocation: true)
Modelopus
ToolsRead, Edit, Glob, Grep, Bash, Agent, AskUserQuestion

What it does

The skill is a generator in the family of brewcode:superreview-setup and brewtools:task-board-setup: it produces a working artifact instead of doing the work itself. It scans the memory surface (root and nested CLAUDE.md, rules, conventions, the AGENTS.md family, agents, skills, the memory dir), then emits five files. docs/** is out of scope, owned by a separate doc flow (/docs, docsync-setup).

The emitted /memory-sync runs disjoint batches, verifies each with an independent checker, and is non-growth: no file ends longer than it started. Focus text steers emphasis; an explicit “only rules” narrows what may be written.

When to use

ScenarioCommand
Wire memory sync into a repo/brewdoc:memory-sync-setup install
Bias toward a concern/brewdoc:memory-sync-setup install "weight stale-fact removal over compression"
Check the install is still true/brewdoc:memory-sync-setup status
Repo gained an agent, rule or CLAUDE.md/brewdoc:memory-sync-setup upgrade
Pause or resume /memory-sync/brewdoc:memory-sync-setup disable / enable
Drop the emitted skill (keeps your files) / the whole diruninstall / purge
Actually sync memory/memory-sync (the emitted skill)

Example

/brewdoc:memory-sync-setup install
memory-sync generated -> .claude/skills/memory-sync/

Surface:    68 files: 5 root, 15 rules, 3 conventions, 26 agents, 18 skills, 1 local
Batches:    6  (disjoint)
Excluded:   docs/** (separate doc flow), source code, secrets,
            .claude/reports/**, .claude/worktrees/**

Run it:  /memory-sync                       -> scope session (default), whole surface
         /memory-sync all "only rules"      -> re-verify facts in authorized rules only

Counts are illustrative; real ones come from the scanned project.

Workflow

  1. Mode gate

    An explicit mode wins; empty input means status or install. At most one question, before work starts.

  2. Analyze

    generate.sh scan finds the memory surface, VERIFY-ONLY files, exclusions, default branch, language policy and a fact catalogue (one shell command per claim).

  3. Emit

    generate.sh emit fills the template and stamps provenance frontmatter. It refuses to overwrite a live install.

  4. Fill blocks

    Thirteen multi-row placeholders are filled through Edit: eleven in SKILL.md, two in references/hard-sync.md.

  5. Validate and report

    generate.sh validate fails on leftover placeholders or missing assets, then the report prints surface, batches and how to run it.

Modes in detail #
ModeWritesDoes
statusnothingRuns generate.sh status: provenance rows, surface stamped vs counted now, missing files. Verdict IN SYNC / STALE (n drifts) / STALE-LEGACY (n drifts) / NOT INSTALLED, prefixed PARKED - when disabled
install5 filesFull analysis and emit. Refuses if the dir exists
upgradeeditsRe-scans, refreshes tables, keeps hand-edits, ends with generate.sh restamp (also deletes a pre-5.5.1 disable-model-invocation key)
enableone renameSKILL.md.disabled -> SKILL.md; no regeneration
disableone renameSKILL.md -> SKILL.md.disabled. Claude Code discovers a project skill only through SKILL.md, so references and hand-edits stay byte-identical
uninstalldeletes manifestRemoves SKILL.md (or parked form) plus the 4 references, after confirmation; user-added files are kept and listed
purgedeletes dirThe whole .claude/skills/memory-sync/, plus crashed .memory-sync-emit.* staging

Under --unattended, upgrade skips when the emitted skill is parked or not installed; see how the flag works.

Enable/disable is entry-file parking, not a flag: status reports INSTALLED=parked, never NOT INSTALLED. Removed aliases: init, on, off, setup, remove, reset, create, update, cleanup.

What the emitted skill does #
AxisBehavior
Scopesession (default), branch, commit <sha> / <a>..<b>, recent[:N] (default 10), all
DepthNORMAL (default) or HARD
ReachMEMORY (default) or REFS (adds tracked outside references cited by always-loaded files)
PhasesGATHER (parallel, read-only) -> SYNC (one agent per batch, one message) -> VERIFY (checker is never the writer) -> SELF-SYNC -> PROPOSE (new agent/skill proposed, never auto-created) -> REPORT (chat only)
AgentsRe-audited against current best practice every sweep
InvocationModel-invocable by design; no disable-model-invocation

Emits SKILL.md plus references/memory-guide.md, agent-audit.md, hard-sync.md, prompting-guide.md, nothing else. A fresh .claude/skills/ needs /reload-skills once.

Depth: NORMAL vs HARD #

Depth comes from the request: the token hard, or the intent in prose (“too much context”, “aggressive”). Nothing is regenerated.

NORMALHARD
Fact sync, dedup, compressionyesyes
Pass A: rules paths: precision auditnoyes
Pass B: obvious-knowledge purgenoyes
  • Pass A. Each paths: entry gets a verdict: OK, TOO_BROAD, TOO_NARROW, DANGLING, MISSING, CORRECTLY_GLOBAL. A DANGLING entry is dropped and reported; the rule file is never deleted.
  • Pass B. Deletes what any competent model already knows. Keeps decisions that exist because someone here made them. A line naming a path, command, version or number is kept, and a file cut by more than half is reported before the edit lands.
/memory-sync all hard
Scope and safe evidence #

Scope picks change facts, depth picks processing, reach picks editable files; user narrowing overrides all three. Source code, doc-flow paths and secrets are never written at any reach. Verification reads the minimum non-secret evidence: credential names and key paths can be checked, key contents are never read or copied.

Prompt quality pass #

Each sweep applies the 18-rule table in references/prompting-guide.md to authorized instruction files (CLAUDE.md, .claude/rules/**/*.md, AGENTS.md, agent and skill bodies).

ViolationNORMALHARD
On a line a fact/dedup edit already touchesfixedfixed
On an untouched linereported onlyfixed

A lossless guard protects paths, CLI flags, thresholds, versions, model ids, incident-backed !=/NEVER rows and canonical mode lists. The report gains a Prompt column per file.

Generator internals #
  • Restamp. generate.sh restamp rewrites provenance keys in place and refuses to write if anything outside them would move. Genuine drift still needs a verified correction.
  • Surface counts prune .claude/reports/** and .claude/worktrees/** (copies, not memory). surface_files is always the script’s own count.
  • Version. Read from plugin.json by self-location; if unreadable, emit and restamp hard-fail rather than stamp unknown.
  • Git visibility. A real set difference (git ls-files vs find, comm -23): git-tracked, git-ignored, no-commits, or mixed (N tracked, M untracked). mixed or git-ignored tells VERIFY to re-read files, never trust git diff alone.
  • Foreign marker blocks (such as brewcode:semble in CLAUDE.md) are preserved byte for byte and reported as managed by <setup>.
  • Errors. install on an existing install points to upgrade; a fact with no runnable command is left out; a symlinked or vendor-marked AGENTS.md becomes VERIFY-ONLY.
  • Re-run upgrade when a nested CLAUDE.md, rule, agent or skill is added, the stack or default branch changes, or status shows drift.

docsync-setup

Date-based staleness tracking for edited Markdown; memory-sync verifies instruction claims against source.

Text Optimize

Compresses prompt-shaped files (CLAUDE.md, rules, agent and skill files) for token efficiency.

Brewdoc overview

Every brewdoc skill and what it does.

GitHub source

Emit templates and the full SKILL.md.

Update: /brewtools:plugin-update, /reload-plugins, then /brewcode:setup-status upgrade - FAQ