Skills Directory Structure
Understanding a Skill's directory structure and operating mechanism is the foundation for building maintainable and reusable AI Agent capabilities.
This article breaks down a standard Skill's directory structure, the role of each file, and the complete workflow from scratch.
What is a Skill
A Skill is an independent capability unit used to accomplish a specific class of tasks.
If an Agent is compared to an operating system, a Skill is like an application; if an Agent is compared to a project manager, a Skill is a professional capability that can be invoked.
Common Types of Skills
The following are some typical Skill application scenarios:
| Type | Description | Applicable scenarios |
|---|---|---|
| PDF document analysis | Extract PDF content and generate a summary | Document processing, information extraction |
| Web Scraping | Automated web data acquisition | Data collection, information monitoring |
| SQL optimization | Analyze and optimize SQL queries | Database performance tuning |
| Data statistics | Data calculation and statistical processing | Data analysis, report generation |
| Image recognition | Recognize content in images | OCR, image classification |
The Relationship Between Skill and Agent
The Skill itself is not responsible for deciding when to use it; the Agent is truly responsible for that decision.
The complete workflow is as follows:
Key point: The Agent does not load the complete content of all Skills at once. It first reads the description of each Skill, and after hitting the target Skill, loads the complete content. The reason is: if there are hundreds of Skills, loading them all every time would be an extremely wasteful use of Tokens.
The Standard Directory Structure of a Skill
A complete Skill is not a single file but a directory containing multiple files.
The following is the complete directory structure of a standard Skill:
my-skill/
│
├── SKILL.md ← 核心执行文件
├── metadata.json ← 元信息
├── examples/ ← 示例目录
│ ├── example1.md
│ └── example2.md
│
├── scripts/ ← 可执行脚本
│ ├── main.py
│ └── utils.py
│
├── resources/ ← 资源目录
│ ├── prompt.md
│ └── config.yaml
│
├── tests/ ← 测试目录
│ ├── test_cases.md
│ └── eval.yaml
│
├── README.md ← 使用说明
│
└── CHANGELOG.md ← 变更日志
Next, we break down the role of each file and directory one by one.

SKILL.md: Core Execution File
This is the most important file in a Skill; it defines all the execution logic of the Skill.
It contains the following key information:
| Section | Description | Purpose |
|---|---|---|
| Description | Skill function description | For the Agent to match and use |
| When to use | Clarify applicable scenarios | Avoid false triggering |
| When NOT to use | Clarify non-applicable scenarios | Prevent conflicts with other Skills |
| Input | Define input format | Standardize the calling method |
| Instructions | Execution steps | Guide task execution |
| Output | Output format description | Ensure result consistency |
The following is an example of a standard SKILL.md:
Example
PDF Analysis Skill
Description
Used to analyze PDF content and generate a summary.
When to use
Suitable for:
-
PDF reading
-
Summary extraction
-
Content analysis
When NOT to use
Not applicable to:
-
Image editing
-
Video processing
Input
PDF files
Instructions
1
. Extract text
2
. Recognize chapter structure
3
. Summarize main content
4
. Output key points
Output
Markdown-format summary
Common Incorrect Ways of Writing
Many beginners write overly brief SKILL.md files, for example:
Not recommended
PDF Skill
Read PDF
Summarize content
Return result
The problem with this approach is: you don't know when to use it, when not to use it, the output format is unclear, and it easily conflicts with other Skills.
A qualified SKILL.md should let the Agent judge at a glance whether this Skill is suitable for the current task.
metadata.json: Skill Metadata
This file provides machine-readable structured data to help the Agent quickly filter Skills.
Example
{
"name": "pdf-analyzer",
"version": "1.0.0",
"description": "Analyze PDF and generate a summary",
"tags": ["pdf", "summary"],
"category": "document"
}
Common Field Descriptions
| Field | Purpose | Importance |
|---|---|---|
| name | Skill name | Required |
| description | Function description, which the Agent relies on for matching | Most important |
| version | Version number | Recommend |
| tags | Tags for easy retrieval | Recommend |
| category | Classification | Optional |
| author | Author | Optional |
| permissions | Required permissions | Optional |
Among these, the description field is the most important because the Agent usually relies on it for matching.
The matching process is roughly as follows: after the user makes a request, the Agent scans the descriptions of all Skills, and upon finding a matching description, loads the complete Skill content and executes it.
examples: Examples Directory
Many developers overlook this part, but it is actually very important.
Directory structure
examples/
├── example1.md
├── example2.md
Example file content
Example
Inputs:
Help me analyze this PDF
Output:
Document summary
Core Content
1
. ...
2
. ...
3
. ...
The Role of examples
| Purpose | Description |
|---|---|
| Provide few-shot examples | Help the model understand expected behavior through examples |
| Standardize output format | Clarify output structure and style through examples |
| Improve output stability | Reduce random behavior and make results more predictable |
Empirically, good examples are often more effective than adding more prompts.
scripts: Executable Scripts
A Skill is more than just prompts; sometimes it needs to actually execute code to do real work.
Common scenarios requiring scripts include: reading PDFs, performing OCR, calling databases, data processing, generating charts, and so on.
Directory structure
scripts/
├── main.py
└── utils.py
Python Script Example
Example
File path: scripts/extract.py
Function: extract text content from a PDF file
from
pypdf
import
PdfReader
Open the PDF file
reader
=
PdfReader
(
"demo.pdf"
)
Store the extracted text
text
=
""
Iterate over each page and extract text
for
page
in
reader.
pages
:
text +
=
page.
extract_text
(
)
Output all text content
(
text
)
The Skill's workflow is: read file -> execute script -> obtain result, and then hand the result to the large model for processing.
resources: Resources Directory
Used to store auxiliary content, separating configuration from code.
Directory structure
resources/
├── prompt.md
├── config.yaml
Possible resource types
| Resource types | Description | Example |
|---|---|---|
| Prompt template | Reusable prompt templates | prompt.md |
| Configuration file | Parameters and settings | config.yaml |
| Text template | Email and report templates | template.txt |
| Image resources | Icons and diagrams | logo.png |
| SQL templates | Predefined query templates | query.sql |
Configuration file example
Example
File path: resources/config.yaml
Summary-related configuration
max_length
:
1000
Maximum summary length (number of characters)
language
:
zh
Output language: zh=Chinese, en=English
Putting configuration in a separate file means you don't need to change the code to modify parameters later.
tests: Test Directory
Mature projects usually include tests to verify a Skill's effectiveness and stability.
Directory structure
tests/
├── test_cases.md
└── eval.yaml
Test case example
Example
Test:
Inputs:
Help me analyze the PDF
Expected:
Output a summary
Include key points
The Role of Testing
| Purpose | Description |
|---|---|
| Verify effectiveness | Ensure the Skill output meets expectations |
| Regression testing | Verify that old functionality is unaffected after modifications |
| Automated evaluation | Batch testing with automated processes |
| A/B testing | Compare the output quality of different versions |
Skills without tests are prone to the problem of "change one sentence and old functionality suddenly fails".
README: Usage Instructions
README is for developers, explaining how to install and use this Skill.
Example
Installation
Copy to the skills directory
Usage
Upload PDF
Output formats
Markdown
The core problem it solves is: later, you yourself don't know how to use the Skill you wrote.
Complete Case: PDF Analysis Skill
Below, a complete example ties together all the concepts above.
Overview of the Directory Structure
pdf-analyzer/
├── SKILL.md
├── metadata.json
├── examples/
│ └── summary.md
├── scripts/
│ └── extract.py
├── tests/
│ └── eval.md
└── README.md
Complete Invocation Flow
用户:
上传 PDF 并总结
↓
Agent:
扫描所有 Skills
↓
发现:
description: 分析 PDF 并生成摘要
↓
命中 pdf-analyzer
↓
读取 SKILL.md
↓
调用 extract.py
↓
提取 PDF 内容
↓
生成摘要
↓
返回结果
Why Skills Are Designed as a Directory Structure
Many people ask: why not use a single prompt.txt to handle everything?
The reason is that once the scale grows, it becomes unmanageable.
Problems with the Single-File Approach
| Problem | Specific Manifestation |
|---|---|
| Unmaintainable | All content piled into one file, difficult to modify |
| Untestable | No test cases, so you don't know whether it works after changes |
| Unreusable | Every Skill has to be written from scratch |
| No version control | Difficult to track change history |
| No multi-person collaboration | One file modified by multiple people easily causes conflicts |
Advantages of the Directory Approach
| Advantage | Implementation |
|---|---|
| maintainable | Clear responsibilities for each file, fast to locate modifications |
| Reusability | Scripts and configurations can be shared across Skills |
| Testable | Independent test directory supporting automated verification |
| Scalable | Adding new features only requires adding files |
| Publishable | Package the directory to distribute |
Summary
A Skill is essentially not a prompt but a complete software capability package.
Core File Relationships
SKILL.md
↓
定义行为
metadata.json
↓
定义信息
examples/
↓
定义示例
scripts/
↓
定义能力
tests/
↓
定义质量
README
↓
定义使用方式
A prompt can only solve a problem once, whereas a Skill turns capabilities into a lasting asset.