claude-code-sync
Idempotent update of an existing Claude Code setup — re-fingerprint the repo, propagate updates to sub-repos, refresh docs/context, section-merge CLAUDE.md/README.md, fix configuration drift. Use this skill whenever the user runs /cc-sync, asks to "update the claude setup", "propagate to sub-repos", "fix drift", "resync", or reports that the .claude/ directory has gone stale.
What this skill does
# Claude Code Sync
Updates an existing setup without blowing away user customizations. Idempotent — safe to run weekly, monthly, or on a schedule.
## What sync does
1. **Re-fingerprint**: scan the repo for stack changes since last setup. New framework? New DB? New CI/CD tool?
2. **Delta propagation**: push plugin rule updates (`cc-always.md`, `cc-patterns.md`) into the repo's `.claude/rules/`.
3. **Section-merge CLAUDE.md**: update the "Build & Test", "Tech Stack", "Key Paths" sections if stack changed; leave custom sections alone.
4. **Fix drift** (`--fix-drift` flag): find config that drifted from plugin defaults — missing hooks, missing MCP servers, outdated skill versions — and repair.
5. **Propagate to sub-repos**: for monorepos, walk workspace children and apply changes to their `.claude/` dirs.
6. **Scaffold docs/context/** (if absent): create the 22-template knowledge base that complements `.claude/`.
7. **Auto-install LSPs**: detect missing LSP servers from the stack and offer install commands.
8. **Persist sync state**: write `.claude/sync-state.json` with timestamp, plugin version, delta summary.
## Section-merge protocol for CLAUDE.md
CLAUDE.md sections are identified by `## ` headings. Sync protocol:
| Section | Action |
|---|---|
| `## Build & Test` | Replace (regenerated from fingerprint) |
| `## Tech Stack` | Replace |
| `## Key Paths` | Replace |
| `## Architecture` | Preserve (user-curated) |
| `## Conventions` | Merge (preserve user additions, update detected items) |
| `## Don't Touch` | Merge (preserve user additions) |
| `## Knowledge Library` (Obsidian) | Replace if managed-by-plugin marker present |
| Any other section | Preserve as-is |
Managed sections carry a `<!-- plugin:cc-setup managed -->` marker. Unmarked sections are never touched.
## Drift detection (`--fix-drift`)
Compares current state to plugin baseline:
| Check | Fix |
|---|---|
| Missing `.claude/rules/cc-always.md` | Copy from plugin |
| Missing `.claude/rules/cc-obsidian-intro.md` | Copy from plugin |
| `cc-patterns.md` older than plugin's | Offer update (user confirms) |
| Hook script path doesn't match registered hook | Reconcile or remove dead registration |
| Settings allowlist has entries for removed tools | Prune |
| MCP server in `.mcp.json` has no backing install | Warn |
| Skills in `.claude/skills/` belong to old plugin version | Offer replacement |
Never deletes user-added config. All destructive fixes require explicit confirmation.
## Sub-repo propagation
For monorepos (turbo/nx/lerna/pnpm-workspaces), sync walks workspace packages and:
1. If package has its own `.claude/` → sync it (same protocol as root).
2. If package has no `.claude/` → create a minimal one that references the root's CLAUDE.md.
3. Generate per-package CLAUDE.md stubs for LOC > 10k packages.
## docs/context/ scaffolding
If `docs/context/` does not exist, create from 22 templates:
- `docs/context/README.md`
- `docs/context/architecture/overview.md`
- `docs/context/architecture/modules.md`
- `docs/context/conventions/code-style.md`
- `docs/context/conventions/git-workflow.md`
- `docs/context/conventions/testing.md`
- `docs/context/decisions/0001-use-claude-code.md`
- `docs/context/runbooks/deploy.md`
- `docs/context/runbooks/rollback.md`
- `docs/context/glossary.md`
- ... (full list via `cc_kb_docs_context_templates`)
## Sync state file
`.claude/sync-state.json`:
```json
{
"version": "1.0",
"last_synced": "2026-04-16T14:00:00Z",
"plugin_version": "8.0.0",
"stack_fingerprint": "node-ts-nextjs-postgres-prisma-jest-vercel",
"sub_repos_synced": 0,
"drift_fixed": ["added missing cc-obsidian-intro.md", "pruned 2 dead hook registrations"],
"next_check_due": "2026-05-16"
}
```
## MCP delegation
| Need | Tool |
|---|---|
| Hook pack recommendations after stack change | `cc_docs_hook_pack_recommend(signals)` |
| LSP config for newly detected language | `cc_kb_lsp_config(language)` |
| Topology for new work patterns | `cc_docs_team_topology_recommend(...)` |
## Anti-patterns
- Running sync without reading `.claude/sync-state.json` → can't tell what changed since last sync.
- `--fix-drift` without user confirmation → destroys custom config that looks like drift.
- Syncing sub-repos without their owners' awareness → surprises.
- Re-running setup instead of sync → overwrites user customizations.
## Reference
- [drift-rubric.md](references/drift-rubric.md) — what counts as drift vs. valid customization
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.