/sync
/sync commits all the changes in your workspace and pushes them to your remote repository. Claude writes the commit message for you and does not ask you to approve it. Before it pushes, it checks that the remote is the repository recorded for this workspace.
When to Use It
Section titled “When to Use It”Use /sync when you want your work saved to the remote repository without updating project records. Three common moments are listed below.
- After
/setup, to commit your personalised configuration. - Before you move to another computer, so the other machine can pull your latest work.
- At any point during the day when you want a safe copy off your machine.
To record what you did against your projects as well, use /night, which updates your project records and then commits and pushes.
How to Run It
Section titled “How to Run It”- Type
/syncin the message box at the bottom of the Claude Code panel and press Enter. - Check the confirmation that Claude shows when the push is complete.
/sync takes no arguments.
What It Does
Section titled “What It Does”- Checks the workspace identity. Claude reads
workspace.githubRepofrom.claude/state/state.jsonand, if it holds a value, compares it with the address of youroriginremote. If the two do not match, Claude stops and shows an error without committing or pushing anything. - Stages the changes. Claude runs
git statusto see what has changed and thengit add .to stage every change in the workspace. - Commits. Claude reads the staged changes, writes a short message that describes them and commits with a
Co-Authored-By: Claudeline at the end of the message. - Pushes and confirms. Claude runs
git pushand then reports the number of files changed, the commit hash and the remote branch it updated.
Why the Identity Check Matters
Section titled “Why the Identity Check Matters”If you work with more than one workspace, for example your own and one you manage for a colleague, a push from the wrong folder could send one workspace’s files to the other’s repository. The identity check stops that. It uses the repository address you gave during /setup. If you answered none, the field is empty and the check is skipped.
What It Reads and Writes
Section titled “What It Reads and Writes”| File or source | Read or write |
|---|---|
.claude/state/state.json |
Read for workspace.githubRepo |
| Your local repository | Every change is staged and committed |
| Your remote repository | Written, through git push |
Example
Section titled “Example”/syncClaude words the confirmation in its own way, but it always gives the number of files, the commit hash and the branch pushed.
Committed 4 files (a1b2c3d): Add speaker list and agenda for the spring workshopPushed to origin/main
