agentleFS
lastxuanainlastxuanain/ainward-skills/skills/code-sync/SKILL.md

code-sync

Skill5 starsChanged 9 days agoMITView on GitHub

Port scoped changes across branches by intent with parallel isolation. Do NOT trigger on plain git merge/pull/push. Triggers: /code-sync, "code sync", "sync to branch", "port changes to", "semantic merge", "代码同步", "同步到分支", "把改动同步到".

  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. LNSD/lorecraft★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository6 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 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.

  • 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. Distinctive:

    Do not use for plain git merge, git pull, git push, or fast-forward branch operations where no semantic inspection was requested.

    line 27
  2. Distinctive:

    No blind git cherry-pick, no pasting obsolete structures onto a refactored target.

    line 52
  3. Very specific:

    Action-first; pause only on genuine conflicts: No pre-execution checklist cards.

    line 65
  4. Very specific:

    If origin/<target> exists, compare with git rev-list --left-right --count <target>...origin/<target>:

    line 99
  5. Very specific:

    Run fast, side-effect-free targeted checks (tsc, lint, affected unit tests) inside the target workspace.

    line 145

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

Code Sync (语义化代码同步与跨分支移植)

Port bug fixes, features, or refactors onto another branch by engineering intent rather than mechanical patch replay—preserving strict parallel-session isolation, adapting idiomatically to the target branch's current architecture, and running straight through whenever no true conflict exists.

When to use

  • Porting changes from this conversation, uncommitted workspace edits, a diverged branch, or specific commits/files onto a target branch (main, develop, release/*), especially when parallel tasks share the repo or the target branch has refactored modules/contracts.
  • Do not use for plain git merge, git pull, git push, or fast-forward branch operations where no semantic inspection was requested.

Host adaptation

  • ask_question below means the host's single-choice question tool (AskUserQuestion in Claude Code, ask_question in Antigravity). Without one, print the options as a numbered list and wait for a reply. Put the (Recommended) option first; never add a manual "Other" option when the host adds one natively.
  • Code links follow the host's own convention first (e.g. relative [orderService.ts](src/order/orderService.ts:42) in Claude Code); otherwise [orderService.ts](file:///abs/path/orderService.ts#L42-L58), falling back to plain path/orderService.ts:42-58. Use basenames as link text; no raw full-path walls, symbol inventories, or multi-column boilerplate tables.
  • Reply in the user's language.

Core rules

  1. Adapt by intent, never replay blindly. Extract the problem solved and the behavioral invariants (execution flow, state/contracts, side effects, non-silent error handling), then implement them natively against <target>'s current module boundaries, shared helpers, types, and tests. No blind git cherry-pick, no pasting obsolete structures onto a refactored target.
  2. Strict bidirectional parallel isolation.
    • Source allowlist: when syncing this conversation's changes (本次对话的改动) or named commits/paths, extract only the files, logical hunks, and commits authored in that scope. Never run git log <target>..<source> for a session-scoped sync; silently ignore unrelated dirty files and parallel commits.
    • Target snapshot only: read only the current snapshot of <target> files and the direct callers/callees/shared peers of the synced units. Do not browse unrelated <target> history (except a narrow --follow lookup if a file moved, or attributing a direct line/contract conflict). Never touch, stage, or stash unrelated dirty files.
  3. Action-first; pause only on genuine conflicts. No pre-execution checklist cards. Ask via ask_question only for missing/ambiguous scope, true semantic/contract divergence, overlapping dirty edits on a target file to modify, or diverged local vs. remote target history.
  4. Proportional output. Scale the summary to the size of the port.

Workflow

Step 1: Read-Only Sensing & Scope Lock

  1. Inspect local Git state offline (git branch --show-current, git status --porcelain=v1 -b, git worktree list). Run git fetch only if a named branch is completely absent locally or the user asks.
  2. Resolve the sync scope:
    • Session changes (本次对话的改动): only uncommitted hunks and/or commit SHAs authored in this conversation. Zero-edit guard: if the user asked for session changes but no code edits happened in this conversation, ask via ask_question which scope to use (Workspace Uncommitted, Branch Commits, or Specific Commits/Files)—never silently fall back to git diff or target..source.
    • Workspace uncommitted / branch commits (target..source) / explicit commits or paths: lock to the requested boundary, excluding unrelated parallel dirty files.
  3. Anchor parameters: if source, target, and scope are unambiguous from the prompt, proceed. Otherwise ask only the missing items in one ask_question card.

Step 2: Target Snapshot Audit & Conflict Routing

  1. Resolve <audit_target_ref> without false stalls. origin/<target> here is the locally cached remote ref (no fetch was run); say so in the summary whenever it is used.
    • If origin/<target> exists, compare with git rev-list --left-right --count <target>...origin/<target>:
      • 0 ahead, K > 0 behind (local <target> simply lags the cached remote): do not pause; set <audit_target_ref> = origin/<target> and align <target> as described in Step 3.1.
      • A > 0 ahead and K > 0 behind (genuinely diverged): flag for the decision gate below.
      • Otherwise set <audit_target_ref> = <target>.
  2. Classify each cohesive source change unit against <audit_target_ref> (using mounted worktree files when they match <audit_target_ref>, else git show / git grep):
    • Already Covered (Skip): equivalent behavior already exists, or a target refactor superseded the root cause with all invariants intact.
    • Port / Adapt: missing or incomplete—plan the minimal idiomatic adaptation + companion types/configs/tests.
    • True Conflict: the target altered contracts/business rules incompatibly, or a target file to modify has concurrent uncommitted edits (target_dirty_conflict).
  3. Route:
    • Zero Port / Adapt and zero True Conflict: stop in 2–4 lines explaining each unit is already covered on <target> (with links where helpful; no question card).
    • Conflict-free fast path (Port / Adapt > 0, no conflicts/divergence): go straight to Step 3.
    • Conflict/divergence gate: state the blocking conflict, dirty clash, or branch divergence in 3–5 plain lines and open one merged ask_question card before editing.

Step 3: Safe Isolated Adaptation, Verification & Delivery

  1. Land without disrupting <source>, never running an unprompted git stash:
    • <target> checked out in the current or another existing worktree: edit only the synced files there. If <audit_target_ref> is origin/<target> and that worktree is clean, first fast-forward it with git -C <wt> merge --ff-only origin/<target>. If it is dirty, do not move it: audit and land against local <target> instead, and note in the summary that it lags origin/<target> by K commits.
    • <target> not checked out anywhere: if lagging, fast-forward the ref safely with git fetch . origin/<target>:<target> (refuses non-ff updates), then create a sibling worktree ../<repo>-sync-<sanitized-target> on <target>, keeping <source> untouched.
  2. Adapt and run targeted checks:
    • Apply clean target-native edits + companion types/tests (no drive-by refactoring, no leftover shims).
    • Run fast, side-effect-free targeted checks (tsc, lint, affected unit tests) inside the target workspace. If a fresh temporary worktree lacks local dependencies (node_modules/.venv), do not install unprompted—mark Not verified with the exact command to run on <target>. Never claim unrun checks passed, and never git commit or git push unprompted.
  3. Proportional summary & conditional temp-worktree closure:
    • One scannable summary scaled to change size (6–10 lines for small ports; grouped bullets for multi-module ports):
      • Outcome (1–2 lines): <source> → <target> (plus temp worktree path, or the cached-origin/<target> alignment note), ported vs. skipped counts, and real check status.
      • Change bullets: plain functional effect + file links for ported and skipped units.
      • Review pointer (1 line, conditional): suggest /agent-review only when non-trivial semantic rewrites occurred or temp-worktree checks were skipped.
    • Closing gate: stop with no question card when you edited in an existing worktree. Open one ask_question card only if Step 3.1 created a temporary worktree:
      • (Recommended) Commit synced files on <target> and remove temporary worktree
      • Keep uncommitted changes and temporary worktree for manual inspection (If confirmed: commit only the synced target files, run git worktree remove, and report the commit hash.)

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.