AI Coding: Skills, Tool Protocols, Workflows, Rules, and Memory Explained

    Skills, tool protocols, workflows, rules, and memory serve different roles in AI coding systems. This article explains their responsibilities, lifecycle and context costs, common implementation mistakes, and how to combine them into a maintainable architecture. It also examines tool-loading overhead and the metrics needed to evaluate reliability and efficiency.

    As AI coding tools evolve from single-turn conversations into engineered context systems, skills, tool protocols, workflows, rules, and memory are often treated as interchangeable. All can influence model output and consume context, but they solve different problems:

    • Skills: How should a particular type of task be performed?
    • Tool protocols: How does the model connect to and invoke external capabilities?
    • Workflows: In what order should a multistep task run?
    • Rules: What behavioral constraints must be followed?
    • Memory: What information should persist across sessions?

    Treating these mechanisms as equivalent leads to common mistakes: using rules as memory, using workflows as skills, or loading every available tool by default.

    1. Start with a Layered Mental Model

    These five concepts operate at different levels of abstraction:

    • Skills are reusable capability packages, typically containing instructions, examples, templates, scripts, or procedures. Their purpose is to encapsulate know-how.
    • Tool protocols standardize connections between a model and external tools or data sources. They support tool discovery, parameter descriptions, invocation, and result delivery.
    • Workflows orchestrate steps, states, branches, retries, and human approvals. Their purpose is process control.
    • Rules constrain model behavior and output formats, establishing boundaries and consistency.
    • Memory preserves information across requests or sessions, providing long-term context.

    Their lifecycles also differ. Rules often remain active throughout a session or are loaded in layers. Memory requires writing, retrieval, expiration, and deletion. Skills are typically triggered by relevant tasks. Tools are exposed through protocols as needed. Workflows coordinate execution across one or more tasks.

    Each mechanism has a different cost profile:

    • Rules and memory incur context-injection costs.
    • Tool protocols incur tool-definition and returned-result costs.
    • Skills incur on-demand loading costs.
    • Workflows primarily incur orchestration and state-management costs.

    Understanding these differences is essential to choosing the right mechanism.

    2. Skills: Package “How to Do It” as a Reusable Asset

    A skill is more than an additional prompt. It turns successful practices for a category of tasks into a maintainable asset.

    A skill package typically includes its intended use cases, input and output contracts, procedures, examples, failure handling, required tools, and version information. For example, a release-notes skill might specify how to extract information from change records, organize it into a fixed structure, check for sensitive information, and produce a draft for approval.

    Skills offer high information density, reuse, and on-demand loading. Instead of keeping every procedure in the system prompt, the system loads the relevant skill when needed, reducing unrelated context.

    However, skills introduce risks: version drift, excessive permissions, outdated examples, and conflicts with rules. They should be versioned, testable, governed by least privilege, and validated against acceptance examples.

    The following configuration is illustrative:

    1. {
    2. "skill": "release_notes",
    3. "trigger": "when release notes need to be prepared",
    4. "load": "on_demand",
    5. "inputs": ["change records", "target version"],
    6. "steps": [
    7. "extract changes",
    8. "categorize changes",
    9. "check for sensitive information",
    10. "generate a draft"
    11. ],
    12. "requires_confirmation": true
    13. }

    3. Tool Protocols: Define How to Connect and Invoke

    Tool protocols provide a standardized connection layer. They tell the model which tools are available, what parameters each tool requires, and what structure its results will have. They also bring invocation results back into context.

    A protocol does not guarantee that a task will be completed correctly. It provides connectivity.

    Tool definitions have an upfront cost

    Tool proliferation is a common problem. In one reported setup, a protocol service for code-hosting tools exposed roughly 46 tools by default, adding nearly 20,000 tokens of tool definitions per request. Those definitions consumed context before any tool was called.

    Returned data creates a second cost

    In another measurement of a similar task, a single tool response containing release information occupied approximately 20,000 tokens—even more than all the tool definitions combined.

    The ability to return data does not mean all of it should be returned. Engineering controls should include result trimming, field filtering, pagination, summarization, and caching.

    More tools also increase selection difficulty

    As the tool catalog grows, selecting the right tool becomes harder.

    Server-side tool retrieval can substantially reduce upfront definition costs. For example, it can reduce the initial exposure cost of roughly 46 tools to fewer than 600 tokens. However, it adds a retrieval step.

    In one measurement, input-token usage was approximately:

    • Command-line approach: 1,400 tokens
    • Skill-based approach: 3,300 tokens
    • Protocol service with all tools loaded by default: 59,000 tokens

    These are measurements from particular setups, not universal benchmarks. Server-side retrieval can greatly reduce upfront context costs, but its effect on total cost varies with model size. For smaller models, the additional retrieval step may increase overall cost.

    The goal is therefore not to expose everything. It is to make tools grouped, available on demand, retrievable, and controlled in what they return.

    4. Workflows: Control the Execution Sequence

    Workflows handle orchestration: step order, state transitions, conditional branches, failure retries, idempotency, human approvals, and auditing.

    A bug-fixing workflow, for example, might include:

    1. Reproduce the defect.
    2. Locate the cause.
    3. Modify the code.
    4. Run tests.
    5. Generate a change description.
    6. Wait for review.

    A workflow can invoke skills and tools through their protocols. It should not, however, be responsible for remembering project preferences or defining coding standards.

    Workflows provide determinism and observability, making them particularly useful for repetitive tasks and processes with strict compliance requirements.

    The main risk is over-orchestration. Encoding every judgment call into a process makes it rigid. Treating a workflow as a skill library also makes individual procedures harder to reuse.

    A better separation is to put stable execution sequences in workflows, reusable methods in skills, and behavioral boundaries in rules.

    5. Rules: Define Required and Prohibited Behavior

    Rules constrain model behavior. Common examples include coding style, directory structure, commit-message formats, security restrictions, output formats, and tool-use boundaries.

    Rules should be concise, explicit, and testable. They should also be loaded according to their scope, such as project, team, or task.

    Rules are not a knowledge base and should not contain large amounts of background material. They are not memory either: understanding a rule should not depend on access to earlier conversations.

    Rule governance centers on conflict detection and verifiability. Two rules may contradict one another—for example, “provide as much detail as possible” and “output only the conclusion.” Rules therefore need clear priorities and scopes, along with evaluations that measure compliance.

    More rules do not automatically mean greater safety. Long rule sets consume context and can cause important constraints to be overlooked.

    6. Memory: Preserve Relevant Information Across Sessions

    Memory retains preferences, project facts, past decisions, and lessons learned across sessions.

    The distinction from rules is straightforward:

    • Rules specify constraints that must be followed.
    • Memory provides historical information that can inform the current task.

    Rules are usually maintained explicitly by people, while memory may be written automatically by the system.

    Memory requires read and write policies covering:

    • What information may be stored
    • At which layer it should be stored
    • When it should be retrieved
    • When it should expire
    • How it can be deleted

    Without governance, memory becomes noise and may introduce privacy or compliance risks.

    Memory is also different from a skill. Memory answers, “What did this project decide previously?” A skill answers, “What procedure should be used for this type of task?”

    The two can work together. A skill may retrieve relevant memory during execution, but the source and freshness of that memory must be checked.

    7. How to Choose and Combine These Mechanisms

    Use the problem you are solving to identify the appropriate mechanism:

    Question Primary mechanism
    How should this type of task be performed? Skills
    How can the model connect to and invoke an external system? Tool protocols
    How should steps, retries, and approvals be coordinated? Workflows
    What boundaries must be respected? Rules
    What should persist across sessions? Memory

    A practical architecture uses rules as the foundation, memory as project context, skills for reuse, workflows for orchestration, and tool protocols for connectivity.

    For deployments on Baidu AI Cloud, general-purpose logging, monitoring, access controls, and controlled storage capabilities can support auditing and governance. The central architectural requirement remains the same: keep the responsibilities of the five mechanisms separate.

    Evaluation should go beyond whether a single task produced the correct answer. It should also track:

    • Input-token usage
    • Tokens returned by tools
    • Retrieval steps
    • Rule compliance rate
    • Memory hit rate
    • Human rework rate

    Treating the context budget as an engineering resource is essential to moving AI coding systems from merely usable to maintainable, auditable, and scalable.