Get the FREE Ultimate OpenClaw Setup Guide →

brewdoc:auto-sync

Use Caution
npx machina-cli add skill kochetkov-ma/claude-brewcode/auto-sync --openclaw
Files (1)
SKILL.md
5.3 KB

Auto-Sync

<instructions>

Mode Detection

EXECUTE using Bash tool (args: $ARGUMENTS):

bash "scripts/detect-mode.sh" $ARGUMENTS

Script path is relative to skill directory.

Parse output: MODE|ARG|FLAGS. If exit code non-zero → report error, EXIT.

ModeTriggerScope
STATUSstatusReport INDEX state → EXIT
INITinit <path>Tag file + add to INDEX → EXIT
GLOBALglobal~/.claude/** (excludes managed dirs)
PROJECTempty.claude/** (excludes managed dirs)
FILEfile pathSingle file
FOLDERfolder pathAll .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

{"p":"skills/auth/SKILL.md","t":"skill","u":"2026-02-05","pr":"default"}
FieldDescription
pRelative path
tType: skill/agent/rule/config/doc
uLast sync date (YYYY-MM-DD)
prProtocol: default/override

Paths: Project .claude/auto-sync/INDEX.jsonl | Global ~/.claude/auto-sync/INDEX.jsonl

Frontmatter Fields

Required (3):

auto-sync: enabled
auto-sync-date: 2026-02-05
auto-sync-type: skill

Optional override (multiline 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:

SCOPE="project"  # or "global"
INDEX_DIR=".claude/auto-sync"
[ "$SCOPE" = "global" ] && INDEX_DIR="$HOME/.claude/auto-sync"
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 "scripts/discover.sh" "$SCOPE_PATH" typed

Script path is relative to skill directory. Output: TYPE|PATH per line (types: skill, agent, rule, config, doc). Capped at MAX_FILES (default 50).

  1. 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)
  2. Find stale entries — EXECUTE using Bash tool:

bash "scripts/index-ops.sh" stale "$INDEX_FILE" "$INTERVAL_DAYS"

Script path is relative to skill directory.

  1. 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 available in your context (injected 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:

## 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

ErrorAction
INDEX corruptRebuild from discovery
File not foundSkip, add to errors
Agent timeoutRetry once
No tagged filesReport "0 found"
/brewdoc:doc called"Use /brewdoc:auto-sync"

Source

git clone https://github.com/kochetkov-ma/claude-brewcode/blob/main/brewdoc/skills/auto-sync/SKILL.mdView on GitHub

Overview

brewdoc:auto-sync provides universal documentation synchronization for skills, agents, and markdown files. It supports modes status, init, global, project, file, and folder to keep the .claude/auto-sync INDEX in sync with your docs.

How This Skill Works

The system detects the scope and file types via discover.sh, tags files with required frontmatter, and records them in INDEX.jsonl. It relies on frontmatter fields auto-sync, auto-sync-date, and auto-sync-type, and uses auto-sync-override to determine the index protocol; indexes can live in project or global locations.

When to Use It

  • You need to verify current sync state and identify non-indexed files (STATUS phase).
  • Tag a new document or path to be tracked by using INIT <path>.
  • Sync all docs in the global scope (~/.claude) to share updates across environments.
  • Sync docs within a specific project scope (.claude) to focus on your workspace.
  • Sync a single file or an entire folder's Markdown docs to update their entries.

Quick Start

  1. Step 1: Run a status check to see current INDEX and indexed files.
  2. Step 2: Tag a doc or directory with INIT <path> to add it to the index.
  3. Step 3: Run a sync (PROJECT, GLOBAL, FILE, or FOLDER) to apply updates and refresh INDEX entries.

Best Practices

  • Ensure required frontmatter fields (auto-sync, auto-sync-date, auto-sync-type) are present before tagging.
  • Run STATUS before performing a SYNC to validate what will be updated.
  • Exclude managed directories from auto-scan unless explicitly included.
  • Use discover.sh to correctly identify file type and scope before indexing.
  • Back up INDEX.jsonl after large changes or re-scans.

Example Use Cases

  • Index all skills and agents in a repo using GLOBAL mode.
  • Initialize tagging for a new skill directory with INIT <path>.
  • Sync a single markdown file to ensure its doc is current.
  • Sync an entire folder of skills with the FOLDER mode.
  • Override default behavior by adding auto-sync-override in frontmatter.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers