Writing Agent Skills: A Practical Guide to Building High-Quality Skills

    This article explains why writing Agent Skills should be treated as a small engineering activity rather than a one-off documentation task. It walks through the physical folder structure of a Skill, how to write metadata and instructions that improve routing accuracy, how to build meta-skills that help author and validate other Skills, and how to verify and iterate with measurable metrics. Common anti-patterns are listed at the end to help you avoid them.

    1. Why Writing a Skill Should Be an Engineering Activity

    The core value of Agent Skills is to capture reusable task experience: instructions, scripts, and reference material are organized into a conventional folder that an agent discovers and loads at runtime as the task requires, extending capability boundaries without changing the underlying model. In practice, most people hit three problems the first time they write a Skill:

    1. Unclear boundaries — a large, all-in-one workflow is squeezed into a single file.
    2. Vague instructions — natural language says a task should be “done well,” with no verifiable conditions.
    3. No validation — the Skill ships as soon as it is written, and nobody can answer whether it actually takes effect.

    For this reason, writing a Skill should be treated as a small engineering activity with five stages: requirements analysis, structural design, implementation, validation, and iteration. Engineering it is the prerequisite for a higher success rate.

    2. The Physical Structure of a Skill: Convention Over Configuration

    A Skill is simply a folder that must contain an entry file (usually named SKILL.md); everything else is optional resources. A typical structure looks like this:

    1. pdf-skill/
    2. ├── SKILL.md # Metadata and core instructions (required)
    3. ├── forms.md # Form-filling guide (optional)
    4. ├── reference.md # Detailed interface/field reference (optional)
    5. └── scripts/
    6. └── extract_fields.py

    Three design points matter here. First, keep the entry file lean — it should only say when to use the Skill, what it does, and which steps to follow. Second, push long field tables and error-code tables down into reference documents so they load only on demand and save context. Third, hand deterministic operations to scripts and let the model handle judgment and orchestration, rather than making it “mentally compute” parsing logic.

    3. Metadata and Instructions: What Determines Hit Rate

    The header metadata of the entry file usually contains the name and description. The description is not an introduction — it is the basis for routing. The agent uses it to decide whether the current task falls within the Skill’s scope. So the description should state the trigger scenario, the shape of the input, and the output artifact, and avoid undecidable phrasing such as “used for processing documents.”

    The instruction body is best written in a three-part pattern: conditions, steps, and acceptance criteria.

    1. ---
    2. name: form-filling
    3. description: Use when the user provides a structured form and a source document and asks for automatic filling and field validation; the output is a form file with validation results.
    4. ---
    5. ## Conditions
    6. - The input includes a source document and a blank form
    7. - Field-by-field checking is required rather than free generation
    8. ## Steps
    9. 1. Call scripts/extract_fields.py to extract candidate values
    10. 2. Align them using the field mapping table in reference.md
    11. 3. Mark missing fields as pending confirmation; do not guess
    12. ## Acceptance criteria
    13. - Every required field has a value or is explicitly marked
    14. - The output passes the built-in format validation

    Negative constraints such as “do not guess” and “mark as pending confirmation” often stabilize quality better than positive descriptions alone.

    4. Using a Skill to Write Skills

    Around the need to “assist in writing Skills,” common industry practice can be summarized as four general capabilities, which you can implement yourself as meta-skills:

    1. Scaffolding generation: produce a folder skeleton and an entry-file template from a one-line requirement, with consistent naming and fields.
    2. Spec validation: check whether the metadata is complete, whether the description is decidable, whether referenced paths exist, and whether scripts come with execution instructions.
    3. Instruction review: identify vague wording, missing acceptance criteria, and non-executable steps, and provide rewrite suggestions.
    4. Test case generation: derive positive and negative inputs from the description to verify triggering and execution.

    A minimal validation script might look like this:

    1. import re, pathlib, sys
    2. def check(root: pathlib.Path) -> list[str]:
    3. entry = root / "SKILL.md"
    4. errs = []
    5. if not entry.exists():
    6. return ["SKILL.md is missing"]
    7. text = entry.read_text(encoding="utf-8")
    8. if not re.match(r"^---\n.*?\n---\n", text, re.S):
    9. errs.append("Header metadata is missing")
    10. if "description" not in text:
    11. errs.append("description is missing; routing is impossible")
    12. for ref in re.findall(r"\]\(([^)]+\.md)\)", text):
    13. if not (root / ref).exists():
    14. errs.append(f"Referenced file does not exist: {ref}")
    15. return errs
    16. if __name__ == "__main__":
    17. errs = check(pathlib.Path(sys.argv[1]))
    18. print("\n".join(errs) or "OK")

    5. Validation and Iteration: Turning Subjective Impressions into Observable Metrics

    Keep a minimal test set for each Skill covering typical inputs, boundary inputs, and inputs that should be rejected, and record trigger accuracy, step completion rate, and the number of manual rework rounds. When a Skill needs to handle large batches of tasks or integrate with common cloud product categories such as container platforms, object storage, logging services, and monitoring/alerting, execution results can be collected uniformly to form a sustainable, observable iteration loop.

    6. Common Anti-Patterns

    • A single file carrying too many responsibilities, causing context bloat and lower hit rate;
    • A description written as marketing copy, with no trigger conditions;
    • Scripts without dependency or usage notes, failing frequently at execution time;
    • Testing only positive cases, never the “should not trigger” scenarios;
    • No version history, so changes cannot be rolled back.

    In short, the key to writing a good Skill is not polished wording but clear boundaries, decidable instructions, loadable resources, and verifiable results. With this method in hand, you can reliably produce high-quality skills whether or not you use assisted generation.