by Duy Lam
Puts a project into a known-good git state before the first prompt of every session: brings the branch the session opened on level with the remote's default branch (main, falling back to master), initializes submodules recursively, attaches each top-level submodule to the superproject's branch instead of a detached HEAD, and brings each one level with its own remote at the branch .gitmodules declares. This keeps a claude remote-control worktree current with upstream on start, since that worktree is built before any session hook runs and SessionStart is the only moment left to reconcile it. The sync is always a merge and never destroys anything - a fast-forward when the branch has no local commits, a merge commit when it does. Does nothing outside a git repo or in a repo with no remote, never fails a session, and turns the sync off when GIT_AUTOSYNC_DISABLE is set. Also bundles a read-only recap skill that reports, for the superproject and each top-level submodule, the local branch and tracking remote (each with its commit id) and the pull requests whose head is that branch.
Claude Code1 Skill