The Five Mechanisms of AI Coding: Skills, MCP, Protocols, Workflows, Rules, and Memory
This article explains how Skills, MCP (Model Context Protocol), Workflows, Rules, and Memories serve different layers of an AI coding system. It clarifies their boundaries, shows how to design each one correctly, and demonstrates how they work together in a complete spreadsheet-to-web-report scenario, with guidance on selection, governance, and reliability.
1. Start with the Right Mental Model: They Are Not Five Kinds of the Same Tool
In AI-powered coding environments, Skill, MCP, Workflow, Rules, and Memories often appear together, which leads to the misconception that they are five different forms of prompts. In reality, they operate at different layers of the system.
Five questions help distinguish them:
- Skill: How should this type of task be done?
- MCP (Model Context Protocol): How can external tools and resources be connected in a standardized way?
- Workflow: How are multiple steps organized, advanced, and recovered?
- Rules: What constraints must be followed during execution?
- Memories: Which historical information is worth retaining and reusing?
For example, when asking an agent to generate a web report from a spreadsheet: skills provide methods for analyzing the spreadsheet, identifying metrics, and structuring pages; the protocol lets the agent access files or invoke tools; the workflow arranges stages such as reading, validation, generation, and review; rules require that data not be fabricated and sensitive information not be leaked; memories store display preferences the user has already confirmed.
Note that the boundaries between these terms are not perfectly consistent across implementations. Some environments implement workflows as prompt templates, while others provide execution engines with persistent state. Memories may just be summary files rather than an independent retrieval system. When interpreting these concepts, look at how they actually run, not just at their names.
2. Skill: Packaging Task Methods as Reusable Capabilities
1. A skill is more than a prompt
A skill can be understood as a capability package organized around a type of task. It typically includes:
- Name and purpose description
- Applicable and non-applicable conditions
- Input requirements and output standards
- Execution steps and quality checks
- Optional references, templates, or scripts
The textual instructions guide the model, scripts handle deterministic computation or transformation, and templates ensure consistent output formats. Therefore, treating a skill as merely “a longer prompt” is insufficient.
For example, a “generate web report” skill should not just say “make a beautiful page.” It should specify how to handle multiple worksheets, how to determine metric units, which chart types suit different data structures, and how missing values should be displayed.
2. Skill discovery and skill execution are two different things
Some implementations first provide the model with skill names and short descriptions, then load the detailed content once a task matches. This on-demand loading keeps irrelevant information out of the context.
However, two pitfalls must be avoided:
First, a similar description does not guarantee an accurate match. Overly broad skill names and vague applicability conditions increase the chance of selecting the wrong skill.
Second, loading a skill does not equal granting execution permissions. A skill may require reading files, but whether reading is allowed is determined by the runtime environment, tool permissions, and user authorization.
3. How to organize a skill
The following is an illustrative directory layout; it is not a mandatory standard for all AI coding environments:
report-skill/├── instruction.md├── references/│ └── presentation-guide.md├── examples/│ └── sample-report.md└── scripts/└── table-reader
The instruction file should answer three questions first:
- When should this skill be used?
- What key decisions occur during execution?
- How is a successful result judged?
References should carry longer domain knowledge, keeping details out of the main instructions. Deterministic parsing, format conversion, and data validation can be delegated to scripts, reducing the inconsistencies that arise when the model repeatedly reasons about them.
3. MCP: A Protocol for Connecting Capabilities, Not a Task Method
1. The protocol solves “how to interact”
The Model Context Protocol is a protocol mechanism for connecting intelligent applications to external capabilities. A common architecture includes a host application, clients, and servers: the host contains the agent, clients manage connections, and servers expose available capabilities.
A server can expose tools, resources, and reusable prompt templates. For example:
- Tools: execute retrieval, read structured data, or trigger an operation
- Resources: provide documents, file contents, or other context
- Prompt templates: offer templates that clients can use
Actual support depends on the specific implementation. Do not assume that all capabilities are available just because the protocol is connected.
2. The protocol does not decide business strategy
A tool that reads a spreadsheet can return cell values, but it typically does not decide:
- Which metrics should be placed on the front page
- Whether anomalous data should be excluded from summaries
- Which business calculation basis a chart should use
- Which step requires human confirmation
These questions belong to skills, workflows, or rules.
Also, using a skill does not require MCP. A skill can call local scripts or tools already provided by the host. Conversely, adopting MCP does not require a skill directory.
Skills and protocols are two cooperative layers, not substitutes for each other.
3. A standardized connection is not a secure connection
The protocol standardizes interaction, but it cannot automatically guarantee that servers are trustworthy, data is correct, or operations are compliant.
In practice, you still need to:
- Grant minimal permissions scoped to the task
- Restrict accessible directories and data ranges
- Require approvals for delete, write, and publish operations
- Log tool calls and results of key operations
- Treat tool-returned content as external input, not as high-priority instructions
If a retrieved document contains text like “ignore the previous rules,” treat it as data to be processed, not as an instruction to follow.
4. Workflow: Turning Tasks into an Advancing Process
1. Workflows focus on relationships between steps
Skills emphasize “the method for a type of task”; workflows emphasize “how multiple steps are organized.”
A report-generation process can be designed as:
Receive file↓Parse spreadsheet↓Validate data and metric definitions↓Generate page draft↓Check data consistency and presentation↓Human review↓Deliver result
If validation finds a required field missing, the flow should move to gathering supplementary information rather than continuing to generate. If human review rejects the output, the flow should return to the revision stage instead of re-running every step.
2. A step list in a prompt is not reliable orchestration
Writing “first do A, then B, finally C” in a prompt provides sequencing guidance, but it cannot guarantee that every step is executed, nor does it automatically provide breakpoint recovery or retry capability.
When reliable execution is needed, you should explicitly maintain:
- The current stage
- Each stage’s inputs and outputs
- State transition conditions
- Retry counts and termination conditions
- Approval results
- External side effects already produced
Especially for steps involving publishing or writing, check before retrying whether the operation has already completed, to avoid duplicate submissions. Retry strategies should also distinguish transient failures from business errors: a connection timeout can be retried a limited number of times, while a missing required field should prompt for supplementary information.
3. Skills can be invoked by workflows
A complete workflow may combine multiple skills, such as data cleaning, metric analysis, and page generation. Each skill may also contain its own local steps.
The key criterion for whether an independent workflow is needed is not the number of steps, but whether explicit state, conditional branching, human approval nodes, and recoverable execution are required.
5. Rules: Constraining Execution Behavior, Not Adding Execution Capability
1. Rules answer “what must or must not be done”
Rules are suited to stable, cross-task constraints, such as:
- Never fabricate business data that does not exist in the input
- Check project conventions before modifying files
- Never expose access credentials in output
- External write operations require authorization
- When data is missing, clearly flag it—do not default to zero
Rules can also be scoped at organization, project, or directory level, but the exact loading mechanism and precedence are determined by the runtime environment; do not assume there is a universal filename or a universal override order.
2. Rules should be short, specific, and verifiable
“Ensure quality” is too abstract to execute and check. A better formulation is:
Summary values in the report must be calculated from the input data using the same calculation basis; if the basis cannot be confirmed, pause generation and request confirmation.
Rules should also state scope and exceptions. For example, “do not modify files” and “generating new deliverable files is allowed” need a clear boundary; otherwise, unnecessary conflicts arise.
3. Prompt rules are not a security isolation mechanism
Writing “do not access directory X” in a prompt cannot replace filesystem permission controls; writing “do not leak secrets” in rules cannot replace credential isolation and output checks.
Key security boundaries should be enforced by permission systems, sandboxes, approvals, and audits. Rules guide model behavior; enforced controls limit actual capabilities. The two should be used together.
6. Memories: Continuing Information, Not Permanently Saving Every Conversation
1. Memory focuses on cross-task reuse
Memories can store user preferences, confirmed project facts, or intermediate progress. For example:
- The user prefers Chinese metric names
- A project follows a specific directory organization convention
- The unit for the current report’s amounts has been confirmed
- A previous review noted that a metric needs additional explanation
Not all of these are suitable for permanent storage. A unit may belong only to the current report; display preferences may apply across many tasks; project facts may change as versions evolve.
2. Memories need provenance and validity scope
A memory item should ideally include:
- The information content
- Its source
- Confirmation status
- Scope of applicability
- Update time
- Expiration or cleanup conditions
User-confirmed facts and model inferences must be treated differently. Retrieving a historical record does not mean it is still valid. For example, if an old memory says “display in ten-thousands by default” but the user now explicitly requires “display in yuan,” the current request takes precedence. Memory is auxiliary context and should not be treated as an immutable rule.
3. Memory carries privacy and pollution risks
Do not indiscriminately save complete conversations, sensitive business data, or access credentials. Unconfirmed inferences that are repeatedly retrieved can gradually take on the appearance of established “facts.”
Therefore, provide correction, deletion, and expiration mechanisms, and require key facts to be re-confirmed in high-risk scenarios.
7. Complete Practice: Generating a Web Report from a Spreadsheet
When expanding the original request into a deliverable plan, first confirm inputs, calculation bases, and delivery boundaries—do not immediately ask the model to generate pages.
1. Determine inputs and acceptance criteria
Inputs should include at least:
- The original spreadsheet
- The worksheets or data ranges to display
- Metric definitions, units, and time ranges
- The page purpose and target readers
- Requirements for style fidelity and interactivity
Acceptance criteria may include data consistency, missing-value annotation, page readability, sensitive-information handling, and basic usability in the target browsing environment.
Merged cells, formulas, charts, and print layouts in a spreadsheet cannot always be directly and equivalently converted into web structures. Distinguish between “restoring visual style” and “rebuilding a business presentation,” and confirm in advance which differences are acceptable.
2. Give the skill a concrete method
The report skill can include the following steps:
- Identify header rows, data regions, and summary regions
- Confirm formula results and readable content
- Extract structured data while preserving source locations
- Validate missing values, duplicate records, and units
- Select display components based on business meaning
- Generate the page and check key metrics
- Output the result along with notes on conversion limitations
Formula cells deserve particular attention: some read methods return only the formula text or cached values and cannot guarantee recalculation. When a reliable result cannot be obtained, state that clearly instead of guessing.
3. Let each mechanism do its job
- Skill encapsulates report transformation and verification methods
- MCP provides file reading or other tool access when unified connections are needed
- Workflow maintains the parse → validate → generate → review → deliver state
- Rules constrain data authenticity, privacy handling, and operation permissions
- Memories retain confirmed display preferences and project background
When generating pages, escape special characters in the data so spreadsheet text is not treated as executable content. Whether sensitive fields are hidden should be decided by explicit rules, not guessed by the model.
8. Selection and Governance: Solve the Problem First, Then Choose the Mechanism
In practice, use this decision order:
Only lacking a consistent approach?
Write a skill first, with clear inputs, steps, and output standards.Need to access external systems?
Choose an appropriate connection method; consider MCP only when protocol-based integration is needed.Need branching, approvals, retries, or recovery?
Build an explicit workflow rather than relying solely on step prompts.Have cross-task constraints?
Extract rules, and enforce the critical limits through permission controls.Need to retain confirmed information?
Build memories with scope, provenance, and updatability.
Don’t stuff all knowledge into rules, and don’t turn all history into memories. Excess context adds noise, and duplicated or conflicting configurations reduce execution stability.
From an engineering standpoint, manage versions of skills, rules, and workflows separately, retain change records, and run regression tests with representative tasks. Tests should cover not only successful outputs but also failure scenarios such as corrupted files, missing fields, insufficient permissions, and external content containing malicious instructions.
9. Conclusion: Reusable Capability and Reliable Execution Require Layered Design
These five mechanisms together form different parts of an AI coding system, but none of them can replace all the others on its own. Skills consolidate methods, protocols connect capabilities, workflows organize processes, rules constrain behavior, and memories carry information forward. A truly reliable solution places each type of information where it belongs, while enforcing clear state, permission boundaries, and acceptance criteria.
Understanding these distinctions lets developers move from “constantly appending prompts” to “designing reusable, checkable, and governable task systems.”
