AI Coding Agents Explained: 13 Primitives Across 5 ToolsAI 编码代理的原理:5 个工具中的 13 个基本概念

AI coding agents use the same concepts under different names. This guide maps 13 agent primitives across Claude Code, Cursor, Gemini, Copilot and OpenCode.AI 编码代理使用不同的名称来表达相同的概念。本指南将 Claude Code、Cursor、Gemini、Copilot 和 OpenCode 中的 13 个代理基本概念进行了映射。

AI Coding Agents Explained: 13 Primitives Across 5 Tools
AI Agent PrimitivesAI 代理基本概念

The terminology differs from AI agent tool to AI agent tool. One tool's "rules" are another's "memory file"; one tool's "command" is another's "skill." The safest way to structure a cheatsheet is therefore not by vendor, but by generic AI primitives - and then map each tool's terminology onto those primitives.术语因 AI 代理工具而异。一个工具的“规则”是另一个工具的“记忆文件”;一个工具的“命令”是另一个工具的“技能”。因此制作速查表最稳妥的方法不是按厂商,而是按通用 AI 基本概念,然后将各工具的术语映射到这些基本概念上。

This keeps the mental model stable even as tools rename features, merge concepts, or ship new ones every other week.这样即使工具更改功能名称、合并概念或每两周发布新功能,也能保持心智模型的稳定。

Below are the primitives I find most useful, with examples. At the end there's a mapping table and a short "which one do I reach for?" section, because the hardest part in practice isn't knowing the primitives - it's telling a few of them apart.以下是我在实践中发现最有用的基本概念,并附带示例。文末有一个映射表和一个简短的“我应该使用哪个?”部分,因为实际应用中最难的部分并不是知道这些基本概念——而是将它们区分开来。

Generic primitives通用基本概念

Instructions / Rules指令 / 规则

Persistent guidance, conventions, and knowledge for the agent. Loaded every session so the agent stays anchored to your project's reality.为代理提供的持久性指导、约定和知识。每次会话都会加载,使代理保持与您项目的实际情况一致。

Examples:示例:

  • Architecture rules(架构规则)
  • Coding guidelines(编码规范)
  • Testing strategy(测试策略)
  • Deployment strategy(部署策略)
  • Git Workflow(Git 工作流)

Mapping note: AGENTS.md is emerging as a cross-vendor convention for this primitive and is now read by several tools. Vendor-specific variants include CLAUDE.md, GEMINI.md, and .cursorrules / rule files.映射说明:AGENTS.md 正在成为一种跨厂商的约定标准,且已被多个工具读取。厂商专用变体包括 CLAUDE.md、GEMINI.md 以及 .cursorrules / 规则文件。

Prompts / Commands提示词 / 命令

A reusable task description, often manually invoked.一种可重复使用的任务描述,通常由手动调用。

Examples:

  • /review → initiate a code review(/review → 启动代码审查)
  • /create-adr → create an architecture decision record for a specific aspect/create-adr → 为特定方面创建架构决策记录
  • /write-tests → write unit tests for a specific class, component, …/write-tests → 为特定类、组件等编写单元测试

Skills技能

A packaged capability with instructions, resources, and optionally scripts. Unlike a command, a skill can bundle reference material and executable helpers, and can often be invoked autonomously by the agent when relevant - not just manually.包含指令、资源和可选脚本的能力打包。与命令不同,技能可以打包参考资料和可执行辅助程序,并且通常可以在相关时由代理自主调用,而非仅仅手动调用。

Examples:

  • Generate a C4 model(生成 C4 模型)
  • Perform a security review(执行安全审查)
  • Generate test data(生成测试数据)

Agents / Subagents代理 / 子代理

A specialized role with its own task, context boundaries, and sometimes its own tool permissions. The point is context isolation: a subagent works in its own window so it doesn't pollute the main session.拥有独立任务、上下文边界,有时还有独立工具权限的专门角色。其目的是上下文隔离:子代理在自己的窗口中工作,因此不会污染主会话。

Examples:

  • Architect Agent(架构代理)
  • Reviewer Agent(审查员代理)
  • Tester Agent(测试员代理)
  • Requirement Engineer Agent(需求工程师代理)

Modes模式

A runtime behavior switch for the same agent, as opposed to a separate role. Worth distinguishing from agents/subagents because it changes how the agent acts rather than who it is.同一代理的运行时行为切换,与独立角色不同。值得与代理/子代理区分开来,因为它改变的是代理的行为方式,而不是代理的角色。

Examples:

  • Plan mode (think first, don't edit)(计划模式(先思考,不要编辑))
  • Ask / read-only mode(提问 / 只读模式)
  • Edit / auto-accept mode(编辑 / 自动接受模式)
  • Output style / persona(输出风格 / 人设)

Hooks钩子

Deterministic automation triggered by lifecycle events. Hooks are code, not prompts - they fire predictably regardless of what the model decides.由生命周期事件触发的确定性自动化。钩子是代码,不是提示词;无论模型如何决定,它们都会按预期触发。

Examples:

  • Before tool use(工具使用之前)
  • After file change(文件更改之后)
  • Before commit(提交之前)
  • After session start(会话开始之后)

Tools / MCP Servers工具 / MCP 服务器

External capabilities and data sources made available to the agent.提供给代理的外部能力和数据源。

Examples:

Context References / Mentions上下文引用 / 提及

The manual mechanism for pulling specific things into the current context - distinct from Memory (which is persistent and often automatic) and from Tools (which are external). This answers the question: what is the agent looking at right now?将特定内容拉取到当前上下文中的手动机制——这与记忆(持久且通常是自动的)以及工具(外部)不同。这回答了一个问题:代理现在正在看什么?

Examples:

  • @file / @folder references(@文件 / @文件夹引用)
  • @symbol (a specific class or function)(@符号(特定的类或函数))
  • @url / docs references(@url / 文档引用)
  • Pinned or attached files(固定或附加的文件)

Memory / Context Store记忆 / 上下文存储

Persistent context that survives across sessions.在会话之间保持存活的持久上下文。

Examples:

  • Project memory(项目记忆)
  • Personal preferences(个人偏好)
  • Workspace memories(工作区记忆)

Codebase Indexing / Retrieval代码库索引 / 检索

Semantic search over a large codebase (embeddings, indexing) so the agent can find relevant code without you pasting it in. Often invisible and automatic, but it's a real primitive - it's how the agent retrieves from a repo too big to fit in context.对大型代码库进行语义搜索(嵌入,索引),以便代理可以在您不粘贴的情况下找到相关代码。这通常是不可见且自动的,但它是一个真实的基本概念——也就是代理如何从太大的仓库中检索内容。

Examples:

  • Repository embedding index(仓库嵌入索引)
  • Semantic "find related code"(语义“查找相关代码”)
  • Documentation / knowledge indexing(文档 / 知识索引)

Permissions / Sandboxing / Autonomy权限 / 沙箱 / 自主性

The safety boundary: what the agent is allowed to do, and how much it can do without asking. Easy to overlook because it lives in settings, but it's the difference between a helpful assistant and an unsupervised process running shell commands.安全边界:代理被允许做什么,以及在不请求许可的情况下能做多少。这很容易被忽视,因为它位于设置中,但这是有益助手和不受监管的进程(运行 shell 命令)之间的区别。

Examples:

  • Allow / deny lists for tools and commands(工具和命令的允许/拒绝列表)
  • Auto-approve rules(自动批准规则)
  • Sandboxed execution(沙箱执行)
  • Autonomy levels (ask everything ↔ fully auto)(自主性级别(询问一切 ↔ 完全自动))

Checkpoints / Sessions / State检查点 / 会话 / 状态

Within- and across-session runtime state: the ability to rewind, restore, resume, and compact. Distinct from Memory - Memory is what the agent remembers, checkpoints are being able to undo and go back.会话内和会话间的运行时状态:重做、恢复、继续和压缩的能力。与记忆不同——记忆是代理记得什么,检查点是能够撤销和回溯。

Examples:

  • Checkpoint / rewind to an earlier point(检查点 / 重做到较早的点)
  • Session resume(会话恢复)
  • Context compaction(上下文压缩)
  • Undo of agent edits(撤销代理的编辑)

Packages / Plugin Extensions包 / 插件扩展

A distribution unit that bundles skills, rules, hooks, commands, and MCP servers into one installable thing.将技能、规则、钩子、命令和 MCP 服务器打包为一个可安装东西的分发单元。

Examples:

Free Cheat Sheet as PDF免费 PDF 速查表

Every AI coding tool calls the same things by different names. This one-page cheat sheet maps them all - 13 agent primitives across Claude Code, Cursor, Gemini, Copilot and OpenCode, each linked to the official docs. Grab it free below 👇每个 AI 编码工具都用不同的名称调用相同的东西。这个单页速查表将它们全部映射出来——13 个代理基本概念,涵盖 Claude Code、Cursor、Gemini、Copilot 和 OpenCode,每个都链接到官方文档。请在下方免费获取 👇