‹ 首页

graceful-degradation

@parcadei · 收录于 1 周前 · 上游提交 5 个月前

Graceful Degradation with Helpful Messages

适合你,如果需要在系统部分不可用时仍保持良好用户体验

/ 下载安装
graceful-degradation.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add parcadei/continuous-claude-v3/graceful-degradation
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- parcadei/continuous-claude-v3/graceful-degradation
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify parcadei/continuous-claude-v3/graceful-degradation
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
3859GitHub stars
~418上下文体积 · 单文件
镜像托管

怎么用

商店整理自技能原文 · 版本 d07ff4b · 表述以原文为准
它做什么

当某个可选服务不可用时,Claude 不会静默失败,而是给出清晰的提示:说明哪个服务缺失、哪些功能降级,以及如何启用该服务,然后继续提供剩余功能。

什么时候触发

当 Claude 需要调用一个可选的外部服务(如本地 AI 模型服务器)但该服务未运行或不可达时触发。

装好后可以这样说
Claude 会返回降级消息,包含启用服务的具体步骤。
技能原文 SKILL.md作者撰写 · MIT · d07ff4b

Graceful Degradation with Helpful Messages

When optional services are unavailable, degrade gracefully with actionable fallback messages.

Pattern

Check availability at the start, cache the result, and provide helpful messages that explain what's missing and how to fix it.

DO
  • Check service availability early (before wasting compute)
  • Cache health check results for the session (e.g., 60s TTL)
  • Provide actionable fallback messages:
  • What service is missing
  • What features are degraded
  • How to enable the service
  • Continue with reduced functionality when possible
DON'T
  • Silently fail or return empty results
  • Check availability on every call (cache it)
  • Assume the user knows how to start missing services
Example: LMStudio Check Pattern
let lmstudioAvailable: boolean | null = null;
let lastCheck = 0;
const CACHE_TTL = 60000; // 60 seconds

async function checkLMStudio(): Promise<boolean> {
  const now = Date.now();
  if (lmstudioAvailable !== null && now - lastCheck < CACHE_TTL) {
    return lmstudioAvailable;
  }

  try {
    const response = await fetch('http://localhost:1234/v1/models', {
      signal: AbortSignal.timeout(2000)
    });
    lmstudioAvailable = response.ok;
  } catch {
    lmstudioAvailable = false;
  }
  lastCheck = now;
  return lmstudioAvailable;
}

// Usage
if (!await checkLMStudio()) {
  return {
    result: 'continue',
    message: `LMStudio not available at localhost:1234.

To enable Godel-Prover tactic suggestions:
1. Install LMStudio from https://lmstudio.ai/
2. Load "Goedel-Prover-V2-8B" model
3. Start the local server on port 1234

Continuing without AI-assisted tactics...`
  };
}
Fallback Message Template
[Service] not available at [endpoint].

To enable [feature]:
1. [Step to install/start]
2. [Configuration step if needed]
3. [Verification step]

Continuing without [degraded feature]...
Source Sessions
  • This session: LMStudio availability check with 60s caching and helpful fallback
  • 174e0ff3: Environment variable debugging - print computed paths for troubleshooting
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。