Five Mechanisms of AI Coding: Skills, Tools, Workflows, Rules, and Memory
This article explains why skills, MCP tools, workflows, rules, and memory are not interchangeable features but mechanisms that operate on different layers of an AI coding system. It breaks down what each one actually does, how they combine on a real task such as generating an HTML report from a spreadsheet, and how teams should adopt them in a deliberate order. Readers will learn how to judge an environment's real capabilities by its loading, execution, and permission mechanisms rather than by feature names, and how to pair these mechanisms with access control, executable checks, and auditing for a reusable, traceable, and governable engineering practice.
1. Start With a Mental Model: They Don’t Sit on the Same Layer
When you use AI coding tools, a few questions come up again and again. If you’ve already written rules, why configure skills? If you’ve already connected external tools, why can’t the agent still complete tasks reliably? If there’s memory, do you still need to restate the project requirements each time?
The root of all these questions is treating mechanisms that live on different layers as interchangeable features.
Five sentences are enough to build the right intuition:
- Skill: how a certain kind of task should be done.
- MCP: how the agent connects to external tools and resources.
- Workflow: in what order and under what conditions the whole task advances.
- Rules: which constraints must be obeyed during execution.
- Memories: which historical information is worth keeping and reusing later.
For example, suppose a user asks to “generate a demonstrable HTML report from a spreadsheet.” The agent may first need to understand the business definitions, then read the file, transform the data, generate the page, and finally check the result. This task involves method, tools, process, constraints, and historical context all at once, so all five mechanisms can play a role together.
One caveat: apart from a protocol concept like MCP, the other terms are not implemented identically across different AI coding environments. A skill might be organized as a documentation directory, or registered through configuration; a workflow might be nothing more than a prompt template, or driven by an execution engine with state management. To judge real capability, look at how something is loaded, executed, and permissioned, rather than inferring from the feature name alone.
2. Skill: Turning Domain Experience Into a Reusable Method
1. A skill solves “I know the tools, but not how to use them well”
Having file-reading and code-execution abilities doesn’t mean the agent can correctly produce a business report. It still needs to know:
- How to identify the title, headers, and data regions in a workbook;
- How to handle merged cells, empty values, and number formats;
- What should be kept as-is and what can be reorganized;
- How to judge whether the generated result meets the presentation requirements.
A skill’s job is to organize this knowledge into a capability unit aimed at a certain class of task.
From an engineering standpoint, a skill usually includes a name, applicable scenarios, operating instructions, reference material, and optionally scripts, templates, and examples. It doesn’t only describe “what to do”; it also explains “why do it this way,” “how to handle exceptions,” and “how to accept the result when finished.”
2. A skill shouldn’t be equated with a single prompt
The core description of a skill is often written in natural language, so the prompt is an important part of it. But once a skill includes executable scripts, reference files, and output templates, it goes beyond a single prompt and is closer to a small task package.
A neutral way to organize the directory looks like this:
report-skill/├── skill.md├── references/│ └── layout-guidelines.md├── examples/│ └── sample-report.html└── scripts/└── workbook-reader
The filenames here only illustrate the organizing idea; they aren’t a mandatory convention of any specific environment. The actual directory layout, metadata format, and loading mechanism should follow what the runtime environment supports.
A report skill’s instructions might include:
Goal:Generate a demonstrable static HTML report from the workbook the user provides.Input:Workbook path, target worksheet, output location, presentation requirements.Method:1. Check the input file and the target worksheet.2. Extract cell values, merged regions, and necessary formatting information.3. Clarify header levels, metric units, and data definitions.4. Generate the page, and escape all external input.5. Verify key metrics and page structure against the source file.Failure handling:When calculation results cannot be obtained reliably, mark the item as pending confirmation;do not guess missing data, and do not silently substitute anomalous values.
3. Selecting a skill is not the same as executing it
Names and descriptions help the system discover candidate skills, and some environments also do semantic matching based on user intent. But “a skill was selected” doesn’t mean the task is guaranteed to be done, and it certainly doesn’t mean any scripts inside it automatically get permission to run.
Whether a skill is invoked, which files enter the context, and whether scripts can execute all depend on the host environment’s implementation and permission policy.
Therefore, a skill description should state its applicable and non-applicable conditions accurately. For instance, “generate a static presentation report” should not be described as “complete all data analysis tasks,” or it will easily cause mismatches and misjudgments of capability.
3. MCP: It Provides Connectivity, Not Business Judgment
1. MCP focuses on how external capabilities are discovered and invoked
MCP, the Model Context Protocol, is a protocol for connecting agent applications to external capabilities such as tools and resources.
In a common architecture, the agent application interacts with servers through a client. A server can expose callable tools, readable resources, and so on, and the client fetches descriptions and issues requests according to the protocol.
What it solves is the connectivity and interaction problem, for example:
- Querying data in a business system;
- Fetching documents or file resources;
- Calling a controlled data-processing service;
- Submitting an authorized operation request to an external system.
But a successful connection doesn’t automatically resolve business-semantic questions. A query tool can return sales data, yet it may not know whether the report should use tax-inclusive or tax-exclusive amounts. That kind of judgment has to be supplied by the task description, a skill, rules, or human confirmation.
2. Using a skill doesn’t necessarily require MCP
If the AI coding environment already has local file reading and controlled script execution, a skill can use those abilities directly to get the work done.
MCP only enters the execution chain when you need to connect to an external service through it. So “a skill needs tools” should not be understood as “a skill must depend on MCP.”
Conversely, merely configuring MCP doesn’t automatically form a skill. Tool descriptions usually cover inputs, outputs, and purpose, whereas a skill needs to explain how multiple tools work together, how to handle business exceptions, and how to judge that the final result is correct.
3. A protocol connection is not a permission guarantee
A protocol can standardize interaction, but whether data access is compliant, whether a call is authorized, and whether returned content is trustworthy still have to be controlled by the system itself.
In practice, you should make clear:
- Which data a tool may access;
- Whether modification or deletion is allowed;
- Which calls require human approval;
- Whether returned content might contain sensitive information or malicious instructions;
- Whether the call process can be audited.
In particular, distinguish “data returned by a tool” from “instructions the system should follow.” Text inside external documents or service responses should not automatically gain the standing to modify rules, expand permissions, or trigger high-risk operations.
4. Workflow: Organizing a Task Into a Process With Dependencies
1. A workflow focuses on how the whole task advances
A skill emphasizes the method for one class of task; a workflow emphasizes the dependencies, branches, and state across multiple steps.
A report workflow can be written as:
Receive request↓Validate file and business definitions↓Extract data and layout information↓Generate HTML report↓Check data and page├── Fail → fix or request confirmation└── Pass → deliver preview
Here, “generate HTML report” can use a skill, “extract data” can call an external tool, and “pre-delivery check” can apply project rules. The workflow is responsible for putting these actions in the right place.
2. A process description is not a reliable process engine
If a workflow is only natural-language steps, the model may skip steps, repeat execution, or ignore branch conditions.
If a workflow is managed by a programmatic execution mechanism, it can more explicitly implement input/output validation, step-state persistence, timeout handling, bounded retries, and human approval. However, these capabilities are not guaranteed by the name “Workflow”; they must be provided by the actual system.
For high-risk tasks, key controls should be implemented as executable checks rather than a single sentence like “please be careful.”
3. Retries must account for side effects
Retrying after a file read fails is usually low-risk; retrying after sending a notification, overwriting a file, or updating a business record fails may produce duplicate operations.
So workflow design should distinguish read-only steps from steps with side effects. The latter should account for duplicate-execution detection, explicit operation identifiers, result confirmation, and, where necessary, compensation plans.
5. Rules: Continuously Constrain Behavior, Not Replace the Method
1. Rules answer “what can be done and what cannot”
Rules are suited to expressing relatively stable constraints, for example:
- Generated code should follow the project’s existing style;
- Output must not contain keys or complete sensitive records;
- Source data must not be modified without authorization;
- Deletion, overwriting, or publishing must be confirmed first;
- Amounts, ratios, and dates in a report must keep a consistent format.
These requirements can take effect across multiple tasks, so there’s no need to repeat the full description in every skill.
Rules can be organized by scope, such as organization-level security requirements, project-level development conventions, code standards for a specific directory, and constraints for the current task. Different environments may load rules at different scopes and resolve conflicts differently, so a team should make the actual precedence explicit.
2. Rules should be verifiable
“Output must be high quality” is hard to check; “the generated page must not reference external scripts, and values must match the source data” is much more concrete.
When writing rules, you can add a corresponding check method for each requirement:
- Sensitive-information constraint: scan the output for sensitive fields;
- File-operation constraint: validate the target path and overwrite behavior;
- Data-consistency constraint: spot-check key cells and aggregate values;
- Page-dependency constraint: check for references to external resources.
Also recognize that natural-language rules cannot replace real security boundaries. Forbidding reads of a certain directory should be enforced through access control; forbidding unapproved publishing should be blocked by the release process, rather than relying only on the model’s self-discipline.
6. Memories: Keep Useful Context, but Don’t Treat History as Always Right
1. Memory solves information continuity across sessions
Memory can hold information that later tasks may still need, for example:
- The user prefers a concise report layout;
- A project usually uses a specific time range;
- The current module already has a confirmed design decision;
- A certain class of past error once caused data-display distortion.
Compared with rules, memory leans more toward background facts and experiential information and isn’t necessarily mandatory.
For example, “the user previously preferred dark pages” is a preference memory; “this delivery must use a light page” is a current-task requirement. When the two conflict, the historical preference should not override the explicit new requirement.
2. Conversation logs are not inherently reliable memory
Unfiltered conversation history may contain guesses, outdated conclusions, or decisions that have already been revoked. If it’s kept long-term and reused directly, one mistake can easily spread into later tasks.
Valuable memory should, as much as possible, include:
- The content and its scope of applicability;
- The source and confirmation status;
- Creation or update time;
- Whether periodic review is needed;
- How to delete or correct it.
For business definitions, permissions, and important technical decisions, traceable evidence should also be kept, rather than only storing a conclusion detached from its context.
3. Memory should follow a minimization principle
Keys, complete customer records, or large amounts of raw business data should not be written into long-term memory. It’s usually more appropriate to keep summaries, confirmed preferences, and references pointing to controlled material.
The goal of memory is to reduce repeated communication, not to build a hidden data warehouse that lacks access control.
7. A Complete Case: Generating an HTML Report From a Spreadsheet
Suppose a business team provides a workbook and asks for a presentation page that opens offline. The task isn’t only to display data; it should also preserve multi-level headers, metric grouping, and visual hierarchy as much as possible.
1. Define inputs and acceptance criteria first
Before execution, confirm:
- Which worksheet and data region to use;
- Whether there are formulas, hidden rows/columns, or merged cells;
- Whether the layout must be preserved or re-laying-out is allowed;
- How number units, percentages, and dates should be displayed;
- Whether the page may use external resources;
- Whether the final file contains sensitive data.
These questions affect the implementation path and should be resolved before generating the page, not reworked repeatedly after delivery.
2. Give each of the five mechanisms a clear responsibility
Skill handles the report-generation method.
It guides the agent to extract structure, transform layout, handle exceptions, and complete verification.
MCP provides external access as needed.
If the file is in a controlled remote system, it can be read through the corresponding service; if local capabilities are enough, there’s no need to add an extra connection.
Workflow handles stage progression.
It requires input checks to be completed first, then data parsing, then generation, validation, and delivery; when a key business definition is missing, it pauses and requests confirmation.
Rules handle the boundaries that must not be crossed.
For example, no modifying the source file, no outputting un-desensitized fields, no overwriting existing results without confirmation.
Memories provide confirmed historical background.
For example, the user’s usual presentation layout and the project’s metric definitions, but before use you should still check whether they apply to this task.
3. Take the workbook-to-page conversion loss seriously
Spreadsheets and HTML have different display models. Merged cells, print areas, conditional formatting, and formula results don’t necessarily map one-to-one.
So the generation strategy should distinguish:
- Data semantics: values, units, times, and aggregation definitions must be accurate;
- Structural semantics: header levels, grouping relationships, and subtotal positions need to be preserved;
- Visual presentation: colors, font sizes, borders, and spacing can be adjusted per agreement.
Don’t sacrifice data accuracy just to make it visually “more like the original sheet.” If the parsing tool can’t compute formulas, use confirmed available results or prompt the user to supply them; don’t assume all formulas have been evaluated correctly.
4. Run layered validation before delivery
The data layer checks record counts, key values, and aggregate relationships; the structural layer checks whether headers align with data; the presentation layer checks for content overflow and whether empty values are clear; the security layer checks input escaping, sensitive information, and external-resource dependencies.
For high-value reports, it’s advisable to keep a conversion note recording the data source, processing scope, known limitations, and pending items. That way the page is not only “openable” but also explainable and reviewable.
8. Team Adoption: Moving From Piling Up Configs to Layered Governance
If you only have one simple task, a clear task description and basic tools may already be enough. Only as repetitive tasks, external systems, process risks, and cross-session information gradually increase do you need to introduce more mechanisms step by step.
A practical order of adoption is:
- If a domain method keeps recurring, organize it into a Skill first.
- If you need external data or operations, then set up a controlled connection.
- If there are multi-stage dependencies, approvals, or recovery needs, introduce a Workflow.
- If there are stable constraints across tasks, form Rules with matching checks.
- If there’s historical information that stays valid, build Memories that can be corrected and deleted.
When maintaining these, teams should version skills and rules, assign clear owners, and use fixed samples for regression testing. Changes in tool permissions, data structures, and model behavior can all make a previously effective configuration stop working.
In the end, the value of the five mechanisms lies not in their number but in clear responsibilities: skills distill methods, protocols connect capabilities, workflows organize execution, rules constrain boundaries, and memory carries context forward. Only by combining them with access control, executable validation, and auditing can AI coding move from “occasionally producing a correct result” to a reusable, traceable, and governable engineering practice.
