agentleFS
oopsla5xxoopsla5xx/oops-skills/.claude/skills/sync-ai-context/SKILL.md

sync-ai-context

Skill4 starsChanged 4 months agoMITView on GitHub

Refresh stale .ai/ context files before starting a task — detect which of commands.md, architecture.md, conventions.md are outdated and patch only those sections. Run at the start of each task session.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 4 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Check and update stale .ai/ files before starting a task.

    line 8
  2. Distinctive:

    Use when: starting a new task, after pulling from remote, or when the context is suspected to be inaccurate.

    line 10
  3. Distinctive:

    Read the entire output. The script produces 3 types of results:

    line 22
  4. Very specific:

    Add or update the corresponding targets in commands.md.

    line 39
  5. Distinctive:

    Read the changed parts. Update only the affected section (usually "What the project is" or "Stack").

    line 45
  6. Very specific:

    Read the contents of that directory (ls <dir>).

    line 48
  7. Very specific:

    Update the relevant rule in conventions.md.

    line 54
  8. Distinctive:

    After updating a file: touch that file to reset the baseline for the next check.

    line 58
  9. Very specific:

    find -newer uses filesystem mtime: If the project was just git cloned, all files will have mtime = the clone time — the script will …

    line 79
  10. Very specific:

    Do not update when unsure: If a STALE signal is package.json newer but only the version field changed → skip it, commands.md does not need …

    line 81

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 AI Context

Check and update stale .ai/ files before starting a task. Only patch the stale parts — do not rewrite the entire file.

Use when: starting a new task, after pulling from remote, or when the context is suspected to be inaccurate.


Run

Step 1 — Detect stale files

bash .claude/skills/sync-ai-context/check-staleness.sh

Read the entire output. The script produces 3 types of results:

  • OK — this file is still fresh, skip it
  • STALE <source> is newer than <target> — the relevant section needs updating
  • MISSING — file does not exist yet, run /setup-ai-context first

Step 2 — Handle each STALE signal

If package.json is newer than commands.md:

node -e "const d=require('./package.json'); Object.entries(d.scripts||{}).forEach(([k,v])=>console.log(k+': '+v))"

Compare the output with .ai/commands.md. Update only the sections with different commands — do not remove any section unless you are certain it has been removed from the project.

If Makefile is newer than commands.md:

grep -E "^[a-zA-Z_-]+:" Makefile | sed 's/:.*//'

Add or update the corresponding targets in commands.md.

If README.md is newer than architecture.md:

head -60 README.md

Read the changed parts. Update only the affected section (usually "What the project is" or "Stack").

If there is a new directory not present in architecture.md: Read the contents of that directory (ls <dir>). Add 1-2 lines of description to the "Module structure" section — do not describe it if the purpose is unclear.

If a lint config (.eslintrc*, biome.json, ruff.toml...) is newer than conventions.md:

cat <config-file>

Update the relevant rule in conventions.md. Do not remove old rules unless the new config clearly contradicts them.

Step 3 — Implicitly update timestamps

After updating a file: touch that file to reset the baseline for the next check.

touch .ai/commands.md          # only files that were just updated
touch .ai/context/architecture.md
touch .ai/context/conventions.md

Step 4 — Report

Print:

  • Which files were updated and which sections were changed
  • Which files were OK (no action needed)
  • Any STALE signals the agent does not have enough information to handle — needs to ask the user

Gotchas

Script exit code 1 is not an error: Exit 1 only means there are stale files. Exit 0 = everything is fresh. Do not treat exit 1 as a failure.

find -newer uses filesystem mtime: If the project was just git cloned, all files will have mtime = the clone time — the script will report many false STALEs. In this case, use the "RECENT GIT CHANGES" section to make judgments instead of relying on file timestamps.

Do not update when unsure: If a STALE signal is package.json newer but only the version field changed → skip it, commands.md does not need updating. Prefer not being wrong over not updating.

Monorepo: The script detects new directories at depth 1-2. If the project is a monorepo with many apps/, only care about directories inside the sub-project being worked on.

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.