Understanding Skills, Workflows, Rules, and Memories in AI Programming
AI programming assistants often blur the line between methods, constraints, and context. This article clarifies five core components of agentic AI systems—skills, tool access protocols, workflows, rules, and memories—and explains how they differ, how they work together, and how to structure them for more predictable AI behavior.
Why These Concepts Are Often Confused
In AI-assisted programming, developers frequently combine “what the model should do,” “what the model should follow,” and “what the model should remember” into a single prompt. As a result, one block of text may contain operational steps, coding standards, and project background all at once, making it difficult for the model to distinguish what must be executed every time from what is only relevant to a specific task.
These concepts fundamentally serve several basic needs of an intelligent agent: capability expansion, external interaction, process control, behavioral constraints, and state retention. AI coding tools are just one typical application of intelligent agents, so understanding the boundaries of these components is useful for designing any agent-based system.
Skills: Reusable Task Method Packages
Definition
A skill is a modular capability unit, typically composed of three parts:
- Structured description: Includes the name and a functional explanation, enabling the model to determine when to invoke it based on semantics.
- Execution logic: Steps, rules, examples, and precautions required to complete the task.
- Optional resources: Reference documents, example files, executable scripts, and similar assets.
In simple terms, a skill is a manual that tells the model “how a certain type of task should be done.” It is still organized prompt content, but unlike ordinary prompts, it has clear boundaries, reusability, and trigger conditions.
How It Works
Skills are typically loaded on demand. The model first reads the names and descriptions of all available skills, then determines whether the current request matches any of them. Only after a match is found does it load the detailed steps and resources for that skill. This approach avoids cramming all operational details into the context at once, keeping the system manageable even as the number of skills grows.
Example: Converting a Spreadsheet Template into an HTML Dashboard
Suppose a business team has designed a report template in a spreadsheet, containing fields such as dashboard name, display format, metric name, metric measurement, measurement unit, business definition, business dimension, and anomaly threshold. The team wants the model to read this template and generate an HTML dashboard for demonstration purposes.
The execution flow for this skill can be broken down into four steps:
- Invoke a script to parse the spreadsheet and extract structured fields.
- Design the display scheme based on the chosen format and business dimensions.
- Generate mock data for each metric and annotate the trigger effects of anomaly thresholds.
- Output the final HTML page and accompanying data files.
The first step relies on the script for deterministic parsing. The model does not need to parse the file format itself; it only calls the script and processes the structured result, illustrating the combined “description plus script” approach.
Directory Structure Example
report-dashboard/ # Skill root directory├── instructions.md # Main instruction file: description, steps, rules├── reference.md # Optional: field definitions and business definitions├── examples.md # Optional: input/output examples└── scripts/└── parse_table.py # Helper script for parsing the spreadsheet
The header of the main instruction file can be formatted as follows:
name: Generate HTML dashboard from spreadsheet datadescription: Invoke when the user requests generating a demo HTML dashboard based on metrics and dimensions defined in a spreadsheet
The model relies on the description field to decide whether to trigger the skill, so it should clearly state applicable inputs and outputs, avoiding descriptions that are overly broad or overly narrow.
Tool Access Protocols (MCP): Enabling Models to Call External Capabilities Safely
Skills address the question of “how to do something,” while tool access protocols address “what external capabilities can be accessed.” Models cannot directly read databases, query ticket systems, or call messaging interfaces—they need a standardized channel to connect with external services.
The core functions of such protocols include:
- Unified interface format: Tools declare their names, parameters, and return structures consistently, so clients do not need custom adapter code for each tool.
- Clear permission boundaries: Each tool exposes only the agreed operations, making it easier to restrict access scope.
- Replaceability: The underlying implementation can be swapped out as long as the interface description remains unchanged.
An illustrative tool declaration looks like this:
{"name": "query_order_status","description": "Query the current status of an order by order ID","parameters": {"order_id": { "type": "string", "description": "Order number" }}}
In practice, common external capabilities include object storage, message queues, container platforms, logging services, and monitoring alerts. A skill can declare which tools it needs, but the tools themselves do not contain operational logic. The division of labor is clear: skills provide the “how,” and tools provide the “what can be accessed.”
Workflows: Pre-Orchestrated Execution Paths
A workflow is a multi-step process defined in advance by a person or a system, including step order, branch conditions, parallel relationships, and exception handling. Compared to skills, workflows are more deterministic: what happens at each step and when to move to the next step are largely decided at design time.
Using code review as an example, a typical workflow might look like this:
1. Retrieve the list of changed files2. Run static checks on each file3. If high-severity issues are found, mark as blocking and notify the author4. If all checks pass, generate a review summary5. Compile results and output the final report
Workflows are best suited for scenarios where the process is fixed, steps are enumerable, and repeatability is required—such as pre-release checks, data synchronization, or batch processing. Their main drawback is limited flexibility. When unexpected situations arise outside the defined flow, workflows typically require human intervention or additional branches.
In practice, workflows often act as the orchestration framework, while skills handle the parts that require judgment. For example, the workflow decides “when to generate a report,” and the skill decides “how the report should be structured and worded.”
Rules: Persistent Constraints
Rules describe constraints and preferences that the model must follow in any task—such as coding style, naming conventions, prohibited APIs, or security requirements that take priority.
The main difference between rules and skills lies in how they are triggered. Skills are loaded when a specific task matches, while rules typically take effect automatically in every session. Therefore, rules are best used for content that is independent of specific tasks yet needs to be observed over the long term.
An example rules file:
- Function names use lowercase with underscores- All public interfaces must validate their parameters- Database operations must use parameterized queries- Before modifying a shared module, explain the impact scope first
Rules should be kept concise. Excessively verbose rules consume context space and may conflict with specific tasks. A good rule should be verifiable—the model can check its output against the rule to ensure compliance.
Memories: Information Retained Across Sessions
Memories store factual information—such as a project’s tech stack, historical team decisions, user preferences, or previously discussed issues and their conclusions. They address the question of “what was said last time,” allowing the agent to avoid re-explaining context in every new session.
The distinction between memories and rules lies in their nature. Rules are requirements for behavior; memories are records of facts. For example, “reply in Chinese” is a rule, while “this project uses a three-tier architecture with the data access layer in a separate module” is a memory.
When working with memories, several points require attention:
- Timeliness: Project structure changes over time, and outdated memories can mislead the model—regular updates or cleanup are necessary.
- Accuracy: Memories should come from reliable sources; avoid storing the model’s inferences as established facts.
- Privacy and security: Personal information or sensitive configuration should not be stored casually, and mechanisms for viewing and deleting memories should be provided.
- Volume control: When memories accumulate, use retrieval or summarization for on-demand loading rather than injecting everything at once.
Comparison of the Five Concepts
| Dimension | Skill | Tool Access Protocol | Workflow | Rule | Memory |
|---|---|---|---|---|---|
| Core question | How to complete a type of task | Which external capabilities are available | In what order do steps execute | What must be followed | What facts need to be known |
| Content nature | Methods and steps | Interfaces and permissions | Flows and branches | Constraints and preferences | Facts and history |
| Trigger method | Semantically matched, loaded on demand | Called by model on demand | Preset conditions or manual start | Usually active in every session | Retrieved or loaded at session start |
| Determinism | Medium—relies on model judgment | High—interfaces are fixed | High—flows are fixed | Medium—requires model adherence | Depends on record quality |
| Typical failure | Vague description causes false triggers | Interface changes cause call failures | Missing exception branches cause interruption | Conflicting rules | Outdated memories cause misjudgment |
As the table shows, the five components are largely complementary. Skills provide methods, protocols provide capabilities, workflows provide the skeleton, rules provide boundaries, and memories provide context.
Practical Recommendations for Combined Use
When designing an agent system or configuring an AI programming environment, consider the following practices:
- Classify problems first. When a new requirement arises, determine whether it belongs to method, capability, flow, constraint, or fact—then decide which component it belongs to.
- Keep rules and skills separate. Place coding standards that apply to all tasks in rules, and place task-specific procedures in skills, avoiding duplication.
- Write precise skill descriptions. Descriptions should clearly state applicable scenarios, inputs, and outputs so the model can trigger them accurately.
- Workflows handle determinism; skills handle judgment. Use workflows for fixed process skeletons and skills for steps that require contextual understanding.
- Maintain memories regularly. Set up an update mechanism for memories, prune outdated content, and prevent stale information from persisting.
- Iterate incrementally. Start from a concrete task and accumulate skills and rules over time—this is easier to validate than designing a comprehensive system from the outset.
Understanding the boundaries between these components leads to cleaner prompts, more predictable agent behavior, and a clear structure for teams to reuse experience effectively.
