cache-manager
Manage OpenAPI spec cache and implementation state for efficient diff-based sync
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Manage OpenAPI spec cache and implementation state for efficient diff-based sync
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Check and install OpenAPI Sync MCP server dependency
Best practice templates for API layer scaffolding
Detect and analyze FSD layer structure in a project
Generate FSD-compliant slice boilerplate with pattern matching
Check FSD import boundary rules and detect violations
Manage analysis cache for incremental FSD validation
| name | cache-manager |
| description | Manage OpenAPI spec cache and implementation state for efficient diff-based sync |
Smart caching system for saving tokens and time.
When this skill is invoked, Claude MUST perform these steps in order:
Check which mode is requested:
| Flag | Mode | Action |
|---|---|---|
--force | Force | Skip cache, always fetch fresh |
--offline | Offline | Use cache only, fail if no cache |
| (default) | Smart | Check cache validity first |
Read tool to check if .openapi-sync.cache.json existsFor Remote URL source (starts with http:// or https://):
WebFetch tool with prompt: "Make a HEAD request to check ETag and Last-Modified headers"ETag matches cached httpCache.etag → Cache is VALIDLast-Modified matches cached httpCache.lastModified → Cache is VALIDFor Local File source:
Bash tool: stat -f "%m" <filepath> (macOS) or stat -c "%Y" <filepath> (Linux)localCache.mtime:
.openapi-sync.cache.json✅ Using cached spec (ETag unchanged) or ✅ Using cached spec (file not modified)🔄 Fetching spec...WebFetch tool to GET the full specRead tool to read the fileopenapi or swagger field)Write to .openapi-sync.cache.json with this structure:
{
"version": "1.0.0",
"_generated": "Auto-generated by /oas:sync. Do not edit manually.",
"lastFetch": "<current ISO timestamp>",
"specHash": "<SHA256 hash of normalized spec>",
"source": "<original source URL or path>",
"httpCache": {
"etag": "<ETag header value or null>",
"lastModified": "<Last-Modified header value or null>"
},
"localCache": {
"mtime": "<file mtime in milliseconds or null>"
},
"meta": {
"title": "<spec info.title>",
"version": "<spec info.version>",
"endpointCount": <number of endpoints>
},
"endpoints": { /* grouped by tag */ },
"schemas": { /* schema name -> short hash */ }
}
For full error code reference, see ../../docs/ERROR-CODES.md.
1. Log warning: "[E102] ⚠️ Network error checking cache, attempting full fetch..."
2. Try full fetch
3. If full fetch also fails AND cache exists:
- Log: "[E102] ⚠️ Using cached version (network unavailable)"
- Recovery: Use cached spec
4. If full fetch fails AND no cache:
- Error: "[E101] ❌ Cannot fetch spec and no cache available"
- Action: Abort operation
1. If JSON parse fails:
- Log: "[E602] ⚠️ Cache corrupted, refetching..."
- Recovery: Delete corrupted cache file, perform full fetch
1. If --offline flag AND no cache file:
- Error: "[E601] ❌ Offline mode requires existing cache"
- Fix: Run without --offline first to create cache
- Action: Abort operation
1. If cannot write cache file:
- Warning: "[E604] ⚠️ Failed to write cache file"
- Cause: Permission denied or disk full
- Recovery: Continue without caching (operation succeeds)
.openapi-sync.json # User config (version controlled)
.openapi-sync.cache.json # Spec cache (add to .gitignore)
.openapi-sync.state.json # Implementation state (add to .gitignore)
To generate a spec hash for comparison:
The .openapi-sync.state.json tracks implementation progress:
{
"version": "1.0.0",
"lastSync": "<timestamp of last /oas:sync>",
"lastScan": "<timestamp of last codebase scan>",
"implemented": {
"<tag>": {
"path": "<src path>",
"endpoints": ["operationId1", "operationId2"],
"files": { "api": "...", "types": "...", "hooks": "..." }
}
},
"partial": {
"<tag>": {
"implemented": ["op1"],
"missing": ["op2", "op3"]
}
},
"missing": ["tag1", "tag2"],
"coverage": {
"total": { "endpoints": 100, "implemented": 80, "percentage": 80 },
"byTag": { "<tag>": { ... } }
}
}
When computing diff between old and new spec:
Input: oldSpec (from cache), newSpec (freshly fetched)
Output: { added: [], removed: [], modified: [], unchanged: [] }
1. Create maps of endpoints by key (method + path)
2. For each endpoint in newSpec:
- If not in oldSpec → added
- If in oldSpec but different hash → modified
- If in oldSpec and same hash → unchanged
3. For each endpoint in oldSpec:
- If not in newSpec → removed
4. Return categorized changes
Use these exact messages for consistency:
| Situation | Message |
|---|---|
| Cache valid (ETag) | ✅ Using cached spec (ETag unchanged) |
| Cache valid (mtime) | ✅ Using cached spec (file not modified) |
| Cache stale | 🔄 Spec changed, fetching updates... |
| No cache | 📥 No cache found, fetching spec... |
| Force mode | 🔄 Force mode: refetching spec... |
| Offline mode | 📦 Offline mode: using cached spec |
| Network error | ⚠️ Network error, using cached version |
For detailed performance optimization strategies, see ../../docs/PERFORMANCE.md.
Key optimizations implemented: