Building Reusable Agent Workflows: A Guide to Instruction-File-Driven Task Orchestration

    In LLM-driven development and operations, teams need a lightweight way to turn team conventions, code review processes, and release templates into repeatable workflows. This article explores how to build reusable AI Agent workflows using custom instruction files: Markdown files with YAML metadata define task steps and methodology, while capability plugins extend runtime tools. It explains the three-phase loading mechanism of discovery, catalog, and loading, discusses directory structure and priority design, and demonstrates a release-note generation workflow. It also covers engineering best practices such as negative constraints, CI/CD integration, and treating workflow definitions as versioned code.

    In today’s LLM-driven software development and operations, AI Agents are moving beyond simple Q&A assistants and becoming workflow engines that participate deeply in engineering practice. A common pain point is how to turn team conventions, code review processes, or release-note templates into reusable, repeatable workflows. Traditional approaches often depend on complex code development or hardcoded prompts. This article explores an instruction-file-driven orchestration approach: define reusable task instructions in Markdown files to build lightweight, highly reusable Agent workflows.

    1. Two Layers: Task Instructions vs. Capability Plugins

    Before discussing workflow construction, it is important to distinguish two core concepts: task instructions and capability plugins.

    Task instructions define steps and methodology. A task instruction is essentially a reusable instruction set stored in a local directory. It uses YAML metadata to describe trigger conditions and purpose, and uses a Markdown body to specify the steps and standards the Agent should follow. Task instructions do not require compiled code such as TypeScript and do not register new functions or tools at runtime. When loaded, the Markdown body is injected directly into the current Agent context and guides the Agent to use existing basic tools such as file system access, shell commands, and full-text search.

    Capability plugins define runtime capability boundaries. The plugin mechanism extends what an Agent can physically do. If the Agent lacks a capability—for example, accessing an external API or operating on a specific database—a plugin is needed to register new tool interfaces.

    In short, the instruction layer is the “thinking logic of the brain,” while the plugin layer is the “physical extension of hands and feet.” Decoupling the two lets developers focus on orchestrating complex tasks in natural language, without getting involved in low-level code compilation and deployment.

    2. Loading Mechanism: A Three-Phase Design Based on Context Cost

    In large projects, teams may accumulate dozens or even hundreds of custom workflows. Injecting all instructions into the Agent context at once consumes many tokens and can also split the model’s attention, reducing inference quality. That is why mainstream AI coding tools commonly adopt a three-phase “discovery, catalog, loading” mechanism.

    Discovery phase. At startup, the system scans predefined directory structures and parses the YAML metadata of each instruction file. This phase extracts only filename, description, and applicable scenarios—not the body content.

    Catalog phase. The extracted metadata forms a lightweight “session catalog.” In daily requests, the Agent’s context only has to carry this short catalog. This keeps the Agent aware of all available workflows while maintaining a very low context cost.

    Loading phase. When the current task matches a workflow’s applicable scenario, or when the user explicitly invokes the workflow, the system loads the complete Markdown body into the current context. This on-demand loading is key to balancing capability richness and inference efficiency.

    3. Directory Structure and Priority Design

    To support both project isolation and personal preference, instruction files can be placed in multiple levels:

    Project-level directory. The best location for version control with project source code is .dsh/skills in the project root, or the cross-tool shared path .agents/skills. This ensures that everyone who pulls the project gets the same workflow definitions.

    User-level and custom directories. Personal common workflows can be placed in the user home directory, such as ~/.dsh/skills. For larger organizations, an additional shared directory can be configured through configuration files.

    Priority override. When the same workflow name appears under different directories, the system uses a predefined Rank value to determine priority. Usually, the project-level directory has the highest priority, followed by project-level shared directories, and then user-level directories. This lets project-level standards override personal habits while ensuring team standards remain the most binding in a specific project context.

    4. Example: Building a Release-Note Generation Workflow

    The following example shows how to build a minimal workflow that generates user-facing Chinese release notes based on code changes.

    First, create the directory and instruction file in the project root:

    1. mkdir -p .dsh/skills/release-note
    2. touch .dsh/skills/release-note/SKILL.md

    Then define metadata and execution steps in SKILL.md. Use kebab-case for the directory name and keep it consistent with the name field in the metadata:

    1. ---
    2. name: release-note
    3. description: Generate user-facing Chinese release notes based on Git diff, including changes, impact, and upgrade tips
    4. whenToUse: Use when the user asks to organize changelog, version notes, or release announcements
    5. ---
    6. # Release Note Workflow
    7. 1. **Get change baseline**: Read the Git diff of the current branch relative to the last official release, and extract commit information and changed files.
    8. 2. **Classify changes**: Organize the content into four categories: new features, bug fixes, compatibility changes, and upgrade actions.
    9. 3. **Clean information**: Remove internal implementation details, temporary branch names, debugging traces, and any credentials.
    10. 4. **Mark risks**: For downstream impacts that cannot be accurately assessed, mark them as “pending maintainer confirmation.” The Agent must not infer or fabricate impact.
    11. 5. **Format output**: Output Chinese release notes within 300 characters, plus a list of changed files.

    5. Engineering Best Practices

    For real-world enterprise use, keep these points in mind:

    1. Add explicit negative constraints. In addition to telling the Agent what to do, the instruction body should clearly state what not to do. In the example above, forbidding the Agent from inferring impact helps reduce hallucination.

    2. Integrate with cloud-native pipelines. These workflows can be combined with container platforms and CI/CD pipelines. For example, when a code merge request is triggered, the workflow can automatically generate preliminary release notes and reduce manual polishing.

    3. Manage versioning and review. Instruction files are plain text, so they should be reviewed like business code. Team standards evolve directly through iterations of workflow instructions.

    In summary, orchestrating Agent workflows with custom instruction files is a high-cohesion, low-coupling engineering practice. It removes heavy code development and lets developers define complex task flows in their most natural language. Combined with on-demand loading and priority mechanisms, it provides an efficient path for teams to codify engineering standards.