@adonis0123/skill-development 1.0.1
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/.claude-skill.json +47 -0
- package/README.md +79 -0
- package/SKILL.md +637 -0
- package/install-skill.js +315 -0
- package/package.json +34 -0
- package/references/skill-creator-original.md +209 -0
- package/uninstall-skill.js +191 -0
package/install-skill.js
ADDED
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
|
|
25
|
+
// shared/src/install-skill.ts
|
|
26
|
+
var import_fs2 = __toESM(require("fs"));
|
|
27
|
+
var import_path2 = __toESM(require("path"));
|
|
28
|
+
var import_os2 = __toESM(require("os"));
|
|
29
|
+
var import_child_process = require("child_process");
|
|
30
|
+
|
|
31
|
+
// shared/src/utils.ts
|
|
32
|
+
var import_fs = __toESM(require("fs"));
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
34
|
+
var import_os = __toESM(require("os"));
|
|
35
|
+
var CWD = process.env.INIT_CWD || process.cwd();
|
|
36
|
+
var DEFAULT_TARGET = {
|
|
37
|
+
name: "claude-code",
|
|
38
|
+
paths: {
|
|
39
|
+
global: ".claude/skills",
|
|
40
|
+
project: ".claude/skills"
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function getEnabledTargets(config) {
|
|
44
|
+
if (!config.targets) {
|
|
45
|
+
return [DEFAULT_TARGET];
|
|
46
|
+
}
|
|
47
|
+
return Object.entries(config.targets).filter(([_, target]) => target.enabled).map(([name, target]) => ({
|
|
48
|
+
name,
|
|
49
|
+
paths: target.paths
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
function extractSkillName(packageName) {
|
|
53
|
+
if (packageName.startsWith("@")) {
|
|
54
|
+
return packageName.split("/")[1] || packageName;
|
|
55
|
+
}
|
|
56
|
+
return packageName;
|
|
57
|
+
}
|
|
58
|
+
function detectInstallLocation(targetPaths, isGlobal) {
|
|
59
|
+
if (isGlobal) {
|
|
60
|
+
return {
|
|
61
|
+
type: "personal",
|
|
62
|
+
base: import_path.default.join(import_os.default.homedir(), targetPaths.global)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
let projectRoot = CWD;
|
|
66
|
+
while (projectRoot !== import_path.default.dirname(projectRoot)) {
|
|
67
|
+
const hasPackageJson = import_fs.default.existsSync(import_path.default.join(projectRoot, "package.json"));
|
|
68
|
+
const hasGit = import_fs.default.existsSync(import_path.default.join(projectRoot, ".git"));
|
|
69
|
+
const isInNodeModules = projectRoot.includes("/node_modules/") || import_path.default.basename(projectRoot) === "node_modules";
|
|
70
|
+
if ((hasPackageJson || hasGit) && !isInNodeModules) {
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
projectRoot = import_path.default.dirname(projectRoot);
|
|
74
|
+
}
|
|
75
|
+
const finalIsInNodeModules = projectRoot.includes("/node_modules/") || import_path.default.basename(projectRoot) === "node_modules";
|
|
76
|
+
if (finalIsInNodeModules) {
|
|
77
|
+
console.warn("\u26A0 Warning: Could not find project root directory, using current directory");
|
|
78
|
+
projectRoot = CWD;
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
type: "project",
|
|
82
|
+
base: import_path.default.join(projectRoot, targetPaths.project)
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function isGlobalInstall() {
|
|
86
|
+
return process.env.npm_config_global === "true";
|
|
87
|
+
}
|
|
88
|
+
function copyDir(src, dest) {
|
|
89
|
+
import_fs.default.mkdirSync(dest, { recursive: true });
|
|
90
|
+
const entries = import_fs.default.readdirSync(src, { withFileTypes: true });
|
|
91
|
+
for (const entry of entries) {
|
|
92
|
+
const srcPath = import_path.default.join(src, entry.name);
|
|
93
|
+
const destPath = import_path.default.join(dest, entry.name);
|
|
94
|
+
if (entry.isDirectory()) {
|
|
95
|
+
copyDir(srcPath, destPath);
|
|
96
|
+
} else {
|
|
97
|
+
import_fs.default.copyFileSync(srcPath, destPath);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function ensureDir(dir) {
|
|
102
|
+
if (!import_fs.default.existsSync(dir)) {
|
|
103
|
+
import_fs.default.mkdirSync(dir, { recursive: true });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function removeDir(dir) {
|
|
107
|
+
if (import_fs.default.existsSync(dir)) {
|
|
108
|
+
import_fs.default.rmSync(dir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function readSkillConfig(dir) {
|
|
112
|
+
const configPath = import_path.default.join(dir, ".claude-skill.json");
|
|
113
|
+
if (!import_fs.default.existsSync(configPath)) {
|
|
114
|
+
throw new Error(".claude-skill.json not found");
|
|
115
|
+
}
|
|
116
|
+
return JSON.parse(import_fs.default.readFileSync(configPath, "utf-8"));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// shared/src/install-skill.ts
|
|
120
|
+
function fetchFromRemote(tempDir, remoteSource) {
|
|
121
|
+
try {
|
|
122
|
+
console.log(` \u{1F310} Fetching latest from ${remoteSource}...`);
|
|
123
|
+
(0, import_child_process.execSync)(`npx degit ${remoteSource} "${tempDir}" --force`, {
|
|
124
|
+
stdio: "pipe",
|
|
125
|
+
timeout: 6e4
|
|
126
|
+
});
|
|
127
|
+
if (import_fs2.default.existsSync(import_path2.default.join(tempDir, "SKILL.md"))) {
|
|
128
|
+
console.log(" \u2713 Fetched latest version from remote");
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
console.warn(" \u26A0 Remote fetch succeeded but SKILL.md not found");
|
|
132
|
+
return false;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
135
|
+
console.warn(` \u26A0 Could not fetch from remote: ${message}`);
|
|
136
|
+
console.log(" \u2139 Using bundled version as fallback");
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function getSourceDir(config, packageDir) {
|
|
141
|
+
if (!config.remoteSource) {
|
|
142
|
+
return {
|
|
143
|
+
sourceDir: packageDir,
|
|
144
|
+
cleanup: () => {
|
|
145
|
+
},
|
|
146
|
+
isRemote: false
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const tempDir = import_path2.default.join(import_os2.default.tmpdir(), `skill-fetch-${Date.now()}`);
|
|
150
|
+
const remoteSuccess = fetchFromRemote(tempDir, config.remoteSource);
|
|
151
|
+
if (remoteSuccess) {
|
|
152
|
+
return {
|
|
153
|
+
sourceDir: tempDir,
|
|
154
|
+
cleanup: () => {
|
|
155
|
+
try {
|
|
156
|
+
import_fs2.default.rmSync(tempDir, { recursive: true, force: true });
|
|
157
|
+
} catch {
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
isRemote: true
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
import_fs2.default.rmSync(tempDir, { recursive: true, force: true });
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
sourceDir: packageDir,
|
|
169
|
+
cleanup: () => {
|
|
170
|
+
},
|
|
171
|
+
isRemote: false
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function updateManifest(skillsDir, config, targetName, isRemote) {
|
|
175
|
+
const manifestPath = import_path2.default.join(skillsDir, ".skills-manifest.json");
|
|
176
|
+
let manifest = { skills: {} };
|
|
177
|
+
if (import_fs2.default.existsSync(manifestPath)) {
|
|
178
|
+
try {
|
|
179
|
+
manifest = JSON.parse(import_fs2.default.readFileSync(manifestPath, "utf-8"));
|
|
180
|
+
} catch {
|
|
181
|
+
console.warn(" Warning: Could not parse existing manifest, creating new one");
|
|
182
|
+
manifest = { skills: {} };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const skillName = extractSkillName(config.name);
|
|
186
|
+
manifest.skills[config.name] = {
|
|
187
|
+
version: config.version,
|
|
188
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
189
|
+
package: config.package || config.name,
|
|
190
|
+
path: import_path2.default.join(skillsDir, skillName),
|
|
191
|
+
target: targetName,
|
|
192
|
+
...config.remoteSource && { source: config.remoteSource }
|
|
193
|
+
};
|
|
194
|
+
import_fs2.default.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
195
|
+
}
|
|
196
|
+
function installToTarget(target, config, sourceDir, isRemote) {
|
|
197
|
+
var _a;
|
|
198
|
+
console.log(`
|
|
199
|
+
\u{1F4E6} Installing to ${target.name}...`);
|
|
200
|
+
const isGlobal = isGlobalInstall();
|
|
201
|
+
const location = detectInstallLocation(target.paths, isGlobal);
|
|
202
|
+
const skillName = extractSkillName(config.name);
|
|
203
|
+
const targetDir = import_path2.default.join(location.base, skillName);
|
|
204
|
+
const altTargetDir = import_path2.default.join(location.base, config.name);
|
|
205
|
+
console.log(` Type: ${location.type}${isGlobal ? " (global)" : " (project)"}`);
|
|
206
|
+
console.log(` Directory: ${targetDir}`);
|
|
207
|
+
if (import_fs2.default.existsSync(altTargetDir) && altTargetDir !== targetDir) {
|
|
208
|
+
console.log(" \u{1F9F9} Cleaning up alternative path format...");
|
|
209
|
+
removeDir(altTargetDir);
|
|
210
|
+
console.log(` \u2713 Removed directory: ${config.name}`);
|
|
211
|
+
}
|
|
212
|
+
ensureDir(targetDir);
|
|
213
|
+
const skillMdSource = import_path2.default.join(sourceDir, "SKILL.md");
|
|
214
|
+
if (!import_fs2.default.existsSync(skillMdSource)) {
|
|
215
|
+
throw new Error("SKILL.md is required but not found");
|
|
216
|
+
}
|
|
217
|
+
import_fs2.default.copyFileSync(skillMdSource, import_path2.default.join(targetDir, "SKILL.md"));
|
|
218
|
+
console.log(" \u2713 Copied SKILL.md");
|
|
219
|
+
const filesToCopy = config.files || {};
|
|
220
|
+
for (const [source, dest] of Object.entries(filesToCopy)) {
|
|
221
|
+
const sourcePath = import_path2.default.join(sourceDir, source);
|
|
222
|
+
if (!import_fs2.default.existsSync(sourcePath)) {
|
|
223
|
+
console.warn(` \u26A0 Warning: ${source} not found, skipping`);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const destPath = import_path2.default.join(targetDir, dest);
|
|
227
|
+
if (import_fs2.default.statSync(sourcePath).isDirectory()) {
|
|
228
|
+
copyDir(sourcePath, destPath);
|
|
229
|
+
console.log(` \u2713 Copied directory: ${source}`);
|
|
230
|
+
} else {
|
|
231
|
+
const destDir = import_path2.default.dirname(destPath);
|
|
232
|
+
ensureDir(destDir);
|
|
233
|
+
import_fs2.default.copyFileSync(sourcePath, destPath);
|
|
234
|
+
console.log(` \u2713 Copied file: ${source}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
updateManifest(location.base, config, target.name, isRemote);
|
|
238
|
+
if ((_a = config.hooks) == null ? void 0 : _a.postinstall) {
|
|
239
|
+
console.log(" \u{1F527} Running postinstall hook...");
|
|
240
|
+
try {
|
|
241
|
+
(0, import_child_process.execSync)(config.hooks.postinstall, {
|
|
242
|
+
cwd: targetDir,
|
|
243
|
+
stdio: "pipe"
|
|
244
|
+
});
|
|
245
|
+
console.log(" \u2713 Postinstall hook completed");
|
|
246
|
+
} catch {
|
|
247
|
+
console.warn(" \u26A0 Warning: postinstall hook failed");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
console.log(` \u2705 Installed to ${target.name}`);
|
|
251
|
+
return targetDir;
|
|
252
|
+
}
|
|
253
|
+
function installSkill() {
|
|
254
|
+
console.log("\u{1F680} Installing AI Coding Skill...\n");
|
|
255
|
+
const packageDir = __dirname;
|
|
256
|
+
const config = readSkillConfig(packageDir);
|
|
257
|
+
const enabledTargets = getEnabledTargets(config);
|
|
258
|
+
if (enabledTargets.length === 0) {
|
|
259
|
+
console.warn("\u26A0 No targets enabled in configuration");
|
|
260
|
+
console.warn("Please enable at least one target in .claude-skill.json");
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
console.log(`Installing skill "${config.name}" to ${enabledTargets.length} target(s):`);
|
|
264
|
+
enabledTargets.forEach((target) => {
|
|
265
|
+
console.log(` \u2022 ${target.name}`);
|
|
266
|
+
});
|
|
267
|
+
const { sourceDir, cleanup, isRemote } = getSourceDir(config, packageDir);
|
|
268
|
+
if (isRemote) {
|
|
269
|
+
console.log(`
|
|
270
|
+
\u{1F4E1} Source: Remote (${config.remoteSource})`);
|
|
271
|
+
} else {
|
|
272
|
+
console.log("\n\u{1F4E6} Source: Bundled (local)");
|
|
273
|
+
}
|
|
274
|
+
try {
|
|
275
|
+
const installedPaths = [];
|
|
276
|
+
for (const target of enabledTargets) {
|
|
277
|
+
try {
|
|
278
|
+
const installPath = installToTarget(target, config, sourceDir, isRemote);
|
|
279
|
+
installedPaths.push({ target: target.name, path: installPath });
|
|
280
|
+
} catch (error) {
|
|
281
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
282
|
+
console.error(`
|
|
283
|
+
\u274C Failed to install to ${target.name}:`, message);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
console.log("\n" + "=".repeat(60));
|
|
287
|
+
console.log("\u2705 Installation Complete!");
|
|
288
|
+
console.log("=".repeat(60));
|
|
289
|
+
if (installedPaths.length > 0) {
|
|
290
|
+
console.log("\nInstalled to:");
|
|
291
|
+
installedPaths.forEach(({ target, path: installPath }) => {
|
|
292
|
+
console.log(` \u2022 ${target}: ${installPath}`);
|
|
293
|
+
});
|
|
294
|
+
console.log("\n\u{1F4D6} Next Steps:");
|
|
295
|
+
console.log(" 1. Restart your AI coding tool(s)");
|
|
296
|
+
console.log(' 2. Ask: "What skills are available?"');
|
|
297
|
+
console.log(" 3. Start using your skill!");
|
|
298
|
+
}
|
|
299
|
+
} finally {
|
|
300
|
+
cleanup();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
installSkill();
|
|
305
|
+
} catch (error) {
|
|
306
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
307
|
+
console.error("\n\u274C Failed to install skill:", message);
|
|
308
|
+
console.error("\nTroubleshooting:");
|
|
309
|
+
console.error("- Ensure .claude-skill.json exists and is valid JSON");
|
|
310
|
+
console.error("- Ensure SKILL.md exists");
|
|
311
|
+
console.error("- Check file permissions for target directories");
|
|
312
|
+
console.error("- Verify at least one target is enabled in .claude-skill.json");
|
|
313
|
+
console.error("- Try running with sudo for global installation (if needed)");
|
|
314
|
+
process.exit(1);
|
|
315
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adonis0123/skill-development",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Claude Code Skill - 技能开发指南,提供创建有效技能的完整流程和最佳实践。安装时自动从 Anthropic 官方仓库拉取最新版本。",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"postinstall": "node install-skill.js",
|
|
7
|
+
"preuninstall": "node uninstall-skill.js",
|
|
8
|
+
"test": "node install-skill.js && echo 'Installation test completed.'"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"SKILL.md",
|
|
12
|
+
"references/",
|
|
13
|
+
"install-skill.js",
|
|
14
|
+
"uninstall-skill.js",
|
|
15
|
+
".claude-skill.json",
|
|
16
|
+
"utils.js"
|
|
17
|
+
],
|
|
18
|
+
"keywords": [
|
|
19
|
+
"claude-code",
|
|
20
|
+
"skill",
|
|
21
|
+
"development",
|
|
22
|
+
"guide",
|
|
23
|
+
"anthropic",
|
|
24
|
+
"progressive-disclosure"
|
|
25
|
+
],
|
|
26
|
+
"author": "adonis",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/Adonis0123/agent-skill-npm-boilerplate.git",
|
|
31
|
+
"directory": "packages/skill-development"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/Adonis0123/agent-skill-npm-boilerplate/tree/main/packages/skill-development"
|
|
34
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: skill-creator
|
|
3
|
+
description: Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
|
|
4
|
+
license: Complete terms in LICENSE.txt
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Skill Creator
|
|
8
|
+
|
|
9
|
+
This skill provides guidance for creating effective skills.
|
|
10
|
+
|
|
11
|
+
## About Skills
|
|
12
|
+
|
|
13
|
+
Skills are modular, self-contained packages that extend Claude's capabilities by providing
|
|
14
|
+
specialized knowledge, workflows, and tools. Think of them as "onboarding guides" for specific
|
|
15
|
+
domains or tasks—they transform Claude from a general-purpose agent into a specialized agent
|
|
16
|
+
equipped with procedural knowledge that no model can fully possess.
|
|
17
|
+
|
|
18
|
+
### What Skills Provide
|
|
19
|
+
|
|
20
|
+
1. Specialized workflows - Multi-step procedures for specific domains
|
|
21
|
+
2. Tool integrations - Instructions for working with specific file formats or APIs
|
|
22
|
+
3. Domain expertise - Company-specific knowledge, schemas, business logic
|
|
23
|
+
4. Bundled resources - Scripts, references, and assets for complex and repetitive tasks
|
|
24
|
+
|
|
25
|
+
### Anatomy of a Skill
|
|
26
|
+
|
|
27
|
+
Every skill consists of a required SKILL.md file and optional bundled resources:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
skill-name/
|
|
31
|
+
├── SKILL.md (required)
|
|
32
|
+
│ ├── YAML frontmatter metadata (required)
|
|
33
|
+
│ │ ├── name: (required)
|
|
34
|
+
│ │ └── description: (required)
|
|
35
|
+
│ └── Markdown instructions (required)
|
|
36
|
+
└── Bundled Resources (optional)
|
|
37
|
+
├── scripts/ - Executable code (Python/Bash/etc.)
|
|
38
|
+
├── references/ - Documentation intended to be loaded into context as needed
|
|
39
|
+
└── assets/ - Files used in output (templates, icons, fonts, etc.)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
#### SKILL.md (required)
|
|
43
|
+
|
|
44
|
+
**Metadata Quality:** The `name` and `description` in YAML frontmatter determine when Claude will use the skill. Be specific about what the skill does and when to use it. Use the third-person (e.g. "This skill should be used when..." instead of "Use this skill when...").
|
|
45
|
+
|
|
46
|
+
#### Bundled Resources (optional)
|
|
47
|
+
|
|
48
|
+
##### Scripts (`scripts/`)
|
|
49
|
+
|
|
50
|
+
Executable code (Python/Bash/etc.) for tasks that require deterministic reliability or are repeatedly rewritten.
|
|
51
|
+
|
|
52
|
+
- **When to include**: When the same code is being rewritten repeatedly or deterministic reliability is needed
|
|
53
|
+
- **Example**: `scripts/rotate_pdf.py` for PDF rotation tasks
|
|
54
|
+
- **Benefits**: Token efficient, deterministic, may be executed without loading into context
|
|
55
|
+
- **Note**: Scripts may still need to be read by Claude for patching or environment-specific adjustments
|
|
56
|
+
|
|
57
|
+
##### References (`references/`)
|
|
58
|
+
|
|
59
|
+
Documentation and reference material intended to be loaded as needed into context to inform Claude's process and thinking.
|
|
60
|
+
|
|
61
|
+
- **When to include**: For documentation that Claude should reference while working
|
|
62
|
+
- **Examples**: `references/finance.md` for financial schemas, `references/mnda.md` for company NDA template, `references/policies.md` for company policies, `references/api_docs.md` for API specifications
|
|
63
|
+
- **Use cases**: Database schemas, API documentation, domain knowledge, company policies, detailed workflow guides
|
|
64
|
+
- **Benefits**: Keeps SKILL.md lean, loaded only when Claude determines it's needed
|
|
65
|
+
- **Best practice**: If files are large (>10k words), include grep search patterns in SKILL.md
|
|
66
|
+
- **Avoid duplication**: Information should live in either SKILL.md or references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window. Keep only essential procedural instructions and workflow guidance in SKILL.md; move detailed reference material, schemas, and examples to references files.
|
|
67
|
+
|
|
68
|
+
##### Assets (`assets/`)
|
|
69
|
+
|
|
70
|
+
Files not intended to be loaded into context, but rather used within the output Claude produces.
|
|
71
|
+
|
|
72
|
+
- **When to include**: When the skill needs files that will be used in the final output
|
|
73
|
+
- **Examples**: `assets/logo.png` for brand assets, `assets/slides.pptx` for PowerPoint templates, `assets/frontend-template/` for HTML/React boilerplate, `assets/font.ttf` for typography
|
|
74
|
+
- **Use cases**: Templates, images, icons, boilerplate code, fonts, sample documents that get copied or modified
|
|
75
|
+
- **Benefits**: Separates output resources from documentation, enables Claude to use files without loading them into context
|
|
76
|
+
|
|
77
|
+
### Progressive Disclosure Design Principle
|
|
78
|
+
|
|
79
|
+
Skills use a three-level loading system to manage context efficiently:
|
|
80
|
+
|
|
81
|
+
1. **Metadata (name + description)** - Always in context (~100 words)
|
|
82
|
+
2. **SKILL.md body** - When skill triggers (<5k words)
|
|
83
|
+
3. **Bundled resources** - As needed by Claude (Unlimited*)
|
|
84
|
+
|
|
85
|
+
*Unlimited because scripts can be executed without reading into context window.
|
|
86
|
+
|
|
87
|
+
## Skill Creation Process
|
|
88
|
+
|
|
89
|
+
To create a skill, follow the "Skill Creation Process" in order, skipping steps only if there is a clear reason why they are not applicable.
|
|
90
|
+
|
|
91
|
+
### Step 1: Understanding the Skill with Concrete Examples
|
|
92
|
+
|
|
93
|
+
Skip this step only when the skill's usage patterns are already clearly understood. It remains valuable even when working with an existing skill.
|
|
94
|
+
|
|
95
|
+
To create an effective skill, clearly understand concrete examples of how the skill will be used. This understanding can come from either direct user examples or generated examples that are validated with user feedback.
|
|
96
|
+
|
|
97
|
+
For example, when building an image-editor skill, relevant questions include:
|
|
98
|
+
|
|
99
|
+
- "What functionality should the image-editor skill support? Editing, rotating, anything else?"
|
|
100
|
+
- "Can you give some examples of how this skill would be used?"
|
|
101
|
+
- "I can imagine users asking for things like 'Remove the red-eye from this image' or 'Rotate this image'. Are there other ways you imagine this skill being used?"
|
|
102
|
+
- "What would a user say that should trigger this skill?"
|
|
103
|
+
|
|
104
|
+
To avoid overwhelming users, avoid asking too many questions in a single message. Start with the most important questions and follow up as needed for better effectiveness.
|
|
105
|
+
|
|
106
|
+
Conclude this step when there is a clear sense of the functionality the skill should support.
|
|
107
|
+
|
|
108
|
+
### Step 2: Planning the Reusable Skill Contents
|
|
109
|
+
|
|
110
|
+
To turn concrete examples into an effective skill, analyze each example by:
|
|
111
|
+
|
|
112
|
+
1. Considering how to execute on the example from scratch
|
|
113
|
+
2. Identifying what scripts, references, and assets would be helpful when executing these workflows repeatedly
|
|
114
|
+
|
|
115
|
+
Example: When building a `pdf-editor` skill to handle queries like "Help me rotate this PDF," the analysis shows:
|
|
116
|
+
|
|
117
|
+
1. Rotating a PDF requires re-writing the same code each time
|
|
118
|
+
2. A `scripts/rotate_pdf.py` script would be helpful to store in the skill
|
|
119
|
+
|
|
120
|
+
Example: When designing a `frontend-webapp-builder` skill for queries like "Build me a todo app" or "Build me a dashboard to track my steps," the analysis shows:
|
|
121
|
+
|
|
122
|
+
1. Writing a frontend webapp requires the same boilerplate HTML/React each time
|
|
123
|
+
2. An `assets/hello-world/` template containing the boilerplate HTML/React project files would be helpful to store in the skill
|
|
124
|
+
|
|
125
|
+
Example: When building a `big-query` skill to handle queries like "How many users have logged in today?" the analysis shows:
|
|
126
|
+
|
|
127
|
+
1. Querying BigQuery requires re-discovering the table schemas and relationships each time
|
|
128
|
+
2. A `references/schema.md` file documenting the table schemas would be helpful to store in the skill
|
|
129
|
+
|
|
130
|
+
To establish the skill's contents, analyze each concrete example to create a list of the reusable resources to include: scripts, references, and assets.
|
|
131
|
+
|
|
132
|
+
### Step 3: Initializing the Skill
|
|
133
|
+
|
|
134
|
+
At this point, it is time to actually create the skill.
|
|
135
|
+
|
|
136
|
+
Skip this step only if the skill being developed already exists, and iteration or packaging is needed. In this case, continue to the next step.
|
|
137
|
+
|
|
138
|
+
When creating a new skill from scratch, always run the `init_skill.py` script. The script conveniently generates a new template skill directory that automatically includes everything a skill requires, making the skill creation process much more efficient and reliable.
|
|
139
|
+
|
|
140
|
+
Usage:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
scripts/init_skill.py <skill-name> --path <output-directory>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The script:
|
|
147
|
+
|
|
148
|
+
- Creates the skill directory at the specified path
|
|
149
|
+
- Generates a SKILL.md template with proper frontmatter and TODO placeholders
|
|
150
|
+
- Creates example resource directories: `scripts/`, `references/`, and `assets/`
|
|
151
|
+
- Adds example files in each directory that can be customized or deleted
|
|
152
|
+
|
|
153
|
+
After initialization, customize or remove the generated SKILL.md and example files as needed.
|
|
154
|
+
|
|
155
|
+
### Step 4: Edit the Skill
|
|
156
|
+
|
|
157
|
+
When editing the (newly-generated or existing) skill, remember that the skill is being created for another instance of Claude to use. Focus on including information that would be beneficial and non-obvious to Claude. Consider what procedural knowledge, domain-specific details, or reusable assets would help another Claude instance execute these tasks more effectively.
|
|
158
|
+
|
|
159
|
+
#### Start with Reusable Skill Contents
|
|
160
|
+
|
|
161
|
+
To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
|
|
162
|
+
|
|
163
|
+
Also, delete any example files and directories not needed for the skill. The initialization script creates example files in `scripts/`, `references/`, and `assets/` to demonstrate structure, but most skills won't need all of them.
|
|
164
|
+
|
|
165
|
+
#### Update SKILL.md
|
|
166
|
+
|
|
167
|
+
**Writing Style:** Write the entire skill using **imperative/infinitive form** (verb-first instructions), not second person. Use objective, instructional language (e.g., "To accomplish X, do Y" rather than "You should do X" or "If you need to do X"). This maintains consistency and clarity for AI consumption.
|
|
168
|
+
|
|
169
|
+
To complete SKILL.md, answer the following questions:
|
|
170
|
+
|
|
171
|
+
1. What is the purpose of the skill, in a few sentences?
|
|
172
|
+
2. When should the skill be used?
|
|
173
|
+
3. In practice, how should Claude use the skill? All reusable skill contents developed above should be referenced so that Claude knows how to use them.
|
|
174
|
+
|
|
175
|
+
### Step 5: Packaging a Skill
|
|
176
|
+
|
|
177
|
+
Once the skill is ready, it should be packaged into a distributable zip file that gets shared with the user. The packaging process automatically validates the skill first to ensure it meets all requirements:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
scripts/package_skill.py <path/to/skill-folder>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Optional output directory specification:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
scripts/package_skill.py <path/to/skill-folder> ./dist
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
The packaging script will:
|
|
190
|
+
|
|
191
|
+
1. **Validate** the skill automatically, checking:
|
|
192
|
+
- YAML frontmatter format and required fields
|
|
193
|
+
- Skill naming conventions and directory structure
|
|
194
|
+
- Description completeness and quality
|
|
195
|
+
- File organization and resource references
|
|
196
|
+
|
|
197
|
+
2. **Package** the skill if validation passes, creating a zip file named after the skill (e.g., `my-skill.zip`) that includes all files and maintains the proper directory structure for distribution.
|
|
198
|
+
|
|
199
|
+
If validation fails, the script will report the errors and exit without creating a package. Fix any validation errors and run the packaging command again.
|
|
200
|
+
|
|
201
|
+
### Step 6: Iterate
|
|
202
|
+
|
|
203
|
+
After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.
|
|
204
|
+
|
|
205
|
+
**Iteration workflow:**
|
|
206
|
+
1. Use the skill on real tasks
|
|
207
|
+
2. Notice struggles or inefficiencies
|
|
208
|
+
3. Identify how SKILL.md or bundled resources should be updated
|
|
209
|
+
4. Implement changes and test again
|