用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill graceful-degradation命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | graceful-degradation |
| description | >- Use when this capability is needed. |
Graceful degradation is a design principle that ensures systems continue operating when components fail. Rather than crashing or returning errors, the system automatically falls back to slower but working alternatives.
flowchart TD
subgraph request[Request]
A[Operation Requested]
end
subgraph tiers[Fallback Tiers]
T1[Tier 1: Optimal]
T2[Tier 2: Acceptable]
T3[Tier 3: Guaranteed]
end
subgraph result[Result]
Success[Success]
end
A --> T1
T1 -->|Works| Success
T1 -->|Fails| T2
T2 -->|Works| Success
T2 -->|Fails| T3
T3 --> Success
%% Ghostty Hardcore Theme
style A fill:#65d9ef,color:#1b1d1e
style T1 fill:#a7e22e,color:#1b1d1e
style T2 fill:#fd971e,color:#1b1d1e
style T3 fill:#f92572,color:#1b1d1e
style Success fill:#a7e22e,color:#1b1d1e
The key insight: degrade performance, not availability.
From From 5 Seconds to 5 Milliseconds:
Volume Mount → API Call → Rebuild Cache
1-5ms 50ms 5000ms
# Kubernetes volume mount with optional flag
volumes:
- name: cache-volume
configMap:
name: deployment-cache
optional: true # Tier 1 can fail gracefully
See examples.md for detailed code examples.
Artifact Cache → Dependency Cache → Fresh Install
seconds minutes minutes+
See examples.md for detailed code examples.
Primary Endpoint → Secondary Endpoint → Cached Response → Static Fallback
SSO → API Token → Service Account → Anonymous (read-only)
Degrading without logging or alerting means you won't know when Tier 1 is broken.
// Bad: silent fallback
func getData() []byte {
if data, _ := cache.Get(); data != nil {
return data
}
return fetchFromAPI() // No indication we're in degraded mode
}
// Good: observable fallback
func getData() []byte {
if data, err := cache.Get(); err == nil {
metrics.CacheHit()
return data
}
metrics.CacheMiss()
log.Warn("cache miss, falling back to API")
return fetchFromAPI()
}
Every chain needs a final tier that always succeeds.
// Bad: can fail completely
func getConfig() (*Config, error) {
if cfg := cache.Get(); cfg != nil {
return cfg, nil
}
return api.FetchConfig() // What if API is also down?
}
// Good: guaranteed fallback
func getConfig() *Config {
if cfg := cache.Get(); cfg != nil {
return cfg
}
if cfg, err := api.FetchConfig(); err == nil {
return cfg
}
return DefaultConfig() // Always works
}
Using Tier 3 as the happy path defeats the purpose.
# Bad: always does full install
- run: npm ci
- uses: actions/cache/save@v4
with:
path: node_modules/
# Good: cache-first approach
- uses: actions/cache@v4
id: cache
with:
path: node_modules/
key: deps-${{ hashFiles('package-lock.json') }}
- if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
You need to know:
- name: Report cache tier
run: |
if [ "${{ steps.mount-cache.outcome }}" = "success" ]; then
echo "cache_tier=mount" >> metrics.txt
elif [ "${{ steps.api-cache.outcome }}" = "success" ]; then
echo "cache_tier=api" >> metrics.txt
else
echo "cache_tier=rebuild" >> metrics.txt
fi
See reference.md for additional techniques and detailed examples.
These patterns are complementary, not contradictory:
| Scenario | Pattern | Reasoning |
|---|---|---|
| Precondition not met | Fail Fast | Don't waste resources on doomed operations |
| Runtime component fails | Graceful Degradation | Continue with fallback |
| Invalid input | Fail Fast | User error, report immediately |
| Network timeout | Graceful Degradation | Infrastructure issue, retry/fallback |
| Missing required config | Fail Fast | Can't continue safely |
| Cache miss | Graceful Degradation | Expensive path still works |
Decision rule: Fail fast on precondition failures. Degrade gracefully on runtime failures.
Degrading without logging or alerting means you won't know when Tier 1 is broken.
See examples.md for detailed code examples.
Every chain needs a final tier that always succeeds.
See examples.md for detailed code examples.
Using Tier 3 as the happy path defeats the purpose.
See examples.md for detailed code examples.
You need to know:
- name: Report cache tier
run: |
if [ "${{ steps.mount-cache.outcome }}" = "success" ]; then
echo "cache_tier=mount" >> metrics.txt
elif [ "${{ steps.api-cache.outcome }}" = "success" ]; then
echo "cache_tier=api" >> metrics.txt
else
echo "cache_tier=rebuild" >> metrics.txt
fi
See examples.md for code examples.
See reference.md for complete documentation.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.