brain-save
Skill18 starsChanged 2 months agoMITView on GitHub
Save session context, decisions, progress, and plans to the Claude Brain Logseq graph. Triggers: "save to brain", "save this", "remember this", "store this decision", "log this", "save progress", "before I quit", "wrap up". Don't fire for read operations (use brain-load) or status checks (use brain-status).
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- evalSkill
- releaseSkill
- brain-doctorSkill
- brain-initSkill
- brain-loadSkill
- brain-statusSkill
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 2 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 20
Put text arguments in single quotes.
- Very specific: line 27
brain save-begin <page> [--also FILE…]: Don't list the graph first. - Very specific: line 49
Write each :: child only when it has a real value.
- Distinctive: line 63
Edit the page surgically: Never rewrite a whole page.
- Very specific: line 67
If an Edit anchor doesn't match, Logseq normalized the file: see skills/_shared/logseq-format.md.
- Very specific: line 68
Rotation: if step 2's table shows a page total over 64 KB, or a Session Log over 40 entries, suggest rotation per references/rotation.md.
- Very specific: line 72
index: missing: Read pages/Index.md and add the one-liner under ## Projects, its descriptor taken from the page's first Overview bullet. - Very specific: line 85
Run save-begin once per page, before its first Edit.
- Distinctive: line 86
Never hand-edit the Map line, and never compute a byte figure yourself.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Brain Save
Persist session context to the Claude Brain Logseq graph, for continuity across sessions and devices. A routine save is: save-begin, one Read, three Edits, save-finish. It reads no file but this one.
Running the helper
- Bash:
sh "<this skill's base directory>/../_shared/bin/brain" <command> … - PowerShell-only Windows:
& "$(Split-Path (Split-Path (Get-Command git).Source))\bin\bash.exe" "<base>/../_shared/bin/brain" <command> … - Neither works: stop and say "logseq-brain needs Git for Windows (Git Bash) — https://git-scm.com/download/win".
- In Cowork, always pass
--graph <connected folder>. Elsewhere pass--graphonly when the graph is not configured. It may go anywhere on the line. On exit 2 withgraph not resolved, followskills/_shared/path-resolution.md, then pass--graph. - Put text arguments in single quotes; a
'inside becomes'\''. In double quotes the shell runs backticks and expands$. - Exit 0 clean, 1 findings (act on them), 2 error (act on its reason; don't retry blindly). Quote every
coverage:line. Never recompute a figure it printed. Itsgraph:line is the folder for your own Read, Edit and Write calls.
Save process
- Targets. Take the project from the names, files and repos discussed, or the user's words. If unclear, ask: "This touched [X] and [Y] — save to both?" Several pages are saved one at a time, each running steps 2–7 before the next begins.
brain save-begin <page> [--also FILE…]. Don't list the graph first. It baselines the page,pages/Index.mdand today's journal, and prints what you edit:== digest: the property block and## Digest(amap: staleormissinghere is expected:save-finishrecomputes the Map);== session-log: the newest entry;== current-plan;== anchors: the page's Index line and the end of today's## Sessions.
Name every other file this save may write with
--also:pages/Meta.md,pages/Decisions.md,pages/Tasks___<ID>.md. If the need appears while composing, rerunsave-beginwith the full list before the first Edit, never after: a rerun resets the baselines.page not found(exit 2): never write to a missing page. Offer to create it via brain-init's "Adding a New Project". If declined, list the projects (brain status) and let the user pick.- Task pages: the page-top block must hold
status::withactive | blocked | done. Seedstatus:: activeif it's missing. On completion signals ("merged", "deployed", "closed", "released", "hotovo"), suggeststatus:: done, and never write a status change the user didn't confirm. Read or edit a task page only to change itsstatus::, passing it in--also. A worked task with no page gets only the Current Plan pointer and an offer to create it. Never create one uninvited.
- One Read of the page, for Edit:
Readwithoffset: 1, limit: 1. That unlocks Edit for the whole file. The text you replace comes from step 2's output. Need another section's text for an anchor (Implementation, Decisions)? Usebrain read <page> '<section>', not a whole-page Read. Don't read Index or the journal:save-finishwrites them. - Compose.
- Session Log entry (always), appended after the newest entry:
Write each- yyyy-MM-dd: Brief summary of what was done - Detail - files-modified:: key files changed - skills-used:: skills or tools used - related-tickets:: Jira IDs - open-questions:: unresolved questions to carry forward::child only when it has a real value. - Current Plan: replace it when the plan changed; there is exactly one plan. For a Jira task, keep a pointer only:
- PROJ-1234: titlewithstatus::,estimate::,task-folder::andsummary::children. Add the ID torelated-tickets::. The full plan lives in the task folder. - Implementation: append only notes that will matter in future sessions.
- Meta (
pages/Meta.md, in--also): only new, lasting preferences, conventions or tools. Never one-off instructions or sensitive data. Details inreferences/categories.md§ 6. - Decisions, detected on every save: scan your composed text for decision-shaped statements ("decided", "chose X over Y", "went with", "will use", "instead of", "superseded", "rozhodnuto", "zvolili jsme"). Ask once, as a batch: "These N statements look like decisions — record them in Decisions? (1) … (2) …" Record only approved ones, and for those read
references/decisions.md(the conflict check and the cross-project copy topages/Decisions.md, which must then be in--also). Declined ones stay as Session Log prose. - Invariants. Self-check every line against these before any Edit, and correct silently. Logseq parses a file as soon as it changes and never deletes a page it created, so a bad line fixed seconds later can still leave a phantom page.
- Backticks for code, never
{{ }}. - No
#directly before a number or word, even after a letter (C#-parity,PKCS#12): backtick the token or rephrase. - Links to projects and tasks are namespaced:
[[Tasks/…]],[[Projects/…]]. - File paths are markdown links
[x](file:///…)or backticks. Never[[file://…]], never relative[x](docs/x.md). - Jira drafts go verbatim in fenced blocks.
key::only in the page-top block. In a Session Log line,- status: blockedis prose.- Everything is a bullet; dates are
yyyy-MM-dd.
- Backticks for code, never
- Session Log entry (always), appended after the newest entry:
- Edit the page surgically. Never rewrite a whole page. New entries go at the end of their section.
- One Edit for the properties and
## Digestprose (they are adjacent). Setlast-updated::anddigest-updated::to today. Writefocus::andnext::(both required). Writeopen::only when something is genuinely open; otherwise remove the line. Each value is one line of at most 120 bytes. Rewrite the prose bullets from this session's knowledge, in slot order: Identity, Now, Binding (dated pointers to decisions), Hazard, then a free slot. Task pages usually need only Identity and Now. The whole section is capped at 800 B, Map included. Leave the Map line alone;save-finishcomputes it. A page with no## Digestgets one here, right after the property block, perskills/_shared/digest.md§ Surface 2. Say in step 7 that it was backfilled, and that a Rebuild from source is available. - Current Plan (replace), then Session Log (append).
- Implementation, Decisions, Meta, and a task page's
status::, when needed. - If an Edit anchor doesn't match, Logseq normalized the file: see
skills/_shared/logseq-format.md. - Rotation: if step 2's table shows a page total over 64 KB, or a Session Log over 40 entries, suggest rotation per
references/rotation.md. It is a suggestion only, and it runs after step 6.
- One Edit for the properties and
brain save-finish <page> --summary '<one line>' --index '<latest version or milestone> — <current focus>'. Use single quotes. Pass--indexfor a project page only. The summary becomes- [[Projects/<Name>]]: <summary>under today's## Sessions. The index text replaces the parenthetical of the page's one-liner inpages/Index.md(e.g.v0.8.0 shipped 2026-06-23 — v0.9.0 in design). Both are rewritten on every save. The command validates, writes the Sessions bullet, the Index text and the Map, checks every filesave-beginbaselined, and logs the activity line.- A refusal (text, cap or Map; exit 1 or 2) wrote nothing. Fix the cause, then rerun the same command. For
over:lines, shorten the free slot first, then Binding and Hazard, with one Edit. A refused text gets rephrased. index: missing: Readpages/Index.mdand add the one-liner under## Projects, its descriptor taken from the page's first Overview bullet. Then runbrain check pages/Index.md.index: ambiguous: tell the user.check …error-tier findings: a line this save wrote breaks a rule, and the activity line is deferred. The helper has written the Map, so Read the page again before fixing with Edit. Then run thebrain check … && brain activity …it printed.- Warn-tier (
broken-link,new-property-key): tell the user; don't block. For example: "linkedTasks/CRMGM-2070, which has no page yet". nonconvergent-map/duplicate-map: seeskills/_shared/hygiene-rules.md.
- A refusal (text, cap or Map; exit 1 or 2) wrote nothing. Fix the cause, then rerun the same command. For
- Confirm in plain language: what was written, the check result, any warn-tier items, and a digest backfill if one happened.
Auto-suggest
See references/auto-suggest.md. Suggest only; never auto-save.
Important notes
- Run
save-beginonce per page, before its first Edit. A rerun resets the baselinessave-finishchecks against; if it printswarning: changed since the last save-begin, runbrain linton the files it names before you finish. - Never hand-edit the Map line, and never compute a byte figure yourself.
- A rotation moves Session Log entries verbatim. A finding its
brain checkreports on the archive page is carried-over content: report it and leave it for brain-doctor.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

