brewdoc:auto-sync
Universal documentation sync for skills, agents, and markdown files. Pulls latest docs from official sources and updates files in place. Modes: status, init <path>, global, file, folder. Triggers: sync docs, auto-sync, update documentation, refresh skill docs, sync agent docs, documentation sync, pull latest docs.
What this skill does
# Auto-Sync
<instructions>
## Mode Detection
**EXECUTE** using Bash tool (args: `$ARGUMENTS`):
```bash
bash "${CLAUDE_SKILL_DIR}/scripts/detect-mode.sh" $ARGUMENTS
```
Parse output: `MODE|ARG|FLAGS`. If exit code non-zero → report error, EXIT.
| Mode | Trigger | Scope |
|------|---------|-------|
| STATUS | `status` | Report INDEX state → EXIT |
| INIT | `init <path>` | Tag file + add to INDEX → EXIT |
| GLOBAL | `global` | `~/.claude/**` (excludes managed dirs) |
| PROJECT | empty | `.claude/**` (excludes managed dirs) |
| FILE | file path | Single file |
| FOLDER | folder path | All .md in folder |
**Managed directories** (excluded from auto-scan, explicit path required):
- `rules/` — sync via `/brewdoc:auto-sync .claude/rules`
- `agents/` — sync via `/brewdoc:auto-sync .claude/agents`
- `skills/` — sync via `/brewdoc:auto-sync .claude/skills`
## INDEX Format
```jsonl
{"p":"skills/auth/SKILL.md","t":"skill","u":"2026-02-05","pr":"default"}
```
| Field | Description |
|-------|-------------|
| `p` | Relative path |
| `t` | Type: `skill`/`agent`/`rule`/`config`/`doc` |
| `u` | Last sync date (YYYY-MM-DD) |
| `pr` | Protocol: `default`/`override` |
**Paths:** Project `.claude/auto-sync/INDEX.jsonl` (primary) | Global `${BD_PLUGIN_DATA}/auto-sync/INDEX.jsonl` (plugin data dir — used for GLOBAL mode because `~/.claude/*` is blocked by protected-path policy)
## Frontmatter Fields
Required (3):
```yaml
auto-sync: enabled
auto-sync-date: 2026-02-05
auto-sync-type: skill
```
Optional override (multiline YAML):
```yaml
auto-sync-override: |
sources: src/**/*.ts, .claude/agents/*.md
focus: API endpoints, error handling
preserve: ## User Notes, ## Custom Config
```
## Override Field
When `auto-sync-override:` present in frontmatter → INDEX gets `pr: "override"`.
Stored in frontmatter only — **never in document body**.
</instructions>
<phase name="status">
1. Read INDEX.jsonl, verify indexed files exist
2. Find all `.md` files in scope
3. Compare indexed vs found → identify non-indexed
4. Detect type for non-indexed (`discover.sh typed`) — output: `TYPE|PATH` per line
5. Output report: Indexed (path, type, protocol, last sync, stale), Non-Indexed (path, detected type, reason), Summary (counts)
6. EXIT
</phase>
<phase name="init">
Input: `init <path>`
1. Read `<path>` — if NOT found → error, EXIT
2. If has `auto-sync: enabled` → "Already tagged", EXIT
3. Detect type via discover.sh
4. Add frontmatter: `auto-sync: enabled`, `auto-sync-date: {today}`, `auto-sync-type: {type}`
5. Check frontmatter `auto-sync-override:` → set `pr: override|default`
6. Add to INDEX.jsonl
7. Output: path, type, protocol; EXIT
</phase>
<phase name="sync">
## Sync Mode (PROJECT/GLOBAL/FILE/FOLDER)
### Phase 1: Setup INDEX
**EXECUTE** using Bash tool:
```bash
SCOPE="project" # or "global"
# Primary: project-relative .claude/auto-sync/ (required — ~/.claude/* is
# blocked by Claude Code's protected-path policy in headless sessions).
INDEX_DIR=".claude/auto-sync"
if [ "$SCOPE" = "global" ]; then
# GLOBAL mode scans ~/.claude/** (read-only) but writes its INDEX to
# the plugin data dir, NOT to ~/.claude/auto-sync (blocked path).
INDEX_DIR="${BD_PLUGIN_DATA:-$HOME/.claude/brewdoc}/auto-sync"
fi
mkdir -p "$INDEX_DIR" && INDEX_FILE="$INDEX_DIR/INDEX.jsonl" && touch "$INDEX_FILE"
echo "INDEX=$INDEX_FILE"
```
### Phase 2: Discover + Queue (load config: `INTERVAL_DAYS`, `PARALLEL_AGENTS` from `.claude/tasks/cfg/brewdoc.config.json`)
1. Find tagged files — **EXECUTE** using Bash tool:
```bash
bash "${CLAUDE_SKILL_DIR}/scripts/discover.sh" "$SCOPE_PATH" typed
```
Output: `TYPE|PATH` per line (types: `skill`, `agent`, `rule`, `config`, `doc`). Capped at `MAX_FILES` (default 50).
2. For each file not in INDEX → auto-add:
- Read file, use type from discover output
- If no frontmatter → add `auto-sync: enabled`, `auto-sync-date`, `auto-sync-type`
- Check `<auto-sync-override>` → set `pr`
- Add to INDEX (`index-ops.sh add`)
3. Find stale entries — **EXECUTE** using Bash tool:
```bash
bash "${CLAUDE_SKILL_DIR}/scripts/index-ops.sh" stale "$INDEX_FILE" "$INTERVAL_DAYS"
```
4. Queue: new + stale files
### Phase 3: Process + Report
1. Launch `bd-auto-sync-processor` agents (max `PARALLEL_AGENTS` batches, model="sonnet"):
```
Task(subagent_type="brewdoc:bd-auto-sync-processor",
prompt="PATH: {path} | TYPE: {type} | FLAGS: {flags}")
```
> **Context:** BD_PLUGIN_ROOT is injected into agent prompt by pre-task.mjs hook.
2. For each result:
- If status = `updated` or `unchanged` → update INDEX `u` to today (`index-ops.sh update`)
- If status = `error` → log to Errors table, do NOT update INDEX (file remains stale for retry)
3. Output report:
```markdown
## Auto-Sync Complete
| Metric | Count |
|--------|-------|
| Discovered | {N} |
| Queued (stale/new) | {N} |
| Updated | {N} |
| Unchanged | {N} |
| Errors | {N} |
### Updated
| Path | Type | Changes |
|------|------|---------|
### Errors
| Path | Error |
|------|-------|
```
</phase>
## Error Handling
| Error | Action |
|-------|--------|
| INDEX corrupt | Rebuild from discovery |
| File not found | Skip, add to errors |
| Agent timeout | Retry once |
| No tagged files | Report "0 found" |
| `/brewdoc:doc` called | "Use /brewdoc:auto-sync" |
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.