Agent Skills: A Practical Guide to Writing and Using Them
This article explains what Agent Skills are and why they matter, how the three-level progressive disclosure structure keeps context costs under control, and how to turn a method into executable constraints through single responsibility, explicit steps, verifiable rules, examples, failure paths, and lazy-loaded resources. It also covers standalone skills versus tool-augmented workflows, plus testing, iteration, and distribution practices. Readers will get a reusable framework for building their first stable skill in about half an hour.
1. Why a Skill Layer Is Needed
A recurring inefficiency shows up when working with large language models: every time a new session starts, the user has to restate their preferences, approval flows, glossary, output format, and background knowledge. The context window is limited, yet the “working method” that genuinely needs to persist over time barely changes. A Skill is the engineering answer to this tension: it packages a set of instructions and resources as a folder, turning one-off verbal agreements into assets that can be versioned, reused, and shared.
Skills are best suited to high-frequency, repetitive workflows with stable steps. Examples include generating a frontend page skeleton from a requirements document, producing research conclusions under a unified analysis framework, applying team templates to output standardized documents, or chaining several discrete steps into a repeatable pipeline. A Skill does not replace the model’s existing baseline capabilities such as code execution or document generation; it layers a set of “process constraints” on top, so output shifts from “relying on prompt luck every time” to “delivering consistently against a defined spec.”
For teams that have already built an external tool integration layer, a Skill adds one more layer of encapsulation: it converges raw tool-calling capability into business workflows with clear semantics, well-defined boundaries, and testability, which lowers the chance of misuse and raises reuse rates.
2. Core Mechanism: The Three Levels of Progressive Disclosure
The key design principle is progressive disclosure: load information in layers by relevance instead of pushing everything into the context at once. The typical three-level structure is:
- Level 1: YAML front matter. Always in the model’s persistent view, holding only the name and a purpose description. Its job is to let the model quickly decide “does the current task need this skill.” Keep fields minimal, and make the description state clearly when the skill applies and when it does not.
- Level 2: The skill body (usually a single Markdown main file). Read only once the model judges it relevant; it carries the full instructions, steps, constraints, acceptance criteria, and examples.
- Level 3: Additional files in the directory, including templates, checklists, reference samples, and script notes. The model consults them on demand, so they never occupy persistent context.
This layering pays off in three ways: it controls context cost, it reduces interference between skills, and it naturally supports a “overview first, details later” reading path. A schematic directory and front matter look like this:
my-skill/├── SKILL.md # Level 2: full instructions├── templates/ # Level 3: templates├── references/ # Level 3: reference material└── scripts/ # Level 3: notes on helper scripts
---name: spec-to-frontenddescription: Produces a frontend page skeleton from a requirements document; applies when a clear requirements document exists and a consistent style is needed, not for pixel-level reproduction of a visual mockup.---
3. From Planning to Design: Writing the Method as Executable Constraints
In the planning stage, answer four questions first: what triggers the skill, what materials the input contains, what the expected deliverable is, and how to judge whether it is acceptable. Those four answers determine the skeleton of both the front matter description and the body structure. For the design stage, follow these practices:
- Single responsibility. One skill solves one class of problem. Avoid “universal assistant” pileups, which make it hard for the model to tell when the skill should be used.
- Explicit steps. Write the flow as numbered steps, stating the input, action, and output of each step to leave less room for improvisation.
- Constraints up front and verifiable. Express naming conventions, directory structure, and forbidden patterns as checkable items rather than abstract slogans.
- Example-driven. Provide a set of input-output sample pairs; this usually works better than long adjective-heavy descriptions.
- Failure paths. Specify how to respond when information is insufficient, materials conflict, or the request exceeds the skill’s capability boundary, for instance asking a clarifying question instead of guessing.
- Lazy-load resources. Push long tables and long lists down to Level 3 files, keeping only an index and decision rules in the body.
A minimal body skeleton could be:
## When to Use## Input Requirements## Steps1. Parse the requirements document and extract feature points and acceptance conditions2. Generate the directory and component skeleton3. Apply templates/page.md to output the page4. Run the self-check list before delivery## Output Specification## Error Handling## Reference File Index
4. Two Typical Forms: Standalone Skills and Tool-Augmented Workflows
The first form is the standalone skill. It depends on no external system and completes the task with the model’s own capabilities plus bundled resources. It fits document generation, format conversion, and review-checklist execution, and it has the lowest adoption cost.
The second form is the tool-augmented workflow, where the skill orchestrates external capabilities at the instruction layer. Here it helps to decouple “capability access” from “process orchestration”: the underlying layer is supported by general cloud services, for example object storage holding templates and artifacts, a message queue for asynchronous decoupling, a container platform running long tasks, and logging plus monitoring and alerting for observability. The skill body only describes when to call, what to pass in, and how to validate the response. This keeps the skill readable and makes the underlying implementation easy to swap.
5. Testing, Iteration, and Distribution
Build a repeatable set of small test cases covering the happy path, boundary inputs, and invalid inputs, and focus on three things: whether the skill is triggered correctly, whether it follows the steps strictly, and whether the output passes the acceptance checklist. When iterating, adjust the front matter description first to calibrate triggering, then tune step granularity and example quality, and only consider splitting the skill as a last resort.
For distribution, give skills semantic versions and a change log, and include a statement of applicability boundaries when sharing within a team. When publishing to a broader community, provide a minimal runnable example and a clear directory description. The same methodology can be applied to Baidu AI Cloud practice, turning internal conventions into reusable skill assets.
In short, the value of a Skill is not making the model “smarter” but locking down deterministic processes. Master the three main threads, progressive disclosure, single responsibility, and verifiable constraints, and you can build your first stable, usable skill in roughly half an hour, then keep evolving it into a standardized team-level capability.
