Agents Search — Discovery and Management
Discover, search, and manage Claude Code sub-agents installed under ~/.claude/agents/.
Supports four sub-commands: search, list, fetch, and invalidate.
Arguments
$0 — sub-command: search, list, fetch, or invalidate. If not provided, default to list.
$1 — query string (for search), agent name (for fetch), or --fetch flag (for invalidate).
Sub-Commands
search <query>
Find installed agents whose name or description matches a query string.
Steps:
Use Glob to enumerate all files at ~/.claude/agents/*.md.
For each file, use Read to load its content (frontmatter + body). Parse YAML frontmatter
(the block between the first --- and the second ---) to extract:
name (string)
model (string, may be absent — default to inherit)
tools (array or comma-separated string, may be absent — default to "")
description (string — use only the first line if multi-line)
Perform a case-insensitive substring match of <query> against both name and the first
line of description. Include a file if either field matches.
If one or more agents match, render a markdown table:
| Name | Model | Tools | Description |
| ---- | ----- | ----- | ----------- |
| ... | ... | ... | ... |
Tools column: join array entries with ", " or display the raw string; truncate to 40 chars
with … if longer.
Description column: first line of the description field only.
If no agents match, output exactly:
No agents found matching '<query>'
If Glob returns no results (no agents installed), check ~/.claude/cache/agents-catalog.md — if it exists and is less than 12 hours old (use Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0) to check mtime), display results from the catalog instead and note they are from the cached remote catalog.
list
List all installed agents grouped by model tier.
Steps:
Use Glob to enumerate all files at ~/.claude/agents/*.md.
For each file, Read its frontmatter and extract name, model, tools, description
(same parsing rules as search).
Group agents by model tier in this order:
- opus — entries where
model contains opus
- sonnet — entries where
model contains sonnet
- haiku — entries where
model contains haiku
- inherit — entries with no
model field, model: inherit, or any other value
For each non-empty tier, render a section header and a table:
### Opus
| Name | Model | Tools | Description |
| ---- | ----- | ----- | ----------- |
If ~/.claude/agents/ does not exist or contains no .md files, output:
No agents installed. Run `/agents:search fetch <name>` to install one.
If Glob returns no results (no agents installed), check ~/.claude/cache/agents-catalog.md — if it exists and is less than 12 hours old (use Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0) to check mtime), display results from the catalog instead and note they are from the cached remote catalog.
fetch <name>
Read a specific agent's full definition and offer install / view options.
Steps:
- Construct the local path
~/.claude/agents/<name>.md.
- Attempt
Read on that path.
- If found locally: display the agent's frontmatter fields (one per line,
key: value)
followed by the full body. Then present the user with options:
- Already installed — offer to re-display or customize.
- Customize — open the file for editing via a follow-up Edit call.
- View only — no further action.
- If not found locally: check whether
~/.claude/cache/agents-catalog.md exists via Read.
If the catalog exists, search it for a section or entry matching <name> (case-insensitive).
If a match is found, display the matching content and offer the user three options:
- Install — write the agent definition to
~/.claude/agents/<name>.md using Write.
- Customize — show the content and ask the user to provide edits before writing.
- View only — no further action.
If the catalog does not exist or contains no match, output:
Agent '<name>' not found locally or in catalog.
Run `/agents:search invalidate --fetch` to refresh the catalog, then try again.
invalidate [--fetch]
Clear the local agent catalog cache, optionally refreshing it from GitHub.
Steps:
If --fetch flag is present: Read the mtime of ~/.claude/cache/agents-catalog.md
now (before deleting anything) using
Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0).
Store the result for informational use later.
Check whether ~/.claude/cache/agents-catalog.md exists via Read.
- If it exists, delete it using
Bash: rm ~/.claude/cache/agents-catalog.md.
- If it does not exist, note "No cache file found."
Without --fetch (cache clear only):
Output:
Cache cleared.
With --fetch (clear and refresh — user explicitly requested a fresh fetch):
- Fetch the catalog using
WebFetch from:
https://raw.githubusercontent.com/VoltAgent/awesome-claude-code-subagents/main/README.md
Use HTTPS only (SEC-3).
If the fetch succeeds, ensure ~/.claude/cache/ exists
(Bash: mkdir -p ~/.claude/cache) and save the content to
~/.claude/cache/agents-catalog.md using Write.
Output:
Catalog refreshed. <N> bytes written to ~/.claude/cache/agents-catalog.md
If the fetch fails (network error, non-200, timeout), do not hard-fail (REL-1).
Warn the user:
Warning: Could not fetch catalog (network error). Existing cache cleared.
Run `/agents:search invalidate --fetch` again when connectivity is restored.
Do not throw or abort; return gracefully.
Cache TTL
Whenever search or list falls back to ~/.claude/cache/agents-catalog.md for data,
check whether the cache is stale before using it:
Run Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0) to get mtime.
If (now - mtime) > 43200 seconds (12 hours), display an inline notice:
(Cache is stale — last updated more than 12 h ago. Run `/agents:search invalidate --fetch` to refresh.)
Then continue with the stale data rather than blocking the user.
Tool Usage
All file I/O uses Claude Code built-in tools — this is a skill, not a shell script:
| Operation |
Tool |
| Enumerate agents |
Glob |
| Read file content / frontmatter |
Read |
| Search catalog content |
Grep |
| Write / install agent |
Write |
| Delete cache file |
Bash(rm <path>) |
| Create cache directory |
Bash(mkdir -p <path>) |
| Check file mtime |
Bash(stat -c %Y <path>) (GNU) / Bash(stat -f %m <path>) (BSD/macOS) |
| Fetch remote catalog |
WebFetch |
Key Principles
- Case-insensitive everywhere. All name and description matching is case-insensitive.
- Graceful degradation. Network failures in
invalidate --fetch warn and continue; they
never abort the session or raise an unhandled error (REL-1).
- HTTPS only. The catalog URL must always use
https:// (SEC-3).
- Read before write. Use
Read to check existing files before Write to avoid blind
overwrites without user confirmation.
- User drives installs. Never silently write to
~/.claude/agents/ without presenting
options and getting implicit or explicit user consent.
- Tier order is fixed.
list always outputs opus → sonnet → haiku → inherit. Never
reorder based on agent count or alphabetical sort within tiers (alphabetical within a tier
is acceptable).
1---2name: agents-search3description: Discover, search, and manage Claude Code agents. Use when you want to find available agents, list installed agents, or refresh the agent catalog. Triggers on: "search agents", "list agents", "find agent", "what agents", "agent catalog".4---56# Agents Search — Discovery and Management78Discover, search, and manage Claude Code sub-agents installed under `~/.claude/agents/`.9Supports four sub-commands: `search`, `list`, `fetch`, and `invalidate`.1011## Arguments1213- `$0` — sub-command: `search`, `list`, `fetch`, or `invalidate`. If not provided, default to `list`.14- `$1` — query string (for `search`), agent name (for `fetch`), or `--fetch` flag (for `invalidate`).1516---1718## Sub-Commands1920### `search <query>`2122Find installed agents whose name or description matches a query string.2324**Steps:**25261. Use `Glob` to enumerate all files at `~/.claude/agents/*.md`.272. For each file, use `Read` to load its content (frontmatter + body). Parse YAML frontmatter28 (the block between the first `---` and the second `---`) to extract:29 - `name` (string)30 - `model` (string, may be absent — default to `inherit`)31 - `tools` (array or comma-separated string, may be absent — default to `""`)32 - `description` (string — use only the first line if multi-line)333. Perform a **case-insensitive substring match** of `<query>` against both `name` and the first34 line of `description`. Include a file if either field matches.354. If one or more agents match, render a markdown table:3637 ```38 | Name | Model | Tools | Description |39 | ---- | ----- | ----- | ----------- |40 | ... | ... | ... | ... |41 ```4243 - `Tools` column: join array entries with `", "` or display the raw string; truncate to 40 chars44 with `…` if longer.45 - `Description` column: first line of the `description` field only.46475. If no agents match, output exactly:4849 ```50 No agents found matching '<query>'51 ```52536. If Glob returns no results (no agents installed), check `~/.claude/cache/agents-catalog.md` — if it exists and is less than 12 hours old (use `Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0)` to check mtime), display results from the catalog instead and note they are from the cached remote catalog.5455---5657### `list`5859List all installed agents grouped by model tier.6061**Steps:**62631. Use `Glob` to enumerate all files at `~/.claude/agents/*.md`.642. For each file, `Read` its frontmatter and extract `name`, `model`, `tools`, `description`65 (same parsing rules as `search`).663. Group agents by model tier in this order:67 - **opus** — entries where `model` contains `opus`68 - **sonnet** — entries where `model` contains `sonnet`69 - **haiku** — entries where `model` contains `haiku`70 - **inherit** — entries with no `model` field, `model: inherit`, or any other value714. For each non-empty tier, render a section header and a table:7273 ```markdown74 ### Opus7576 | Name | Model | Tools | Description |77 | ---- | ----- | ----- | ----------- |78 ```79805. If `~/.claude/agents/` does not exist or contains no `.md` files, output:8182 ```83 No agents installed. Run `/agents:search fetch <name>` to install one.84 ```85866. If Glob returns no results (no agents installed), check `~/.claude/cache/agents-catalog.md` — if it exists and is less than 12 hours old (use `Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0)` to check mtime), display results from the catalog instead and note they are from the cached remote catalog.8788---8990### `fetch <name>`9192Read a specific agent's full definition and offer install / view options.9394**Steps:**95961. Construct the local path `~/.claude/agents/<name>.md`.972. Attempt `Read` on that path.98 - **If found locally:** display the agent's frontmatter fields (one per line, `key: value`)99 followed by the full body. Then present the user with options:100 - Already installed — offer to re-display or customize.101 - Customize — open the file for editing via a follow-up Edit call.102 - View only — no further action.1033. **If not found locally:** check whether `~/.claude/cache/agents-catalog.md` exists via `Read`.104 - If the catalog exists, search it for a section or entry matching `<name>` (case-insensitive).105 If a match is found, display the matching content and offer the user three options:106 - Install — write the agent definition to `~/.claude/agents/<name>.md` using `Write`.107 - Customize — show the content and ask the user to provide edits before writing.108 - View only — no further action.109 - If the catalog does not exist or contains no match, output:110111 ```112 Agent '<name>' not found locally or in catalog.113 Run `/agents:search invalidate --fetch` to refresh the catalog, then try again.114 ```115116---117118### `invalidate [--fetch]`119120Clear the local agent catalog cache, optionally refreshing it from GitHub.121122**Steps:**1231241. **If `--fetch` flag is present:** Read the mtime of `~/.claude/cache/agents-catalog.md`125 now (before deleting anything) using126 `Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0)`.127 Store the result for informational use later.1281292. Check whether `~/.claude/cache/agents-catalog.md` exists via `Read`.130 - If it exists, delete it using `Bash`: `rm ~/.claude/cache/agents-catalog.md`.131 - If it does not exist, note "No cache file found."1321333. **Without `--fetch`** (cache clear only):134 Output:135136 ```137 Cache cleared.138 ```1391404. **With `--fetch`** (clear and refresh — user explicitly requested a fresh fetch):141 - Fetch the catalog using `WebFetch` from:142 `https://raw.githubusercontent.com/VoltAgent/awesome-claude-code-subagents/main/README.md`143 - Use HTTPS only (SEC-3).144 - If the fetch succeeds, ensure `~/.claude/cache/` exists145 (`Bash: mkdir -p ~/.claude/cache`) and save the content to146 `~/.claude/cache/agents-catalog.md` using `Write`.147 Output:148149 ```150 Catalog refreshed. <N> bytes written to ~/.claude/cache/agents-catalog.md151 ```152153 - If the fetch fails (network error, non-200, timeout), **do not hard-fail** (REL-1).154 Warn the user:155156 ```157 Warning: Could not fetch catalog (network error). Existing cache cleared.158 Run `/agents:search invalidate --fetch` again when connectivity is restored.159 ```160161 Do not throw or abort; return gracefully.162163---164165## Cache TTL166167Whenever `search` or `list` falls back to `~/.claude/cache/agents-catalog.md` for data,168check whether the cache is stale before using it:1691701. Run `Bash(stat -c %Y ~/.claude/cache/agents-catalog.md 2>/dev/null || stat -f %m ~/.claude/cache/agents-catalog.md 2>/dev/null || echo 0)` to get mtime.1712. If `(now - mtime) > 43200` seconds (12 hours), display an inline notice:172173 ```174 (Cache is stale — last updated more than 12 h ago. Run `/agents:search invalidate --fetch` to refresh.)175 ```176177 Then continue with the stale data rather than blocking the user.178179---180181## Tool Usage182183All file I/O uses Claude Code built-in tools — this is a skill, not a shell script:184185| Operation | Tool |186| ------------------------------- | ----------------------------------------------------------------------- |187| Enumerate agents | `Glob` |188| Read file content / frontmatter | `Read` |189| Search catalog content | `Grep` |190| Write / install agent | `Write` |191| Delete cache file | `Bash(rm <path>)` |192| Create cache directory | `Bash(mkdir -p <path>)` |193| Check file mtime | `Bash(stat -c %Y <path>)` (GNU) / `Bash(stat -f %m <path>)` (BSD/macOS) |194| Fetch remote catalog | `WebFetch` |195196---197198## Key Principles1992001. **Case-insensitive everywhere.** All name and description matching is case-insensitive.2012. **Graceful degradation.** Network failures in `invalidate --fetch` warn and continue; they202 never abort the session or raise an unhandled error (REL-1).2033. **HTTPS only.** The catalog URL must always use `https://` (SEC-3).2044. **Read before write.** Use `Read` to check existing files before `Write` to avoid blind205 overwrites without user confirmation.2065. **User drives installs.** Never silently write to `~/.claude/agents/` without presenting207 options and getting implicit or explicit user consent.2086. **Tier order is fixed.** `list` always outputs opus → sonnet → haiku → inherit. Never209 reorder based on agent count or alphabetical sort within tiers (alphabetical within a tier210 is acceptable).