AI Coding: How Skills, MCP, Workflows, Rules, and Memories Work Together

    Skills, MCP, workflows, rules, and memories influence AI coding agents in different ways. This article explains their responsibilities, implementation boundaries, and risks, then shows how they work together to generate a static HTML report from a spreadsheet. It also outlines how to organize reusable methods, enforce constraints, manage long-term context, and keep execution reliable and auditable.

    1. Why These Five Concepts Are Easy to Confuse

    In an AI coding environment, an agent may receive a task description, project guidelines, external tools, and previously recorded preferences at the same time. Because all of these can influence the model’s output, they are often grouped together as “prompts.”

    From an engineering perspective, however, they address different questions:

    • Skill: How should a particular type of task be performed?
    • MCP: How can external tools and context be accessed through a standardized interface?
    • Workflow: What process should the overall task follow?
    • Rules: What constraints must be respected during execution?
    • Memories: What historical information should be retained for future use?

    Think of them as reusable method packages, a connection protocol, process definitions, constraint sets, and long-term context. They are not five interchangeable configurations. They operate at different layers and can work together.

    These terms also differ in their level of standardization. MCP is a protocol, while skills, rules, workflows, and memories may have different file formats, loading strategies, and implementation boundaries across AI coding tools. To classify a mechanism, look at what it actually does—not just what it is called.

    2. Skills: Packaging Task Methods into Reusable Capabilities

    A Skill Is More Than a Longer Prompt

    A skill is a capability package organized around a particular class of tasks. It typically includes a task description, procedures, input requirements, and output conventions. It may also contain reference material, examples, templates, and helper scripts.

    The main distinction between a skill and an ordinary conversational instruction is not length. It is whether the content defines a reusable, maintainable method.

    For example, “generate a report page” describes a goal. A report-generation skill should also explain:

    • How to read the spreadsheet.
    • How to identify metrics, units, and business dimensions.
    • Which data can be used directly.
    • When simulated data is permitted.
    • How to choose a presentation format.
    • How to verify consistency between the page and its data.

    A skill can therefore include both prompt text and executable resources. Treating it as nothing more than a prompt overlooks its value in organizing engineering knowledge and reusing assets.

    How Skills Are Selected and Used

    Users may explicitly request a skill, or an agent may select one based on the task description. Some implementations initially load only a skill’s name and short description, then read its full instructions after determining that it is relevant. This reduces unrelated content in the model’s context.

    Automatic matching is not inherently reliable. Vague descriptions, overlapping skills, or incomplete inputs can lead to incorrect selection. Critical tasks should define explicit applicability and exit conditions rather than relying entirely on semantic judgment.

    An Illustrative Capability Package

    1. report_skill/
    2. ├── SKILL.md
    3. ├── references/
    4. │ └── metric_definition.md
    5. ├── examples/
    6. │ └── sample_input.md
    7. └── scripts/
    8. └── parse_sheet.py

    Here, SKILL.md describes the task method, the reference file explains business definitions, the example clarifies expected inputs and outputs, and the script handles deterministic data reading and validation.

    This structure is illustrative. It does not mean that every AI coding tool supports the same directory layout, or that creating these files automatically registers a skill.

    3. MCP: Connecting Capabilities, Not Replacing Task Methods

    MCP, the Model Context Protocol, standardizes interactions between clients and servers. It allows AI applications to discover and use tools, read resources, and access reusable prompt templates through a consistent interface.

    Its focus is the connection and interaction contract—not the complete execution plan for a business task.

    The Key Difference Between MCP and Skills

    Suppose a task requires querying metric data:

    • MCP can expose the query capability and define how parameters and results are exchanged.
    • A skill can explain when to query, how to interpret the results, and how to build the report.
    • A workflow can coordinate confirmation, validation, and delivery before and after the query.

    In short, MCP addresses how to connect and invoke, while a skill addresses how to apply those capabilities to complete a task.

    A skill does not necessarily depend on MCP. It may use local scripts, the current file contents, or other authorized capabilities. Likewise, an MCP server does not have to be tied to a particular skill. Its tools may support many different tasks.

    A Standardized Connection Does Not Guarantee Correct Results

    Discovering and invoking a tool establishes a degree of consistency in the interaction path. It does not automatically guarantee that:

    • Parameters satisfy business requirements.
    • Returned data is complete and trustworthy.
    • The caller has the correct permissions.
    • The operation has no unintended side effects.
    • The agent interprets the result correctly.

    Write, delete, and publish operations require permission checks and any necessary approvals at the tool-execution layer. Security requirements should not be relaxed simply because an agent initiated the call.

    Tool results and external resource content should also be treated as data sources, not inherently high-priority instructions. Text such as “ignore existing rules” inside external content must not alter the system’s constraint boundaries.

    4. Workflows: Turning Tasks into Controlled Execution Processes

    A workflow organizes task steps, dependencies, branching conditions, and failure paths. It may be a written process description or a process managed by a programmatic execution engine.

    These forms provide different levels of reliability. A natural-language workflow depends on the model understanding and following it. A programmatic workflow can use state checks to restrict transitions and record execution status.

    A Workflow Is More Than a Checklist

    A mature workflow describes more than the successful path. It should answer:

    • What inputs does the current step require?
    • What conditions must be met before proceeding?
    • Should a failure trigger a retry, rollback, or stop?
    • Which steps require human confirmation?
    • How can execution resume after an interruption?
    • Which operations must not be repeated?

    For example, a report-generation workflow might look like this:

    1. Receive file
    2. → Validate file and fields
    3. → Interpret business definitions
    4. → Determine whether clarification is required
    5. → Design the presentation
    6. → Generate the page
    7. → Run checks
    8. → Deliver the artifact

    If a business definition is missing, the workflow should request clarification rather than allow the model to infer it. If real data is unavailable, it should first confirm whether simulated data is permitted.

    How Workflows and Skills Divide Responsibilities

    A skill usually focuses on a particular capability. A workflow coordinates multiple capabilities.

    For instance, a workflow may invoke a data-parsing skill, a page-generation skill, and a quality-checking skill in sequence. A skill can contain its own procedures, but tasks involving cross-stage state, approvals, retries, and recovery generally need an outer workflow to manage execution.

    5. Rules: Defining Persistent Behavioral Boundaries

    Rules are constraints on an agent’s behavior. They are useful for requirements shared across tasks, such as:

    • Do not read sensitive files unrelated to the task.
    • Do not expose credentials in code or logs.
    • Run the necessary checks after modifying code.
    • Include an explicit empty-data message on pages.
    • Do not present simulated data as real business results.

    Rules do not primarily explain how to complete a particular task. They specify what must not be violated while completing any applicable task.

    Rules Need Clear Scope and Verifiable Requirements

    Rules may apply to an entire project, a category of files, or a particular task. An overly broad scope introduces irrelevant constraints, while an overly narrow scope can miss important cases.

    “Pay attention to code quality” is less useful than “After modifying data-parsing logic, check for missing fields, null values, and unit inconsistencies.” The latter identifies both the target and the acceptance criteria.

    When rules conflict, resolve them according to the actual environment’s instruction hierarchy and configuration mechanisms. Do not assume every tool uses the same priority order.

    Text Rules Are Not Enforced Security Controls

    If “do not delete files” exists only in prompt text, it remains a behavioral instruction to the model. Actual security boundaries require read-only permissions, access controls, isolated environments, and approval mechanisms.

    For high-risk operations, rules express the intended restriction, while the execution system enforces it. Both are necessary.

    6. Memories: Preserving Useful Context, Not Accumulating Conversations

    Memories retain information that may remain useful in later tasks, including user preferences, project background, and confirmed technical decisions.

    Suitable examples include:

    • The user prefers explanations in Chinese.
    • The current project requires static pages that work offline.
    • A metric’s business definition has been confirmed.
    • The team displays monetary values to two decimal places.

    Not all historical content should become memory. Temporary experiment results, unconfirmed assumptions, obsolete configurations, and sensitive data should not be retained indiscriminately.

    Memories Need Provenance and Freshness

    Memory is valuable only if it can be retrieved, trusted, and shown to remain applicable. Important records should, where practical, include their scope, source, confirmation date, and conditions for updating them.

    For example, “This project does not permit simulated data” may be a confirmed project requirement. “The user seemed to dislike a particular chart just now” may reflect only a temporary preference. These statements should not carry the same authority.

    The Boundary Between Memories and Rules

    Rules primarily express requirements. Memories primarily capture historical facts and context. Memory can help interpret a rule, but it should not automatically override one.

    If long-term memory conflicts with a clear current request, first check whether the stored information is outdated, then apply the relevant instruction priorities. Historical preferences must not substitute for current authorization, particularly where data authenticity, security, or permissions are involved.

    7. Comparing the Five Mechanisms

    Mechanism Core question Typical contents Main risks
    Skill How should this type of task be performed? Methods, procedures, templates, scripts Outdated methods, incorrect skill selection
    MCP How can external capabilities be connected? Tools, resources, interaction contracts Unauthorized calls, untrusted results
    Workflow How should the task progress? State, dependencies, branches, recovery Skipped steps, repeated side effects
    Rules What requirements must be followed? Standards, restrictions, acceptance criteria Conflicts, unclear scope
    Memories What information should carry forward? Preferences, background, confirmed decisions Stale information, incorrect records, privacy exposure

    These responsibilities do not map rigidly to particular storage locations. A project constraint may be recorded in memory, but it should become an explicit rule if it needs to be applied consistently. A workflow may be described inside a skill, but reliable recovery requires execution state to be managed by the execution system.

    The central design principle is to avoid confusing where information is stored with the responsibility it serves.

    8. Practical Example: Generating a Static Report from a Spreadsheet

    Suppose a user provides a spreadsheet defining dashboard names, presentation formats, metric names, measures, units, business definitions, business dimensions, and anomaly thresholds. The requested output is an HTML report that can be viewed without a backend service.

    The five mechanisms can be applied as follows.

    Use a Skill to Define the Report-Generation Method

    The report skill should specify input fields, parsing logic, and output requirements. A helper script reads the spreadsheet and produces structured results. The model interprets the business meaning and designs the page, but must not arbitrarily alter the source data.

    Missing fields, inconsistent units, or conflicting business definitions should produce a list of issues. Whether generation can continue should depend on the applicable task rules and user confirmation.

    The deliverable must match the request: a static HTML report, not another spreadsheet.

    Use a Workflow to Control Each Stage

    The workflow can include the following checkpoints:

    1. Can the input file be read?
    2. Are all required fields present?
    3. Are real and simulated data clearly distinguished?
    4. Does the presentation follow the spreadsheet’s definitions?
    5. Does the page have external dependencies?
    6. Do displayed values match the structured data?
    7. Can the final artifact be opened in the agreed way?

    If fully offline viewing is required, “no backend service” is not sufficient. The page must also avoid remote stylesheets, fonts, and scripts.

    Use Rules to Protect Data Authenticity and Security

    For this task, rules should include at least the following:

    • Do not change metric definitions or units without authorization.
    • Clearly label simulated data.
    • Do not default missing values to zero.
    • Account for comparison direction and units when evaluating thresholds.
    • Apply appropriate escaping to external text inserted into HTML.
    • Do not send source files or data to external services without authorization.

    A statement such as “the threshold is 10” is not enough to determine an anomaly. The task must specify whether an anomaly means above 10, below 10, or outside a defined range. Such semantic gaps must be handled explicitly.

    Use MCP and Memories Only Where Needed

    A task involving only local files may not need MCP. Introduce the relevant connection only when the report requires an authorized external data source, shared resource, or other service capability.

    Memories can preserve confirmed long-term preferences, such as a default color palette or commonly used metric definitions. They should not automatically retain the entire source business dataset.

    9. Keeping Configuration Manageable

    A common mistake is to put everything into one lengthy instruction file: task procedures, permission restrictions, user preferences, and historical context. This is easy to start with, but difficult to update, test, and troubleshoot.

    A more maintainable division is:

    • Put reusable task methods in skills.
    • Put cross-task constraints in rules.
    • Put multi-stage execution control in workflows.
    • Use MCP when external capability connections are needed.
    • Store confirmed, durable information in memories.

    Key assets should also have version control, change records, and test cases. Test skills against input boundaries, workflows against failure paths, and rules for conflicts. Memories should support updates and deletion, while tool connections should be checked for permissions and returned-data quality.

    Together, these five mechanisms serve one goal: enabling agents to complete tasks using explicit methods, controlled processes, and auditable boundaries. Separating responsibilities—and enforcing critical constraints in the execution system—is what moves AI coding from occasionally producing correct results toward consistently reliable delivery.