agentleFS
TheophilusChinomonaTheophilusChinomona/idev/skills/cache-refresh/SKILL.md

cache-refresh

Skill0 starsChanged 5 months agoMITView on GitHub

Keeps idev skill caches fresh after source files are created, deleted, or renamed. Use after structural file changes or when the user says refresh caches.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈12

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep all skill caches fresh by detecting when source files change and triggering targeted cache updates.

    line 9
  2. Distinctive:

    Incremental: After Claude creates, deletes, or renames a file during a task

    line 12
  3. Distinctive:

    Full refresh: When user says "refresh caches" or when caches are older than 7 days

    line 13
  4. Distinctive:

    After Claude creates, renames, or deletes a source file, determine which caches are affected:

    line 29
  5. Distinctive:

    When a refresh is requested (or the session-start hook has flagged old caches), check what is actually stale:

    line 78
  6. Distinctive:

    When triggered by user ("refresh caches") or expiry:

    line 100
  7. Distinctive:

    Run these as parallel agents for speed.

    line 112
  8. Distinctive:

    Do NOT rescan everything after a single file change — use incremental updates

    line 134
  9. Distinctive:

    Do NOT skip cache updates after creating files — stale caches cause real bugs

    line 135
  10. Distinctive:

    Do NOT run a full refresh every time caches are mentioned — only when actually stale

    line 136
  11. Distinctive:

    Do NOT update caches for non-source file changes (.md, .txt, config)

    line 137
  12. Distinctive:

    Do NOT block the user's task to refresh — update in the background when possible

    line 138

≈ “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

Cache Refresh Skill

Purpose

Keep all skill caches fresh by detecting when source files change and triggering targeted cache updates. Prevents stale data from causing wrong file paths, missing registrations, or outdated function line numbers.

Activation

  • Incremental: After Claude creates, deletes, or renames a file during a task
  • Full refresh: When user says "refresh caches" or when caches are older than 7 days

Note: skills do not run at session start. The session-start hook surfaces cache ages; this skill defines what to do when the user or another skill asks for a refresh (for example, after the hook reports stale caches).


How It Works

This skill does NOT use a file watcher daemon. Instead, it hooks into Claude's own actions — every time Claude creates or modifies a file, this skill updates the relevant caches incrementally.


Phase 1: Track File Changes During Session

After Claude creates, renames, or deletes a source file, determine which caches are affected:

File change → Affected caches:

New .cs file (Entity)       → file-index, backend-patterns (Function Index), post-creation-verify
New .cs file (Controller)   → file-index, architecture-scanner (apiRoutes), backend-patterns
New .cs file (Service)      → file-index, backend-patterns
New .tsx/.ts file            → file-index, frontend-patterns (Function Index)
New .service.ts file         → file-index, architecture-scanner (apiRoutes)
New .hook.ts file            → file-index, frontend-patterns
New route added              → architecture-scanner, file-index
DI registration changed      → post-creation-verify (registration points may shift)
DbContext changed             → post-creation-verify (registration points may shift)
Any file deleted              → file-index (remove entry), pattern cache Function Index (remove entry)

Phase 2: Incremental Update Rules

After creating a new feature:

1. Add new files to file-index/index.md under the correct feature section
2. Add new API routes to architecture-scanner/cache.json apiRoutes
3. Add new function entries to pattern cache Function Index sections
4. Update post-creation-verify registration points if DI/DbContext files were modified
5. Update session-resume recentFiles.modified list
6. Update task-journal with completed task

After modifying an existing file:

1. If function was added/removed → update Function Index entries
2. If DI file was modified → update post-creation-verify registration points
3. If route was added → update architecture-scanner apiRoutes

After deleting a file:

1. Remove from file-index
2. Remove from architecture-scanner apiRoutes (if controller/service)
3. Remove function entries from the pattern cache Function Index

Phase 3: Staleness Detection

When a refresh is requested (or the session-start hook has flagged old caches), check what is actually stale:

1. Read each cache's "generated" date
2. If older than 7 days → mark for full refresh
3. If git is available: run `git log --since="CACHE_DATE" --name-only --pretty=format:""`
   → Get list of files changed since cache was generated
   → If changed files overlap with cached paths → mark for targeted refresh
4. If no git: compare cache date only

Staleness levels:

Fresh (< 1 day old, no conflicting changes): Use as-is
Stale (1-7 days, minor changes): Incremental update
Expired (> 7 days): Full rescan

Phase 4: Full Refresh

When triggered by user ("refresh caches") or expiry:

1. Regenerate file-index/index.md (scan all features)
2. Regenerate architecture-scanner/cache.json (scan routes)
3. Regenerate backend-patterns function-index (scan key files)
4. Regenerate frontend-patterns function-index (scan key files)
5. Regenerate post-creation-verify/cache.json (rescan DI line numbers)
6. Regenerate build-check/cache.json (rescan build commands)
7. Update all "generated" dates

Run these as parallel agents for speed.


Phase 5: Integration

After every file creation/modification by Claude:
  1. cache-refresh determines which caches are affected
  2. Updates them incrementally (add/remove entries)
  3. No full rescan needed for single-file changes

When the session-start hook reports cache ages:
  1. If a refresh is warranted, run the staleness check (~1 grep command)
  2. If stale → targeted refresh
  3. If fresh → use as-is

Anti-Patterns

  1. Do NOT rescan everything after a single file change — use incremental updates
  2. Do NOT skip cache updates after creating files — stale caches cause real bugs
  3. Do NOT run a full refresh every time caches are mentioned — only when actually stale
  4. Do NOT update caches for non-source file changes (.md, .txt, config)
  5. Do NOT block the user's task to refresh — update in the background when possible

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.