A Practical Guide to the Five Core Components in AI Programming: Skills, MCP, Workflows, Rules, and Memories

    In AI-assisted programming, components like Skill, MCP, Workflow, Rules, and Memories often appear together but serve distinct purposes. This guide clarifies the differences and synergies among these five components from a system design perspective. It explores how to encapsulate reusable methods, manage external connections, orchestrate observable execution paths, define behavioral constraints, and leverage historical context effectively. Through practical examples and a comparative framework, developers will learn how to correctly identify, implement, and orchestrate these components to build reliable, testable, and governable AI agents.

    1. Building a Holistic Understanding: Five Concepts Map to Five Problems

    In intelligent programming tools, Skill, MCP, Workflow, Rules, and Memories frequently appear simultaneously. Because they are often configured via text, they are sometimes mistaken for different types of prompts. However, from a system design perspective, these five components solve fundamentally different problems.

    For an AI agent to consistently complete a task, it generally needs to answer five questions:

    • Skill: How should this type of task be done?
    • MCP: How do we connect to external tools, data, and resources?
    • Workflow: What is the execution sequence, and how are branches handled?
    • Rules: What constraints must be followed during execution?
    • Memories: What historical information is worth retaining for future use?

    You can think of them as “methods, connections, processes, boundaries, and experiences.” These responsibilities complement each other but cannot simply replace one another.

    It is also important to emphasize that the exact meaning of these terms may vary across different implementations. This is especially true for skills, rules, and memories, where storage location, loading mechanisms, and scope of effect might differ. When evaluating the nature of a component, focus on its actual role in the execution chain rather than just its filename or UI label.

    2. Skill: Encapsulating Task Methods as Reusable Capabilities

    2.1 The Core of a Skill is a Task Method, Not Just a Prompt

    A Skill typically refers to a modular capability unit designed for a specific task. It can include a task description, applicable conditions, operational steps, input/output conventions, reference materials, and optional execution scripts.

    For instance, “generating a web report from a business spreadsheet” can be encapsulated as a skill. This skill should do more than just tell the model to “generate a report”; it should explain:

    • How to identify headers, data regions, and summary rows;
    • How to handle merged cells, dates, percentages, and amounts;
    • How to preserve the original information hierarchy;
    • How to choose the combination of charts and tables;
    • How to verify that the generated page matches the original data.

    Therefore, equating a Skill entirely with a prompt is inaccurate. While prompt text is often an important entry point for a skill, a complete skill may also rely on executable programs, templates, and validation rules.

    2.2 How Skills are Discovered and Used

    A common practice is to provide the model with skill names and brief descriptions first, then load detailed instructions on demand based on task requirements. This lazy-loading approach reduces irrelevant content from entering the context.

    However, “automatic semantic triggering” is not a unified guarantee across all skill systems. Skills might also be explicitly specified by the user, invoked by a workflow node, or selected by application-side logic.

    Skill descriptions should clearly outline task boundaries. For example:

    Applicable for converting organized business spreadsheets into static web reports, preserving original metrics and units. It does not infer missing data or directly publish to production environments.

    This type of description is more likely to be accurately selected than “good at creating beautiful reports,” and is more beneficial for testing.

    2.3 Skills Need Clear Inputs, Outputs, and Failure Conditions

    An engineered skill should define at least three types of conventions:

    Input Conventions: What files, data fields, and user instructions are required.

    Output Conventions: What artifacts are generated, what structure is used, and what validation results are included.

    Failure Conditions: What the system should do when encountering unrecognizable table structures, missing fields, or insufficient permissions—whether to stop, ask, or gracefully degrade.

    If a skill only contains operational steps without these boundaries, it is prone to hallucinating completions when information is insufficient, leading to seemingly complete but actually incorrect results.

    3. MCP: Unifying External Connections, Not Defining Business Methods

    3.1 MCP Solves Interaction and Connection Problems

    MCP typically refers to the Model Context Protocol, used to standardize interactions between agent applications and external services. Implementations can provide capabilities like tool calling and resource access through the protocol.

    For example, when an agent needs to read business data, query internal documentation, or call a report validation service, it can use the corresponding protocol connection to complete the operation.

    It is necessary to distinguish between three layers:

    • The protocol defines the interaction method;
    • The server implements specific capabilities;
    • The client or agent application discovers, selects, and calls capabilities.

    Thus, MCP itself is neither a database nor a report generator. What tasks can actually be accomplished depends on the functions provided by the connected service and the granted permissions.

    3.2 The Difference Between MCP and Skill

    Skill describes “how to complete a task,” while MCP provides “a standardized way to interact with external capabilities.”

    A report skill might require reading spreadsheets, retrieving metric definitions, and validating business logic. It can call tools provided via the protocol, or it can use local programs or other controlled interfaces. Therefore, a skill does not need to depend on MCP to exist.

    Conversely, a data query capability provided through MCP is not necessarily bound to a specific skill. Multiple skills or workflows might use the same query service.

    3.3 A Successful Connection Does Not Mean Safe Execution

    External connections must be paired with identity authentication, authorization, and call auditing. It is especially important to distinguish read-only operations from operations with side effects, such as:

    • Reading a file vs. overwriting a file;
    • Querying data vs. modifying data;
    • Generating a page vs. publishing a page externally.

    For high-risk behaviors like writing, deleting, or publishing, you cannot rely solely on the model “understanding the risk.” A more reliable approach is to enforce permission limits, parameter validation, and human confirmation at the execution layer.

    Additionally, content returned from external resources should be treated as data to be processed, not automatically granted high-priority behavioral instructions, to prevent malicious text from interfering with task execution.

    4. Workflow: Organizing Tasks into Observable Execution Paths

    4.1 Workflow Defines Relationships Between Steps

    Workflow is used to organize multiple task nodes and their dependencies. It focuses on more than just “what steps exist”; it includes:

    • Which step executes first;
    • Which steps can run in parallel;
    • Under what conditions different branches are entered;
    • Whether to retry upon failure;
    • Which nodes require human approval;
    • How to record execution state and recover tasks.

    In a reporting scenario, a workflow might be:

    Receive file -> Check input -> Extract data -> Generate page -> Validate result -> Human confirmation -> Publish artifact

    Here, “generate page” can call the report skill, “extract data” can use an external tool, and “human confirmation” is an independent process control node.

    4.2 A Workflow is Not Just a Step List in a Prompt

    A prompt can also outline “step one, step two, step three,” but this does not mean the system possesses reliable process execution capabilities.

    Engineered workflows typically require state management, error handling, timeout control, and artifact storage. Without these mechanisms, if execution is interrupted, it may be impossible to know how far the task progressed or whether a specific operation has already caused side effects.

    Workflows can use fixed orchestration or allow the model to plan dynamically within constrained limits. For critical phases like data publishing or permission changes, clear and verifiable process constraints are usually more appropriate.

    4.3 Retries Should Consider Side Effects

    Retrying a failed data read usually carries low risk; retrying a failed publish might generate duplicate artifacts.

    Therefore, nodes with side effects need to consider idempotency, deduplication, or pre-execution state checks. When necessary, compensation operations should be prepared, rather than broadly assuming “just execute it again after failure.”

    5. Rules: Defining Boundaries, Not Replacing Mandatory Controls

    5.1 Rules Focus on Cross-Task Consistent Constraints

    Rules generally refer to behavioral guidelines the agent must follow. They can apply to an entire environment, a specific project, or a particular task.

    Common rules include:

    • Do not modify files in specified directories;
    • Do not write sensitive information to logs;
    • Do not alter business metric definitions;
    • New features must include necessary tests;
    • External publishing must be confirmed beforehand.

    Skills emphasize methods; rules emphasize boundaries. The same report skill can be subject to different project rules when used across different projects.

    5.2 Rules Should Be Specific, Verifiable, and Executable

    “Ensure code quality” is difficult to verify directly; “modifications to calculation logic must be accompanied by corresponding tests” is much easier to enforce.

    When writing rules, try to include the applicable scope, trigger conditions, required behavior, and exception handling. For example:

    When input data lacks units, pause the generation of display content involving amounts or percentages, and ask the user to confirm before proceeding.

    This rule explicitly reduces the risk of misinterpreting data.

    5.3 Prompt-Layer Rules Differ from System-Level Mandatory Constraints

    Text rules can guide the model but cannot guarantee absolute execution. Security and compliance requirements should be implemented at the system layer whenever possible:

    • File permissions restrict modification scope;
    • Data access controls restrict query content;
    • Publishing interfaces require approval credentials;
    • Automated checks prevent sensitive fields from entering artifacts.

    Rules can also conflict. The system needs to define scopes and priorities, and request user confirmation when conflicts cannot be resolved, rather than letting the model arbitrarily ignore a rule.

    6. Memories: Retaining Valuable Information, Not Infinitely Saving History

    6.1 Memory Facilitates Cross-Task Information Reuse

    Memories generally refer to information that can be reused in subsequent interactions. This may include user preferences, project conventions, confirmed business backgrounds, and historical decisions.

    For example:

    • The user prefers a concise report layout;
    • A specific project uses a fixed date display format;
    • A metric’s calculation logic has been confirmed by the business team;
    • The reasoning and applicable conditions behind a specific solution choice.

    However, current dialogue context, complete chat history, and long-term memory are not the same concept. Chat history is an interaction archive; long-term memory is usually filtered, organized, or indexed information that can be retrieved and utilized later.

    6.2 Memory Must Have Scope and Timeliness

    “The user likes dark mode pages” might just be a requirement for a single demo and should not automatically become a permanent preference across all projects.

    A reliable memory entry should include:

    • Information content;
    • Source and confirmation status;
    • Applicable user or project;
    • Timestamp;
    • Validity period or expiration conditions.

    For business facts that are subject to change, retrieved old memories should be re-verified. Just because something was correct previously does not mean it can be directly applied to the current task.

    6.3 Memory Cannot Automatically Upgrade to a Rule

    If a memory records “tests were skipped last time,” it does not mean skipping tests is allowed this time. Memory provides context; rules dictate constraints. Their levels of authority are different.

    Furthermore, avoid long-term storage of sensitive information without authorization, and provide mechanisms to view, correct, delete, and expire memories. Multi-user systems particularly need to isolate memories across different users, projects, and permission scopes.

    7. Comprehensive Case: Generating a Web Report from a Business Spreadsheet

    The following complete task illustrates how the five components collaborate.

    7.1 Clarify the Task Goal

    The user provides a business spreadsheet and requests a presentable web report. The artifact needs to retain metrics, units, summary relationships, and major visual hierarchies, but does not require pixel-perfect replication of the original layout.

    First, confirm whether the input contains formulas, multiple sheets, hidden regions, and sensitive fields, and clarify what content is allowed into the presentation artifact.

    7.2 Use Rules to Define Non-Negotiable Boundaries

    Project rules can stipulate:

    • Do not rewrite original values and statistical definitions;
    • Do not display unauthorized personal information;
    • Do not guess business data based on empty cells;
    • Do not publish to external URLs without confirmation.

    These constraints apply throughout the entire task, not just during the page generation phase.

    7.3 Use Workflow to Organize Execution

    The workflow breaks the task into input check, data extraction, page generation, result validation, and human confirmation.

    If ambiguous headers are found, the flow enters an inquiry branch; if sensitive fields are detected, it enters a processing or approval branch; if validation fails, it routes back to a correction node rather than publishing directly.

    7.4 Use Skill to Provide the Generation Method

    The report skill handles identifying data structures, selecting layouts, retaining units, organizing charts, and generating the page, while providing a validation checklist.

    Its output should not be just the page file; it can also include data mapping explanations, unresolved issues, and validation results for reviewers to trace.

    7.5 Use MCP or Other Controlled Connections for External Capabilities

    When the task requires querying metric definitions or calling validation services, corresponding capabilities can be accessed via protocol connections. The specific connection method is determined by the system environment; a single protocol should not be treated as the sole entry point for all tool calls.

    7.6 Use Memories to Reduce Repeated Confirmations

    If the user has explicitly confirmed the date format and layout preferences for a project, these can be reused in subsequent tasks. However, new requests from the current user should take priority, and critical business logic should be re-verified against its validity period.

    8. How to Determine Which Component to Use

    Requirement Preferred Component Basis for Judgment
    Reuse methods for similar tasks multiple times Skill Encapsulates domain knowledge, steps, and resources
    Connect to external data or execution capabilities MCP or other connection mechanisms Solves external interaction problems
    Manage task dependencies, branches, and approvals Workflow Organizes execution paths and states
    Unify coding, security, and business constraints Rules Dictates boundaries that must be followed
    Retain confirmed preferences and context Memories Supports future information reuse

    In actual systems, the same piece of information might serve multiple purposes. For example, a business metric definition might be saved in memory or written into a skill’s reference materials. However, the system must still clarify its authoritative source to prevent long-term drift among multiple copies.

    9. Implementation Advice: Divide Responsibilities First, Add Complexity Later

    When building an intelligent programming system, you do not need to configure all concepts from the start. A more rational sequence is to first identify task risks and repetition frequency, then incrementally add components.

    First, encapsulate high-frequency tasks with stable methods into skills. Second, use rules to define non-negotiable boundaries. When tasks involve multi-stage collaboration, approval, and recovery, introduce workflows. When external data and operational capabilities are needed, build controlled connections. Finally, only incorporate information with genuine reuse value into memory.

    Each component should have an independent validation method: skills validate output quality, connections validate permissions and error handling, workflows validate branches and recovery, rules validate compliance, and memories validate accuracy, isolation, and timeliness.

    The true value of these five components lies not in adding more configuration items, but in splitting the agent’s behavior into understandable, testable, and governable parts. Understanding these five dimensions—“methods, connections, processes, boundaries, and experiences”—is the only way to avoid stuffing all requirements into a single long prompt, gradually establishing reliable intelligent programming practices.