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.
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- clarify-scopeSkill
- create-pr-descriptionSkill
- debugSkill
- implement-tddSkill
- plan-tasksSkill
- review-prSkill
- setup-ai-contextSkill
- shipSkill
- write-specSkill
- write-test-scenariosSkill
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
- Very specific: line 8
Check and update stale .ai/ files before starting a task.
- Distinctive: line 10
Use when: starting a new task, after pulling from remote, or when the context is suspected to be inaccurate.
- Distinctive: line 22
Read the entire output. The script produces 3 types of results:
- Very specific: line 39
Add or update the corresponding targets in commands.md.
- Distinctive: line 45
Read the changed parts. Update only the affected section (usually "What the project is" or "Stack").
- Very specific: line 48
Read the contents of that directory (ls <dir>).
- Very specific: line 54
Update the relevant rule in conventions.md.
- Distinctive: line 58
After updating a file: touch that file to reset the baseline for the next check.
- Very specific: line 79
find -neweruses filesystem mtime: If the project was just git cloned, all files will have mtime = the clone time — the script will … - Very specific: line 81
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 …
≈ “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.
Files
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.shRead the entire output. The script produces 3 types of results:
OK— this file is still fresh, skip itSTALE <source> is newer than <target>— the relevant section needs updatingMISSING— file does not exist yet, run/setup-ai-contextfirst
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.mdRead 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.mdStep 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.
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
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.

