返回新聞
產品展示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 模型發布追蹤器
覺得有用嗎?