agentleFS
70asunflower70asunflower/70asunflower-skills/siyuan-backup-sync/SKILL.md

siyuan-backup-sync

Skill1 starsChanged 14 days agoMITView on GitHub

Git backup/sync workflow for the SiYuan data repository (70asunflower/siyuan-backup). Use when committing/pushing the siyuan data repo or fixing a blocked push. Triggers: 思源备份, 思源同步, 笔记备份, 思源 git, 仓库同步. Covers the gh-credential push command, LFS quota awareness, the mandatory 'close SiYuan before git' rule, the temp/install/*.exe .gitignore, and the plumbing-based history cleanup when a large installer accidentally got committed and blocks the push (GitHub GH001 >100MB).

  • Deletes or force-pushes
  • Commits and pushes

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    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
  1. Very specific:

    Only temp/*.exe and *.db are LFS.

    line 36
  2. Very specific:

    Keep backup-before-cleanup until the user confirms the push succeeded.

    line 68
  3. Distinctive:

    Don't git push --force published history.

    line 74
  4. Very specific:

    Always verify git rev-list --left-right --count origin/main...HEAD shows 0 0 after a successful push.

    line 76

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SiYuan Backup / Git Sync

Repo: D:\MyData\Warehouse\siyuan-backup → remote https://github.com/70asunflower/siyuan-backup.git. This is the user's personal note backup — treat it as precious. Least-surprise, never force-push published history.

0. MANDATORY before ANY git operation

Close SiYuan first. It holds a SQLite write lock; committing while it's open risks a corrupted snapshot. Wait for the user to close it (don't kill it yourself — that's a state-changing op needing explicit consent).

1. Safe commit scope

Commit only:

  • data/ (notes + attached assets)
  • history/ (snapshots)
  • conf/conf.json

Exclude (add to .gitignore):

  • .lock
  • temp/queue/
  • temp/*.db-shm, temp/*.db-wal
  • temp/*.db (mutates live; skip to avoid an inconsistent in-flight snapshot)

2. Push command (interactive creds are disabled in this env)

git -c credential.helper="!gh auth git-credential" push

gh is already logged in as 70asunflower. Plain git push fails because terminal credential prompts are blocked.

3. LFS awareness

  • LFS quota: 1 GB(2026-10 快照时 ~927 MB used——数值会漂移,用前 gh api 现查)。Watch it.
  • .sy data files are NOT LFS-tracked → safe to commit freely.
  • Only temp/*.exe and *.db are LFS. A fresh SiYuan installer (siyuan-3.7.x-win.exe, ~200 MB) is NOT auto-LFS and will blow GitHub's 100 MB hard limit.

4. Prevent installer commits (.gitignore)

temp/install/*.exe
!temp/install/siyuan-3.7.0-win.exe   # keep the LFS-tracked one

SiYuan's own backup script does git add -A, which would re-commit installers without this rule.

5. Fix a blocked push (GH001: >100 MB file in history)

Symptom: push rejected because an old (unpushed) commit contains a big temp/install/*.exe. Strategy — rewrite only the unpushed range origin/main..HEAD; keep all already-published history hashes unchanged → push stays a fast-forward (no force-push, cloud safe).

Steps (plumbing, never touches the working tree — safe while SiYuan is open):

# 1. snapshot safety branch (local only, optional but recommended)
git branch backup-before-cleanup

# 2. for EACH commit in the range that contains the blob, rewrite its tree
#    without the exe, using a throwaway index:
GIT_INDEX_FILE=/tmp/idx git read-tree <rev>^{tree}
GIT_INDEX_FILE=/tmp/idx git rm --cached --ignore-unmatch temp/install/siyuan-3.7.1-win.exe
newtree=$(GIT_INDEX_FILE=/tmp/idx git write-tree)
newrev=$(git commit-tree $newtree -p <parent> -m "<msg>")
git update-ref refs/heads/main $newrev

# 3. repeat for every commit that carries the blob (a child commit's tree
#    ALSO contains it if it was built on top of the tainted one!)

⚠️ Lessons (easy to get wrong):

  1. The blob must be stripped from every commit tree in the range that contains it — not just the one that first added it. Child commits inherit the tainted tree.
  2. Plumbing rewrites only the main ref and does not update the real index. Before committing anything else, run git reset --mixed <clean-rev> so the index matches, or you'll re-add the exe.
  3. Keep backup-before-cleanup until the user confirms the push succeeded.

Then push: git -c credential.helper="!gh auth git-credential" push (fast-forward). To reclaim the ~209 MB the old branch holds in .git: git branch -D backup-before-cleanup && git gc --prune=now (only after success + user OK).

6. Gotchas

  • Don't git push --force published history.
  • git filter-branch refuses on a dirty tree (SiYuan leaves 500+ modified files) → use the plumbing approach above instead.
  • Always verify git rev-list --left-right --count origin/main...HEAD shows 0 0 after a successful push.
  • Device rule: only edit SiYuan on one machine at a time (workstation vs home PC) to avoid sync conflicts.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.