agentleFS
cosmefaecosmefae/claude-skills/skills/sync-references/SKILL.md

sync-references

Skill2 starsChanged 5 months agoMITView on GitHub

Audits, relinks, and synchronizes documentation references in a project; detecting broken links, stale paths, orphan files, llms.txt inconsistencies, skills-directory desync (skills folder vs README/SKILLS.md/llms.txt), READMEs, AGENTS.md, SKILL.md, HANDOFF.md, and CHANGELOG.md. Generates updated indexes and validates YAML frontmatter. Use when the user mentions "broken links", "relink docs", "update refs", "sync llms.txt", "index files", "document references", "tag files", "orphan files", "audit documentation", "validate llms.txt", or "sync skills".

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 8 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run the audit script against the project directory:

    line 32
  2. Very specific:

    Search for the file with Glob by base name

    line 57
  3. Very specific:

    README.md: ensure every folder under docs/ and every active subproject has an entry in the index with a link and a one-line description.

    line 62
  4. Very specific:

    Skills directory: when adding or renaming a skill, update in the same pass SKILLS.md (table and contracts), README.md ("Available skills" …

    line 64
  5. Distinctive:

    llms.txt: follow the spec in llms-spec.md:

    line 66
  6. Distinctive:

    Remove entries for files that no longer exist

    line 71
  7. Distinctive:

    Add entries for new unindexed files

    line 72
  8. Distinctive:

    Don't overwrite existing frontmatter, only add missing fields.

    line 86
  9. Very specific:

    When changes are applied, append an entry to CHANGELOG.md:

    line 90
  10. Distinctive:

    Always deliver at the end:

    line 107
  11. Distinctive:

    If the user asks for an audit only, without applying fixes, generate the report above but do not modify any file.

    line 138
  12. Distinctive:

    Remove the hooks manually:

    line 188

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

sync-references

Audits and synchronizes a project's documentation reference graph. Operates on Markdown files and LLM context files.

Target artifacts

FileRole
README.mdProject root index
llms.txtStructured LLM context (spec: llms-spec.md)
AGENTS.mdInstructions for AI agents
SKILL.mdSkill definition
HANDOFF.mdTask handoff
CHANGELOG.mdChange history
docs/**/*.mdInternal documentation

Configuration

This skill defaults to scanning a project's skills/ directory (auto-detected: tries .claude/skills/, then .cursor/skills/, then skills/ at the project root, in that order; first one found wins). If your project uses a different convention, pass it explicitly: "sync references, skills are in packages/*/skills/".

Workflow

1. Audit

Run the audit script against the project directory:

zsh <skill-dir>/scripts/audit-refs.sh <project-root>

Where <skill-dir> is wherever this skill is installed (e.g. .claude/skills/sync-references, ~/.claude/skills/sync-references, or a project-local path). Resolve it relative to how the skill was invoked, don't assume a fixed location.

The script returns:

  • broken-links: Markdown links with a non-existent target
  • orphan-files: .md files with no inbound reference
  • missing-from-llms: files present on disk but absent from llms.txt
  • stale-llms: paths in llms.txt that don't exist on disk
  • skill-sync: each skill folder (containing a SKILL.md) must appear in llms.txt (link containing the skill's SKILL.md path), in README.md (skill name in backticks in the table), and in SKILLS.md (link with the same relative path)
  • missing-frontmatter: files in docs/ without a YAML block (---) when expected

2. Relink

For each reported broken-link:

  1. Locate the referenced file using Glob with name variations
  2. Compute the correct relative path from the source file
  3. Apply the fix with Edit
  4. Log it in the final report

For stale-refs in @path mentions:

  • Search for the file with Glob by base name
  • Replace the stale path

3. Index

README.md: ensure every folder under docs/ and every active subproject has an entry in the index with a link and a one-line description.

Skills directory: when adding or renaming a skill, update in the same pass SKILLS.md (table and contracts), README.md ("Available skills" table), and llms.txt (skills section). Run the audit script to validate SKILL-SYNC-*.

llms.txt: follow the spec in llms-spec.md:

  • # Title (single h1)
  • > description (blockquote)
  • ## Section (h2 per category)
  • - [Name](path): description (one line per artifact)
  • Remove entries for files that no longer exist
  • Add entries for new unindexed files

4. Tagging (YAML frontmatter)

For files in docs/ without frontmatter, inject a minimal block:

---
title: <infer from the file's h1>
tags: [<folder-category>]
updated: <YYYY-MM-DD>
---

Don't overwrite existing frontmatter, only add missing fields.

5. CHANGELOG

When changes are applied, append an entry to CHANGELOG.md:

## [sync-references] YYYY-MM-DD

### Fixed
- `path/to/file.md`: broken link `old-ref` → `correct-ref`

### Added
- `llms.txt`: entry added for `docs/new-file.md`

### Tagged
- `docs/file.md`: frontmatter injected

Output

Always deliver at the end:

## sync-references Report: <date>

**Project**: <root>
**Files audited**: N
**Issues found**: N

### Broken links fixed (N)
- `file.md:12`: `../old/path` → `../correct/path`

### Orphan files (N)
- `docs/unreferenced-file.md`: suggestion: add to README.md#section

### llms.txt: synchronized (N additions, N removals)
- ➕ `docs/new.md`
- ➖ `docs/deleted.md` (file no longer exists)

### Skill sync (N)
- `skill-name` missing from `llms.txt` / `README.md` / `SKILLS.md`: suggested fix: …

### Frontmatter injected (N)
- `docs/file.md`

### No action needed
- (list of files that are ok)

Report-only mode

If the user asks for an audit only, without applying fixes, generate the report above but do not modify any file. Flag each issue with the suggested fix for manual application.

Automation (Git Hooks)

For automatic synchronization when .md files are renamed/moved, install the git hooks:

Installation

From your project's git root:

zsh <skill-dir>/hooks/install.sh

The installer will:

  1. Copy 3 hooks to .git/hooks/ (post-commit, post-merge, post-rewrite)
  2. Configure the default mode (silent)
  3. Validate the installation

Operating modes

Configure via git config (local to the repository):

# Silent mode (default): only logs to .git/sync-refs.log
git config sync-refs.mode silent

# Report mode: shows the report in the terminal after commits
git config sync-refs.mode report

# Fix mode: auto-fixes references (not implemented yet)
git config sync-refs.mode fix

View the execution log

tail -f .git/sync-refs.log

Installed hooks

HookWhen it runsBehavior
post-commitAfter each commitDetects changed .md files → runs sync
post-mergeAfter pulls/mergesAlways runs sync (--force)
post-rewriteAfter rebasesRuns sync on rebases

Uninstall

Remove the hooks manually:

rm .git/hooks/post-commit
rm .git/hooks/post-merge
rm .git/hooks/post-rewrite
git config --unset sync-refs.mode

Additional resources

  • Full llms.txt spec: llms-spec.md
  • Audit script: scripts/audit-refs.sh

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.