@virling/ccdoctor 0.1.0 → 0.3.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 +17 -1
- package/README.md +20 -2
- package/bin/ccdoctor.js +10 -1
- package/package.json +7 -6
- package/src/checks.js +33 -15
- package/src/config.js +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,20 @@ All notable changes to this project are documented here. The format follows [Kee
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.3.0] - 2026-11-27
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Claude Code plugin: `/plugin install ccdoctor@virling` runs the checks at every session start and warns only when something is broken.
|
|
12
|
+
- `ccdoctor hook`: the SessionStart hook mode behind the plugin.
|
|
13
|
+
|
|
14
|
+
## [0.2.0] - 2026-11-27
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- MCP servers shipped by enabled plugins are checked and probed.
|
|
19
|
+
- Run from any folder inside a project: ccdoctor walks up to the project folder Claude Code keys its config by.
|
|
20
|
+
|
|
7
21
|
## [0.1.0] - 2026-11-27
|
|
8
22
|
|
|
9
23
|
### Added
|
|
@@ -13,5 +27,7 @@ All notable changes to this project are documented here. The format follows [Kee
|
|
|
13
27
|
- Warns when an MCP server is registered but the hooks it ships are missing.
|
|
14
28
|
- `--json` output; exit code 1 when any check fails.
|
|
15
29
|
|
|
16
|
-
[Unreleased]: https://github.com/virling/ccdoctor/compare/v0.
|
|
30
|
+
[Unreleased]: https://github.com/virling/ccdoctor/compare/v0.3.0...HEAD
|
|
31
|
+
[0.3.0]: https://github.com/virling/ccdoctor/compare/v0.2.0...v0.3.0
|
|
32
|
+
[0.2.0]: https://github.com/virling/ccdoctor/compare/v0.1.0...v0.2.0
|
|
17
33
|
[0.1.0]: https://github.com/virling/ccdoctor/releases/tag/v0.1.0
|
package/README.md
CHANGED
|
@@ -10,12 +10,23 @@ Typical catch: an MCP server is registered but the hooks that make it useful are
|
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
|
-
Run it from
|
|
13
|
+
Run it from your project, or any folder inside it. ccdoctor walks up to the project folder Claude Code uses:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
npx @virling/ccdoctor
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
+
### Check every session automatically
|
|
20
|
+
|
|
21
|
+
Install it as a Claude Code plugin and it runs at the start of every session. It stays silent when everything is fine, and when something is broken you see a one-line warning and Claude is told the details:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
/plugin marketplace add virling/agentmem
|
|
25
|
+
/plugin install ccdoctor@virling
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The session-start check skips `--probe`, so it only reads files and finishes in well under a second.
|
|
29
|
+
|
|
19
30
|
## Example
|
|
20
31
|
|
|
21
32
|
```
|
|
@@ -46,7 +57,7 @@ Exit code is 1 when any check fails.
|
|
|
46
57
|
|
|
47
58
|
- **Settings.** `~/.claude/settings.json` (or `$CLAUDE_CONFIG_DIR/settings.json`), and `.claude/settings.json` and `.claude/settings.local.json` in the current folder. Invalid JSON fails.
|
|
48
59
|
- **Hooks.** Every `command` hook in those files. The executable must exist on `PATH` or as a file (`~` and `$CLAUDE_PROJECT_DIR` are expanded). For `node`, `bash`, `python3` and similar, the script path must exist too. A script run directly without the executable bit warns. Only the first command of a shell line is checked.
|
|
49
|
-
- **MCP servers.** User scope (`mcpServers` in `~/.claude.json`), local scope (`projects[<this folder>].mcpServers` in `~/.claude.json`)
|
|
60
|
+
- **MCP servers.** User scope (`mcpServers` in `~/.claude.json`), local scope (`projects[<this folder>].mcpServers` in `~/.claude.json`) project scope (`.mcp.json`), and servers shipped by enabled plugins (their `.mcp.json` or `mcpServers` in `.claude-plugin/plugin.json`, with `${CLAUDE_PLUGIN_ROOT}` expanded). For stdio servers the command must resolve. A name defined in more than one scope warns. `env` values, headers and URLs are never printed.
|
|
50
61
|
- **Plugins.** Each plugin set to `true` in `enabledPlugins` must have a folder under `~/.claude/plugins/cache/<marketplace>/<plugin>/`. Missing ones warn.
|
|
51
62
|
- **Wiring.** A stdio MCP server named `agentmem`, or whose package ships `hooks/hooks.json`, warns when no hook command (in settings or enabled plugins) mentions its name or package folder.
|
|
52
63
|
- **Probe** (`--probe`). Starts each stdio server, sends `initialize`, `notifications/initialized` and `tools/list`, reports the tool count or the error, then kills it. http and sse servers are not probed.
|
|
@@ -63,6 +74,13 @@ ccdoctor --help
|
|
|
63
74
|
|
|
64
75
|
ccdoctor never writes to your configuration.
|
|
65
76
|
|
|
77
|
+
## More tools from Virling
|
|
78
|
+
|
|
79
|
+
- [agentmem](https://github.com/virling/agentmem): project memory for AI coding agents, shared across Claude Code, Cursor, Codex and other MCP clients.
|
|
80
|
+
- [ciwhy](https://github.com/virling/ciwhy): finds the real error in a failed GitHub Actions run and tells you if it is flaky.
|
|
81
|
+
- [npmship](https://github.com/virling/npmship): releases an npm package and verifies it landed on npm, in CI and on GitHub.
|
|
82
|
+
- [subagents](https://github.com/virling/subagents): reviews what Claude Code subagents did in a session and flags repeated or wasted work.
|
|
83
|
+
|
|
66
84
|
## License
|
|
67
85
|
|
|
68
86
|
[PolyForm Noncommercial 1.0.0](LICENSE)
|
package/bin/ccdoctor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { doctor, format, summary } from "../src/checks.js";
|
|
2
|
+
import { doctor, format, hookOutput, summary } from "../src/checks.js";
|
|
3
3
|
import { paths } from "../src/config.js";
|
|
4
4
|
|
|
5
5
|
const HELP = `ccdoctor: check a Claude Code setup for broken or unwired pieces
|
|
@@ -8,6 +8,7 @@ const HELP = `ccdoctor: check a Claude Code setup for broken or unwired pieces
|
|
|
8
8
|
ccdoctor --probe also start each stdio MCP server and list its tools
|
|
9
9
|
ccdoctor --timeout <s> probe timeout in seconds (default 10)
|
|
10
10
|
ccdoctor --json print results as JSON
|
|
11
|
+
ccdoctor hook SessionStart hook mode: prints a warning only when something is wrong
|
|
11
12
|
ccdoctor --help
|
|
12
13
|
|
|
13
14
|
Reads ~/.claude (or CLAUDE_CONFIG_DIR), ~/.claude.json and the current folder's
|
|
@@ -19,6 +20,14 @@ if (flags.has("--help") || flags.has("-h")) {
|
|
|
19
20
|
console.log(HELP);
|
|
20
21
|
process.exit(0);
|
|
21
22
|
}
|
|
23
|
+
if (args[0] === "hook") {
|
|
24
|
+
let raw = "";
|
|
25
|
+
for await (const chunk of process.stdin) raw += chunk;
|
|
26
|
+
const cwd = (raw.trim() && JSON.parse(raw).cwd) || process.cwd();
|
|
27
|
+
const out = hookOutput(await doctor(paths({ cwd })));
|
|
28
|
+
if (out) process.stdout.write(JSON.stringify(out));
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
22
31
|
const ti = args.indexOf("--timeout");
|
|
23
32
|
const timeout = ti >= 0 ? Number(args[ti + 1]) * 1000 : 10000;
|
|
24
33
|
const unknown = args.filter((a, i) => !["--probe", "--json", "--timeout"].includes(a) && !(ti >= 0 && i === ti + 1));
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@virling/ccdoctor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Check a Claude Code setup for broken hooks, MCP servers and plugins",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ccdoctor": "bin/ccdoctor.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "node --test"
|
|
10
|
+
"test": "node --test",
|
|
11
|
+
"version": "node scripts/sync-version.js && git add .claude-plugin"
|
|
11
12
|
},
|
|
12
13
|
"engines": {
|
|
13
14
|
"node": ">=20"
|
|
@@ -21,11 +22,11 @@
|
|
|
21
22
|
"diagnostics"
|
|
22
23
|
],
|
|
23
24
|
"files": [
|
|
24
|
-
"
|
|
25
|
-
"src",
|
|
26
|
-
"README.md",
|
|
25
|
+
"CHANGELOG.md",
|
|
27
26
|
"LICENSE",
|
|
28
|
-
"
|
|
27
|
+
"README.md",
|
|
28
|
+
"bin",
|
|
29
|
+
"src"
|
|
29
30
|
],
|
|
30
31
|
"publishConfig": {
|
|
31
32
|
"access": "public"
|
package/src/checks.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { checkCommand, expand, isFile, tokenize } from "./command.js";
|
|
4
|
-
import { pluginDir, readJson, settingsFiles } from "./config.js";
|
|
4
|
+
import { pluginDir, pluginServers, projectRoot, readJson, settingsFiles } from "./config.js";
|
|
5
5
|
import { probe } from "./probe.js";
|
|
6
6
|
|
|
7
7
|
function packageRoot(file) {
|
|
@@ -26,6 +26,10 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
|
|
|
26
26
|
const results = [];
|
|
27
27
|
const short = (s) => s.split(p.home).join("~");
|
|
28
28
|
const add = (section, level, name, detail = "") => results.push({ section, level, name: short(name), detail: short(detail) });
|
|
29
|
+
const claudeJson = readJson(p.claudeJson);
|
|
30
|
+
const root = projectRoot(p, Object.keys(claudeJson.data?.projects || {}));
|
|
31
|
+
if (root !== p.cwd) add("Settings", "info", `project root ${root}`);
|
|
32
|
+
p = { ...p, cwd: root };
|
|
29
33
|
const ctx = { cwd: p.cwd, home: p.home, PATH: p.PATH, vars: { ...p.env, CLAUDE_PROJECT_DIR: p.cwd } };
|
|
30
34
|
|
|
31
35
|
const settings = settingsFiles(p).map((f) => ({ ...f, ...readJson(f.file) })).filter((f) => !f.missing);
|
|
@@ -43,15 +47,18 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
|
|
|
43
47
|
}
|
|
44
48
|
if (!commands.length) add("Hooks", "info", "no hooks configured");
|
|
45
49
|
|
|
50
|
+
const enabled = Object.assign({}, ...valid.map((s) => s.data.enabledPlugins || {}));
|
|
51
|
+
const plugins = Object.keys(enabled).filter((k) => enabled[k] === true).map((key) => ({ key, dir: pluginDir(p.configDir, key) }));
|
|
52
|
+
|
|
46
53
|
const servers = [];
|
|
47
|
-
const collect = (map, scope) => Object.entries(map || {}).forEach(([name, config]) => servers.push({ name, scope, config }));
|
|
48
|
-
const claudeJson = readJson(p.claudeJson);
|
|
54
|
+
const collect = (map, scope, vars = {}) => Object.entries(map || {}).forEach(([name, config]) => servers.push({ name, scope, config, vars }));
|
|
49
55
|
const mcpJson = readJson(path.join(p.cwd, ".mcp.json"));
|
|
50
56
|
if (claudeJson.error) add("MCP servers", "fail", p.claudeJson, `invalid JSON: ${claudeJson.error}`);
|
|
51
57
|
if (mcpJson.error) add("MCP servers", "fail", path.join(p.cwd, ".mcp.json"), `invalid JSON: ${mcpJson.error}`);
|
|
52
58
|
collect(claudeJson.data?.mcpServers, "user");
|
|
53
59
|
collect(claudeJson.data?.projects?.[p.cwd]?.mcpServers, "local");
|
|
54
60
|
collect(mcpJson.data?.mcpServers, "project");
|
|
61
|
+
for (const pl of plugins.filter((pl) => pl.dir)) collect(pluginServers(pl.dir), `plugin ${pl.key}`, { CLAUDE_PLUGIN_ROOT: pl.dir });
|
|
55
62
|
if (!servers.length) add("MCP servers", "info", "no MCP servers registered");
|
|
56
63
|
|
|
57
64
|
const stdio = [];
|
|
@@ -61,12 +68,12 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
|
|
|
61
68
|
add("MCP servers", "info", `${s.name} (${s.scope}, ${type})`, "remote, not checked");
|
|
62
69
|
continue;
|
|
63
70
|
}
|
|
64
|
-
const r = checkCommand([s.config.command ?? "", ...(s.config.args || [])], ctx);
|
|
71
|
+
const r = checkCommand([s.config.command ?? "", ...(s.config.args || [])], { ...ctx, vars: { ...ctx.vars, ...s.vars } });
|
|
65
72
|
add("MCP servers", r.level, `${s.name} (${s.scope})`, r.detail);
|
|
66
73
|
stdio.push(Object.assign(s, { check: r }));
|
|
67
74
|
}
|
|
68
75
|
for (const name of new Set(servers.map((s) => s.name))) {
|
|
69
|
-
const list = servers.filter((s) => s.name === name);
|
|
76
|
+
const list = servers.filter((s) => s.name === name && !s.scope.startsWith("plugin"));
|
|
70
77
|
if (list.length > 1) add("MCP servers", "warn", name, `defined more than once: ${list.map((s) => s.scope).join(", ")}`);
|
|
71
78
|
}
|
|
72
79
|
|
|
@@ -75,10 +82,11 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
|
|
|
75
82
|
const runnable = stdio.filter((s) => s.check.level !== "fail");
|
|
76
83
|
const probed = await Promise.all(
|
|
77
84
|
runnable.map((s) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
85
|
+
const vars = { ...p.env, ...s.vars };
|
|
86
|
+
const env = { ...vars };
|
|
87
|
+
for (const [k, v] of Object.entries(s.config.env || {})) env[k] = expand(String(v), vars, p.home);
|
|
88
|
+
const args = (s.config.args || []).map((a) => expand(a, vars, p.home));
|
|
89
|
+
return probe(expand(s.config.command, vars, p.home), args, { cwd: p.cwd, env, timeout });
|
|
82
90
|
})
|
|
83
91
|
);
|
|
84
92
|
runnable.forEach((s, i) => {
|
|
@@ -88,16 +96,13 @@ export async function doctor(p, { probe: doProbe = false, timeout = 10000 } = {}
|
|
|
88
96
|
for (const s of stdio.filter((s) => !runnable.includes(s))) add("Probe", "info", s.name, "not probed (command not found)");
|
|
89
97
|
}
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
if (!keys.length) add("Plugins", "info", "no plugins enabled");
|
|
94
|
-
for (const key of keys) {
|
|
95
|
-
const dir = pluginDir(p.configDir, key);
|
|
99
|
+
if (!plugins.length) add("Plugins", "info", "no plugins enabled");
|
|
100
|
+
for (const { key, dir } of plugins) {
|
|
96
101
|
add("Plugins", dir ? "ok" : "warn", key, dir ? "" : "enabled but not found in plugins/cache");
|
|
97
102
|
if (dir) commands.push(...hookCommands(readJson(path.join(dir, "hooks", "hooks.json")).data?.hooks).map((h) => h.command));
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
for (const s of stdio) {
|
|
105
|
+
for (const s of stdio.filter((s) => !s.scope.startsWith("plugin"))) {
|
|
101
106
|
const root = packageRoot(s.check.files.at(-1));
|
|
102
107
|
const shipsHooks = root && isFile(path.join(root, "hooks", "hooks.json"));
|
|
103
108
|
if (s.name !== "agentmem" && !shipsHooks) continue;
|
|
@@ -112,6 +117,19 @@ export function summary(results) {
|
|
|
112
117
|
return { ok: count("ok"), warn: count("warn"), fail: count("fail") };
|
|
113
118
|
}
|
|
114
119
|
|
|
120
|
+
export function hookOutput(results) {
|
|
121
|
+
const problems = results.filter((r) => r.level !== "ok" && r.level !== "info");
|
|
122
|
+
if (!problems.length) return null;
|
|
123
|
+
const list = problems.map((r) => `${r.level} ${r.section}: ${r.name}${r.detail ? `: ${r.detail}` : ""}`);
|
|
124
|
+
return {
|
|
125
|
+
systemMessage: `ccdoctor: ${problems.length} problem${problems.length === 1 ? "" : "s"} in your Claude Code setup. ${list[0]}${problems.length > 1 ? ` (and ${problems.length - 1} more)` : ""}. Run npx @virling/ccdoctor for details.`,
|
|
126
|
+
hookSpecificOutput: {
|
|
127
|
+
hookEventName: "SessionStart",
|
|
128
|
+
additionalContext: `ccdoctor found problems in this Claude Code setup. Tell the user about them before starting other work:\n${list.join("\n")}`,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
115
133
|
export function format(results) {
|
|
116
134
|
const lines = [];
|
|
117
135
|
for (const section of new Set(results.map((r) => r.section))) {
|
package/src/config.js
CHANGED
|
@@ -26,6 +26,20 @@ export function settingsFiles(p) {
|
|
|
26
26
|
return files.filter((f, i) => files.findIndex((g) => g.file === f.file) === i);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// Claude Code keys project config by the folder it was started in, so walk up from a subfolder to find it.
|
|
30
|
+
export function projectRoot(p, known = []) {
|
|
31
|
+
for (let dir = p.cwd; dir !== path.dirname(dir) && dir !== p.home; dir = path.dirname(dir)) {
|
|
32
|
+
if (known.includes(dir) || fs.existsSync(path.join(dir, ".mcp.json")) || fs.existsSync(path.join(dir, ".claude"))) return dir;
|
|
33
|
+
}
|
|
34
|
+
return p.cwd;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function pluginServers(dir) {
|
|
38
|
+
const manifest = readJson(path.join(dir, ".claude-plugin", "plugin.json")).data?.mcpServers;
|
|
39
|
+
const fromManifest = typeof manifest === "string" ? readJson(path.join(dir, manifest)).data?.mcpServers : manifest;
|
|
40
|
+
return { ...readJson(path.join(dir, ".mcp.json")).data?.mcpServers, ...fromManifest };
|
|
41
|
+
}
|
|
42
|
+
|
|
29
43
|
export function pluginDir(configDir, key) {
|
|
30
44
|
const installed = readJson(path.join(configDir, "plugins", "installed_plugins.json")).data?.plugins?.[key]?.[0]?.installPath;
|
|
31
45
|
if (installed && fs.existsSync(installed)) return installed;
|