Sync template

From tranhieutt/software_development_department · View interactive version

Sync template is an AI agent skill from the GitHub repository tranhieutt/software_development_department. Syncs the .claude/ directory from an upstream template repository, showing a diff and applying new or modified files without overwriting local customizations. Use when updating SDD template files or when the user mentions template sync or upstream update.

How to use this skill

Skill file

Sync the .claude/ directory from an upstream template repository into this project.

Determine the upstream URL

If $ARGUMENTS is provided, use it as the upstream repository URL.

If $ARGUMENTS is empty, check CLAUDE.md for a line like:

**Template upstream**: <url>

If no URL is found in either place, ask the user:

"What is the upstream template repository URL to sync from? (e.g. https://github.com/owner/repo)"

Do not proceed until a URL is confirmed.


Steps

1. Fetch the upstream template

Run:

SYNC_TMP=$(mktemp -d /tmp/template-sync-XXXXXX)
git clone --filter=blob:none --sparse "$UPSTREAM_URL" "$SYNC_TMP" 2>&1
cd "$SYNC_TMP" && git sparse-checkout set .claude

If the clone fails (no internet, repo moved, auth required, etc.) stop immediately and report the error clearly. Do not attempt fallbacks.

2. Show a diff summary

Compare $SYNC_TMP/.claude/ against the project's .claude/ directory and report:

If there are no differences, say so and skip to clean-up.

3. Ask for confirmation

Present the diff summary and ask:

"Apply these changes from <upstream-url>? Type yes to apply or no to cancel."

Do not proceed until the user explicitly confirms with "yes".

4. Apply the changes

From the project root, run:

cp -r "$SYNC_TMP/.claude/." .claude/

This will:

5. Report

List each file that was added or updated, grouped by type:

6. Clean up

rm -rf "$SYNC_TMP"

Confirm: "Sync complete. Temp directory removed."


Important constraints

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.