update-experts
purpose
Scan the .experts/ directory tree, detect expert files that were added or removed since the index files were last updated, and reconcile every index.md to match the actual file system.
rules
- Scan the full directory tree first. Walk every folder under
.experts/and collect all.mdfiles. Separate them into three categories: index files (index.md), utility files (root-level system files likebuilder.md,analyzer.md,fallback.md,update-experts.md), and expert files (everything else that isn't prefixed with_). - Build the expected inventory from the file system. For each domain folder (
tools/,languages/,languages/{lang}/,.project/), list every expert.mdfile present on disk (excludingindex.md). This is the source of truth. - Build the registered inventory from each index file. Parse each domain's
index.mdto extract: (a) the## file inventorylist and (b) expert filenames referenced inRead:or→ Readdirectives within## task clusters. This is what the routing system currently knows about. - Diff the two inventories per domain. Identify: (a) New experts — files on disk not in the index, (b) Removed experts — files in the index not on disk, (c) Orphaned references —
Read:directives pointing to files that don't exist. - For each new expert, read the file to extract routing metadata. Open the new expert file and extract: the
# titleline, the## purposeline, trigger phrases from## instructions, and anyWhen:signal words. This metadata is needed to write the index entry. - Update domain
index.mdfiles for new experts. For each new expert: (a) Add a task cluster entry under## task clusterswith aWhen:line derived from the expert's trigger phrases and a→ Readdirective pointing to the file. (b) Add the filename to## file inventoryin alphabetical order. - Update domain
index.mdfiles for removed experts. For each removed expert: (a) Delete its task cluster entry from## task clusters. (b) Remove the filename from## file inventory. (c) Remove anyDepends on:references to it from other clusters. - Update the root
index.mdfor signal word changes. After updating domain indexes, check if new experts introduced signal words not already present in the rootindex.mdrouting rules for that domain. Add them. Similarly, remove signal words that only belonged to a now-deleted expert. - Update the root
index.mdutilities section. If a new root-level utility file was added (not inside a domain folder), add it to## utilitieswith a→ Readdirective, signals line, and one-line description. If a utility was removed, delete its entry. - Handle language sub-domains. Languages have a two-level structure:
languages/index.mdroutes tolanguages/{lang}/index.md, which routes to individual expert files. New language folders need entries inlanguages/index.md. New expert files within a language folder need entries in that language'sindex.md. - Detect new domain folders. If a folder exists under
.experts/that contains anindex.mdbut has no routing entry in the rootindex.md, flag it as a new domain and add a routing entry with signals derived from itsindex.mdpurpose and task clusters. - Detect orphaned domain folders. If the root
index.mdreferences a domain folder that doesn't exist on disk, remove the routing entry and warn the developer. - Never modify expert files themselves. This utility only touches
index.mdfiles. Expert content, rules, patterns, and instructions are never altered. - Report all changes. After updating, output a structured summary showing: files scanned, new experts wired, removed experts unwired, signal words added/removed, and any warnings (orphaned references, missing metadata).
workflow
phase 1 — scan
- List all folders under
.experts/recursively. - For each folder, list all
.mdfiles. - Categorize every file: index, utility, or expert.
- Build the file-system inventory:
{ domain → [expert files] }.
phase 2 — parse indexes
- Read every
index.mdfile found in phase 1. - Extract registered experts from
## file inventoryandRead:/→ Readdirectives. - Build the index inventory:
{ domain → [registered files] }.
phase 3 — diff
- For each domain, compute:
added = filesystem - indexremoved = index - filesystemorphaned_refs = Read directives pointing to missing files
- For root-level files, compare against
## utilitiesin the rootindex.md.
phase 4 — gather metadata for new experts
- For each file in
added, read the expert file. - Extract: title, purpose, trigger phrases from
## instructions, signal words. - If the expert lacks
## instructionsor trigger phrases, derive signal words from the title and purpose.
phase 5 — update indexes
- Apply additions and removals to each domain
index.md:- Add/remove task cluster entries.
- Add/remove file inventory entries.
- Clean up
Depends on:/Cross-domain deps:references to removed files.
- Apply signal word changes to root
index.mdrouting rules. - Apply utility additions/removals to root
index.md## utilitiessection.
phase 6 — report
Output a structured summary:
## Update Report
### Scanned
- Domains: {count}
- Expert files: {count}
- Index files: {count}
### Changes
#### New experts wired
- {domain}/index.md ← {filename} (signals: {words})
#### Removed experts unwired
- {domain}/index.md → {filename} removed
#### Signal words updated
- Root index.md: added {words} to {domain} signals
- Root index.md: removed {words} from {domain} signals
#### Utilities updated
- Root index.md: added {filename} to utilities
- Root index.md: removed {filename} from utilities
### Warnings
- {any orphaned references, missing metadata, etc.}
### No changes needed
- {domains where filesystem matches index}patterns
Parsing file inventory from an index
# File inventory formats to recognize:
# Pipe-delimited (tools/index.md style):
# git.md | json-yaml.md | prompt-engineer.md
→ Split on ` | `, strip backticks
# Backtick-delimited (languages/typescript/index.md style):
# `idioms.md` | `patterns.md` | `pitfalls.md` | `type-system.md`
→ Split on ` | `, strip backticks
# Comment placeholder (.project/index.md style):
# <!-- empty — populated by analyzer.md + builder.md -->
→ Empty listParsing Read directives from task clusters
# Single-file directive (tools style):
# → Read `.experts/tools/git.md`
→ Extract path, derive filename: git.md
# Multi-file directive (language sub-domain style):
# Read:
# - `idioms.md`
# - `patterns.md`
→ Extract each filename from bullet list
# Domain-level directive (root index.md style):
# → Read `.experts/languages/index.md`
→ This points to an index, not an expert — skip when inventorying expertsDeriving signal words from an expert file
# Priority order for extracting signals:
1. ## instructions → "Trigger phrases:" line
→ Parse the comma-separated quoted phrases
2. ## interview → question text
→ Extract domain-specific keywords
3. ## purpose → one-line description
→ Extract nouns and noun phrases
4. # title → filename stem
→ Use as a last-resort signal wordpitfalls
- Confusing index files with expert files. Every domain has an
index.mdthat is a router, not an expert. Never addindex.mdto a file inventory or create a task cluster pointing to an index within its own domain. - Missing the two-level language structure.
languages/index.mdroutes tolanguages/{lang}/index.md, which routes to expert files. A new file inlanguages/python/must updatelanguages/python/index.md, notlanguages/index.mddirectly. A new language folder must updatelanguages/index.md. - Overwriting hand-crafted cluster descriptions. When adding a new expert to an existing index, don't rewrite the existing task clusters. Only add the new entry and update the file inventory.
- Duplicating signal words in root index. Before adding signal words to a domain's entry in the root
index.md, check that those words don't already appear in another domain's signals. Duplicate signals cause ambiguous routing. - Forgetting locked files.
*.locked.mdfiles are valid experts that should appear in indexes. Don't skip them during scanning — they route identically to unlocked files. - Treating
_prefixed.mdfiles as experts. Files starting with_are system/template files, not routable experts. Exclude them from inventory and index updates.
instructions
Use this expert when the developer wants to synchronize the routing indexes with the actual expert files on disk. This is the maintenance counterpart to builder.md — the builder creates experts, this utility ensures the routing system reflects what exists.
Trigger phrases: "update experts," "sync indexes," "update index," "refresh routing," "fix index files," "new experts not routed," "clean up indexes," "reconcile experts."
Pair with: builder.md (run update-experts after bulk expert creation to wire everything at once). Pair with: analyzer.md (run update-experts after the analyzer recommends and creates project experts).
research
Deep Research prompt:
"Write a meta-expert for maintaining a modular AI expert routing system's index files. Cover: recursive directory scanning to discover expert files, parsing index.md files to extract registered file inventories and Read directives, diffing filesystem state against index state, extracting routing metadata (signal words, trigger phrases) from expert files, updating multi-level index hierarchies (root router, domain routers, sub-domain routers), handling additions and removals symmetrically, managing signal word propagation from domain indexes to root index, reporting changes in a structured format, and common maintenance pitfalls (index/expert confusion, two-level language routing, locked files, underscore-prefixed system files, duplicate signal words across domains)."