Skills, Protocols, Workflows, Rules, and Memories in AI Coding: What Is the Difference?
This article explains the differences between skills, MCP-style context protocols, workflows, rules, and memories in AI coding and agent systems. It compares their roles, triggers, scope, and engineering risks, then shows how to combine them into a governed runtime architecture with practical examples.
In AI coding and agent systems, skills, context protocols, workflows, rules, and memories often appear together. Beginners frequently mistake them all for prompts or plugins. In practice, they solve problems at different layers, and their lifecycles, scope, and verification methods are completely different. In one sentence: rules define boundaries, memories provide context, skills codify methods, protocols handle connectivity, and workflows orchestrate execution.
The best way to understand these five concepts is to place them in the same runtime architecture: the LLM handles understanding and generation, while the runtime handles context injection, permission control, tool invocation, and process advancement. Together, these five concept classes supplement capabilities outside the model, but they should not be conflated.
1. A Unified Comparison
| Concept | Main question it answers | Essence | Typical trigger | Scope | Engineering risks |
|---|---|---|---|---|---|
| Skill | “How should this type of task be done?” | A reusable, composable task method package | Selected by name, description, and semantics | Task-level, domain-level | Stale instructions, missing dependencies, unrepresentative examples |
| MCP-style context protocol | “How can external tools and data be connected reliably?” | A connection contract between the model and tools/data sources | Invoked by an agent or workflow request | Integration-level, service-level | Excessive permissions, untrusted returned content, call failures |
| Workflow | “In what order should multiple steps execute?” | Process orchestration and state progression | Triggered by events, schedules, humans, or parent workflows | Process-level, production-level | Rigid processes, insufficient exception handling, unobservable steps |
| Rules | “What must be done, and what must never be done?” | Constraints, policies, and acceptance boundaries | Persistently injected or enabled by condition | Organization, project, session | Conflicts, ambiguity, written but not enforced |
| Memories | “What is already known, and how should context continue?” | State retained across sessions or tasks | Retrieved before planning, written after tasks by policy | User, project, session | Staleness, contamination, privacy leakage, mistaken as a source of truth |
As the table shows, these concepts are not substitutes for one another; they form a layered relationship. A mature system typically needs rules to ensure safety, memories to provide background, skills to keep task methods consistent, protocols to make external capabilities accessible, and workflows to keep critical processes controllable.
2. Skills: Codifying “How to Do It” as Reusable Capability
A skill, often called an Agent Skill, packages the applicable conditions, execution steps, constraints, examples, resources, and scripts for a type of task into a capability module. Its core value is not “writing one more prompt.” Rather, it turns expert practice into an asset that is discoverable, reusable, versionable, and testable.
A skill usually includes a name, description, applicable scenarios, execution steps, input/output constraints, examples, dependent tools, and necessary scripts or reference materials. The name and description are especially important because the runtime often needs to decide whether to load the skill based on user intent. If the description is too broad, the skill may be triggered incorrectly; if it is too narrow, it may never be matched.
For example, a skill that “converts structured tables into HTML presentation reports” can use the following directory:
skills/report-from-table/├── SKILL.md├── references.md├── examples.md└── scripts/└── read-table
The main instruction file can be written as:
---name: spreadsheet-to-html-reportdescription: Use when the user asks to convert structured table data into a presentable HTML report---# Convert Structured Tables into HTML Reports## When to use- Input contains explicit metrics, dimensions, units, or business definitions- The user wants a report or dashboard suitable for presentation## Steps1. Read and validate the input table, and check whether fields are complete2. Identify metrics, dimensions, display formats, and anomaly thresholds3. Design the presentation for each metric and generate demo data4. Output an HTML report while listing missing items and assumptions## Constraints- Do not fabricate business definitions that cannot be derived from the input- Missing data must be explicitly marked- Explain anomalies rather than hiding them## Tools- Use the table-reading script to obtain normalized data- The final output must include verifiable field mapping notes
Skills differ from ordinary prompts in three main ways. First, a skill has a stable entry point and metadata, so the runtime can load it on demand. Second, a skill can bundle scripts, templates, and reference documents, not just natural language. Third, a skill can be tested, reviewed, and version-controlled. From an engineering perspective, skills should have clear inputs and outputs, executable steps, and explicit exception handling. Avoid writing them as broad, all-purpose assistant instructions.
3. MCP-Style Context Protocols: Solving Connectivity, Not Business Methods
MCP can be understood as a context access protocol between models and external tools or data sources. It focuses on how external capabilities are described, discovered, constrained by parameters, checked for permissions, returned as results, and isolated by session. It lets agents avoid hard-coding a separate integration for every data source.
It is important to emphasize that the protocol itself is not a skill, nor is it responsible for determining business steps. It will not automatically tell the model to “check logs before changing code,” nor does it guarantee that the model will use tools correctly. It solves standardization at the connectivity layer. A connector can expose capabilities such as querying logs, reading changes, retrieving documents, and querying tickets, but when to call them, in what order, and what to do after a failure still need to be constrained by skills, rules, or workflows.
A safe invocation chain typically includes the following steps:
- The model or workflow proposes a tool invocation intent.
- The runtime validates the tool name and parameter schema against registration information.
- The permission module checks whether the current user, project, and session allow the operation.
- The connector accesses the external system and returns structured results.
- The runtime applies redaction, truncation, or trust marking to the results.
- The model continues reasoning based on the results and requests human confirmation when necessary.
The most important engineering principles at the protocol integration layer are least privilege, explicit authorization, input/output schema validation, audit logs, and failure fallback. In particular, external returned content should not be trusted by default, because it may contain prompt injection, stale information, or malicious instructions. For write operations, publishing operations, and delete operations, human confirmation or secondary validation should be preferred.
4. Workflows: Turning Multi-Step Processes into Controllable Orchestration
Workflows handle process advancement: what happens first, what happens next, under what conditions to branch, how to retry after failure, which steps require human approval, and how final artifacts are archived. It is closer to a state machine, flowchart, or task orchestration script than to a task description.
Workflows are suitable for scenarios with high repetition, strong compliance requirements, and auditability, such as code change review, pre-release checks, troubleshooting, batch migration, and document generation and approval. An illustrative workflow is shown below:
id: code-review-flowtrigger: code-change-requestedsteps:- id: fetch-changeaction: connector.read-code-change- id: retrieve-contextaction: memory.retrieve-project-conventions- id: reviewaction: skill.code-reviewinput: fetch-change.output- id: check-evidenceaction: connector.query-test-results- id: gateaction: rule.validatecondition: has-blocking-issue- id: human-approvalaction: human.confirmwhen: gate.failed- id: publish-summaryaction: connector.publish-review-summary
The difference between workflows and skills is this: a skill answers “how to do this type of task,” while a workflow answers “how many steps this task has, who advances it, and under what conditions.” A workflow can call skills and protocol connectors. A skill can be reused by multiple workflows, but a workflow should not hard-code all business methods into the process; otherwise, the process becomes fragile and difficult to maintain.
5. Rules: Mandatory Policies and Acceptance Boundaries
Rules are explicit policies that constrain system behavior, usually including security requirements, compliance requirements, coding standards, output formats, prohibited actions, and acceptance criteria. The essence of rules is boundaries, not methods. For example:
- Do not output secrets, tokens, or private data.
- Code changes must describe their impact scope.
- Do not claim completion without test evidence.
- Changes involving production configuration must receive human approval.
- Ask when information is insufficient; do not fabricate facts.
- Output must include a change summary, risks, and rollback recommendations.
Rules should be as executable and verifiable as possible. Anything that can be enforced by the runtime, static checks, tests, or an approval system should not exist only in a prompt. Rules also need explicit priorities and conflict handling policies. For example, organization-level security rules take precedence over project-level style rules, and temporary user preferences cannot override mandatory security policies. If rules are too many, too broad, or contradictory, the model will selectively ignore them. Therefore, keep the number restrained, enable rules by project phase, and review them regularly.
Rules and memories are the easiest to confuse. Rules are authoritative constraints, while memories are context that may become stale. Memories cannot override rules, and the model must not break security boundaries because it “remembers doing it this way before.”
6. Memories: Continuing Context, but Not a Source of Truth
Memories preserve state and experience across sessions and tasks, such as user preferences, project conventions, historical decisions, common troubleshooting methods, and current task progress. They let agents avoid starting from zero every time and help maintain interaction continuity.
Memories can usually be divided into user preferences, project knowledge, episodic experience, and task state. Different memories should use different scopes and lifecycles: session memory is short, project memory lasts longer, and organization-level memory requires stronger governance. When designing a memory mechanism, focus on write policy, retrieval policy, confidence, source tracking, expiration, and deletion. Unreviewed model summaries should not become long-term memories directly; time-sensitive information should have a validity period; sensitive information should not be written.
Memory is also not the same as a knowledge base. A knowledge base tends toward authoritative documents and stable materials, while memory tends toward context formed or supplemented during interactions. Memory can hint that “this project used a certain naming convention in the past,” but during actual execution, project documents and rules should still take precedence. For conflicting information, retain the source and indicate uncertainty rather than silently overwriting it.
7. How to Combine Them
A relatively complete AI coding assistant can use the following combination:
- Rules: always inject security, compliance, quality, and approval boundaries.
- Memories: retrieve project conventions, historical decisions, and user preferences before planning.
- Skills: provide standardized methods for tasks such as code review, test generation, migration planning, and report generation.
- Protocol connectors: read code changes, defect records, logs, documents, and test results on demand.
- Workflows: organize critical tasks into observable, retryable, and approvable steps.
An illustrative configuration can be written as:
agent:rules:- security/no-secret-output- delivery/require-test-evidence- review/require-human-approval-for-productionmemories:scopes: [project, user]retrieval: before-planningskills:- code-review@1.2- release-note@2.0- migration-plan@1.1connectors:- code-change-reader- test-result-reader- document-searchworkflows:- code-review-flow- release-readiness-flow
When implementing, consider several principles. First, establish clear contracts for each asset class: skills define inputs and outputs, connectors define parameters and return structures, workflows define steps and failure policies, rules define priorities and enforcement methods, and memories define scope and expiration policies. Second, build regression tests that cover not only the happy path but also tool failures, missing information, rule conflicts, and prompt injection. Third, ensure observability by recording which rules were loaded, which memories were retrieved, which connectors were called, which skill was triggered, and at which step the process failed. Fourth, practice ongoing governance by regularly cleaning up stale skills and memories, reviewing high-risk connector permissions, and auditing rule conflicts.
In summary, skills are reusable methods for doing things, MCP-style protocols are standardized connectivity layers, workflows are controllable process orchestration, rules are boundaries that cannot be arbitrarily crossed, and memories are governed context continuation. Only with clear division of responsibilities and layered governance can AI coding capabilities move from one-off Q&A to stable, auditable, and evolvable engineering systems.
