Loading...
    • Developer Guide
    • API Reference
    • MCP
    • Resources
    • Release Notes
    Search...
    ⌘K

    First steps

    Intro to ClaudeQuickstart

    Models & pricing

    Models overviewChoosing a modelWhat's new in Claude 4.5Migrating to Claude 4.5Model deprecationsPricing

    Build with Claude

    Features overviewUsing the Messages APIContext windowsPrompting best practices

    Capabilities

    Prompt cachingContext editingExtended thinkingStreaming MessagesBatch processingCitationsMultilingual supportToken countingEmbeddingsVisionPDF supportFiles APISearch resultsGoogle Sheets add-on

    Tools

    OverviewHow to implement tool useToken-efficient tool useFine-grained tool streamingBash toolCode execution toolComputer use toolText editor toolWeb fetch toolWeb search toolMemory tool

    Agent Skills

    OverviewQuickstartBest practicesUsing Skills with the API

    Agent SDK

    OverviewTypeScript SDKPython SDK

    Guides

    Streaming InputHandling PermissionsSession ManagementHosting the Agent SDKModifying system promptsMCP in the SDKCustom ToolsSubagents in the SDKSlash Commands in the SDKAgent Skills in the SDKTracking Costs and UsageTodo ListsPlugins in the SDK

    MCP in the API

    MCP connectorRemote MCP servers

    Claude on 3rd-party platforms

    Amazon BedrockVertex AI

    Prompt engineering

    OverviewPrompt generatorUse prompt templatesPrompt improverBe clear and directUse examples (multishot prompting)Let Claude think (CoT)Use XML tagsGive Claude a role (system prompts)Prefill Claude's responseChain complex promptsLong context tipsExtended thinking tips

    Test & evaluate

    Define success criteriaDevelop test casesUsing the Evaluation ToolReducing latency

    Strengthen guardrails

    Reduce hallucinationsIncrease output consistencyMitigate jailbreaksStreaming refusalsReduce prompt leakKeep Claude in character

    Administration and monitoring

    Admin API overviewUsage and Cost APIClaude Code Analytics API
    Console
    Guides

    Plugins in the SDK

    Load custom plugins to extend Claude Code with commands, agents, skills, and hooks through the Agent SDK

    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.

    What are plugins?

    Plugins are packages of Claude Code extensions that can include:

    • Commands: Custom slash commands
    • Agents: Specialized subagents for specific tasks
    • Skills: Model-invoked capabilities that Claude uses autonomously
    • Hooks: Event handlers that respond to tool use and other events
    • MCP servers: External tool integrations via Model Context Protocol

    For complete information on plugin structure and how to create plugins, see Plugins.

    Loading plugins

    Load plugins by providing their local file system paths in your options configuration. The SDK supports loading multiple plugins from different locations.

    TypeScript
    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
    }
    Python
    import asyncio
    from claude_agent_sdk import query
    
    async def main():
        async for message in 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
            pass
    
    asyncio.run(main())

    Path specifications

    Plugin paths can be:

    • Relative paths: Resolved relative to your current working directory (e.g., "./plugins/my-plugin")
    • Absolute paths: Full file system paths (e.g., "/home/user/plugins/my-plugin")

    The path should point to the plugin's root directory (the directory containing .claude-plugin/plugin.json).

    Verifying plugin installation

    When plugins load successfully, they appear in the system initialization message. You can verify that your plugins are available:

    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"]
      }
    }

    Using plugin commands

    Commands from plugins are automatically namespaced with the plugin name to avoid conflicts. The format is plugin-name:command-name.

    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.

    Complete example

    Here's a full example demonstrating plugin loading and usage:

    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);

    Plugin structure reference

    A plugin directory must contain a .claude-plugin/plugin.json manifest file. It can optionally include:

    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:

    • Plugins - Complete plugin development guide
    • Plugins reference - Technical specifications and schemas

    Common use cases

    Development and testing

    Load plugins during development without installing them globally:

    plugins: [
      { type: "local", path: "./dev-plugins/my-plugin" }
    ]

    Project-specific extensions

    Include plugins in your project repository for team-wide consistency:

    plugins: [
      { type: "local", path: "./project-plugins/team-workflows" }
    ]

    Multiple plugin sources

    Combine plugins from different locations:

    plugins: [
      { type: "local", path: "./local-plugin" },
      { type: "local", path: "~/.claude/custom-plugins/shared-plugin" }
    ]

    Troubleshooting

    Plugin not loading

    If your plugin doesn't appear in the init message:

    1. Check the path: Ensure the path points to the plugin root directory (containing .claude-plugin/)
    2. Validate plugin.json: Ensure your manifest file has valid JSON syntax
    3. Check file permissions: Ensure the plugin directory is readable

    Commands not available

    If plugin commands don't work:

    1. Use the namespace: Plugin commands require the plugin-name:command-name format
    2. Check init message: Verify the command appears in slash_commands with the correct namespace
    3. Validate command files: Ensure command markdown files are in the commands/ directory

    Path resolution issues

    If relative paths don't work:

    1. Check working directory: Relative paths are resolved from your current working directory
    2. Use absolute paths: For reliability, consider using absolute paths
    3. Normalize paths: Use path utilities to construct paths correctly

    See also

    • Plugins - Complete plugin development guide
    • Plugins reference - Technical specifications
    • Slash Commands - Using slash commands in the SDK
    • Subagents - Working with specialized agents
    • Skills - Using Agent Skills
    • What are plugins?
    • Loading plugins
    • Path specifications
    • Verifying plugin installation
    • Using plugin commands
    • Complete example
    • Plugin structure reference
    • Common use cases
    • Development and testing
    • Project-specific extensions
    • Multiple plugin sources
    • Troubleshooting
    • Plugin not loading
    • Commands not available
    • Path resolution issues
    • See also
    © 2025 ANTHROPIC PBC

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy

    Products

    • Claude
    • Claude Code
    • Max plan
    • Team plan
    • Enterprise plan
    • Download app
    • Pricing
    • Log in

    Features

    • Claude and Slack
    • Claude in Excel

    Models

    • Opus
    • Sonnet
    • Haiku

    Solutions

    • AI agents
    • Code modernization
    • Coding
    • Customer support
    • Education
    • Financial services
    • Government
    • Life sciences

    Claude Developer Platform

    • Overview
    • Developer docs
    • Pricing
    • Amazon Bedrock
    • Google Cloud’s Vertex AI
    • Console login

    Learn

    • Blog
    • Catalog
    • Courses
    • Use cases
    • Connectors
    • Customer stories
    • Engineering at Anthropic
    • Events
    • Powered by Claude
    • Service partners
    • Startups program

    Company

    • Anthropic
    • Careers
    • Economic Futures
    • Research
    • News
    • Responsible Scaling Policy
    • Security and compliance
    • Transparency

    Help and security

    • Availability
    • Status
    • Support center

    Terms and policies

    • Privacy policy
    • Responsible disclosure policy
    • Terms of service: Commercial
    • Terms of service: Consumer
    • Usage policy
    © 2025 ANTHROPIC PBC