返回新闻
产品展示AI Understanding 简报

Claude Code 推出用于自定义 AI 编码扩展的 Mods 系统

Anthropic 为 Claude Code 发布了新的“Mods”系统,允许开发人员编写在 AI 会话内运行的 JavaScript 或 TypeScript 插件,以自定义行为、添加 UI 元素和拦截工具调用。

5 min readRead the linked source
来源参考来源记录
出版商
claude.dev
来源链接
claude.devhttps://claude.dev/blog/getting-started-with-claude-code-mods/
来源类型
链接来源——主要来源状态尚未确定。
背景60 秒内了解这一点

从这里开始

关键术语

API(应用程序编程接口)
一种软件系统向另一个系统发送请求并接收响应的结构化方式。
人在环
人类审查、指导或覆盖人工智能输出的工作流程。
上下文窗口
语言模型一次可以处理的输入标记的最大数量。
测试一下自己AI 代理测验
Source video from claude.dev · shown with attribution.

发生了什么

Anthropic released a new extension system called 'Mods' for its Claude Code AI coding tool. Mods are small JavaScript or TypeScript files that run inside the Claude Code session, allowing developers to observe events, modify the AI's behavior, or draw custom user interface elements in the terminal or desktop app. The feature is available in Claude Code version 2.1.287 and later and is enabled by default. The source provides a detailed guide on building a 'Token Weather' mod, which visualizes usage, and describes two more complex examples: 'Blast Radius,' which intercepts dangerous shell commands for user confirmation, and 'Replay Theater,' which records and replays file edits made by the AI.

Anthropic has introduced 'Mods,' a new extension mechanism for Claude Code that allows developers to inject custom JavaScript or TypeScript logic directly into the AI's execution environment. Unlike previous customization methods such as settings files or slash commands, Mods operate as hooks within the session lifecycle. They can intercept events like tool calls, prompt submissions, and UI rendering, allowing them to alter the AI's behavior or display custom interface components.

The source details the technical architecture, noting that Mods run in a sandboxed environment without direct access to the DOM or Node.js, communicating with the host via a specific API. The system supports hot reloading, meaning developers can save changes to their Mod code and see them take effect immediately in a running session without restarting Claude Code. This feature is enabled by default in version 2.1.287 and later.

To illustrate the capabilities, the source walks through the creation of a 'Token Weather' Mod, which displays a live visualization of the usage above the prompt. It also describes 'Blast Radius,' a Mod that intercepts potentially destructive shell commands (like `rm -rf` or `git reset --hard`) and prompts the user for confirmation before execution, and 'Replay Theater,' which logs file edits made by the AI and allows users to review them in a step-by-step pane.

The source emphasizes that Mods are distinct from standard settings hooks, which execute shell commands, whereas Mods maintain state within the session and can interact with the UI. Anthropic notes that some of Claude Code's own features, such as AGENTS.md support and the /diff pane, are built using this Mod architecture, with their source code available in the public anthropics/claude-code repository.

来源详情: claude.dev ↗

为什么这很重要

This update significantly expands the customizability of Claude Code, moving it beyond static settings and slash commands to a dynamic plugin architecture. By allowing code to run inside the session with access to session state and UI rendering, developers can build tailored safety nets, custom dashboards, and workflow-specific tools. This shift positions Claude Code as a more flexible platform for enterprise and power users who need to integrate the AI into specific, complex development environments. It also introduces a new layer of security consideration, as third-party mods run with the same access as the AI tool itself, requiring users to vet code before installation.

The introduction of Mods represents a shift from a closed, configuration-based tool to an open, programmable platform. This allows developers to tailor the AI's behavior to specific team workflows, such as enforcing custom code review standards or integrating with internal monitoring tools. The ability to draw custom UI elements means the AI's interface can be adapted to display relevant metrics or controls that are not part of the default experience.

From a safety perspective, the 'Blast Radius' example highlights a practical application for AI safety in coding: providing a checkpoint for high-risk operations. While the source notes this is a safety net rather than a hard permission system, it demonstrates how Mods can be used to mitigate the risks of autonomous AI actions in a development environment.

The ecosystem implications are significant. By allowing Mods to be shared via marketplaces and the Claude directory, Anthropic is fostering a community-driven ecosystem of extensions. This could lead to a wide variety of specialized tools for different programming languages, frameworks, or industry-specific compliance requirements, enhancing the utility of Claude Code for diverse user bases.

Interactive Mechanism

互动机制:它实际上是如何运作的

以交互方式探索这一发展背后的基础技术。

Agent Lifecycle Stage:
1
User Intent & Planning: "Audit customer refund request #4092 and settle payment."
2
Tool Calling: Emits structured JSON call crm_get_transaction(id='4092').
3
Guardrail & Verification:🛡️ Paused: High-value action requires human operator sign-off.
4
Final Settlement: Refund recorded, email receipt dispatched, and audit log stored.
Core takeaway: An AI agent is not just a language model—it is a closed loop of planning, tool invocation, and environment feedback. Production systems require self-healing retries and strict human approval guardrails.
交互式概念检查+10 Points
AI Agents Quiz

An agent must create a draft calendar event for Tuesday at 2 p.m. Which evidence would establish the requested result?

接下来看什么

Developers should watch for the emergence of a community marketplace for Claude Code Mods, as the source notes that plugins can be shared via GitHub repositories or submitted to the Claude directory. Security teams should monitor the safety implications of running third-party code within the AI session, particularly regarding the 'Blast Radius' example which highlights the need for confirmation for destructive commands. Additionally, the stability of the Mod API across future Claude Code releases will be critical, as the source warns that the API can change between releases.

The stability and evolution of the Mod API will be a key factor in its adoption. The source explicitly warns that the API can change between releases, which may require developers to update their Mods frequently. Monitoring the changelog and type declarations provided in the .claude-plugin/types/ folder will be essential for maintaining custom extensions.

Security practices around Mod installation will become more important. Since Mods run with the same access as Claude Code, users must vet third-party code carefully. The source advises reading the repository and only installing from trusted sources, a practice that will likely become standard as the Mod ecosystem grows.

The development of a robust marketplace for Mods could accelerate the adoption of Claude Code in enterprise settings. As more specialized and high-quality Mods become available, the tool may become more attractive to organizations with complex development needs that require deep customization.

相关指南和测验

人工智能代理人工智能模型解释Prompt Engineering测试你所知道的——尝试免费的人工智能测验在我们的词汇表中查找人工智能术语关注 AI 模型发布跟踪器
觉得这有用吗?