Custom Skill Instructions for Reusable Agent Workflows

    Stable agent behavior requires more than ad hoc prompts. This article explains how to encode what to do, in what order, and what counts as done into reusable skill instructions. It covers the boundary between skills, models, and tools; `skill.md` front matter and discovery priority; writing principles; change-review and release-note examples; and how to test, govern, and evolve skills as team-owned working memory.

    Custom Skill Instructions for Reusable Agent Workflows

    Agents cannot reliably complete a class of work through improvised prompts alone. To help different team members and different sessions produce similar results, teams need to write down what to do, in what order to do it, and what counts as done as reusable skill instructions. A skill is not a new model or a new tool plugin. It is an instruction layer independent of both: the model handles understanding and generation, tools handle reading files, running checks, and submitting changes, and skills define boundaries, steps, and acceptance criteria.

    What Skill Instructions Solve

    In day-to-day engineering, code review criteria, commit message formats, release note structures, and incident review outlines often live in chat logs and verbal agreements. Re-describing them each time wastes context and makes it easy to miss security, compatibility, and rollback requirements. A skill turns these agreements into a local file: front matter states who the skill is for, when it applies, and when it does not; the body defines execution order and output style. Calling the skill by name is enough; no one has to paste a long prompt again.

    This design fits three common scenarios. First, high-frequency tasks with fixed steps, such as reviewing merge requests against a checklist. Second, document production with strong constraints, such as release notes that must include changes, impact, verification, and rollback. Third, putting team standards into practice, such as naming, error handling, log fields, and prohibited sensitive information. Skills are not a substitute for architecture decisions that require real-time judgment, and one-off experiments should not be written as global skills that pollute default behavior.

    Boundaries Between Skills, Models, and Tools

    Unclear layering is a common reason skills fail. A skill should describe task semantics and completion criteria. It should not bind itself to one model’s private capabilities or hard-code proprietary commands from a specific tool. When external actions are needed, express them as capability categories: read the repository, search symbols, run static checks, inspect logs, compare diffs. The runtime maps these intents to authorized tools. This makes it possible to keep most of the skill body when models change or toolchains are adjusted.

    Do not promise interfaces, parameters, or performance metrics that do not exist. If the environment cannot run tests, require the agent to list suggested verification items rather than inventing a claim that tests “passed.” If the agent has no write permission, require patch suggestions and risk notes rather than claiming that changes were submitted.

    File Shape and Metadata

    Each skill should have its own directory. The core is a skill description file, with skill.md as a conventional name. The file starts with YAML front matter and uses Markdown for the body. Keep front matter short and searchable, and keep the body executable.

    A schematic example:

    1. ---
    2. name: change-review
    3. description: Review code changes against the team checklist and output required fixes and suggestions
    4. when_to_use: Pre-merge review, diff review after a large refactor
    5. when_not_to_use: Product pricing, permission approval, production change execution
    6. inputs:
    7. - Change description
    8. - Diff scope or related paths
    9. outputs:
    10. - Issue list sorted by severity
    11. - Uncovered verification items
    12. version: "1.2.0"
    13. ---

    Use name as a stable short identifier and avoid drift from the directory name. description should state the result in one sentence rather than piling up adjectives. when_to_use and when_not_to_use are equally important: the latter prevents the skill from being misapplied to release execution, account operations, or other out-of-scope tasks. inputs lists the materials the agent must receive before starting; if inputs are missing, the agent should ask rather than guess. outputs fixes the deliverable shape so humans can spot-check results. version should follow semantic versioning: patch versions for typo and example fixes, minor versions for new checks, and major versions for changes to output structure or scope.

    The body should usually have five fixed sections: Goal, Pre-checks, Execution Steps, Output Template, and Stop Conditions. Stop conditions include insufficient information, changes outside authorized paths, suspected secrets or personal data, and requests to bypass checks. When a stop condition is hit, report only the reason and the information needed to proceed; do not continue rewriting code.

    Discovery Scope and Priority

    Skills must be easy to find without letting personal habits override team baselines. A common approach uses three levels:

    1. Project level: stored in an agreed directory inside the repository, evolving with code review and releases, expressing the repository’s build, branch, and release constraints.
    2. User level: stored in a developer’s local personal directory, containing only editor preferences, common explanation styles, and other habits that do not affect team acceptance.
    3. Custom directories: explicitly added by the team in startup configuration, used for cross-repository platform standards such as log fields, error code ranges, and API compatibility strategy.

    Priority should be written into team agreements and kept simple: project level overrides user level; security and compliance clauses marked as mandatory in custom directories cannot be weakened by any local skill. When skills with the same name exist at multiple levels, the loader should report the source of the conflict rather than silently choosing one. Discovery should scan only agreed directories, not the entire disk, to avoid treating drafts, backups, and unrelated documents as skills.

    In enterprise environments, project-level skills can follow the repository permission model: those who can merge standards can update skills. If a team uses Baidu AI Cloud or similar cloud development and hosting services to host repositories, skill files remain plain text and follow the repository’s branch protection and audit controls; they do not depend on an additional proprietary interface.

    Writing Principles

    One skill should do one type of work. Review and fix can be separate skills: the former only reports problems, while the latter modifies code against an issue list after explicit authorization. When they are mixed, an agent may review and broadly rewrite at the same time, making the result hard to verify.

    Steps should be observable. Each step should state its input, action, and completion criterion. For example, the completion criterion for “read the diff” is the ability to list changed modules and external behavior changes, not “understand the code.” If an existing repository standard can be referenced, do not copy the full standard into the skill. Keep the reference path and mandatory items to avoid maintaining two copies.

    Examples should be short and fictional. Use fictional module names and paths to demonstrate output, and avoid real customer data, key samples, or internal domains in skills. Show both acceptable and unacceptable examples so the agent can align with the format more easily.

    Use positive constraints. “Must list unexecuted verification” is easier to check than “do not miss tests.” For security, state prohibitions clearly: do not output passwords, tokens, or connection strings; do not recommend disabling authentication to pass checks; do not expand file read and write scope.

    Example 1: Change Review

    The goal is to provide actionable review comments before merge, not to rewrite the business logic. Pre-checks confirm that a change description, diff scope, and related module paths are available. Steps can be: summarize behavior changes first; then check six dimensions—correctness, compatibility, error handling, observability, security, and testing; finally classify issues as “blocking” or “suggested.”

    Blocking items include only issues that cause incorrect results, data corruption, permission expansion, sensitive data leakage, or inability to roll back. Suggested items include naming, duplicated logic, and performance optimizations that can be deferred. The output template is fixed: Conclusion (pass, conditional pass, fail), Blocking List, Suggested List, and Unverified Items. If tests were not run, “tests not executed” must appear in unverified items; it must not be written as passed.

    Stop conditions: the diff touches production configuration without a change window description; a suspected secret appears; or the task asks to ignore security checks. In these cases, the skill ends with a risk description.

    Example 2: Release Notes

    The goal is to organize merged changes into consistent notes for external or internal readers. Inputs include the version number, change list, and affected modules. Steps are: merge similar items; separate features, fixes, and breaking changes; for each breaking change, state the affected audience, migration approach, and rollback points; list executed and unexecuted verification; and do not exaggerate unproven performance changes.

    Use fixed headings: Version, Summary, Breaking Changes, Other Changes, Verification, and Rollback. When there are no breaking changes, write “None” explicitly so readers do not assume an omission. For data changes, require a statement on whether the change is re-entrant and whether a backup is needed, but do not provide unconfirmed operational commands.

    Validation, Permissions, and Evolution

    Skills themselves should be tested. A minimal validation set includes: Does the agent ask for missing inputs? Does it stop on out-of-scope requests? Does the output match the template? Are mandatory clauses overridden by user-level skills? Use a fixed set of fictional diffs for regression and compare structure rather than literal sentences. Review skill files as you would review code: explain why checks were added or removed, which repositories are affected, and how to migrate from the old version.

    Permissions should follow least privilege. Project-level skills can read repositories and agreed documents by default. Writing files, running checks, and creating merge requests must be separately authorized by the runtime and declared in the skill as “only after user confirmation.” Skill text must not store credentials. Updates to shared directories should go through review so a personal commit does not become the default behavior for everyone.

    Keep a change log during evolution: date, version, change summary, and breaking points. Deprecate a skill by marking its replacement first, then remove it after one release cycle so old sessions do not suddenly fail. Periodically delete skills that are unused, conflict with current standards, or are too vague to verify. The quality standard is not the number of files, but whether results for the same type of task become more predictable and whether rework decreases.

    Rollout Order

    Start with a task that is done every week and already has oral acceptance criteria. Write it as a project-level skill and trial it with two or three real but desensitized examples. Collect deviations: missed blocking items, unnecessary improvisation, and incorrect stops. Fix the skill, then copy it to a custom directory for other repositories to reference. Personal preferences should always remain at the user level and must not lower project-level security and compatibility requirements.

    With this layering, skill instructions become the team’s working memory: models can change, tools can be added or removed, and steps, boundaries, and acceptance remain constrained by the same reviewable text. This is closer to engineering practice than repeating standards in every session, and it is easier to audit and hand off.