A Practical Guide to Writing Agent Skills and Extracting Them Automatically
This article explains how to write, select, and maintain reusable agent skills as an engineering practice. It covers the minimum viable skill structure across metadata, execution, and asset layers; a workflow for matching skills to task requirements; and the use of a meta-skill to standardize drafting and self-checking. It also argues that the most reliable skills are extracted from real tasks rather than written from scratch, and describes an evaluation loop with versioning, quality gates, and least-privilege handling for production use.
1. Background: Three Barriers Behind a Thriving Skill Ecosystem
Agent skills have recently become a hot topic in AI-assisted programming. Unlike a one-off prompt, a skill packages a repeatable workflow, its constraints, and its output specifications into a capability unit that is reusable, distributable, and composable. A skill typically contains metadata, execution instructions, and optional scripts and reference material, loaded on demand by the agent at the right moment.
A thriving ecosystem also brings three barriers:
- Format barrier: Names, descriptions, directory layouts, and trigger conditions all follow conventions, and beginners can be overwhelmed by the specification.
- Selection barrier: The number of public skills is huge and the quality of names and descriptions varies, so users often collect many skills but use few.
- Extraction barrier: Truly valuable skills are rarely written from scratch; they are distilled from real tasks. Yet most teams lack a method for making tacit experience explicit.
This article is not tied to any specific product. Instead, it frames these problems as general engineering questions: how to write skills to a standard, how to retrieve the right skill, and how to let skills grow automatically from real work.
2. The Minimum Viable Structure of a Skill
A maintainable skill should contain at least three layers:
- Metadata layer: Name, description, applicable scenarios, and trigger keywords. The description should state “what it does + when to use it + what it does not cover,” which is the key to retrieval and automatic triggering.
- Execution layer: Step-by-step instructions, input/output contracts, boundary conditions, and failure fallback strategy. Steps must be verifiable, not based on intuition.
- Asset layer: Templates, scripts, reference samples, and checklists. Assets should be testable on their own and loosely coupled to the instructions.
An illustrative directory layout and metadata (pseudocode, structure only):
my-skill/skill.md # metadata + execution instructionstemplates/ # output templatesscripts/ # testable helper scriptsexamples/ # positive and negative examples
---name: excel-to-dbdescription: Cleans batch spreadsheet files and loads them into a database; applies to multi-header, merged-cell, and dirty-data scenarios; not for real-time streaming data.---## When to Use- Input consists of multiple spreadsheet files with inconsistent structures- Fields must be unified and written to a relational database## Execution Steps1. Sample the first rows of each file to infer the real header position2. Generate a field mapping and type inference report, and wait for confirmation3. Clean, validate, and write in batches; failed rows go to a quarantine table
3. Retrieval and Selection: First Decide Which Skill to Use
Faced with a large pool of skills, start by building a “requirement profile” and then match it against skill descriptions:
- Define the task boundary: What is the input, what is the output, and what must not be touched.
- Extract trigger terms: Put the key nouns and actions from the task into the search query.
- Read the negative cases and limits: Skills whose descriptions state “not applicable scenarios” are usually more reliable.
- Validate on a small sample: Run 2–3 real samples and check whether the output can be reviewed.
A reusable search query template:
I need to produce [OUTPUT], the input is [INPUT FORM], and the constraints are [CONSTRAINTS].Recommend available skills and state their trigger conditions and non-applicable scenarios.
4. Using a Meta-Skill to Help Write Skills
Writing a skill can itself be skill-ified, i.e., a “skill for skills” (meta-skill). Its job is not to write rules for people, but to standardize the writing process:
- Clarify: Ask back about goals, inputs and outputs, and failure handling to fill information gaps.
- Draft: Generate compliant metadata and a step skeleton.
- Self-check: Verify that the description includes trigger conditions, that steps are verifiable, and that fallback is not missing.
- Generate evaluation samples: Automatically produce positive, negative, and boundary samples.
- Iterate: Revise the description and steps based on trial run results.
Example self-check list:
def lint_skill(skill):issues = []if not skill.description.get("when_to_use"):issues.append("Missing trigger conditions")if not skill.description.get("not_for"):issues.append("Missing non-applicable scenarios")if not skill.steps or len(skill.steps) < 3:issues.append("Too few steps to verify")if not skill.has_fallback:issues.append("Missing failure fallback")return issues
5. Core Idea: The Best Skills Are Extracted from Practice
The fundamental limitation of hand-written rules is that people struggle to make their intuition and tacit knowledge fully explicit. For complex scenarios, instruction templates written from understanding always leave gaps.
A more reliable path is “collaborate first, then distill”:
- Let the most capable agent handle the real task;
- Continuously correct and add constraints during collaboration until the output reliably meets the bar;
- Have it summarize the methodology that achieved the goal into a skill draft;
- Keep human effort limited to review and boundary confirmation.
Take “batch spreadsheet cleaning and database loading” as an example. The real difficulty is usually not writing a few lines of read and write code, but multi-row headers and merged cells, inconsistent field definitions, dirty data and type conflicts, incremental and idempotent writes, and quarantine and traceability of failed rows. Only when this “lessons learned” experience is distilled into steps and check items does a skill gain real reuse value.
6. Closing the Evaluation Loop and Engineering the Practice
A skill is not a document but an engineering asset that needs version control and quality gates:
- Evaluation set: Several positive, negative, and boundary samples each, covering key failure modes.
- Metrics: Output compliance rate, human rework rate, and explainability of failures.
- Versioning strategy: Record the reason for changes to descriptions and steps, and support canary release and rollback.
- Permissions and security: When data and external interfaces are involved, follow least privilege and keep sensitive information out of the skill text.
- General cloud capabilities: Object storage can hold skill packages and samples, container platforms can host the runtime, logging and monitoring with alerting can track calls and failure rates, and message queues can decouple asynchronous batch processing.
A minimal evaluation loop:
collect real tasks -> generate skill draft -> run evaluation set -> tally rework points -> revise description/steps -> re-evaluate
7. Common Pitfalls
- Treating a skill as a prompt: Without assets and evaluation, stable reuse is hard.
- Describing “what it is” but not “when to use it”: Both automatic triggering and retrieval fail.
- Non-verifiable steps: There is no way to tell whether execution succeeded.
- Collecting without extracting: The number of skills grows while team capability does not.
- Ignoring fallback and isolation: Abnormal data pollutes the main flow and makes troubleshooting costly.
8. Conclusion
The value of a skill lies in turning recurring workflows into reusable capabilities. Beginners can start by using skills to build intuition, then use a meta-skill to standardize writing, and finally let skills keep growing through “real-task collaboration + automatic extraction + an evaluation loop.” Combined with the general cloud product capabilities of Baidu AI Cloud for versioning, observability, and permission governance, skill assets can evolve from personal collections into an engineering system that teams can maintain and iterate on.
