// Skills API lifecycle with the official TypeScript SDK (GA — no beta header). // STATUS: LIVE_VERIFIED 2026-09-18 for the HTTP sequence (run via scripts/live.py); SDK calls map 1:1. // Run: node --env-file=.env --experimental-strip-types examples/anthropic/skills/skills_lifecycle.ts import Anthropic, { toFile } from "@anthropic-ai/sdk"; const client = new Anthropic(); // 1. Anthropic-provided skills (observed: xlsx, pptx, pdf, docx) for await (const s of client.skills.list({ source: "anthropic" })) console.log("anthropic skill:", s.id, s.latest_version_id); // 2. create a custom skill — SKILL.md with YAML frontmatter (name ≤ 64 chars lowercase/digits/hyphens, description ≤ 1024) const skillMd = `--- name: atlas-platform-agent-demo description: Tiny demo skill created by the API Atlas example; says OK when asked for a status check. --- # Atlas demo skill When asked for a status check, reply with exactly \`OK\`. `; const skill = await client.skills.create({ files: [await toFile(Buffer.from(skillMd), "atlas-platform-agent-demo/SKILL.md", { type: "text/markdown" })], display_name: "atlas-platform-agent-demo", }); console.log("created", skill.id, skill.source.type, skill.latest_version_id); // 3. retrieve / versions / latest console.log("retrieve", (await client.skills.retrieve(skill.id)).display_name); for await (const v of client.skills.versions.list(skill.id)) console.log("version", v.id, v.name); const latest = await client.skills.versions.retrieve("latest", { skill_id: skill.id }); console.log("latest", latest.id); // 4. new version then delete it (the only remaining version cannot be deleted → 400) const v2 = await client.skills.versions.create(skill.id, { files: [ await toFile(Buffer.from(skillMd.replace("`OK`", "`OK` (v2)")), "atlas-platform-agent-demo/SKILL.md", { type: "text/markdown" }), await toFile(Buffer.from("# notes\n"), "atlas-platform-agent-demo/notes.md", { type: "text/markdown" }), ], }); console.log("v2", v2.id, "deleted:", (await client.skills.versions.delete(v2.id, { skill_id: skill.id })).type); // 5. cleanup — deletes the skill and all versions console.log("delete skill:", (await client.skills.delete(skill.id)).type); // 6. Using a skill in Messages (not executed here; ~$0.01 on Haiku 4.5; needs the code execution tool): // await client.beta.messages.create({ model: "claude-haiku-4-5-20251001", max_tokens: 200, betas: ["code-execution-2025-08-25"], // container: { skills: [{ type: "anthropic", skill_id: "xlsx", version: "latest" }] }, // tools: [{ type: "code_execution_20250825", name: "code_execution" }], // messages: [{ role: "user", content: "In one sentence, what does the loaded skill help with?" }] });