Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ Exit codes:
| `name-drift` | warn | Frontmatter `name:` doesn't match the filename or directory |
| `description-collision` | warn | Two skills' descriptions have Jaccard ≥ 0.6 |
| `tools-overloaded` | warn | `tools:` lists 10 or more entries; narrow the list to what this skill actually needs |
| `duplicate-name` | warn | Two or more skills share the same `name:` value; resolution is ambiguous |
| `parse` | error | The file doesn't have valid frontmatter / YAML |

The MCP and built-in tool checks read `~/.claude/settings.json` and
Expand Down
28 changes: 28 additions & 0 deletions src/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function runChecks(
}

diagnostics.push(...checkCollisions(validated));
diagnostics.push(...checkDuplicateNames(validated));
return diagnostics;
}

Expand Down Expand Up @@ -206,3 +207,30 @@ function checkCollisions(skills: ValidatedSkill[]): Diagnostic[] {
}
return out;
}

function checkDuplicateNames(skills: ValidatedSkill[]): Diagnostic[] {
const byName = new Map<string, ValidatedSkill[]>();
for (const s of skills) {
const key = s.name.toLowerCase();
const group = byName.get(key) ?? [];
group.push(s);
byName.set(key, group);
}
const out: Diagnostic[] = [];
for (const group of byName.values()) {
if (group.length < 2) continue;
for (const s of group) {
const others = group
.filter((g) => g.file !== s.file)
.map((g) => `'${g.file}'`)
.join(", ");
out.push({
severity: "warn",
rule: "duplicate-name",
message: `skill name '${s.name}' is also declared in ${others}`,
file: s.file,
});
}
}
return out;
}
30 changes: 30 additions & 0 deletions test/checks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,34 @@ describe("runChecks", () => {
const ds = runChecks([s], config);
expect(ds.find((d) => d.rule === "empty-body")).toBeUndefined();
});

it("flags duplicate skill names", () => {
const a = mkSkill("/test/a/deploy.md", { name: "deploy", description: "deploy the app" });
const b = mkSkill("/test/b/deploy.md", { name: "deploy", description: "deploy to staging" });
const ds = runChecks([a, b], config);
expect(ds.filter((d) => d.rule === "duplicate-name").length).toBe(2);
});

it("does not flag duplicate-name for unique names", () => {
const a = mkSkill("/test/a/deploy.md", { name: "deploy", description: "deploy the app" });
const b = mkSkill("/test/b/release.md", { name: "release", description: "cut a release" });
const ds = runChecks([a, b], config);
expect(ds.find((d) => d.rule === "duplicate-name")).toBeUndefined();
});

it("flags all skills in a three-way duplicate-name group", () => {
const a = mkSkill("/test/a/foo.md", { name: "foo", description: "do foo one way" });
const b = mkSkill("/test/b/foo.md", { name: "foo", description: "do foo another way" });
const c = mkSkill("/test/c/foo.md", { name: "foo", description: "do foo a third way" });
const ds = runChecks([a, b, c], config);
expect(ds.filter((d) => d.rule === "duplicate-name").length).toBe(3);
});

it("duplicate-name message names the conflicting file", () => {
const a = mkSkill("/test/a/deploy.md", { name: "deploy", description: "deploy the app" });
const b = mkSkill("/test/b/deploy.md", { name: "deploy", description: "deploy to staging" });
const ds = runChecks([a, b], config);
const diagA = ds.find((d) => d.rule === "duplicate-name" && d.file === "/test/a/deploy.md");
expect(diagA?.message).toContain("/test/b/deploy.md");
});
});