Sync architecture

From divad12/dotfiles · View interactive version

Sync architecture is an AI agent skill from the GitHub repository divad12/dotfiles. Use when the user says 'sync architecture', 'update the architecture diagram', 'refresh architecture', or 'audit the diagram'. Also auto-invoked by /save and /deep-review, or after adding, removing, or renaming a top-level module.

How to use this skill

Skill file

Sync Architecture Diagram

Detect architecture drift and apply the fix directly to docs/ai/architecture.md. No approval prompt - just edit the file and leave it unstaged so the user sees the diff in git status before the next commit. If the edit is wrong, git checkout docs/ai/architecture.md reverts in one command.

The goal: keep the diagram in sync with zero friction. Asking for approval on every run turns this into a chore; just updating + trusting git-as-review is the right ratio.

Prerequisites

test -f docs/ai/architecture.md || { echo "No architecture.md - run /adaptive-docs-init first or create one manually"; exit 1; }

The diagram must contain a ## This diagram covers section listing the paths it represents. Without that, the skill can't scope the check.

Steps

1. Read the diagram and its coverage

Read docs/ai/architecture.md. Extract:

If there's no coverage section, stop and tell the user to add one. The format is:

## This diagram covers

- `src/app/api/**` - description
- `src/lib/foo/**` - description

Without coverage metadata, there's no principled way to decide what "in sync" means.

2. Find when the diagram last changed

LAST_ARCH_COMMIT=$(git log -1 --format=%H -- docs/ai/architecture.md)
LAST_ARCH_DATE=$(git log -1 --format=%ai -- docs/ai/architecture.md)

If the file has never been committed, use the working directory as the baseline and compare to main.

3. Find what's changed in the covered paths since then

For each path in the coverage section:

git log --since="$LAST_ARCH_DATE" --name-status -- <path>

Collect:

The key signal is structural change (add/delete/rename), not line-level edits. Modifications to internals of an existing module rarely need diagram updates.

4. Classify the changes

For each structural change, ask:

If no structural changes found, tell the user the diagram is still in sync and exit. Don't propose cosmetic edits.

5. Apply the update directly

If structural changes exist, edit docs/ai/architecture.md now. Do not ask for approval.

What to update:

What to preserve:

6. Report what changed

In your skill output, tell the user:

Updated docs/ai/architecture.md:
  - Added box for `src/lib/billing/` (new top-level module since last diagram update)
  - Removed box for `src/lib/legacy-timing/` (deleted this session)
  - Expanded coverage list to include `src/lib/billing/**`

Left unstaged. Review with `git diff docs/ai/architecture.md`. Revert with
`git checkout docs/ai/architecture.md` if the update is wrong.

Be specific. Every bullet should reference the structural change that triggered it.

7. Don't commit

Leave the edit as an unstaged change. The user commits it bundled with the code change that triggered the drift, or with the next /save.

When to say "no drift, all good"

Resist the urge to suggest changes for the sake of it. A good outcome is often "the diagram is still accurate - no action needed." Look for these non-signals:

And these real signals:

Scope discipline

Failure modes to avoid

If `docs/ai/architecture.md` doesn't exist

Don't create it in this skill. That's the job of /adaptive-docs-init step 8b (or manual creation). Bail with a clear message.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.