agentleFS
taxueseektaxueseek/session-digger/skills/env-doctor/SKILL.md

env-doctor

Skill34 starsChanged 4 months agoISCView on GitHub

[已整合至 env-master] 跨 AI 编码环境自检诊断工具箱。 核心思路:充分运用每个环境的原生诊断命令 + 薄脚本补盲区 + 模型推理综合。 推荐使用 /env-master 替代(更全面,含量化评分和统一入口)。 对未知环境使用通用降级探测。 触发:env-doctor、环境自检、环境诊断、体检、环境冲突、配置检查、 doctor、自检、环境健康、env health、infrastructure check、环境巡检

7 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Files
SKILL.md

env-doctor

原生命令为主、薄脚本补盲区、模型推理综合诊断。

核心原则

  1. 原生命令优先 — 每个环境的 built-in 诊断是最权威的,不重写
  2. 脚本只做盲区 — 原生命令做不到的事才用脚本(跨环境、网络、历史模式)
  3. 模型是大脑 — 调度策略由模型动态决定,不写死路由
  4. 未知环境降级 — 遇到未注册的 agent 工具,用通用探测发现能力

调度策略(模型决策参考)

用户请求自检
    │
    ▼
 capabilities.json → 确认目标环境有无注册
    │
    ├── 存在 → 按注册环境调度
    │
    └── 不存在 → 运行时探测:which claude codex grok kimi
                                      └── 发现的视为"已知环境"
    │
    ├── 已知环境(claude/codex/grok/kimi)
    │       │
    │       ▼
    │   调度原生命令(第一优先级,权威数据)
    │       │
    │       ├── 原生命令覆盖的维度 → 直接信任
    │       │
    │       └── 原生命令的 blind_spots → 调度对应脚本补充
    │               │
    │               ▼
    │           脚本数据 + 原生数据 → 模型综合推理 → 报告
    │
    └── 未知环境(未注册)
            │
            ▼
        unknown_env_fallback 通用探测
            │
            ▼
        which / --version / --help / 配置目录 / 配置文件
            │
            ▼
        输出原始数据 + 建议模型是否值得深入

各环境的原生命令

环境命令能查什么输出格式
Claude Code/doctor安装、hooks、PATH、settings、skills、MCPtext
Claude Code/contexttoken 占比、上下文分类visual grid
Claude Code/hooks注册列表、来源、matcherlist
Claude Code/permissionsallow/deny 规则list
Claude Code/mcpMCP 服务器 + OAuth 状态list
Codexcodex doctor --json18 项:网络、auth、config、install、MCP、更新structured JSON
Codexcodex debug models模型目录JSON
Grokgrok inspect [--json]版本、skills、hooks、agents、plugins、MCPtree / JSON
Kimi Codekimi doctor configconfig.toml 校验text
Kimi Codekimi doctor tuitui.toml 校验text

脚本(只做原生命令的盲区)

脚本文件路径何时调用
probe-network.shscripts/probe-network.sh所有环境的 API 可达性(原生只看自己的)
cross-path-audit.shscripts/cross-path-audit.shPATH 冲突(OS 级,单环境不感知)
drift-detector.pyscripts/drift-detector.pySkill 版本漂移(跨目录,单环境不感知)
history-match.pyscripts/history-match.py历史模式匹配(需会话索引,原生无)

调用示例

Preflight(每次运行前必做)

1. 验证 scripts/ 下 4 个脚本存在且可执行
   probe-network.sh / cross-path-audit.sh / drift-detector.py / history-match.py
   ├── 全部存在 → 继续
   └── 缺失 → 记录到报告 "scripts_missing: [...]",跳过对应检查维度

2. 定位 capabilities.json
   ├── SKILL.md 同目录 /capabilities.json → 读取
   └── 不存在 → 降级为运行时探测(which <cmd> && <cmd> --version)

全量巡检(模型决策)

1. 读 capabilities.json 确认可用环境(或运行时探测)
2. 并行调度各环境原生命令(推荐并行,示例见下)
3. 从输出中提取 blind_spots 列表
4. 对每个 blind_spot 调用对应脚本
5. 综合所有数据生成报告

并行执行示例

# 各环境原生诊断并行调度
codex doctor --json & PID1=$!
grok inspect --json  & PID2=$!
kimi doctor config   & PID3=$!
wait $PID1 $PID2 $PID3

# 脚本层并行
python3 scripts/probe-network.sh & PID4=$!
python3 scripts/cross-path-audit.sh & PID5=$!
wait $PID4 $PID5
# 各环境原生诊断
codex doctor --json                           # Codex
grok inspect --json                           # Grok
kimi doctor config                            # Kimi Code

# 脚本补充
python3 scripts/probe-network.sh              # API 可达性
python3 scripts/cross-path-audit.sh           # PATH 冲突
python3 scripts/drift-detector.py             # Skill 漂移
python3 scripts/history-match.py              # 历史模式

针对性检查

# 只看网络
python3 scripts/probe-network.sh

# 只看 Claude 相关的历史模式
python3 scripts/history-match.py --env claude

# 只看 warning 级别的问题
python3 scripts/history-match.py --severity warning

未知环境降级探测

当遇到未注册的 agent 工具(如新的 XYZ Code):

which xyz           # PATH 中是否存在
xyz --version       # 版本号
xyz --help 2>&1 | grep -iE 'doctor|check|status|config|debug'  # 发现诊断入口
ls -la ~/.<xyz>/    # 配置目录结构
cat ~/.<xyz>/config.*  # 配置健康度
ls ~/.<xyz>/skills/ # skill 安装数量

通用探测的目标:发现该环境的自诊断入口,输出原始数据供模型决定是否深入,不强行判断。

严重程度

级别含义行动
CRITICAL需立即处理影响核心功能(API 不可达、auth 过期、config 解析失败)
WARNING建议处理已知会降低效率(hook 过多、skill 漂移、path 冲突)
INFO提示信息可择机优化(环境变量冗余、API 链路分叉)
PASS正常无需操作

退出码约定

码含义
0全部 PASS 或 INFO,无 WARNING/CRITICAL
1存在 WARNING,无 CRITICAL
2存在 CRITICAL

脚本退出码对齐此约定:drift-detector.py 已对齐(0=clean, 1=drift),其余脚本遵循同一规则。

报告格式

=== env-doctor 诊断报告 ===
Date: ISO-8601
Version: 0.3.0
Environments: claude / codex / grok / kimi(实际检测到的)
Data Sources: /doctor + codex doctor --json + grok inspect + kimi doctor + N scripts

CRITICAL (N)
---
WARNING (N)
---
INFO (N)
---
PASS (N)
---

总结: [一句话评估]
建议: [按优先级排列的修复建议]

Path resolution

SD_ROOT="${SESSION_DIGGER_ROOT:-${CLAUDE_PLUGIN_ROOT:-${HERDR_PLUGIN_ROOT:-}}}"
[[ -z "$SD_ROOT" ]] && SD_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")/../.." 2>/dev/null && pwd)"

下游协作

发现推荐
Skill 漂移 / 闲置→ skill-insight + memory-management
会话错误率异常→ /analyze + /recall
配置问题需修复→ /apply(用户确认后)
长会话过多→ /compact 或拆分任务

DO NOT

  • 不重写原生命令已有的检查逻辑——调用它、信任它
  • 不让脚本做模型能推理的事——脚本只采集原始数据
  • 不在输出中暴露 API Key / token 完整值(只显示前 8 位 + 省略号)
  • 不替代各环境原生的诊断命令——是补充和跨环境扩展
  • 不对未知环境强行输出结论——只输出原始数据,让模型判断

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.