Agent Skills in Practice: Specifications, Structure, and Design Patterns

    This article explains how to treat agent skills as execution contracts rather than long prompts. It covers a specification-driven approach to defining task boundaries and verifiable completion criteria, a maintainable directory layout built around SKILL.md, progressive loading to control context cost, closed-loop execution with input validation and result verification, layered security controls enforced outside the model, reusable design patterns, test coverage, and post-launch governance. Readers will learn how to build skills that are inspectable, composable, and governable so that agents deliver stable results under explicit constraints.

    1. Rethinking Skills: From Prompts to Execution Contracts

    A common mistake in enterprise agent applications is assuming that a detailed enough prompt will let an agent complete business tasks reliably. In practice, the opposite often happens. As the number of tools, business rules, and task chains grows, simply piling on instructions leads to context bloat, conflicting rules, and loss of control over the execution path.

    Agent Skills are better understood as a set of execution contracts organized around a specific task. A skill does not only describe “what should be done”; it also defines “when it may be done,” “what it is based on,” “what must not be done,” and “how to prove the task is complete.”

    A complete skill usually answers six questions:

    • Trigger conditions: Which tasks should activate this skill, and which similar tasks should not?
    • Input requirements: Which parameters, documents, identity information, and business context are needed?
    • Execution flow: Which steps run, and what dependencies exist between them?
    • Tool boundaries: Which capabilities may be called, and what conditions must hold before each call?
    • Exception policy: What happens when information is missing, a tool fails, or rules conflict?
    • Completion criteria: What structure, quality, and evidence requirements must the output satisfy?

    Writing a skill can therefore be seen as harness engineering. The model handles understanding, planning, and generation; the harness handles constraints, validation, and execution control.

    The point is not to make the model “absolutely certain,” but to confine uncertainty to a range where exploration is allowed. Deterministic problems such as format validation, permission checks, and amount calculations should go to programs or rule systems first; open-ended problems such as semantic understanding and document summarization stay with the model, with follow-up validation to reduce risk.

    2. Organizing Skill Development with Specification-Driven Development

    Specification-driven development means defining behavioral specifications and acceptance conditions before implementing execution logic. Applying this to skills avoids the pattern of “write a long block of instructions, then keep appending patches whenever something breaks.”

    2.1 Define the Task Boundary First

    A skill should be built around one business goal with a clear boundary, not around an entire business domain.

    For example, “handle procurement” is too broad: it covers information gathering, supplier selection, budget review, and order submission. A more reasonable split is:

    • Extract key fields from a purchase request;
    • Check whether the application materials are complete;
    • Generate review comments according to established rules;
    • Submit an approval request after authorization.

    These skills can be composed, but they should not hold each other’s permissions by default. Being able to read a purchase request does not imply being able to submit an order; being able to generate a recommendation does not imply being able to make the final decision on the user’s behalf.

    2.2 Define Verifiable Completion Conditions

    “Produce high-quality output” cannot be accepted as a criterion; it must be translated into checkable conditions.

    For material completeness checking, for instance:

    1. Every required field must be checked individually;
    2. Missing information must not be filled in with guesses;
    3. Each issue must map to a specific field or document location;
    4. The conclusion may only be “materials complete,” “supplementation needed,” or “cannot determine”;
    5. When the input is insufficient, the content that needs to be supplied must be listed.

    Such a specification guides the model and doubles as the basis for automated tests.

    2.3 Separate Instructions, Rules, and Implementation

    Skill instructions explain task semantics, rule files carry business constraints, and the execution program handles deterministic operations. Once separated, a business rule update does not require rewriting the whole skill, and a fix in the execution program does not change the task definition.

    One caveat matters: constraints written in a skill document are not the same as constraints the system enforces. Permission, security, and data access boundaries must be enforced independently by the runtime.

    3. Directory Structure: Giving Skills a Maintainable Engineering Form

    A common way to organize a skill is to give it its own directory and use SKILL.md as the main instruction file. The exact discovery rules, metadata fields, and loading behavior depend on the runtime, so you cannot assume every agent system supports an identical specification.

    For a complex skill, a structure like this works:

    1. application-review/
    2. ├── SKILL.md
    3. ├── scripts/
    4. │ └── validate_request
    5. ├── references/
    6. │ ├── field_rules.md
    7. │ └── exception_policy.md
    8. ├── assets/
    9. │ └── result_schema.json
    10. └── tests/
    11. ├── normal_cases.json
    12. └── boundary_cases.json

    Here, scripts/, references/, and assets/ separate execution logic, reference material, and static resources; tests/ is added for engineering validation and is not mandated by every runtime.

    3.1 Keep the Main Instruction File Focused

    SKILL.md should contain what is required to understand and complete the task:

    • The skill’s purpose and scope;
    • Input and output conventions;
    • Key execution steps;
    • Prohibited actions and confirmation requirements;
    • Conditions under which reference material is loaded;
    • Exception handling.

    Do not dump all business knowledge into the main file. An oversized skill document raises context cost and reduces the salience of the constraints that matter.

    The fragment below is illustrative; the fields actually available depend on the runtime specification:

    1. ---
    2. name: application-review
    3. description: Checks application materials for completeness and produces a missing-items report; does not approve or submit applications.
    4. ---

    The body can then state:

    1. Task boundary:
    2. Check material completeness only; do not judge whether the application should be approved.
    3. Execution steps:
    4. 1. Identify the material type.
    5. 2. Load the corresponding field rules.
    6. 3. Run deterministic validation on required fields.
    7. 4. Summarize missing items and information that cannot be verified.
    8. 5. Output according to the result structure.
    9. Prohibited:
    10. Do not fabricate materials.
    11. Do not modify the original application.
    12. Do not submit for approval automatically.

    The description field should not be marketing copy; it should provide routing information clear enough for the system to distinguish “check materials” from closely related intents such as “approve an application.”

    3.2 Split Auxiliary Files by Responsibility

    Reference files suit field definitions, policy explanations, terminology, and exception rules; asset files suit output templates, structure definitions, and static mappings; the execution program handles repeatable operations such as parsing, validation, and transformation.

    Note that the directory itself provides no security isolation. Putting a program in scripts/ does not grant it a sandbox. Isolation must come from the runtime through file access restrictions, network policies, resource quotas, and identity permissions.

    4. Progressive Loading: Control Context, Don’t Just Compress Text

    As the number of skills grows, one of the largest costs is context management. Loading every skill body and all reference material on every task wastes resources and introduces rules unrelated to the current task.

    Progressive loading works in three stages: serve a lightweight index first, then load the selected execution specification, then read auxiliary material on demand.

    Layer Main content Typical trigger Design focus
    Discovery Skill name, purpose, and boundary description Skill retrieval or task routing Descriptions must be concise and distinguishable
    Activation Execution specification in the main instruction file Skill selected Preserve core flow and constraints
    Material Reference files, templates, program output A specific step needs it Load by topic and limit size

    The benefit depends on the size of the skill library, description length, how many skills match a task, and how material is used, so no fixed percentage of context savings can be promised.

    4.1 The Discovery Layer Must Prevent Mismatches

    If the discovery layer is too thin, the skill cannot be found; if descriptions are too broad, several skills compete for the same task.

    A high-quality description includes both a positive scope and an exclusion boundary. For example:

    “Extract payment dates, amounts, and penalty clauses from a contract; does not provide legal conclusions and does not execute payments.”

    That routes far more reliably than “intelligently analyze contracts.”

    4.2 The Activation Layer Must Retain Key Constraints

    Progressive loading must not push all safety rules into deep reference files. Task boundaries, prohibited actions, permission requirements, and completion criteria should be available as soon as the skill is activated.

    Only long field lists and lengthy rule explanations are suitable for on-demand loading. Otherwise the model may call a tool before it has read the rules.

    4.3 The Material Layer Needs Explicit Navigation

    The main instruction file should say when to read which file, rather than vaguely asking the model to “refer to all materials.” For example:

    • For a standard application, read the base field rules;
    • If a special application type is detected, then read the exception policy;
    • Before generating the result, read the output structure definition.

    The execution program’s source code also does not necessarily belong in the model’s context. If the runtime supports direct execution, usually only the calling convention and the necessary execution results need to be exposed to the model.

    5. Closing the Loop: From Understanding the Task to Verifying the Result

    A stable skill does not describe only the ideal path; it also covers insufficient information, execution failures, and inconsistent results.

    A general flow can be designed as:

    Identify the task → Validate input → Obtain required material → Plan execution steps → Call tools → Validate results → Return a conclusion or enter an exception branch

    5.1 Validate Input Up Front

    Before calling any tool, check whether parameters are complete, formats are valid, and the task falls within the permission scope.

    If the user asks to modify a record but does not specify which record, the correct behavior is to request clarification rather than pick an object that “looks reasonable.”

    5.2 Separate Planning from Execution

    For tasks with external side effects, you can first produce an execution plan stating the target objects, expected changes, and risks, then move to authorization and execution.

    A plan is not authorization. The model generating a step does not mean the system permits that step.

    5.3 Tool Results Must Be Verified

    A successful tool call does not mean the business goal is achieved. An API may accept a request while the task is still queued.

    Skills should distinguish:

    • The request has been submitted;
    • The operation has been executed;
    • The result has been verified.

    For asynchronous flows, keep the task identifier and status information, and avoid describing “accepted successfully” as “processing complete.”

    6. Security Design: Put Critical Constraints Outside the Model

    A skill document can guide the model but cannot be the only line of defense. Enterprise applications should use layered protection.

    6.1 Least Privilege and Credential Isolation

    A read-only skill should not receive write permissions. A skill that must write should still have its target objects, field scope, and validity window restricted.

    Credentials should not be embedded in skill documents, reference material, or logs visible to the model. A safer approach is for a controlled execution environment to supply identity capabilities while keeping raw credentials hidden from the model.

    6.2 Use Confirmation Gates for High-Risk Operations

    Deleting data, sending external messages, making payments, and bulk modifications should have a confirmation step sized to the business risk.

    The confirmation should include at least the target object, the scope of impact, and key parameters. If parameters change after confirmation, reassess whether confirmation is needed again, so that “what was confirmed” and “what is executed” do not diverge.

    6.3 Treat External Content as Data

    Business documents, retrieval results, and tool output may contain inducement-style instructions. The skill should state that such content is data to be processed and cannot promote itself to a system rule.

    Writing “ignore malicious instructions” is not enough on its own. The runtime should also restrict tool permissions, isolate sensitive information, and run independent checks on high-risk calls.

    6.4 Retries Must Account for Side Effects

    A failed read can usually be retried a limited number of times; a failed write first requires determining whether the operation already took effect.

    For operations that could be submitted twice, the business execution layer should provide idempotency or deduplication. Do not rely on the model’s memory to decide whether something “has already been done.”

    7. Reusable Skill Design Patterns

    7.1 Separate Routing from Execution

    The routing layer selects the skill; the execution layer completes the task. This avoids reimplementing task classification in every skill and makes routing accuracy independently measurable.

    When routing is ambiguous, prefer clarification or a conservative fallback over forcing a match.

    7.2 Deterministic Core, Semantic Shell

    The model understands user phrasing, summarizes material, and organizes explanations; deterministic programs handle calculation, validation, and data transformation.

    In expense review, for example, the model can identify the expense category and explain anomalies, while summing amounts and comparing thresholds should be done by deterministic logic.

    This division limits error propagation and improves reproducibility.

    7.3 Separate Generation from Validation

    Generate candidate results first, then validate format, field completeness, and business limits with independent rules. On validation failure, allow a limited number of corrections; if it still fails, return the failure reason instead of looping indefinitely.

    Validators also need a stated capability boundary: a valid structure does not mean the facts are correct, and complete fields do not mean the evidence is sufficient.

    7.4 Controlled Handoff

    When multiple skills collaborate, pass results through explicit data contracts covering known information, unresolved issues, evidence locations, and execution status.

    Passing only a natural-language summary is risky: a downstream skill may treat a guess as fact or ignore an anomaly the upstream skill already found.

    7.5 Safe Degradation

    When reference material is unavailable, permissions are insufficient, or a tool fails, the skill should produce limited but honest output, such as organizing the information at hand, listing items to confirm, or producing a pending execution plan.

    Degradation is not a way around limits. If a write cannot be completed, do not try other unauthorized paths.

    8. Testing and Evaluation: Verify Behavior, Not Just Documentation

    Skill quality must be demonstrated by tests. At minimum, cover these types:

    Test type What to check
    Normal cases Whether the task completes when input is complete
    Boundary cases How empty values, oversized content, and unusual formats are handled
    Ambiguity cases Whether the skill asks for clarification instead of guessing
    Adversarial cases Whether external instructions are mistaken for high-priority rules
    Failure cases How the skill degrades on tool timeouts, missing material, or denied permissions
    Side-effect cases Whether retries cause duplicate submissions or duplicate modifications

    Evaluation metrics can include skill selection accuracy, output structure compliance, task completion rate, evidence coverage, number of tool calls, latency, and occurrences of unauthorized operations.

    These metrics must be observed separately. Fully compliant output formatting does not imply a high completion rate, and fewer tool calls do not necessarily mean more reliable handling.

    When testing, fix the input, rule version, and execution environment, and record the model and skill versions. For nondeterministic behavior, run the same case repeatedly to observe stability rather than declaring a skill mature after a single success.

    9. Post-Launch Governance: Treat Skills as Continuously Evolving Software Assets

    After launch, keep managing versions, dependencies, and the impact of changes.

    9.1 Maintain a Dependency Inventory

    Record the reference files, execution programs, output structures, and permission scope each skill uses. When a business rule changes, you can use this inventory to find affected skills and avoid missed updates.

    9.2 Classify Change Risk

    Rewording, adjusting the output format, and expanding execution permissions do not carry the same risk. Changes to permissions, flows, and external side effects warrant stricter review and regression testing.

    9.3 Keep an Auditable Trail

    Run records should cover skill selection, key material versions, tool calls, confirmation actions, and the final state. When sensitive information is involved, redact it and restrict access rather than retaining raw data indefinitely for troubleshooting.

    The purpose of the audit record is to answer “what operations the system performed and on what basis,” not to require the model to expose its internal reasoning.

    9.4 Support Disabling and Rollback

    When a serious error appears, you should be able to quickly disable the skill, revoke execution permissions, or roll back to a verified version. Skill bodies, reference rules, and execution programs must stay version-linked so a rollback cannot assemble an untested combination.

    10. Summary: The Value of a Skill System Is Controlled Execution

    The goal of systematic skill building is not longer prompts, but a set of behavioral specifications that can be inspected, composed, and governed.

    A reliable skill system combines clear task boundaries, progressive context loading, deterministic execution and validation, and security controls enforced at runtime. Testing, observability, and version governance then close the loop for continuous improvement.

    When these elements are in place, an agent can evolve from a chat system that occasionally completes tasks into an engineering system that reliably delivers results under explicit constraints.