sync
Sync files between two local directories, repos, or git worktrees. Five modes (plan/interactive/push/pull/mirror), .gitignore-aware, Claude-workflow allowlist via --claude, dropbox-restore-style per-directory prompts.
- License 许可
- MIT
- 最近更新
- 2026-09-10
- Stars
- ★ 3
- Forks
- 1
01 前言 Front Matter
- name
- sync
- description
- Sync files between two local directories, repos, or git worktrees. Five modes (plan/interactive/push/pull/mirror), .gitignore-aware, Claude-workflow allowlist via --claude, dropbox-restore-style per-directory prompts.
- argument-hint
- [--from PATH] <target | --to PATH> [--mode plan|interactive|push|pull|mirror] [--dry-run] [--yes] [--limit N] [--include GLOB] [--exclude GLOB] [--no-gitignore] [--delete] [--claude]
- user-invocable
- true
02 资源文件 27
- 脚本__init__.py—
- 脚本scripts/__init__.py—
- 脚本scripts/apply.py3.1 KB
- 脚本scripts/claude_allowlist.py2.1 KB
- 脚本scripts/diff.py2.8 KB
- 脚本scripts/discover.py2.0 KB
- 脚本scripts/exceptions.py653 B
- 脚本scripts/gitignore.py1.5 KB
- 脚本scripts/plan.py1.4 KB
- 脚本scripts/prompt.py1.5 KB
- 脚本scripts/render.py1003 B
- 脚本scripts/sync.py4.9 KB
- 脚本scripts/types.py642 B
- 脚本tests/__init__.py—
- 脚本tests/conftest.py1.1 KB
- 脚本tests/test_apply.py4.1 KB
- 脚本tests/test_claude_allowlist.py1.8 KB
- 脚本tests/test_diff.py3.6 KB
- 脚本tests/test_discover.py2.3 KB
- 脚本tests/test_exceptions.py590 B
- 脚本tests/test_gitignore.py2.1 KB
- 脚本tests/test_invocation.py1.6 KB
- 脚本tests/test_plan.py1.2 KB
- 脚本tests/test_prompt.py1.6 KB
- 脚本tests/test_render.py911 B
- 脚本tests/test_sync.py11.8 KB
- 脚本tests/test_types.py802 B
03 SKILL.md 正文
/sync
Sync files between two local directories. Source defaults to $PWD (or set
explicitly with --from). Target is the first positional argument or --to
(exactly one — passing both raises "target: use positional or --to, not both").
When the user types /sync ...
- Parse the user's arguments and translate shorthand:
- If the user's first token is a mode name (
plan,interactive,push,pull,mirror), rewrite it to--mode <name>. The script treats any bare positional as thetargetdirectory, soplanas a bare arg collides with--toand errors. - Strip any leading
@from path tokens (e.g.@.claude/docs/…→.claude/docs/…).@is a convention from the Claude Code slash-command surface, not a valid shell path. - If the user passes a literal placeholder like
<every …>, don't pass it through — expand it to concrete paths first, or tell the user you need a real path.
- If the user's first token is a mode name (
- Run from the
claude-damnrepo root (the directory containingpyproject.toml; locate it withgit rev-parse --show-toplevelif needed):
If you are in a claude-damn worktree (PYTHONPATH="$HOME/.claude" python3 -m skills.sync.scripts.sync <args>.worktrees/<slug>), that also works — the module is available from any checkout. Don'tcdinto the source or target being synced;cdinto the repo that hosts the sync module. - Show the output to the user.
Concrete invocation examples
# Plan a sync: /foo → /bar with the Claude allowlist (gitignored files kept)
uv run python -m skills.sync.scripts.sync --mode plan --claude \
--from /Users/you/src --to /Users/you/dst
# Execute a push after plan-mode approval
uv run python -m skills.sync.scripts.sync --mode push --yes --claude \
--from /Users/you/src --to /Users/you/dst
# Positional target (equivalent to --to), source defaults to $PWD
uv run python -m skills.sync.scripts.sync --mode plan /Users/you/dst
Common translation mistakes — do not do these:
# ❌ BAD: `plan` becomes the positional target, collides with --to
uv run python -m skills.sync.scripts.sync plan --claude --to /Users/you/dst
# error: target: use positional or --to, not both
# ❌ BAD: bare @ prefix on the target path
uv run python -m skills.sync.scripts.sync --mode plan --claude \
--from /src @/Users/you/dst
Modes
| Mode | Behavior |
|---|---|
plan (def.) |
Print the plan and exit. Chat with the user to refine (add excludes, change scope), then re-run in a non-plan mode. |
interactive |
Source → target, prompting y/n/a per directory. |
push |
Source → target, non-interactive. Requires --delete to remove target-only files. |
pull |
Target → source, non-interactive. |
mirror |
Bidirectional; newer mtime wins; --delete needed for removals. |
Plan-mode chat loop (the default)
When --mode plan is used (or no --mode is given), you MUST:
- Run the command and show the rendered plan.
- Ask the user if the plan looks right. Suggest common refinements:
- "Want me to exclude
node_modules//dist// anything else?" - "Should I also include Claude files (
--claude)?" - "Which mode do you want when we execute — push, pull, or mirror?"
- "Want me to exclude
- Re-run
--mode planwith updated flags until the user says "go". - Then run the same command again with the chosen mode (e.g.
--mode push --yes) to execute.
--claude flag
Opt-in. Carries over a curated allowlist of Claude-workflow files (CLAUDE.md,
.claude/skills/, .remember/, docs/superpowers/, etc.) even when they're
gitignored. Ephemeral state like .claude/projects/, .claude/plugins/,
.claude/cache/ is always excluded — users cannot opt back in. The built-in
allowlist can be overridden with ~/.claude/sync-allowlist.txt (one glob per
line).
Safety guarantees
.git/is never copied.- All subprocess calls use explicit argv; never
shell=True. - Failures surface as non-zero exit codes with error messages on stderr.
planmode writes nothing.--dry-runon any other mode writes nothing.
04 同仓库更多 Skills
visual-aid
Use when the user asks for a quick visual aid, visual explainer, concept card, one-pager, poster, cheat sheet, infographic, visual summary, summary card, or mini explainer page — especially from input like a block of text, attached images, an attached song (lyrics/audio), a web link, a CSV/dataset, a math formula, a code snippet to walk through, a tutorial's steps, a timeline, or an A-vs-B comparison. Triggers include "make me a quick visual aid", "turn this into a one-pager / cheat sheet / explainer", "summarize this visually", "give me a visual of", "explain this on a single page", "make a concept card for", "whip up a page about", "build a mini page that shows", "something I can paste into a doc explaining X", or any request to render a topic/text/link/image-set/song/data into a standalone page. Prefer this skill over frontend-design when the ask is an explanatory single-file page (not a production UI), over playground when the output is static information display (not an interactive configurator), and over a Markdown/code answer when the user explicitly wants a *page* (HTML). Produces a single self-contained HTML file that opens on double-click without a server.
tesseract
Use when you've been poking at the same file, concept, or problem across many sessions and want to step outside time to see its whole arc — or when you want to leave a note for next-session-you. Triggers: 'I've been going in circles on X', 'what have I learned about X', 'what did past-me say about X', 'I keep rediscovering this'.
tdd
Invoke test-driven development as an explicit one-at-a-time micro-cycle — one test, one piece of functionality, refactor, then repeat for the next behavior
tdd-cat
TDD workflow with subagent-driven-development — /tdd composed with /cat, plus the A/B TDD execution-mode axis (split-phase vs micro-cycle) asked as a third question in /cat's combined pre-dispatch question
task-list
TaskCreate / TaskUpdate / render the current TaskList in response to `/task-list` (with or without flags). The skill body executes immediately on the syntax — no permission-seeking, no echoing the list back as plain text.
super
Brainstorming (alias for /brainstorming)