sync-template

$npx mdskill add tranhieutt/software_development_department/sync-template

Syncs .claude/ from upstream template, showing diff and applying new files.

  • Updates .claude/ directory from an upstream template repository.
  • Depends on git clone, sparse checkout, and Bash commands.
  • Uses provided URL or reads from CLAUDE.md; asks user if missing.
  • Shows diff summary and applies new or modified files without overwriting local customizations.

SKILL.md

.github/skills/sync-templateView on GitHub ↗
---
name: sync-template
type: workflow
description: "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."
argument-hint: "[upstream-repo-url]"
user-invocable: true
allowed-tools: Read, Bash, Glob
effort: 3
when_to_use: "Use when updating the .claude/ directory from an upstream SDD template repository, or when the user mentions template sync or upstream update."
---

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:

```text
**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:
```bash
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:

- **New files** — present in upstream but not locally (will be added)
- **Modified files** — present in both but with different content (will be overwritten)
- **Local-only files** — present locally but not in upstream (will be **kept unchanged** — these are project-specific customizations)

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:
```bash
cp -r "$SYNC_TMP/.claude/." .claude/
```

This will:

- **Overwrite** files that exist in both upstream and locally
- **Add** new files from upstream
- **Preserve** all local-only files (project-specific agents, skills, rules, hooks)

### 5. Report

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

- Added: `[file list]`
- Updated: `[file list]`

### 6. Clean up

```bash
rm -rf "$SYNC_TMP"
```

Confirm: "Sync complete. Temp directory removed."

---

## Important constraints

- Never delete local files that don't exist in upstream — they may be project-specific customizations (agents, skills, rules, hooks added after the template was cloned)
- Never modify `CLAUDE.md`, `PRD.md`, `TODO.md`, or any files outside `.claude/` — this skill only touches `.claude/`
- If the user's `.claude/` has meaningful customizations to a file that upstream has also changed, flag it specifically: "Note: `[file]` was modified locally — upstream changes will overwrite. Review diff before confirming if you want to preserve local changes."

More from tranhieutt/software_development_department

SkillDescription
agent-healthReads production/traces/agent-metrics.jsonl and displays a per-agent performance summary table for the current or a specified session. Highlights agents with high error rates or OPEN circuit breaker state.
agent-styleProvides the vendored agent-style v0.3.5 prose rule pack as a portable Claude skill. Use when installing, syncing, applying, or auditing SDD Agent-Style support in another project, or when a style-review workflow needs the bundled rules.
angular-best-practicesProvides Angular best practices for components, modules, services, and reactive patterns. Use when working with Angular TypeScript files, component templates, NgModules, RxJS observables, or when the user mentions Angular, ng, or Angular CLI.
annotateRecords unexpected API behaviors, undocumented caveats, version bugs, or non-obvious workarounds into .claude/memory/annotations.md. Use immediately when an undocumented behavior or surprising caveat is discovered during development.
aws-serverlessProvides AWS serverless architecture patterns for Lambda, API Gateway, DynamoDB, SQS, and SAM/CDK. Use when working with AWS serverless files (serverless.yml, CDK stacks) or when the user mentions Lambda, API Gateway, serverless, or AWS SAM.
backend-architectDesigns scalable backend architectures covering microservices, event-driven systems, API gateways, and data stores. Use when designing a backend system or when the user mentions backend architecture, scalability, or distributed systems.
cloud-run-puppeteerDeploys Puppeteer browser automation on Google Cloud Run with Docker. Use when running headless browser tasks on Cloud Run, or when the user mentions Cloud Run, Puppeteer, headless Chrome, or serverless browser automation.
codex-sddAdapts SDD for Codex while preserving Claude Code behavior. Use when working in Codex, setting up Codex compatibility, mapping Claude tools to Codex tools, or explaining how SDD should run outside Claude Code.
database-architectDesigns relational and NoSQL database schemas, indexing strategies, migration plans, and data modeling patterns. Use when designing a database or when the user mentions database architecture, schema design, or data modeling.
db-reviewReviews database schemas, queries, and migrations for correctness, performance, security, and best practices. Use when reviewing SQL migration files or when the user mentions database review, schema review, or query audit.