Agent Skill Packaging: From SKILL.md to Reusable Workflows
This article explains how to turn repeated prompting work into reusable agent skills. It covers why ad hoc prompts are hard to version and review, how two-stage discovery keeps context costs low, how skill directories and priority overrides work, and how to build a minimal SKILL.md using release note generation as an example. It also outlines four ways to make a skill reliable, along with common pitfalls to avoid.
1. Why Prompts Need Engineering
Once intelligent coding tools and agent frameworks became widespread, teams started running into the same problem: for one requirement, different members write wildly different prompts; the same code review standard has to be pasted again in every new session; and repetitive tasks such as release notes, defect retrospectives, and API change summaries vary in quality depending on who happens to be doing them. Packing long instructions straight into the system prompt keeps occupying the context window, raises the cost of every single request, and makes the instructions hard to version, review, and reuse.
The way out is to separate “how the task should be done” from the model and the runtime, and turn it into an independent layer of instruction assets. The industry usually calls these assets skills: a reusable task description stored in a local directory, which describes its own purpose with structured metadata and then uses the body to define the steps, constraints, and output format for a certain kind of work. The key difference from a plugin is the boundary of responsibility — a skill answers “what process to follow,” while a plugin answers “what capability to add at runtime.” A skill does not need to register tools and is not tied to a specific implementation language; once loaded, it enters the current context as instruction text and can call existing capabilities such as file read/write, command execution, retrieval, or external service integration.
2. Loading Mechanism: Two-Stage Discovery Is the Core Design
Mature skill systems generally adopt a three-stage model of discover — index — load, and understanding it is essential for cost control.
The first stage is scanning and parsing. The runtime walks the agreed directories, reads the header metadata of each skill file, and extracts only the name and description into the session index. The second stage is matching and loading. When the task semantics match the description, or the user explicitly names the skill, the full body is finally injected into the context.
This progressive loading brings two direct benefits: everyday requests carry only very short index information, so context usage stays under control; and long instructions enter on demand, avoiding the situation where you “pay a context cost long term for a capability you use once in a while.” As a result, how well the metadata is written directly determines whether the skill can be triggered correctly, and how well the body is written determines whether the output is stable once it is triggered. Neither can substitute for the other.
3. Directories and Priority: Let Conventions Evolve With the Code
Where a skill is placed determines its visibility and override relationships. The common conventions are:
project/.dsh/skills/<skill-name>/SKILL.md # project level, committed with the repo.agents/skills/<skill-name>/SKILL.md # project level, shared across tools~/.dsh/skills/<skill-name>/SKILL.md # user level, personal everyday use~/.agents/skills/<skill-name>/SKILL.md # user level, shared across tools
Beyond the conventional directories, you can add more sources through a custom skill directory setting, which makes it easier to maintain shared standards in a separate repository. Priority is usually determined by scoring each source: project level beats a custom directory, and a custom directory beats user level; when two skills share a name, the one with the higher score wins. The practical value of this mechanism is “override what is closest” — a project can tighten general standards for its own tech stack without touching personal global configuration, and individuals can experiment locally without affecting anyone else.
Engineering advice: always put the project-level skill directory under version control and include it in code review, because it is the carrier of team conventions; keep only personal preferences in the user-level directory, to avoid creating hidden “environment differences.”
4. A Minimal Working Example: Release Note Generation
Skill names should use kebab-case, and the directory name should match the name in the metadata to reduce ambiguity when locating it. The minimal skeleton looks like this:
mkdir -p .dsh/skills/release-notetouch .dsh/skills/release-note/SKILL.md
---name: release-notedescription: Generate Chinese release notes for end users based on the code diff within a version range, covering changes, impact, and upgrade actionswhenToUse: When the user asks to compile a changelog, release notes, or an announcement---# Release Note Workflow1. Set the comparison baseline: read the commits and diffs between the current branch and the target tag.2. Categorize: new capabilities, defect fixes, compatibility changes, upgrade actions.3. Redact: remove internal implementation details, temporary branch names, addresses, and credentials.4. Mark anything uncertain as "pending maintainer confirmation"; never infer the impact scope on your own.5. Output about 300 characters of body text, plus one line of upgrade guidance.
This skeleton already contains four reusable elements: an explicit trigger condition, an executable sequence of steps, clear exclusions, and constraints on output length and structure. Missing any one of them noticeably degrades output stability.
5. From Usable to Stable: Four Refinements
First, make tacit experience explicit. Write judgment criteria such as “do not include internal details” and “mark anything uncertain” into the body, instead of relying on the model to figure them out.
Second, constrain the output contract. Specify section order, word count ranges, a glossary, and forbidden expressions, so the result can be consumed directly by downstream processes.
Third, control the context budget. Keep only the workflow and constraints in the body; long tables and template samples can be split into companion files in the same directory and read on demand.
Fourth, close the evaluation loop. Prepare a few typical inputs with expected outputs, and run regression checks after every change to the skill, so you avoid “fixing one scenario and breaking three others.”
6. Common Pitfalls
One is treating a skill as a plugin and trying to declare tool capabilities inside it, which ends in confused responsibilities. Another is writing metadata descriptions that are too vague, so the skill fails to trigger when it should and triggers when it should not. A third is heavy duplication across skills, which leads to drifting standards and should be consolidated through shared directories and override relationships. A fourth is letting the body grow without limit until it crowds the context and defeats the purpose of progressive loading.
7. Conclusion
The essence of the skill layer is turning team knowledge into instruction assets that can be versioned, reviewed, and reused. Master the directory conventions and priority overrides, get the division of labor between metadata and body right, and add regression evaluation, and a one-off prompt becomes a stable agent workflow. In engineering practice on cloud platforms such as Baidu AI Cloud, these instruction assets can also work with general capabilities like object storage, logging, and monitoring and alerting to form a research and development standard system that keeps evolving.
