Agent Skills Guide: How They Work, How to Build Them, and Practical Applications
Learn how Agent Skills package reusable workflows into filesystem-based modules. This guide covers skill structure, progressive loading, runtime execution, integration with protocol-based tools, creation practices, external knowledge retrieval, security controls, and a staged adoption roadmap.
1. Why Agents Need Skills
1.1 Three Limitations of Conversation-Only Workflows
In a purely conversational interface, model behavior depends on two types of input: general knowledge embedded during training, and prompts, tool descriptions, and memory fragments supplied during the session. This works well for one-off tasks, but exposes three structural problems in production.
The first is limited reuse. Review standards, release procedures, and troubleshooting steps must be pasted into the context repeatedly, increasing costs with each invocation.
The second is context consumption. Loading every tool description and process document into the system prompt quickly consumes the context budget and can dilute attention to critical instructions.
The third is weak governance. Workflows scattered across individual prompts are difficult to version, review, or audit. When people leave, their operational knowledge may leave with them.
Skills aim to turn an agent that needs repeated guidance into a team member equipped with an operational handbook.
1.2 What Is an Agent Skill?
An Agent Skill is a filesystem-based, modular package of capabilities. It bundles a recurring, specialized workflow with instructions, scripts, and supporting resources in a directory. The agent discovers and loads the package as needed, rather than receiving every detail upfront.
The concept resembles dependency management: applications declare dependencies, packages live in designated directories, and their contents are resolved when needed. With Skills, however, the caller is a model, the interface consists of natural-language instructions, and the implementation can combine documents, scripts, and assets.
2. Skill Structure: One Directory, One Capability
2.1 Directory Layout
A skill directory can use the following structure. The location of the skills directory depends on the host:
.agent/└── skills/├── release-check/│ ├── SKILL.md # Required: metadata and operating procedure│ ├── reference/ # Optional: supporting standards and field definitions│ │ └── checklist.md│ ├── scripts/ # Optional: executable scripts│ │ └── verify.py│ └── assets/ # Optional: templates, images, and examples│ └── report.tpl└── log-triage/└── SKILL.md
2.2 Writing the Entry File
SKILL.md combines YAML metadata with an instruction body. The metadata helps the agent discover the skill; the body explains how to execute it correctly.
---name: release-checkdescription: Run pre-release checks. Use when the user mentions deployment,release, staged rollout, or rollback planning.Produce a checklist report and risk rating.---# Pre-Release Check Procedure1. Read reference/checklist.md and verify each item.2. Run scripts/verify.py to validate configuration differences.3. If any P0 item fails, stop and report the blocking reason.4. Generate the conclusion using assets/report.tpl.
2.3 Progressive Disclosure: Three Loading Layers
Skills conserve context through layered loading:
- Metadata: Keep only
nameanddescriptionavailable for discovery, at a relatively low context cost. - Instructions: Load the body of
SKILL.mdonce the skill is considered relevant. - Supporting resources: Read files in
reference/andassets/only when needed.
Scripts are invoked during execution rather than routinely loaded into the model’s context. This design allows a skill collection to grow to dozens or hundreds of capabilities without loading every full workflow into every request. The metadata index still grows with the number of skills.
3. How Skills Run: A Four-Step Lifecycle
- Discover: Scan designated directories at startup and build a capability index.
- Match: Select a skill based on the current intent and its description. Description quality directly affects selection accuracy.
- Load and execute: Add the workflow instructions to the context, then let the model follow the standard operating procedure, invoke scripts, and read reference material.
- Release: Stop carrying task-specific skill content once it is no longer needed. Context cleanup and cross-session isolation depend on the host’s session management.
Compared with hard-coded function orchestration, Skills place more workflow coordination on the model side, and many procedural changes require only a document update. Compared with standalone prompts, they provide directory-level organization and reuse.
4. Skills and Protocol-Based Tool Integration
Filesystem-based skill packages and protocol-based tool integration operate at different abstraction layers. They are complementary, not competing approaches.
| Dimension | Skills: Capability Packaging | Protocol-Based Integration |
|---|---|---|
| Abstraction layer | Workflows and knowledge: how to perform a task | Connections and calls: which systems can be accessed |
| Packaging | Local directories and documents | Separate service processes and standardized interfaces |
| Context cost | Progressive disclosure limits loaded workflow content | Tool definitions can consume context as the tool set grows |
| Change effort | Procedural changes often require document edits | Service or interface changes may require a release |
| Permission boundary | Constrained by host filesystem and execution permissions | Controlled independently by the service |
| Typical uses | Standard procedures, domain knowledge, report templates | Databases, code hosting, ticketing, and other dynamic systems |
Protocol-based integration defines where an agent can reach. Skills define the methods it should follow.
The growth of Skills does not make protocol-based integration obsolete. Likewise, Skills that require live information cannot complete a workflow without access to suitable data sources.
5. Finding, Using, and Creating Skills
Finding Skills
Start with mature workflows already maintained by your organization. Next, consider reviewed practices from public communities. Build from scratch when neither option fits.
Audit externally sourced skills before adding them to an approved collection.
Using Skills
Place the directory in the host’s designated skill location. Use lowercase, hyphenated names, and write a description that clearly identifies both the trigger conditions and expected output.
In hosts that support automatic skill discovery, this enables conversational matching without separate per-skill configuration.
A Five-Step Creation Process
- Choose a frequent, stable workflow. One-off tasks rarely justify packaging.
- Define activation boundaries and stopping conditions. Avoid overlapping descriptions that cause skills to compete for the same request.
- Use numbered steps and explicit decision branches. Replace vague instructions with clear actions and criteria.
- Move deterministic logic into scripts. Let the model handle judgment and communication.
- Run regression tests with 5–10 real cases. Measure skill-selection accuracy and output compliance.
Common mistakes include overly broad descriptions that cause false activation, instruction bodies so long that they undermine progressive loading, scripts without timeouts or failure exit codes, and credentials hard-coded into resource files.
6. Practical Application: External Knowledge Retrieval
A practical architecture separates responsibilities:
- The Skill orchestrates the workflow.
- A script retrieves information.
- Object storage or a document repository holds the knowledge.
- A logging service receives retrieval and invocation logs.
- Monitoring and alerts cover failures.
The following script illustrates the retrieval component:
# Core skeleton for scripts/search.pyimport os, sys, json, urllib.requestendpoint = os.environ["KB_ENDPOINT"] # Read credentials only from environment variablestimeout = 10try:req = urllib.request.Request(endpoint, headers={"Authorization": os.environ["KB_TOKEN"]})hits = json.load(urllib.request.urlopen(req, timeout=timeout))except Exception as exc:print(json.dumps({"ok": False, "reason": str(exc)})); sys.exit(1)print(json.dumps({"ok": True, "hits": hits[:5]}, ensure_ascii=False))
How This Compares with Traditional RAG
The comparison below contrasts a conventional indexed RAG pipeline with a Skill that retrieves directly from a source system. Actual behavior depends on the implementation.
| Dimension | Traditional Indexed RAG | Skills + Retrieval Script |
|---|---|---|
| Knowledge updates | Updates require index refreshes or rebuilding | Direct retrieval can access current source data |
| Context cost | Retrieved passages are added to the context | Information is loaded on demand; the script may return summaries |
| Workflow explainability | Chunking and ranking may be less visible | Workflow steps are explicit, readable, and editable |
| Permissions | May depend on permissions synchronized into the index | Can use the source system’s authentication and authorization |
| Implementation effort | Often requires a broader retrieval pipeline | Can be quicker for workflow-oriented knowledge |
A hybrid architecture is often the practical choice: use Skills for stable procedures, RAG for large collections of unstructured material, and protocol-based integration for dynamic business data.
7. Security Considerations
Skills introduce five major risk categories:
- Prompt injection: External documents may contain malicious instructions intended to redirect the workflow.
- Arbitrary script execution: Scripts can act with the permissions granted by the host.
- Credential leakage: Secrets may be hard-coded or exposed in logs.
- Supply-chain compromise: Untrusted third-party skills may contain malicious instructions or code.
- Unauthorized operations: Destructive or high-impact actions, such as deletion or deployment, may run automatically.
Apply corresponding controls:
- Mount approved skill directories as read-only and verify their provenance and signatures.
- Run scripts in a sandbox with least-privilege permissions, enforced timeouts, and resource limits.
- Supply credentials through environment variables or a secrets manager; do not store them in skill files or logs.
- Treat external content as data, not as instructions.
- Require human confirmation for high-risk actions.
- Record end-to-end audit logs and connect them to monitoring and alerting.
For deployments using Baidu AI Cloud, the architecture can combine applicable object storage, logging, and monitoring services into a capability-packaging, data-access, and audit-observability loop. Service availability should be checked for the intended deployment environment.
8. A Maturity Roadmap
Adopt Skills in four stages:
- Package a single workflow.
- Introduce a shared team directory and review process.
- Combine Skills with protocol-based integrations.
- Continuously improve using selection-accuracy and output-compliance metrics.
The decision to create a Skill comes down to three questions: Is the workflow repeated? Is it stable? Can it be described clearly?
