Workflows

August 27, 2026 · View on GitHub

lore has seven workflows. This document explains when to use each one, in plain language. For the operational specification the agent follows when running them, see skill/references/workflows.md.

中文版

Overview

WorkflowWhat it doesFrequency
initSet up .lore/ and platform mirror filesOnce per project
syncUpdate .lore/ after a code changeAfter each feature
querySearch .lore/ for an answerEvery session
auditFind stale or contradictory entriesQuarterly
compressRebuild SUMMARY.mdWhen SUMMARY is stale
mirrorRegenerate platform files from .lore/After batch of syncs
historyShow git commits for an entry / file / scopeWhen investigating

init

One-line: Create .lore/ and take over your existing CLAUDE.md / AGENTS.md.

When you say it: "lore init" — once per project, or when adding lore to a project that already has platform files.

What happens:

  1. Agent scans for existing platform files (CLAUDE.md, AGENTS.md, .cursorrules, etc.)
  2. For each file found, asks you: take over / preserve / abort
  3. Detects monorepo structure (pnpm workspaces, Cargo workspace, etc.) and proposes scope list
  4. Writes initial .lore/ draft (entries with #added:<today> + deterministic IDs)
  5. Shows you a summary of what will be created
  6. On your confirm: moves draft to .lore/, generates SUMMARY.md, refreshes platform files

Real scenarios:

  • New project, first time using lore → lore init
  • Old project already has CLAUDE.md, want lore to manage it → lore init and take over
  • Monorepo with separate frontend/ and backend/ → init detects both, asks for scope names

Output: Full .lore/ directory + updated platform files + populated .config.json.


sync

One-line: After a code change, update .lore/ with what changed.

When you say it: "lore sync" — after committing a feature, refactor, or new dependency.

What happens:

  1. Agent detects the delta from two sources, combined and de-duplicated:
    • Commits since last syncgit diff <last_sync_sha>..HEAD (when the config has a reachable last_sync_sha; falls back to working-tree diff alone if it's absent or unreachable, with a [WARN] to stderr).
    • Uncommitted changesgit diff HEAD when HEAD exists, including net staged and unstaged changes.
    • New files — inspect added paths and scan untracked files listed by git ls-files --others --exclude-standard.
    • Empty repo — enumerate paths with git ls-files --cached --others --exclude-standard and scan current working-tree files; do not run HEAD-based diffs.
  2. If the change is significant (≥50 lines / ≥2 dirs, or new module/dir/dep, or a new convention was discussed), the agent proactively proposes.
  3. For each candidate entry, the agent classifies it as [NEW] / [STALE] / [REFINED] and checks for contradictions against existing entries in the same scope/layer — contradictions are flagged as [ALERT]. This is sync's own contradiction-detection step; a full lore audit is a separate command that walks every entry.
  4. Runs find_duplicates.py --json --candidate "<entry body>" for each candidate before writing (or supplies the body via --candidate-file with a UTF-8 file). Only a semantically equivalent active entry in the applicable scope can suppress a candidate; also compare unsaved candidates with each other.
  5. Emits a proposal with [NEW]/[STALE]/[REFINED]/[ALERT] markers. Default trust level is medium; de-duplicate hits and tags-only REFINEDs auto-apply without per-item confirmation and are reported afterward. Body-changing REFINEDs (new ID + supersede link), NEW, STALE, and ALERT require confirmation.
  6. You accept or reject per marker; accepted markers get applied to .lore/*.md. Then last_sync_sha advances to the current HEAD so the next sync spans the right commit range.

Real scenarios:

  • "I just added a new dependency — update lore" → lore sync
  • "We decided to stop using React Query, switch to SWR" → lore sync after the code change
  • "There's a new module — capture it" → lore sync

Output: Updated .lore/*.md files with new entries (and #verified / #stale tags where appropriate).

Note: sync does NOT update platform mirror files (that's a separate mirror command). Reason: keeps git log of agent-facing files readable.


query

One-line: Search .lore/ for an answer to a question.

When you say it: "lore query " — any time you want to know what's in memory.

What happens:

  1. Agent reads .lore/SUMMARY.md (the table of contents)
  2. Fuzzy matches your query against active entries (neither #stale nor #superseded-by); for historical questions, identifies the status of inactive entries
  3. Returns matched entries with stable [file#ID] references
  4. Optionally drills into specific scope files for more detail

Real scenarios:

  • "What database does this project use?" → lore query database
  • "Why did we pick Zustand?" → lore query zustand
  • "What are the conventions for backend modules?" → lore query backend:conventions

Output: Bounded list of matched entries:

[_global/DECISIONS.md#DEC-2026-07-11-6137] Picked OpenAI-compatible LLM API
[scopes/backend/CONVENTIONS.md#CONV-2026-07-11-9b89] Embedding has two backends

The [file#ID] reference lets the agent cat the file for full text.


audit

One-line: Find stale or contradictory entries in .lore/.

When you say it: "lore audit" — quarterly review, or before a big refactor.

What happens:

  1. Runs find_stale.py to find entries whose reference date (#verified if present, else #added) is older than 90 days, plus broken #superseded-by chains.
  2. For each entry, walks the referenced code path against the current filesystem and checks for contradictions (memory says react@18, package.json says 16).
  3. Writes a structured report to .lore/audit/audit-<date>.md grouped by severity (CONFLICT, STALE, UNVERIFIED, BROKEN_CHAIN).

Real scenarios:

  • "Are there any lore entries that contradict the current code?" → lore audit
  • Quarterly hygiene check → lore audit
  • Before onboarding a new contributor → lore audit to clean up stale entries

Output: A dated report file under .lore/audit/:

# Memory Audit Report

> Date: 2026-07-09
> Findings: 2 CONFLICT, 1 STALE, 5 UNVERIFIED, 0 BROKEN_CHAIN

## Scope: backend

### CONFLICT
- [CONV-2026-03-01-1f8c] says "use webpack"
  Evidence: `package.json` declares `"vite"`

### STALE
- [ARCH-2026-01-15-d7a3] references `nx.json`
  Evidence: file no longer exists at repo root

Note: audit does NOT modify any .lore/*.md file and does NOT emit ALERT blocks (ALERT is reserved for sync and query). To act on findings, run sync with proposal-driven updates.


compress

One-line: Rebuild .lore/SUMMARY.md from current entries.

When you say it: "lore compress" — when SUMMARY is stale (entries > 500, or > 30 days since last compress), or before sharing lore with someone new.

What happens:

  1. Enumerates all entries via list_entries.py
  2. Excludes entries with #stale or #superseded-by, even without a successor; untagged entries remain eligible, and age alone does not exclude an entry
  3. For each (scope, layer) pair, picks 3–5 most important entries
  4. Writes SUMMARY.md per template
  5. If auto_mirror: true in config, regenerates platform mirrors; otherwise asks per target and only writes the ones you accept. (This is the second mirror update trigger — sync deliberately does not regenerate mirrors.)
  6. Stops after mirror regeneration has either written or been declined per target.

Real scenarios:

  • "Refresh the summary" → lore compress
  • "I haven't compressed in 2 months" → lore compress
  • "Onboard a new contributor — make sure SUMMARY is fresh" → lore compress

Output: Updated SUMMARY.md (and possibly mirror files).

Idempotent: Running twice produces the same result (modulo date stamp).


mirror

One-line: Regenerate platform files (CLAUDE.md, AGENTS.md, etc.) from current .lore/.

When you say it: "lore mirror" — after a batch of syncs, or to manually sync mirrors after editing .lore/*.md.

What happens:

  1. Reads current .lore/SUMMARY.md and scope indices
  2. For each target, detects section boundary (## Lore / --- / ## My notes)
  3. Computes new Lore section content
  4. Content-based dedup: skips write if byte-identical to existing
  5. Replaces Lore section; preserves My notes verbatim
  6. Writes file back

Real scenarios:

  • "I just did a batch of syncs — update the agent-facing files" → lore mirror
  • "I edited .lore/SUMMARY.md manually — propagate to mirrors" → lore mirror
  • "Verify the mirror hasn't drifted" → lore mirror (no-op reports confirm)

Output: Updated CLAUDE.md / AGENTS.md / etc., or "No changes needed" if nothing changed.


history

One-line: Show git commits related to an entry, file, or scope.

When you say it: "lore history ||--scope=" — when investigating "why does this exist" or "when did this change".

What happens:

  • Entry form: lore history DEC-2026-02-03-7c19 — finds the entry, derives its #added date, runs git log --since=<date> on the referenced code file
  • File form: lore history frontend/src/store.ts — runs git log --since=1970 on that path
  • Scope form: lore history --scope=frontend — runs file form on every .lore/scopes/frontend/*.md

Real scenarios:

  • "Why did we pick Postgres?" → find the entry via query, then lore history <id>
  • "When did this file change?" → lore history <file>
  • Debugging: "what's the recent history of this module?" → lore history <path>

Output:

# history: [DEC-2026-02-03-7c19]

> Entry: scopes/backend/DECISIONS.md
> Since: 2026-02-03T00:00:00 (entry #added date)
> File: backend/app/auth.py
> Commits: 2 (showing all)

## 9f264f4 (2026-05-12, Alice)
refactor: extract chat agent_loop (#87)

## def5678 (2026-03-08, Bob)
feat: switch chat chain to chat_fast (#74)

Quick reference

I want to...Use
Start lore on a projectinit
Update lore after a code changesync
Find what's in memoryquery
Find stale entriesaudit
Refresh the summarycompress
Update agent-facing filesmirror
Trace why something existshistory

For the operational specification (what the agent actually does step-by-step), see skill/references/workflows.md. For per-platform file mapping (which platforms read which files), see skill/references/platform-mirrors.md.