Elie Schoppik · 2026-01-28

Claude API 技能使用

摘要

本课程深入探讨如何在 Claude Messages API 中使用自定义技能。与 Claude AI 和 Claude Desktop 不同,API 环境需要手动配置代码执行工具和文件 API 才能让技能正常工作。课程通过两个实例演示如何上传技能目录、处理文件输入,并使用沙盒容器执行代码生成输出文件。最后展示了如何组合自定义技能与内置技能(如 docx)来完成复杂任务。

要点

  • Claude AI 和 Claude Desktop 中的技能不会与 Claude API 共享,API 环境需要手动配置代码执行能力
  • 代码执行工具提供隔离的沙盒容器,具备 RAM、磁盘和 CPU 限制,且无互联网连接
  • Files API 用于上传输入文件和下载生成文件,与代码执行工具配合完成技能任务
  • 技能通过 container 参数传递,可指定自定义技能或内置技能,并支持版本控制
  • 可以组合多个技能(如自定义时间序列分析技能与内置 docx 技能)来创建复合输出

视频信息:Skills with the Claude API


中文翻译

在第一节课中,你看到了技能是如何在 Claude AI 中工作的。现在,我们将使用 Claude API 来测试我们在上一节课中制作的两个技能。要使用 Claude API 的技能,我们需要使用代码执行工具和文件 API。这将为 Claude 配备用于读写文件的文件系统访问权限,以及用于执行代码的 bash。让我们开始吧。

我们已经谈论了很多关于技能如何工作以及如何创建它们的内容。我们也稍微谈到了技能在 Claude 生态系统中不同环境之间的可移植性,以及许多其他智能体应用程序。我们从在 Claude AI 和 Claude Desktop 中查看技能开始,现在我们要转而讨论如何使用 Claude Messages API 来使用技能。有两件事需要注意。首先,你在 Claude AI 和 Claude Desktop 中创建的技能不会在 Claude API 或 Claude Code 中共享。第二个重要的部分是,为了让技能工作,我们需要 Claude 具有执行代码、创建和编辑文档、演示文稿、PDF 和数据报告以及使用文件系统的能力。这是我们在使用 Claude API 时必须手动完成的事情。而在使用 Claude AI 和 Claude Desktop 时,这是已经为你配置好的。

在 Claude Desktop 或 Claude AI 中,如果我进入设置并查看功能,你可以看到这里有一个用于代码执行和文件创建的部分。这是我们在直接使用 API 时将更深入讨论的内容。但这是一个默认启用的设置,允许 Claude 执行代码、创建文档、电子表格、演示文稿等。这本质上为 Claude AI 和 Claude Desktop 提供了一台计算机或虚拟机来执行代码并执行所有那些让技能发挥作用的任务。如果此功能被禁用,我们实际上会看到我们需要打开它才能使用技能。

现在让我们转回来,稍微谈谈这个代码执行工具和文件创建是如何工作的,因为在使用 API 时我们需要手动启用它。当使用像 Claude Code 和 Claude Agent 这样的工具时,你可以直接访问文件系统。而使用 Claude API 时,我们不能直接访问,并且需要一个容器来执行代码和一个文件系统来使用。Claude AI 和 Claude Desktop,那个容器化的环境和文件系统是提供给你的,而不是你需要实现的东西。归根结底,功能都是一样的,但我们利用技能的方式略有不同。技能本身不会改变,这些技能的格式也不会改变,但根据你所处的环境,你可能会以稍微不同的方式利用技能的工作方式。

当我们开始探索 Messages API 时,我们将使用代码执行工具。代码执行工具允许 Claude 运行 Bash 或 shell 命令来执行我们在使用技能时看到的所有这些操作。在沙盒环境中创建、查看、编辑文件和编写代码。代码执行工具使我们的应用程序能够拥有一个单独的专用容器来执行代码并使用文件系统。正如你所看到的技能可以做的所有事情,这对于读取我们的技能、在这些技能中执行代码以及处理我们可能想要编辑、查看和创建的其他文件来说是至关重要的。

为了让你直观地了解这看起来像什么,当我们包含代码执行工具时,我们给 Claude 一个执行沙盒或容器。当我们要求 Claude 创建和执行文件时,这些是在安全隔离的环境中执行的。RAM、磁盘、CPU 都有通过限制,更重要的是,不提供互联网连接,并且有开箱即用的预安装库。所以这并不适用于每一种编码环境。这里有一些限制需要注意。同时,我们也可以访问一个文件系统,我们可以开始向其中添加目录。当我们在 Claude Desktop 和 Claude AI 中工作时,你甚至可能已经看到了一些暗示。没有互联网连接的这个限制是 Messages API 特有的。当我们在 Claude AI 或 Claude Desktop 中使用代码执行工具时,我们确实可以访问互联网连接,并且我们可以下载和安装包。

代码执行工具与 Claude API 允许我们使用的另一组 API 配合得非常好。你可以想象,当我们处理文件时,添加、创建、写入、修改文件,我们需要某种机制来实际存储这些底层文件。Claude API 包含一组名为 Files API 的 API,用于上传和下载可以在容器内运行和处理的文件。你可以想象这样一个场景,用户要求总结一些输入并将摘要保存到文本文件中。我们上传该输入文件,将其发送到容器,使用此 Files API 下载生成的文件。我们很快就会在代码中看到这一点。当我们看到从上传和下载文件中获取的 ID 以及它如何与技能和我们的代码执行工具很好地配合工作时。

这正是技能发挥作用的地方。我们在 Claude AI 等工具中开箱即用的技能库,或者如果我们想使用 API 可以包含的技能库,这些技能位于容器提供支持的目录中。当我们开始从这个技能目录读取时,当我们开始向我们的技能添加信息或使用这些底层技能来创建我们可以下载或上传的新文件时,这就是技能发挥作用的地方。我们将看到使用 API 时的一个要求,当我们想要使用技能时,我们也需要使用代码执行工具。

现在我们对代码执行工具和文件 API 允许我们做什么有了很好的了解,让我们看看如何在实际操作中使用它。我们将回顾我们之前构建的两个用于生成练习题以及时间序列分析的自定义技能。所以让我们前往 Jupyter Notebook 并探索这一点。就在这里,我有我们之前使用过的两个自定义技能。我还有一个用于存储我将用来分析时间序列数据的数据的文件夹。我还有一个用于存储讲义的文件夹,我将在使用我的生成练习题技能时使用它。为了在这个 Notebook 中开始,我要加载我需要的环境变量以及一个帮助我从目录中查找特定文件的辅助工具。当我们开始使用我们的技能时,我们将看到它的实际应用。

首先,我要开始使用我的生成练习题技能。所以让我们继续看看我需要做的第一部分。首先,我需要上传技能目录。在这里你可以看到我们正在使用那个 files_from_dir 辅助函数,以及必要的技能 beta 标头。一旦完成,我应该能够看到我创建的技能 ID。这个 betas 列表是我在向 Messages API 发出请求时添加的特定标头。在底层,这些正在变成请求标头,以确保我获取正确的数据并与 API 适当通信。

为了查看我拥有的所有技能,我可以使用这个 .list 方法,并且我要传入一个 custom 源,这样我们就不会加载所有内置技能,而是只确认我已经按预期创建了这些技能。在这里我可以看到标题,以及我稍后将使用的唯一技能 ID。为了使其按预期工作,我们需要使用我们将从中生成练习题的 LaTeX 文件。在这里,我将使用 Files API 上传这个特定的 LaTeX 文件。确保将其设置为读取,然后取回一个文件对象。

我将把这个文件对象与必要的技能结合使用,以确保一切按预期工作。我在这里使用的是 Sonnet,并且我正在传入必要的 beta 标头,不仅用于技能,而且为了让技能在与模型对话时按预期工作,我需要确保我也拥有代码执行 beta。由于我在这里发送文件,我们也必须确保我们拥有 Files API 标头。当使用技能时,这些技能设置在一个名为 container 的关键字参数中,在这里我传入技能列表。这些可以是自定义的或内置的。当我创建许多不同版本的技能时,我可以引用特定的时间戳或只使用我拥有的最新版本。

当我开始与模型通信时,我要求它生成练习题,然后指定我正在使用的文件。这个文件对象是我之前上传 LaTeX 文件时创建的。我们最后确保我们引入了正确的代码执行工具。并向我们的 API 发送消息。现在让我们去看看我们得到的响应。我们可以看到这里使用了多个不同的部分。服务器上的工具、代码执行、使用的其他工具,最后是 bash 代码执行结果。为了让这看起来更清晰一点,让我们添加一些漂亮的格式,这样我们可以继续查看并分析不同的文本响应和工具使用。我们将在这个特定系列中一步一步地看到发生了什么。

当我们查看响应是什么时,其中包括我们的文本以及我们的工具使用和工具结果,模型告诉我们的第一件事是它可以帮助从这些笔记中生成问题,并且它将开始通过读取技能文件并检查讲义。请注意这里,它检测到了它需要使用的技能,但它只读取了 SKILL.md。我们稍后会看到是否需要读取其他文件,我们将利用这种逐步披露。我们还将查看我们输入的 LaTeX 文件。我们将继续查看来自这些文件的底层数据。这是我们之前见过的 YAML Frontmatter,以及来自我们 notes04.tex 文件的 LaTeX。

接下来,我们将继续检查 Markdown 模板以使用适当的结构,因为我们希望输出为 Markdown。在这里我们将利用更多的逐步披露。在这里我们将读取 assets 文件夹内的 markdown_template.md。我们将取回我们读取的响应,现在我们将根据我们传递的讲义生成问题。在这里我们将使用我们的代码执行工具来创建一个特定文件。我们将给该文件 Markdown 文本,我们将取回该文件的结果。我们将继续将其复制到输出目录,并使用我们的 Files API 取回一个稍后可以下载的 file_id。

一旦我们取回结果,我们可以查看已生成的底层文件,并利用该文件 ID 以编程方式下载它。我们可以看到这里它已保存并准备好使用。使用我们在上面看到的文件 ID,让我们继续下载文件。我们将继续检查此响应,并确保我们正确提取了文件 ID。如果我们有它,这是我们期望做的,我们应该能够下载该特定文件。我们将继续将该内容写入名为 notes04.md 的文件。包括文件 ID 以及与 API 通信所需的 beta 标头。我们可以看到这里,我们已经下载了那个 notes04.md 文件,这是来自 Files API 和代码执行工具的,全都是由模型和技能生成的。

在我们下载的这个文件中,我们可以看到我们正在遵循我们在技能中拥有的确切部分。从判断题开始,接着是解释性问题、编码问题,最后是案例应用。我们可以在 Markdown 中预览它,看看它会是什么样子。在这里我们可以看到我们的案例应用,所有必要的东西。现在是评估此特定输出的好时机。我们是否完全按照技能要求的去做了?开始看起来不错。引入一些单元测试真的可以将此提升到一个新的水平。如果我们需要,我们可以回去修改技能,就像我们之前看到的那样,使用 API、代码执行工具以及 Files API。

我们还有能力以编程方式删除技能。为了删除技能,我们首先必须找到与该技能关联的所有版本,然后删除它们。一旦这些版本被删除,我们应该能够删除底层技能。就在这里。接下来,我们将继续使用我们的分析时间序列技能以及另一个技能。这看起来与我们上面看到的非常熟悉,所以让我们通过这些步骤。首先,我们要上传我们的自定义技能。取回技能 ID 并确认我们已经按预期完成了。在这里,我们还可以看到我们不仅加载了自定义技能,我们还可以看到内置技能。这些看起来应该很熟悉,正如我们在 Claude AI 中也看到它们一样。

接下来,我们将继续上传我们的输入文件。这将是我们的零售销售 CSV 文件。我们将构建一条消息发送到 API,就像以前一样,我们将继续使用我们的技能,但在这里我们还将包括 docx 技能。我们要使用这个,因为我们要创建一个总结结果和图表的 Word 文档。所以在这里我们看到了自定义技能与我们拥有的技能 ID 以及版本的组合。并在这种情况下使用 Anthropic 内置技能,即 docx 技能。我们传入与之前必须传入的相同的标头,技能、代码执行和 Files API。

现在这已经运行完毕,我们可以检查我们要获得的特定类型的响应。我们将看到与我们之前看到的类似的东西,但这次发生的事情稍微多一点。让我们去看看在我们漂亮的格式化下幕后发生了什么。所以在这里,模型将通过帮助我们分析时间序列数据来响应。就像以前一样,我们将开始读取这些 SKILL.md 文件的全部内容。我们将读取我们的自定义技能以及我们需要使用的内置 docx 技能。我们可以看到这些结果包括内容,从文件的开头开始,包括整个 SKILL.md。

接下来,我们将继续检查数据以运行我们的时间序列分析。我们将只查看此 CSV 的前 20 行,以检查列名和我们正在处理的数据类型。由于这按预期工作,我们将继续运行诊断并创建可视化。我们需要运行的这些特定命令直接来自我们的技能。在这里我们将继续读取那些底层文件,执行该代码并将结果交还给 Claude 处理。

我们将取回这些执行的结果。我们将取回诊断以及可视化的结果。然后我们将读取摘要和诊断,这是我们的脚本结果,它在一个名为 summary.txt 的文件中。一旦我们创建了该特定文件,我们就可以继续创建一个 Word 文档。内置的 docx 技能包含有关如何处理 Word 文档的正确内容。我们将继续查看如何最好地生成该文档并在此处利用逐步披露。我们不需要 docx 技能中的所有内容,只是使用一种方法来获取那些 Markdown 文件。一旦我们有了它,我们将使用必要的技能创建一个全面的 Word 文档,执行代码以此来做到这一点,并生成底层 Word 文档。

一旦我们有了那个 Word 文档,我们将把它复制到输出目录,就像我们之前看到的那样,取回一个文件 ID,如果我们想下载这个 Word 文档,我们可以使用它。我们可以看到此数据的摘要。现在我们可以下载文件。同样,我们将继续查找该 file_id(如果存在)。我们将继续下载包含必要内容的特定文件作为 docx 文件。如果我们看看它是什么样子的,我们现在有一个包含我们的发现、我们的概述、我们的统计数据的 Word 文档。我们可以看到我们引入了那些图表和可视化,以及我们要请求的统计分析。

这也是一个很好的时机,不仅可以评估我们正在做的事情是否在技能中是预期的,而且我们正在以一种可预测的方式这样做。当我们继续评估时,我们可以随时根据需要修改此技能。但所有这些数据都来自技能以及 docx 技能,以创建这个单独的文件。就像我们之前看到的那样,如果我们想删除此技能,我们可以列出所有版本并删除所有这些版本。一旦这些版本被删除,删除底层技能。在本节课中,我们结合了我们对 Messages API、代码执行工具、Files API 和技能的知识,以获取我们的自定义技能并以编程方式使用它们。在下一节课中,我们将通过 Claude Code,看看如何在 .claude 文件夹中添加我们自己的自定义技能,并构建一个更复杂的命令行应用程序。

English Script

In the first lesson, you saw how skills work with Claude AI. Now, we’ll work with the Claude API to test the two skills we made from the previous lesson. To use skills with the Claude API, we’ll need to use the code execution tool and the files API. This will equip Claude with file system access for reading and writing files and with bash for executing code. Let’s get to it.

We’ve talked quite a bit about how skills work and how to create them. And we talked a little bit as well about the portability of skills across different environments in the Claude ecosystem, as well as many other agentic applications. We started by looking at skills in Claude AI and Claude Desktop, and now we’re going to move to talk about how to use skills using the Claude Messages API. There are two things that are important to note. First, skills that you create in Claude AI and Claude Desktop are not shared in The Claude API or Claude Code. The second important piece is that in order for skills to work, we need the ability for Claude to execute code, create and edit documents, presentations, PDFs, and data reports, and work with a file system. This is something that we’re going to have to manually do when we work with the Claude API. And this is something that is actually configured for you right away when using Claude AI and Claude Desktop.

In Claude Desktop or Claude AI If I go to settings and I take a look at the capabilities, you can see here that there’s a section for code execution and file creation. This is what we’re going to talk about in more depth when we work with the API directly. But this is a setting that is enabled by default that allows Claude to execute code, create docs, spreadsheets, presentations, and more. This essentially gives Claude AI and Claude Desktop a computer or a virtual machine to execute code and perform all those tasks that make Skills happen. If this is disabled, we’ll actually see that we need to turn this on to even be able to use skills.

Now let’s shift back and talk a little bit about how this code execution tool and file creation works, because we’re going to need to enable this manually when we work with the API. When working with tools like Claude Code and the Claude agent, you have direct access to a file system. Whereas using the Claude API, we do not, and need a container to execute code and a file system to work with. Claude AI and Claude Desktop, that containerized environment and file system is given to you and not something you have to implement. At the end of the day, the functionality is all the same, but the way in which we utilize skills is slightly different. The skills themselves do not change, the format of those skills do not change, but depending on the environment that you’re in, you may utilize the way in which skills work slightly differently.

As we start to explore the Messages API, we’re going to use the code execution tool. The code execution tool allows Claude to run Bash or shell commands to perform all these actions that we saw when working with skills. Creating, viewing, editing files, and writing code, all in a sandboxed environment. The code execution tool gives our application the ability to have a separate dedicated container to execute code and work with a file system. as you’ve seen with all the things that skills can do, that is mission critical for reading our skills, executing code within those skills, and working with other files that we might want to edit and view and create.

To give you a visualization of what this looks like, when we include the code execution tool, we give Claude an execution sandbox or a container. When we ask Claude to create and execute files, these are executed in a safe and isolated environment. There are limitations for the RAM, the disk, the CPU, and more importantly, there is no internet connection provided and there are pre-installed libraries that you get out of the box. So this does not work with every single kind of coding environment. There are some limitations here to be mindful of. At the same time, we also get access to a file system that we can start adding directories to. You might have even seen hints of that when we worked with Claude desktop and Claude AI. This limitation of no internet connection is something that is specific to the Messages API. When we’re using the code execution tool in Claude AI or Claude desktop, we do have access to an internet connection and we can download and install packages.

The Code Execution Tool works quite nicely with another set of APIs that the Claude API allows us to work with. As you can imagine, when we’re working with files, adding, creating, writing, modifying files, we need some mechanism for actually storing those underlying files. The Claude API includes a set of APIs called the Files API to upload and download files that can be run and worked on inside of the container. You can imagine a scenario where the user asks to summarize some input and save the summary to a text file. We upload that input file, send it to the container, download generated files with this Files API. We’re going to be seeing this shortly in code. When we see the IDs that we get back from uploading and downloading files and how this works nicely with skills and our Code Execution Tool.

And this is exactly where skills come into play. The library of skills that we get out of the box in tools like Claude AI or that we can include if we want using the API, those live in a directory that are powered in the container. As we start to read from this skills directory, as we start to add information to our skills or use those underlying skills to create new files that we can download or upload, this is where skills come into play. And we’re going to see a requirement when working with the API, when we want to use skills, we need to use the Code Execution Tool as well.

Now that we have a good sense of what the Code Execution Tool and Files API allow us to do, let’s see how to use this in action. We’re going to go and revisit the two previous custom skills that we built for generating practice questions as well as time series analysis. So let’s head over to a Jupyter notebook and explore this. Right here, I have my two custom skills that we’ve worked with before. I also have a folder for data that I’m going to be using to analyze time series data. I also have a folder for lecture notes that I’ll be using when I use my generating practice questions skill. To get started in this notebook, I’m going to load the environment variables that I need as well as a helper to help me find particular files from a directory. We’re going to see this in action when we start using our skills.

To start, I’m going to begin using my generating practice questions skill. So let’s go ahead and take a look at the first part that I need to do. To begin, I need to upload the skill directory. Here you can see we’re using that files_from_dir helper function, as well as the necessary beta headers for skills. Once this is done, I should be able to see the skill ID that I’ve created. This betas list are particular headers that I add when I make a request to the Messages API. Under the hood, these are turning into request headers to make sure that I’m getting the right data back and communicating appropriately with the API.

To take a look at all the skills that I have, I can use this .list method, and I’m going to pass in a source of custom so that we don’t load all the built-in skills and instead just confirm that I’ve created the ones as expected. And here I can see the title, as well as the unique skill ID that I’m going to be using shortly. In order for this to work as expected, we’re going to need to make use of the LaTeX file where we’re going to generate practice questions from. Here, I’ll use the Files API to upload this particular LaTeX file. make sure that it’s set for reading and then get back a file object.

I’ll be using this file object in conjunction with the skills necessary to make sure that it’s all working as expected. I’m using Sonnet here, and I’m passing in the necessary beta headers, not only for skills, but in order for skills to work as expected when talking to the model, I need to make sure I have the code execution beta as well. And since I’m sending a file here, we have to make sure we have the files API header as well. When working with skills, these skills are set in a keyword argument called container, and here is where I pass in the list of skills. These could be custom ones or built-in ones. As I create many different versions of the skills, I can reference a particular timestamp or just use the latest one that I have.

As I start to communicate with the model, I ask it to generate practice questions and then specify the file that I’m working with. This file object was previously created when I uploaded the LaTeX file. We finally make sure we’re bringing in the correct tools for code execution. and send a message to our API. Now let’s go take a look at the response that we got back. We can see here that there are multiple different pieces being used. Tools on the server, code execution, additional tools being used, and then finally, a bash code execution result. To make this a little bit cleaner to look at, let’s add some nice formatting so that we can go ahead and take a look and analyze different text responses and tool use. We’re going to go ahead and see in this particular series what’s happening one step at a time.

When we take a look at what the response is, which includes our text and our tool use and tool results, the first thing the model is telling us is it can help generate questions from these notes and it’s going to start by reading the skill file and examining the lecture notes. Notice here, it’s detected the skill that it needs to use, but it’s only reading the SKILL.md We’re going to see later on if there are additional files that need to be read, we’ll make use of that progressive disclosure. We’re also going to review in our input that LaTeX file as well. We’re going to go ahead and see the underlying data that comes from these files. This is the YAML front matter that we’ve seen before, as well as the LaTeX from our notes04.tex file.

Next, we’re going to go ahead and check the markdown template to use the proper structure because we want our output to be in markdown. Here is where we’re going to leverage a bit more of that progressive disclosure. Here’s where we’re going to read inside of the assets folder that markdown_template.md We’ll get back the response that we’ve read and now we’ll generate the questions based on the lecture notes that we’ve passed. Here we’re going to use our code execution tool to create a particular file. We’ll give that file text in markdown, and we’ll get back the result of that file. We’re going to go ahead and copy that to an output directory and use our Files API to get back a file_id that we can download later on.

Once we get back that result, We can take a look at the underlying file that’s been generated and make use of that file ID to programmatically download it. We can see here it’s been saved and is ready for use. Using that file ID that we saw above Let’s go ahead and download the file. We’ll go ahead and check in this response and make sure that we have the file ID correctly extracted. And if we have that, which we expect to do, we should be able to download that particular file. We’ll go ahead and write to a file called notes04.md with that content. includes the file ID as well as the necessary beta headers to communicate with the API. We can see here, we’ve downloaded that notes04.md file, and this is coming from the Files API with the code execution tool, all generated with the model and a skill.

Inside of this file that we’ve downloaded, we can see that we’re following those exact parts that we had in the skill. Starting with true and false questions, moving on to explanatory questions, to coding questions, and finally, to use case applications. We can preview this in markdown to see what that would look like. And here we can see our use case application, all the things necessary. Now is a good time to evaluate this particular output. Did we do exactly what the skill wanted? It looks good to start. bringing in some unit tests can really take this to the next level. If we need, we can go back and modify the skill, just like we saw before, using the API, the code execution tool, and the Files API as well.

We also have the ability to delete skills programmatically. In order to delete a skill, we first have to find all of the versions associated with that skill and then delete them. Once those versions are deleted, we should be able to delete the underlying skill. Right here. Next, we’re going to go ahead and use our analyzing time series skill alongside another skill. This is going to look pretty familiar to what we saw above, so let’s go through these steps. First, we’re going to upload our custom skill. get back a skill ID and confirm that we’ve done that as expected. Here, we can also see that we’re not loading only the custom skills, we can see the built-in skills as well. These should look pretty familiar, as we saw them as well in Claude AI.

Next, we’re going to go ahead and upload our input file. This is going to be our retail sales CSV file. We’re going to build a message to send to the API, and just like before, we’re going to go ahead and use our skill, but here we’re also going to include the docx skill as well. We’re going to use this because we want to create a word doc summarizing the results and the plots. So here we’re seeing a combination of custom skills with the skill ID that we have as well as the version. and using Anthropic built-in skills in this case, the docx skill. We’re passing in the same headers that we had to pass in before, skills, code execution, and the files API.

Now that this is finished running, we can examine the particular type of response that we get. We’re going to see something similar to what we saw before, but this time there’s just a little bit more happening. Let’s go and see what’s happening under the hood with our nice formatting. So here, the model is going to respond by helping us analyze time series data. And just like before, we’re going to start reading the entirety of these SKILL.md files. We’re going to read our custom skill as well as the built-in docx skill, which we’re going to need to use. We can see the result of those include the content, starting from the beginning of the file and including the entire SKILL.md

Next, we’re going to go ahead and examine the data to run our time series analysis. We’re going to look at just the first 20 lines of this CSV to examine the names of the columns and the type of data that we’re working with. Since this is working as expected, we’re going to go ahead and run the diagnostics and create the visualizations. These particular commands that we need to run are coming directly from our skill. Here is where we’re going to go ahead, read those underlying files, execute that code and hand that back to Claude to work with.

We’re going to get back the result of these executions. We’re going to get that back for diagnostics as well as visualize. We then going to read the summary and diagnostics, which is the result of our script that comes in a file called summary.txt Once we have that particular file created, we can then go ahead and create a Word document. The built-in docx skill includes the correct content for how to work with Word docs. We’re going to go ahead and take a look at how best to generate that document and leverage progressive disclosure here. We don’t need everything from the docx skill, just using a way to get to those markdown files. Once we have that, we’ll create a comprehensive Word document using the skill necessary, execute the code to make it do that, and generate the underlying Word document.

Once we have that Word document, we’ll copy that to the output directory and just like we saw before, get back a file ID that we can use if we want to download this Word document. We can see a summary of what this data looks like. And now we can download the file. Similarly, we’ll go ahead and find that file_id if it exists. We’re going to go ahead and download that particular file with the necessary contents as a docx file. If we take a look at what this looks like, we now have a Word document with our findings, our overview, our statistics. We can see that we brought in those plots and visualizations, as well as the statistical analysis that we’ve requested.

This is also a great time to not only evaluate if what we’re doing is expected in the skill, but that we’re doing this in a predictable fashion. As we continue to evaluate, we can always modify this skill as much as we want. But all this data is coming in from the skill as well as the docx skill. to create this individual file. Like we saw before, if we want to delete this skill, we can list all the versions and delete all those versions. And once those versions are deleted, delete the underlying skill. In this lesson, We’ve combined our knowledge of the Messages API, the Code Execution tool, the Files API, and skills to take our custom skills and work with them programmatically. In the next lesson, we’re going to move to Claude code and see how to add our own custom skills inside of a .claude folder and build a more sophisticated command line application.