File: plugins.md | Updated: 11/15/2025
Agent Skills are now available! Learn more about extending Claude's capabilities with Agent Skills .
English
Search...
Ctrl K
Search...
Navigation
Guides
Plugins in the SDK
Home Developer Guide API Reference Model Context Protocol (MCP) Resources Release Notes
On this page
Plugins allow you to extend Claude Code with custom functionality that can be shared across projects. Through the Agent SDK, you can programmatically load plugins from local directories to add custom slash commands, agents, skills, hooks, and MCP servers to your agent sessions.
Plugins are packages of Claude Code extensions that can include:
For complete information on plugin structure and how to create plugins, see Plugins .
Load plugins by providing their local file system paths in your options configuration. The SDK supports loading multiple plugins from different locations.
TypeScript
Python
Copy
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Hello",
options: {
plugins: [\
{ type: "local", path: "./my-plugin" },\
{ type: "local", path: "/absolute/path/to/another-plugin" }\
]
}
})) {
// Plugin commands, agents, and other features are now available
}
Path specifications
Plugin paths can be:
"./plugins/my-plugin")"/home/user/plugins/my-plugin")The path should point to the pluginβs root directory (the directory containing .claude-plugin/plugin.json).
When plugins load successfully, they appear in the system initialization message. You can verify that your plugins are available:
TypeScript
Python
Copy
import { query } from "@anthropic-ai/claude-agent-sdk";
for await (const message of query({
prompt: "Hello",
options: {
plugins: [{ type: "local", path: "./my-plugin" }]
}
})) {
if (message.type === "system" && message.subtype === "init") {
// Check loaded plugins
console.log("Plugins:", message.plugins);
// Example: [{ name: "my-plugin", path: "./my-plugin" }]
// Check available commands from plugins
console.log("Commands:", message.slash_commands);
// Example: ["/help", "/compact", "my-plugin:custom-command"]
}
}
Commands from plugins are automatically namespaced with the plugin name to avoid conflicts. The format is plugin-name:command-name.
TypeScript
Python
Copy
import { query } from "@anthropic-ai/claude-agent-sdk";
// Load a plugin with a custom /greet command
for await (const message of query({
prompt: "/my-plugin:greet", // Use plugin command with namespace
options: {
plugins: [{ type: "local", path: "./my-plugin" }]
}
})) {
// Claude executes the custom greeting command from the plugin
if (message.type === "assistant") {
console.log(message.content);
}
}
If you installed a plugin via the CLI (e.g., /plugin install my-plugin@marketplace), you can still use it in the SDK by providing its installation path. Check ~/.claude/plugins/ for CLI-installed plugins.
Hereβs a full example demonstrating plugin loading and usage:
TypeScript
Python
Copy
import { query } from "@anthropic-ai/claude-agent-sdk";
import * as path from "path";
async function runWithPlugin() {
const pluginPath = path.join(__dirname, "plugins", "my-plugin");
console.log("Loading plugin from:", pluginPath);
for await (const message of query({
prompt: "What custom commands do you have available?",
options: {
plugins: [\
{ type: "local", path: pluginPath }\
],
maxTurns: 3
}
})) {
if (message.type === "system" && message.subtype === "init") {
console.log("Loaded plugins:", message.plugins);
console.log("Available commands:", message.slash_commands);
}
if (message.type === "assistant") {
console.log("Assistant:", message.content);
}
}
}
runWithPlugin().catch(console.error);
A plugin directory must contain a .claude-plugin/plugin.json manifest file. It can optionally include:
Copy
my-plugin/
βββ .claude-plugin/
β βββ plugin.json # Required: plugin manifest
βββ commands/ # Custom slash commands
β βββ custom-cmd.md
βββ agents/ # Custom agents
β βββ specialist.md
βββ skills/ # Agent Skills
β βββ my-skill/
β βββ SKILL.md
βββ hooks/ # Event handlers
β βββ hooks.json
βββ .mcp.json # MCP server definitions
For detailed information on creating plugins, see:
Development and testing
Load plugins during development without installing them globally:
Copy
plugins: [\
{ type: "local", path: "./dev-plugins/my-plugin" }\
]
Project-specific extensions
Include plugins in your project repository for team-wide consistency:
Copy
plugins: [\
{ type: "local", path: "./project-plugins/team-workflows" }\
]
Multiple plugin sources
Combine plugins from different locations:
Copy
plugins: [\
{ type: "local", path: "./local-plugin" },\
{ type: "local", path: "~/.claude/custom-plugins/shared-plugin" }\
]
Plugin not loading
If your plugin doesnβt appear in the init message:
.claude-plugin/)Commands not available
If plugin commands donβt work:
plugin-name:command-name formatslash_commands with the correct namespacecommands/ directoryPath resolution issues
If relative paths donβt work:
Was this page helpful?
YesNo
Assistant
Responses are generated using AI and may contain mistakes.