When the code drifts from the spec
Hotfixes happen. Engineers still change code by hand. The /sg-sync skill finds where the code and the spec disagree and proposes the matching spec update, so the team can accept it or revert the code.
SpecGraph team
Spec-driven development has a quiet assumption baked in: every change goes through the spec first. That holds for a while. Then production breaks at 2 a.m., someone patches the payment webhook by hand, and the fix ships without anyone touching the spec.
The code is now right. The spec is now wrong. And the coding agent, which trusts the spec, may happily undo the hotfix the next time it touches that file.
Most teams still change code by hand, and they should. Emergency patches, small fixes, a senior engineer who simply knows the answer. The question isn't how to stop that. It is how the spec finds out.
What /sg-sync does
/sg-sync is a skill your coding agent runs in the repository. It reads the spec over MCP, looks at the code, and reports where the two disagree.
You choose the scope: recent changes (uncommitted work plus recent commits), a specific commit range or branch, or a full scan after a long stretch of manual work. It maps what the code actually does (routes, data models, roles and permission checks, environment variables, third-party integrations, validation rules) and compares that with the matching sections of the spec.
Each finding is classified: a capability the spec doesn't describe, a feature that behaves differently, a feature that was removed, a new entity, or an architecture or security change. Every finding cites the file and line it came from. If the agent can't point at code, it isn't drift.
It also skips what doesn't matter at spec level: refactors, renames inside a module, formatting, test-only changes and dependency bumps. A drift report full of noise is a report nobody reads.
Propose, then decide
The report stops and waits. You tell the agent which items to propose. Only those are sent to SpecGraph, each as a separate amendment marked From code, with the evidence attached: which files, which commit.
The team then decides in the Amendments panel, like any other amendment:
- Accept if the code is right. The spec updates, downstream phases are flagged for review, and the next pack the agent reads matches the code.
- Reject if the change shouldn't be part of the product, such as a temporary workaround. The reason is kept with the amendment, and now the code is what has to change. Revert it, or schedule the proper fix as a story.
The skill proposes. People decide. Nothing in the spec changes until someone on the team applies it.
That separation is deliberate. /sg-syncnever edits code and never edits the spec. It doesn't open .envfiles or secrets. It won't re-propose something that is already pending. Its only write is a proposal, and only after a developer has approved that item in their session.
Why this matters more than it sounds
A spec that drifts is worse than no spec, because people trust it. An agent working from a stale contract will reintroduce bugs you already fixed and build features on assumptions that no longer hold. A reviewer comparing a pull request with the spec will flag correct code as wrong.
For brownfield teams this is everyday reality, not an edge case. The code holds years of decisions nobody wrote down. Discovery gets those into the spec once. /sg-sync keeps them there as the code keeps changing.
It also lowers the cost of doing the right thing. Writing a spec update after a hotfix is exactly the task that gets skipped at the end of a long night. Reviewing one, with the evidence already attached, takes a minute.
What you can do this week
- Look at the last few hotfixes on your main branch. For each one, ask whether your spec or ticket system knows it happened.
- Pick one feature and compare what the docs say with what the code does: limits, roles, error paths. The gaps are usually in the details.
- If you use SpecGraph, run
/sg-syncafter your next manual change with the default scope, and read the report before approving anything.
Code will change by hand. Make sure the spec hears about it.
- drift
- sg-sync
- brownfield
- agents