SpecGraph
All posts
github4 November 20264 min read

Two-way sync with GitHub and GitLab

Spec changes land in your repository as reviewable commits. Code changes flow back into the spec as proposals. Here's how the two directions fit together.

ST

SpecGraph team

For a long time we described SpecGraph as one-way. The spec is the source; the repository is downstream. That was the honest shape of the product, and the safe one. Two-way sync is where many tools end up in a swamp of merge conflicts, with nobody sure whose edit wins.

But one-way isn't how teams work. Engineers edit the spec file in the repository. They fix code by hand. A sync that only pushes ends up describing a repository that no longer exists.

So we built both directions, with a clear rule for each.

Spec to repository: reviewable commits

Connect a project to a GitHub or GitLab repository and pick a branch. When the spec changes, you push. SpecGraph writes spec.md and the BMAD pack as one commit containing only the files that changed, with a message that lists what was added, updated and deleted.

Because it is an ordinary commit, it goes through your ordinary process. Point the project at a dedicated branch and open a pull or merge request from it, and spec changes get reviewed by the same people, with the same tools, as code changes. The diff stays readable because it only holds real changes; date stamps in generated files are ignored when deciding what changed.

If someone edited a pushed file in the repository since the last push, SpecGraph shows it as a conflict and won't overwrite it without confirmation.

Repository to spec: two kinds of change

Changes flow back in two different ways, because they mean two different things.

Edits to the spec file. Someone changes spec.mddirectly in the repository. SpecGraph can show what it last pushed, what's on the branch now, and what it would push. Pulling parses the file back into spec fields and lists each edit as its own change. You pick which to apply. Only the edited fields are written, locked phases stay locked, and pulled changes can still be discarded.

Changes to the code.A hotfix, a manual implementation, an emergency patch. These don't touch the spec file, so there is nothing to pull. Instead, the /sg-sync skill in your coding agent compares the code with the spec and proposes amendments, each citing the files and commit it came from. The team accepts or rejects them in SpecGraph.

Spec edits are pulled. Code changes are proposed. Neither direction lets anything into the spec without a person choosing it.

Why not fully automatic

We get asked why sync isn't a background process that keeps everything identical. The answer is that the two sides aren't symmetrical.

The pack is generated from the spec, so it is never pulled back. Edit the spec and the pack follows. Code isn't generated from the spec in the same mechanical way, so a difference between them is a question, not a merge. Maybe the code is right and the spec is stale. Maybe the code is a workaround that should never have shipped. Only the team knows, so the team decides.

Keeping both directions on demand also keeps the history clean. Every push is a commit you chose to make. Every pull and every accepted amendment is recorded. When someone asks why the spec says what it says, there is an answer.

A typical week

  • Monday. A product lead updates two acceptance criteria. One push, one commit with a handful of changed files, reviewed in a pull request next to the code it affects.
  • Wednesday. An engineer fixes an endpoint path directly in spec.md. On the next check SpecGraph shows the edit, and pulling applies that single field.
  • Friday. An on-call fix changes a rate limit in the code. /sg-sync spots it and proposes an amendment with the file reference. The team accepts it, and the next push records the new limit in the repository.

What you can do this week

  • Decide where your spec of record lives. If the answer is “both places”, write down which direction wins for which kind of change.
  • Route spec changes through the same review as code. A spec change that skips review is the easiest way for the contract to drift.
  • Treat a mismatch between code and spec as a decision to make, not a conflict to auto-resolve.

Sync isn't about keeping two copies identical. It is about making sure every difference gets noticed, and then decided.

  • github
  • gitlab
  • sync
  • drift
  • workflow

Stop vibe-coding solo.Ship with the whole org aligned.

Coding agents are fast, and they are obedient: they build exactly what the spec says. SpecGraph makes the spec worth obeying. Every department on the record, conflicts settled before code, one sealed pack your agent works from.

Request access

0%