Clear cache entries based on filters (all, expired, pattern). Delegates to fractary CLI for safe cache operations with dry-run support.
Clears cache entries by scope (all, expired, pattern) with dry-run preview and confirmation.
/plugin marketplace add fractary/claude-plugins/plugin install fractary-codex@fractaryThis skill inherits all available tools. When active, it can use any tool Claude has access to.
scripts/clear-cache.shYour responsibility is to remove entries from the codex cache by delegating to the cli-helper skill which invokes the fractary codex cache clear CLI command.
Architecture (v4.0):
cache-clear skill
↓ (delegates to)
cli-helper skill
↓ (invokes)
fractary codex cache clear
↓ (uses)
@fractary/codex SDK (CacheManager)
This provides safe cache deletion with confirmation, dry-run previews, and atomic index updates via the TypeScript SDK. </CONTEXT>
<CRITICAL_RULES>
Check that scope is one of: all, expired, pattern
IF scope is invalid:
IF scope == "all" AND confirmed != true:
Construct arguments array from inputs:
args = ["cache", "clear"]
// Add scope
if (scope === "all") args.push("--all")
if (scope === "expired") args.push("--expired")
if (scope === "pattern" && filter?.pattern) {
args.push("--pattern", filter.pattern)
}
// Add dry-run flag if requested or scope=all without confirmation
if (dry_run || (scope === "all" && !confirmed)) {
args.push("--dry-run")
}
USE SKILL: cli-helper Operation: invoke-cli Parameters:
{
"command": "cache",
"args": ["clear", ...scope_flags, ...dry_run_flag],
"parse_output": true
}
The cli-helper will:
fractary codex cache clear [--all|--expired|--pattern <p>] [--dry-run] --jsonThe CLI returns JSON like:
Dry-Run:
{
"status": "success",
"operation": "cache-clear",
"dry_run": true,
"would_delete": {
"count": 4,
"size_bytes": 8483,
"entries": [
{
"uri": "codex://fractary/old-service/README.md",
"size_bytes": 5242,
"reason": "Expired 5 days ago"
}
]
}
}
Actual Deletion:
{
"status": "success",
"operation": "cache-clear",
"dry_run": false,
"deleted": {
"count": 4,
"size_bytes": 8483,
"entries": [...]
},
"cache_stats": {
"before": {"total_entries": 42, "total_size_bytes": 3355443},
"after": {"total_entries": 38, "total_size_bytes": 3347960}
}
}
IF status == "success" AND dry_run == true:
IF status == "success" AND dry_run == false:
IF status == "failure":
IF scope == "all" AND dry_run preview shown:
Display formatted output to user.
COMPLETION: Operation complete when results shown.
</WORKFLOW><COMPLETION_CRITERIA> Operation is complete when:
✅ For dry-run:
✅ For actual deletion:
✅ For failed clear:
✅ In all cases:
🔍 DRY-RUN: Cache Clear Preview
───────────────────────────────────────
Would delete 4 entries (8.3 KB):
⚠ codex://fractary/old-service/README.md (5.1 KB)
Reason: Expired 5 days ago
⚠ codex://fractary/deprecated/guide.md (3.2 KB)
Reason: Expired 7 days ago
Total to delete: 8.3 KB
───────────────────────────────────────
Run without --dry-run to execute
🗑️ CACHE CLEAR COMPLETED
───────────────────────────────────────
Deleted 4 entries (8.3 KB):
✓ codex://fractary/old-service/README.md
✓ codex://fractary/deprecated/guide.md
✓ codex://fractary/temp-service/notes.md
✓ codex://fractary/archived/spec.md
Cache stats updated:
- Total entries: 38 (was 42)
- Total size: 3.1 MB (was 3.2 MB)
───────────────────────────────────────
Cache index updated automatically
Documents will be re-fetched when accessed.
⚠️ CONFIRMATION REQUIRED: Delete entire cache
This will delete ALL cached documents:
- Total entries: 42
- Total size: 3.2 MB
Cache is regeneratable - source documents are not affected.
Deleted documents will be re-fetched automatically when accessed.
Delete entire cache?
[Yes, delete all] [Cancel]
ℹ️ CACHE CLEAR: No entries found
No entries matched the specified filter.
Filter: {filter description}
Current cache size: {count} entries ({size})
───────────────────────────────────────
Use /fractary-codex:cache-list to view cache
{
"status": "failure",
"operation": "cache-clear",
"error": "Failed to delete cache entries",
"cli_error": {
"message": "Permission denied writing to cache index",
"suggested_fixes": [
"Check file permissions",
"Ensure cache directory is writable"
]
}
}
{
"status": "failure",
"operation": "cache-clear",
"error": "CLI not available",
"suggested_fixes": [
"Install globally: npm install -g @fractary/cli",
"Or ensure npx is available"
]
}
</OUTPUTS>
<ERROR_HANDLING>
When CLI reports cache index doesn't exist:
When CLI returns error:
When CLI reports file deletion failures:
When scope is missing or invalid:
When cli-helper reports CLI unavailable:
</ERROR_HANDLING>
<DOCUMENTATION> Upon completion, output:Success (Dry-Run):
🎯 STARTING: cache-clear
Scope: {scope}
Filter: {filter details}
Mode: DRY-RUN
───────────────────────────────────────
[Preview of entries to delete]
✅ COMPLETED: cache-clear (dry-run)
Would delete {count} entries ({size})
Source: CLI (via cli-helper)
───────────────────────────────────────
Success (Actual Deletion):
🎯 STARTING: cache-clear
Scope: {scope}
Filter: {filter details}
Mode: EXECUTE
───────────────────────────────────────
[Deletion results]
✅ COMPLETED: cache-clear
Deleted {count} entries ({size})
Cache index updated
Source: CLI (via cli-helper)
───────────────────────────────────────
Documents will be re-fetched when accessed
Failure:
🎯 STARTING: cache-clear
───────────────────────────────────────
❌ FAILED: cache-clear
Error: {error_message}
Suggested fixes:
- {fix 1}
- {fix 2}
───────────────────────────────────────
</DOCUMENTATION>
<NOTES>
v3.0 (bash scripts):
cache-clear
└─ scripts/clear-cache.sh
├─ reads cache index
├─ deletes files
├─ updates index atomically
└─ handles errors
v4.0 (CLI delegation):
cache-clear
└─ delegates to cli-helper
└─ invokes: fractary codex cache clear
Benefits:
This skill delegates to:
fractary codex cache clear [--all|--expired|--pattern <pattern>] [--dry-run] --json
Via the CLI, this skill benefits from:
CacheManager.clear() - Main deletion logicClear expired (safe, no confirmation):
{
"scope": "expired"
}
Clear by pattern:
{
"scope": "pattern",
"filter": {"pattern": "**/*.md"}
}
Clear all (requires confirmation):
{
"scope": "all",
"confirmed": true
}
Dry-run first:
{
"scope": "all",
"dry_run": true
}
All deleted entries will be automatically re-fetched when accessed:
/fractary-codex:fetch retrieves from sourceTo test this skill:
# Ensure CLI installed
npm install -g @fractary/cli
# Populate cache first
fractary codex fetch codex://fractary/codex/README.md
# Test dry-run
USE SKILL: cache-clear
Parameters: {
"scope": "expired",
"dry_run": true
}
# Test actual deletion
USE SKILL: cache-clear
Parameters: {
"scope": "expired"
}
If clear fails:
fractary --versionfractary codex cache clear --expiredfractary codex cache listfractary codex health
</NOTES>
This skill should be used when the user asks about libraries, frameworks, API references, or needs code examples. Activates for setup questions, code generation involving libraries, or mentions of specific frameworks like React, Vue, Next.js, Prisma, Supabase, etc.