agent-skill-doctor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/NOTICE.md +9 -0
- package/README.en.md +275 -0
- package/README.md +275 -0
- package/bin/agent-skill-doctor-phase2.js +250 -0
- package/bin/agent-skill-doctor-phase3.js +215 -0
- package/bin/agent-skill-doctor-risk.js +147 -0
- package/bin/agent-skill-doctor.js +1834 -0
- package/examples/basic-usage.js +113 -0
- package/examples/readme-demo-skills/dangerous-deploy/SKILL.md +14 -0
- package/examples/readme-demo-skills/markdown-reporter-a/SKILL.md +8 -0
- package/examples/readme-demo-skills/markdown-reporter-b/SKILL.md +8 -0
- package/examples/readme-demo-skills/npm-installer/SKILL.md +10 -0
- package/examples/readme-demo-skills/pnpm-installer/SKILL.md +10 -0
- package/package.json +58 -0
- package/rules/default/credential-risk.json +19 -0
- package/rules/default/destructive-risk.json +17 -0
- package/rules/default/shell-network-risk.json +31 -0
- package/src/doctor/conflict.js +139 -0
- package/src/doctor/i18n.js +572 -0
- package/src/doctor/index.js +50 -0
- package/src/doctor/phase2.js +261 -0
- package/src/doctor/risk-lite.js +124 -0
- package/src/doctor/rules.js +57 -0
- package/src/doctor/zombie.js +178 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - 2026-06-08
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial npm package release
|
|
12
|
+
- CLI with scan, diagnose, report, duplicates, risks, conflicts, zombies, plan, apply commands
|
|
13
|
+
- Library API for programmatic usage
|
|
14
|
+
- Zero external dependencies
|
|
15
|
+
- SQLite-based local database
|
|
16
|
+
- Configurable risk rules
|
|
17
|
+
- CI/CD support with exit codes
|
|
18
|
+
- Examples directory with basic usage example
|
|
19
|
+
- Comprehensive README with installation, usage, and API documentation
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
- **Scan** local skill directories and build SQLite database
|
|
23
|
+
- **Diagnose** skills for quality issues, duplicates, drift, risks, conflicts, and zombies
|
|
24
|
+
- **Plan** safe optimization actions with expected state validation
|
|
25
|
+
- **Apply** changes with dry-run safety checks
|
|
26
|
+
- **Report** in Markdown or JSON format
|
|
27
|
+
- **CI support** with exit codes for automated workflows
|
|
28
|
+
|
|
29
|
+
### Technical Details
|
|
30
|
+
- Node.js >= 22.5.0 (uses experimental `node:sqlite` module)
|
|
31
|
+
- CommonJS module system
|
|
32
|
+
- No external dependencies
|
|
33
|
+
- MIT License
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tianliang Zhang and agent-skill-doctor contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Notice
|
|
2
|
+
|
|
3
|
+
This project, agent-skill-doctor, is designed to be derived from or integrated with:
|
|
4
|
+
|
|
5
|
+
- xingkongliang/skills-manager
|
|
6
|
+
- Original copyright: Copyright (c) 2026 Tianliang Zhang
|
|
7
|
+
- Original license: MIT License
|
|
8
|
+
|
|
9
|
+
agent-skill-doctor is an independent project and is not affiliated with, endorsed by, or officially maintained by the original skills-manager author unless explicitly stated.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Agent Skill Doctor
|
|
4
|
+
|
|
5
|
+
AI Agent Skills diagnostics and governance for Claude Code, Codex, Cursor, OpenCode, and other local agent skill folders.
|
|
6
|
+
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://www.npmjs.com/package/agent-skill-doctor)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](#install)
|
|
11
|
+
|
|
12
|
+
[中文](./README.md) · English
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
Agent Skill Doctor diagnoses local AI Agent Skills: duplicate installs, version drift, conflicting instructions, risky commands, zombie skills, weak descriptions, and scan structure warnings. It does not delete or overwrite skill files by default; it diagnoses, reports, and generates repair prompts for your agent.
|
|
19
|
+
|
|
20
|
+
## What It Detects
|
|
21
|
+
|
|
22
|
+
- `risk`: risky text such as `rm -rf`, `.env`, `curl/wget`, `powershell`, or `child_process`.
|
|
23
|
+
- `conflict`: contradictory instructions, such as `npm install` vs `pnpm install`.
|
|
24
|
+
- `duplicate`: exact, same-source, or same-name duplicate skills.
|
|
25
|
+
- `version_drift`: the same skill installed with different refs or content.
|
|
26
|
+
- `zombie`: low-activity or possibly abandoned skills.
|
|
27
|
+
- `description_quality`: missing trigger, input/output, risk notes, or too-short descriptions.
|
|
28
|
+
- `scan_warning`: missing `SKILL.md` or malformed frontmatter.
|
|
29
|
+
|
|
30
|
+
## Scoring Rules
|
|
31
|
+
|
|
32
|
+
- Risk severity comes from JSON rules: destructive file operations are usually `critical`, credential access and remote downloads are usually `high`, shell execution is usually `medium`.
|
|
33
|
+
- Duplicate confidence: exact content `1.0`, same source and slug `0.95`, same name with different content `0.7`.
|
|
34
|
+
- Zombie score is `0.0 - 1.0`; higher means more suspicious:
|
|
35
|
+
- no preset: `+0.25`
|
|
36
|
+
- not installed in any agent: `+0.20`
|
|
37
|
+
- not installed in any project: `+0.20`
|
|
38
|
+
- no recent modification: `+0.15`
|
|
39
|
+
- no activity log: `+0.15`
|
|
40
|
+
- weak description: `+0.05`
|
|
41
|
+
- Zombie protection: `pinned/keep/core/system` tags and official sources return `0`; plugin sources multiply by `0.5`; third-party plugin sources multiply by `0.75`.
|
|
42
|
+
- Zombie levels: `>=0.8` strong suspected zombie, `>=0.6` suspected zombie, `>=0.4` low activity.
|
|
43
|
+
- Description quality starts at 60 points; short descriptions, missing triggers, missing input/output notes, and undocumented risks reduce the score and create findings.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g agent-skill-doctor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Or run without global install:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx agent-skill-doctor help
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Requires Node.js `>= 22.5.0`.
|
|
58
|
+
|
|
59
|
+
## Quick Start: Use It With An Agent
|
|
60
|
+
|
|
61
|
+
Paste this into Claude Code, Codex, Cursor Agent, or another local agent:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
Use agent-skill-doctor to diagnose my local Agent Skills:
|
|
65
|
+
|
|
66
|
+
1. Run: npx agent-skill-doctor diagnose --lang en
|
|
67
|
+
2. Generate an HTML report: npx agent-skill-doctor report --format html --lang en
|
|
68
|
+
3. Review conflicts, duplicates, version drift, zombie skills, and risks.
|
|
69
|
+
4. Do not delete files yet. First produce a repair plan and explain which skills would change.
|
|
70
|
+
5. Give recommendations for risk, duplicate, version_drift, zombie, and description_quality findings.
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The agent can use `fix` to generate targeted repair prompts:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx agent-skill-doctor fix --lang en
|
|
77
|
+
npx agent-skill-doctor fix --type risk --severity high --lang en
|
|
78
|
+
npx agent-skill-doctor fix --type zombie --lang en
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Default scan roots:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
~/.agent/skills
|
|
85
|
+
~/.agents/skills
|
|
86
|
+
~/.agents/skills-core
|
|
87
|
+
~/.codex/skills
|
|
88
|
+
~/.claude/skills
|
|
89
|
+
~/.cursor/skills
|
|
90
|
+
~/.opencode/skills
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Scan a specific directory:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx agent-skill-doctor diagnose --root ./my-skills --lang en
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Reproducible Demo
|
|
100
|
+
|
|
101
|
+
This repo includes a sanitized demo at `examples/readme-demo-skills`. It contains 5 small skills that trigger risk, conflict, duplicate, version drift, zombie, and description quality findings.
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install
|
|
105
|
+
npm run start -- diagnose --root ./examples/readme-demo-skills --rebuild-index --lang en
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Example output:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
Skills: 5
|
|
112
|
+
Findings: 15
|
|
113
|
+
Risk findings: 3
|
|
114
|
+
Conflict findings: 1
|
|
115
|
+
Zombie candidates: 5
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The demo is intentionally small:
|
|
119
|
+
|
|
120
|
+
- `dangerous-deploy` triggers `rm -rf`, `.env`, and `curl` risk findings.
|
|
121
|
+
- `npm-installer` and `pnpm-installer` trigger package-manager conflict, same-source duplicate, and version drift findings.
|
|
122
|
+
- `markdown-reporter-a` and `markdown-reporter-b` trigger an exact duplicate finding.
|
|
123
|
+
- `Dangerous Deploy` has a short description, triggering description quality findings.
|
|
124
|
+
|
|
125
|
+
Generate targeted risk repair prompts:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm run start -- fix --type risk --lang en
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The real CLI output includes your local path. The example below is sanitized for documentation:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
Skill: dangerous-deploy (./examples/readme-demo-skills/dangerous-deploy)
|
|
135
|
+
- [critical] Possible destructive filesystem operation
|
|
136
|
+
- [high] Possible credential access
|
|
137
|
+
- [high] Possible remote download or installer execution
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## HTML Reports And Language Switching
|
|
141
|
+
|
|
142
|
+
Generate a Chinese HTML report:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm run start -- report --format html --lang zh --output ./reports/skill-doctor.zh.html
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Generate an English HTML report:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm run start -- report --format html --lang en --output ./reports/skill-doctor.en.html
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
HTML reports include:
|
|
155
|
+
|
|
156
|
+
- Scan overview and severity distribution
|
|
157
|
+
- Skill list and source details
|
|
158
|
+
- Findings grouped by type
|
|
159
|
+
- Remediation path
|
|
160
|
+
- Copyable agent prompts
|
|
161
|
+
- In-report language toggle
|
|
162
|
+
|
|
163
|
+
## Common Commands
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Scan and write the local diagnostic database
|
|
167
|
+
agent-skill-doctor scan --lang en
|
|
168
|
+
|
|
169
|
+
# Full diagnosis
|
|
170
|
+
agent-skill-doctor diagnose --lang en
|
|
171
|
+
agent-skill-doctor diagnose --json
|
|
172
|
+
|
|
173
|
+
# Inspect one finding type
|
|
174
|
+
agent-skill-doctor risks --json
|
|
175
|
+
agent-skill-doctor conflicts --json
|
|
176
|
+
agent-skill-doctor duplicates --json
|
|
177
|
+
agent-skill-doctor zombies --json
|
|
178
|
+
|
|
179
|
+
# Generate reports
|
|
180
|
+
agent-skill-doctor report --format md --lang en
|
|
181
|
+
agent-skill-doctor report --format json --output ./skill-report.json
|
|
182
|
+
agent-skill-doctor report --format html --lang en
|
|
183
|
+
|
|
184
|
+
# Generate repair prompts
|
|
185
|
+
agent-skill-doctor fix --lang en
|
|
186
|
+
agent-skill-doctor fix --type duplicate --lang en
|
|
187
|
+
agent-skill-doctor fix --type version_drift --lang en
|
|
188
|
+
|
|
189
|
+
# Fail CI by severity
|
|
190
|
+
agent-skill-doctor diagnose --ci --fail-on high
|
|
191
|
+
|
|
192
|
+
# Generate an optimization plan and dry-run it
|
|
193
|
+
agent-skill-doctor plan --safe --json --output ./plan.json
|
|
194
|
+
agent-skill-doctor apply ./plan.json --dry-run
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Data Directory
|
|
198
|
+
|
|
199
|
+
Default location:
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
~/.agent-skill-doctor/
|
|
203
|
+
doctor.db
|
|
204
|
+
reports/
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Override it with an environment variable:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
AGENT_SKILL_DOCTOR_HOME=./.doctor-data agent-skill-doctor diagnose --lang en
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
PowerShell:
|
|
214
|
+
|
|
215
|
+
```powershell
|
|
216
|
+
$env:AGENT_SKILL_DOCTOR_HOME = ".\.doctor-data"
|
|
217
|
+
agent-skill-doctor diagnose --lang en
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Custom Risk Rules
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
agent-skill-doctor diagnose --rules ./rules/default --lang en
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
Rules are JSON files. See `rules/default/`.
|
|
227
|
+
|
|
228
|
+
## Node.js Library Usage
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
const {
|
|
232
|
+
detectDuplicateGroups,
|
|
233
|
+
detectVersionDrift,
|
|
234
|
+
detectConflicts,
|
|
235
|
+
detectZombies,
|
|
236
|
+
scanSkillForRisks,
|
|
237
|
+
loadJsonRules,
|
|
238
|
+
DEFAULT_CONFLICT_RULES
|
|
239
|
+
} = require('agent-skill-doctor');
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Safety Boundaries
|
|
243
|
+
|
|
244
|
+
- Does not write to `skills-manager.db`.
|
|
245
|
+
- Does not delete, move, or overwrite skill files by default.
|
|
246
|
+
- `apply` currently supports `--dry-run` only.
|
|
247
|
+
- Risk findings are not always bugs; they usually mean a skill needs elevated capability and should be explicitly reviewed.
|
|
248
|
+
|
|
249
|
+
## Troubleshooting
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Node version
|
|
253
|
+
node --version
|
|
254
|
+
|
|
255
|
+
# No global install permission
|
|
256
|
+
npx agent-skill-doctor diagnose --lang en
|
|
257
|
+
|
|
258
|
+
# Rebuild the diagnostic database
|
|
259
|
+
rm ~/.agent-skill-doctor/doctor.db
|
|
260
|
+
agent-skill-doctor diagnose --lang en
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
PowerShell:
|
|
264
|
+
|
|
265
|
+
```powershell
|
|
266
|
+
Remove-Item "$env:USERPROFILE\.agent-skill-doctor\doctor.db" -Force
|
|
267
|
+
agent-skill-doctor diagnose --lang en
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## Links
|
|
271
|
+
|
|
272
|
+
- [GitHub](https://github.com/sljdxde/agent-skill-doctor)
|
|
273
|
+
- [npm](https://www.npmjs.com/package/agent-skill-doctor)
|
|
274
|
+
- [Changelog](./CHANGELOG.md)
|
|
275
|
+
- [License](./LICENSE)
|
package/README.md
ADDED
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Agent Skill Doctor
|
|
4
|
+
|
|
5
|
+
AI Agent Skills 诊断与治理工具,适用于 Claude Code、Codex、Cursor、OpenCode 等本地 Agent Skill 目录。
|
|
6
|
+
|
|
7
|
+
[](./LICENSE)
|
|
8
|
+
[](https://www.npmjs.com/package/agent-skill-doctor)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](#安装)
|
|
11
|
+
|
|
12
|
+
中文 · [English](./README.en.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
Agent Skill Doctor 用来帮你检查本地 AI Agent Skills 是否健康:有没有重复安装、版本漂移、互相冲突、危险指令、僵尸 Skill、描述不清等问题。它不会直接删除或覆盖你的 Skill 文件;默认只诊断、出报告、给 Agent 修复提示词。
|
|
19
|
+
|
|
20
|
+
## 它能诊断什么
|
|
21
|
+
|
|
22
|
+
- `risk`:危险能力提示,例如 `rm -rf`、读取 `.env`、`curl/wget`、`powershell`、`child_process`。
|
|
23
|
+
- `conflict`:Skill 之间的指令冲突,例如一个要求 `npm install`,另一个要求 `pnpm install`。
|
|
24
|
+
- `duplicate`:重复 Skill,包含完全重复、同源重复、同名不同内容。
|
|
25
|
+
- `version_drift`:同一个 Skill 在多个位置存在不同版本、不同 ref 或不同内容。
|
|
26
|
+
- `zombie`:疑似长期不用或无人维护的 Skill。
|
|
27
|
+
- `description_quality`:缺少触发条件、输入输出、风险说明,或者描述过短。
|
|
28
|
+
- `scan_warning`:目录结构问题,例如缺少 `SKILL.md` 或 frontmatter 格式异常。
|
|
29
|
+
|
|
30
|
+
## 评分和判定规则
|
|
31
|
+
|
|
32
|
+
- 风险等级来自规则文件:破坏性文件操作通常是 `critical`,凭据访问和远程下载通常是 `high`,shell 执行通常是 `medium`。
|
|
33
|
+
- 重复检测有三个策略:完全相同内容 `confidence=1.0`,同一来源和 slug `confidence=0.95`,同名但内容不同 `confidence=0.7`。
|
|
34
|
+
- 僵尸评分范围是 `0.0 - 1.0`,分数越高越可疑:
|
|
35
|
+
- 未出现在 preset:`+0.25`
|
|
36
|
+
- 未安装到任何 agent:`+0.20`
|
|
37
|
+
- 未安装到任何项目:`+0.20`
|
|
38
|
+
- 近期未修改:`+0.15`
|
|
39
|
+
- 无活动记录:`+0.15`
|
|
40
|
+
- 描述质量过低:`+0.05`
|
|
41
|
+
- 僵尸保护规则:`pinned/keep/core/system` 标签直接归零;官方来源归零;插件来源分数乘 `0.5`;第三方插件来源分数乘 `0.75`。
|
|
42
|
+
- 僵尸阈值:`>=0.8` 是强疑似僵尸,`>=0.6` 是疑似僵尸,`>=0.4` 是低活跃。
|
|
43
|
+
- 描述质量从 60 分起算;描述过短、没有触发条件、没有输入输出、风险未说明都会扣分并生成提示。
|
|
44
|
+
|
|
45
|
+
## 安装
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g agent-skill-doctor
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
不想全局安装也可以直接用:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx agent-skill-doctor help
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
要求 Node.js `>= 22.5.0`,因为工具使用 `node:sqlite`。
|
|
58
|
+
|
|
59
|
+
## 快速开始:让 Agent 使用它
|
|
60
|
+
|
|
61
|
+
推荐把 Agent Skill Doctor 当成 Agent 的诊断工具,而不是只当作人手动运行的 CLI。直接把下面这段发给 Claude Code、Codex、Cursor Agent 或其他本地 Agent:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
请使用 agent-skill-doctor 诊断我的本地 Agent Skills:
|
|
65
|
+
|
|
66
|
+
1. 运行:npx agent-skill-doctor diagnose --lang zh
|
|
67
|
+
2. 生成 HTML 报告:npx agent-skill-doctor report --format html --lang zh
|
|
68
|
+
3. 阅读报告中的冲突、重复、版本漂移、僵尸和风险项。
|
|
69
|
+
4. 先不要删除文件。请先输出修复计划,并说明每一步会改哪些 Skill。
|
|
70
|
+
5. 对 risk / duplicate / version_drift / zombie / description_quality 分别给出建议。
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Agent 可以继续用 `fix` 生成更具体的修复提示词:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx agent-skill-doctor fix --lang zh
|
|
77
|
+
npx agent-skill-doctor fix --type risk --severity high --lang zh
|
|
78
|
+
npx agent-skill-doctor fix --type zombie --lang zh
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
默认扫描范围包含常见 Agent Skill 目录:
|
|
82
|
+
|
|
83
|
+
```text
|
|
84
|
+
~/.agent/skills
|
|
85
|
+
~/.agents/skills
|
|
86
|
+
~/.agents/skills-core
|
|
87
|
+
~/.codex/skills
|
|
88
|
+
~/.claude/skills
|
|
89
|
+
~/.cursor/skills
|
|
90
|
+
~/.opencode/skills
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
如需扫描特定目录:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx agent-skill-doctor diagnose --root ./my-skills --lang zh
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## 本地可复现案例
|
|
100
|
+
|
|
101
|
+
仓库内带了一个脱敏演示目录:`examples/readme-demo-skills`。它包含 5 个小 Skill,用来触发风险、冲突、重复、版本漂移、僵尸和描述质量问题。
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm install
|
|
105
|
+
npm run start -- diagnose --root ./examples/readme-demo-skills --rebuild-index --lang zh
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
实际输出示例:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
技能数: 5
|
|
112
|
+
发现数: 15
|
|
113
|
+
风险发现: 3
|
|
114
|
+
冲突发现: 1
|
|
115
|
+
僵尸技能: 5
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
其中:
|
|
119
|
+
|
|
120
|
+
- `dangerous-deploy` 会触发 `rm -rf`、`.env`、`curl` 三类风险。
|
|
121
|
+
- `npm-installer` 和 `pnpm-installer` 会触发包管理器冲突、同源重复和版本漂移。
|
|
122
|
+
- `markdown-reporter-a` 和 `markdown-reporter-b` 会触发完全重复。
|
|
123
|
+
- `Dangerous Deploy` 的描述过短,会触发描述质量问题。
|
|
124
|
+
|
|
125
|
+
生成针对 Agent 的风险修复提示词:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm run start -- fix --type risk --lang zh
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
CLI 实际输出会显示你的本机路径;下面是 README 中脱敏后的展示格式:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
技能: dangerous-deploy (./examples/readme-demo-skills/dangerous-deploy)
|
|
135
|
+
- [critical] Possible destructive filesystem operation
|
|
136
|
+
- [high] Possible credential access
|
|
137
|
+
- [high] Possible remote download or installer execution
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## HTML 报告和语言切换
|
|
141
|
+
|
|
142
|
+
生成中文 HTML:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
npm run start -- report --format html --lang zh --output ./reports/skill-doctor.zh.html
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
生成英文 HTML:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
npm run start -- report --format html --lang en --output ./reports/skill-doctor.en.html
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
HTML 报告包含:
|
|
155
|
+
|
|
156
|
+
- 扫描概览和严重程度分布
|
|
157
|
+
- Skill 列表和来源信息
|
|
158
|
+
- 按类型分组的问题详情
|
|
159
|
+
- 修复路径
|
|
160
|
+
- 可复制的 Agent Prompt
|
|
161
|
+
- 报告内语言切换按钮
|
|
162
|
+
|
|
163
|
+
## 常用命令
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# 扫描并写入本地诊断数据库
|
|
167
|
+
agent-skill-doctor scan --lang zh
|
|
168
|
+
|
|
169
|
+
# 完整诊断
|
|
170
|
+
agent-skill-doctor diagnose --lang zh
|
|
171
|
+
agent-skill-doctor diagnose --json
|
|
172
|
+
|
|
173
|
+
# 只看某类问题
|
|
174
|
+
agent-skill-doctor risks --json
|
|
175
|
+
agent-skill-doctor conflicts --json
|
|
176
|
+
agent-skill-doctor duplicates --json
|
|
177
|
+
agent-skill-doctor zombies --json
|
|
178
|
+
|
|
179
|
+
# 生成报告
|
|
180
|
+
agent-skill-doctor report --format md --lang zh
|
|
181
|
+
agent-skill-doctor report --format json --output ./skill-report.json
|
|
182
|
+
agent-skill-doctor report --format html --lang zh
|
|
183
|
+
|
|
184
|
+
# 生成修复提示词
|
|
185
|
+
agent-skill-doctor fix --lang zh
|
|
186
|
+
agent-skill-doctor fix --type duplicate --lang zh
|
|
187
|
+
agent-skill-doctor fix --type version_drift --lang zh
|
|
188
|
+
|
|
189
|
+
# CI 中按严重程度失败
|
|
190
|
+
agent-skill-doctor diagnose --ci --fail-on high
|
|
191
|
+
|
|
192
|
+
# 生成优化计划并 dry-run
|
|
193
|
+
agent-skill-doctor plan --safe --json --output ./plan.json
|
|
194
|
+
agent-skill-doctor apply ./plan.json --dry-run
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## 数据目录
|
|
198
|
+
|
|
199
|
+
默认写入:
|
|
200
|
+
|
|
201
|
+
```text
|
|
202
|
+
~/.agent-skill-doctor/
|
|
203
|
+
doctor.db
|
|
204
|
+
reports/
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
可以用环境变量改到项目内或临时目录:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
AGENT_SKILL_DOCTOR_HOME=./.doctor-data agent-skill-doctor diagnose --lang zh
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
PowerShell:
|
|
214
|
+
|
|
215
|
+
```powershell
|
|
216
|
+
$env:AGENT_SKILL_DOCTOR_HOME = ".\.doctor-data"
|
|
217
|
+
agent-skill-doctor diagnose --lang zh
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## 自定义风险规则
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
agent-skill-doctor diagnose --rules ./rules/default --lang zh
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
规则文件是 JSON,参考 `rules/default/`。
|
|
227
|
+
|
|
228
|
+
## 作为 Node.js 库使用
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
const {
|
|
232
|
+
detectDuplicateGroups,
|
|
233
|
+
detectVersionDrift,
|
|
234
|
+
detectConflicts,
|
|
235
|
+
detectZombies,
|
|
236
|
+
scanSkillForRisks,
|
|
237
|
+
loadJsonRules,
|
|
238
|
+
DEFAULT_CONFLICT_RULES
|
|
239
|
+
} = require('agent-skill-doctor');
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## 安全边界
|
|
243
|
+
|
|
244
|
+
- 不写入 `skills-manager.db`。
|
|
245
|
+
- 不默认删除、移动或覆盖 Skill 文件。
|
|
246
|
+
- `apply` 当前只支持 `--dry-run`。
|
|
247
|
+
- 风险项不一定是 bug;它们通常表示该 Skill 需要高权限,应该由人或 Agent 明确确认。
|
|
248
|
+
|
|
249
|
+
## 故障排除
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Node 版本
|
|
253
|
+
node --version
|
|
254
|
+
|
|
255
|
+
# 无全局安装权限时
|
|
256
|
+
npx agent-skill-doctor diagnose --lang zh
|
|
257
|
+
|
|
258
|
+
# 清理诊断数据库后重扫
|
|
259
|
+
rm ~/.agent-skill-doctor/doctor.db
|
|
260
|
+
agent-skill-doctor diagnose --lang zh
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
PowerShell 删除数据库:
|
|
264
|
+
|
|
265
|
+
```powershell
|
|
266
|
+
Remove-Item "$env:USERPROFILE\.agent-skill-doctor\doctor.db" -Force
|
|
267
|
+
agent-skill-doctor diagnose --lang zh
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## 链接
|
|
271
|
+
|
|
272
|
+
- [GitHub](https://github.com/sljdxde/agent-skill-doctor)
|
|
273
|
+
- [npm](https://www.npmjs.com/package/agent-skill-doctor)
|
|
274
|
+
- [更新日志](./CHANGELOG.md)
|
|
275
|
+
- [许可证](./LICENSE)
|