Claude Code: Plugin System

Last updated: 2026-08-31

Plugins make Claude Code's capabilities pluggable — install a plugin, gain a new ability, without modifying core code.

💡 Tip: Claude Code plugins and MCP are two different extension methods. Plugins modify Claude Code's own behavior; MCP extends its ability to connect to the outside world.

📋 Prerequisites: Chapter 13 - SubAgents

1. What You'll Learn


2. Plugin System Architecture

(1) Plugin Types

Type Purpose Example
Tool plugins Add new tools/commands Code analysis tool
Hook plugins Custom behavior on specific events Auto-lint before commit
Theme plugins Change output style Colored diff display
Integration plugins Connect third-party services Jira integration

(2) Plugin vs MCP Comparison

Dimension Plugin MCP
Extension direction Modify Claude Code behavior Connect external services
Runtime location Within Claude Code process Independent process
Communication Direct function calls Protocol communication
Use case Add commands, change output Databases, APIs, browsers
Dev difficulty Medium Low

3. Official and Community Plugins

(1) Official Plugins

Plugin Function Install
claude-plugin-lint Auto-lint modified files claude plugin add lint
claude-plugin-test Auto-run tests after modifications claude plugin add test
claude-plugin-git Enhanced git integration claude plugin add git
claude-plugin-doc Auto-generate documentation claude plugin add doc

(2) Plugin Management

BASH
# View installed plugins
claude plugin list

# Install official plugin
claude plugin add lint

# Install community plugin
claude plugin add @community/claude-plugin-jira

# Disable plugin
claude plugin disable lint

# Uninstall plugin
claude plugin remove lint

# Update plugins
claude plugin update

▶ Example 1: Lint Plugin Workflow

TEXT 📖 Display only
# After installing lint plugin

> Refactor slugify function in src/utils/string.ts

Claude Code:
  → Reading src/utils/string.ts
  → Modifying slugify function...
  → [lint plugin] Running: npm run lint -- --fix
  → [lint plugin] Found 1 issue: missing return type
  → Auto-fixing: adding string return type
  → [lint plugin] All clean ✓
  → Running: npm test -- string.test.ts
  ✅ All tests passed

4. Plugin Configuration

(1) Global Configuration

JSON
// ~/.claude/plugins.json
{
  "plugins": [
    {
      "name": "lint",
      "enabled": true,
      "config": {
        "runOnSave": true,
        "fix": true
      }
    }
  ]
}

(2) Project-Level Configuration

JSON
// .claude/plugins.json
{
  "plugins": [
    {
      "name": "lint",
      "config": {
        "command": "npm run lint:fix",
        "files": ["src/**/*.ts"]
      }
    }
  ]
}

5. Plugin Development Basics

▶ Example 2: Simple Plugin

TYPESCRIPT
export default {
  name: "my-custom-linter",
  version: "1.0.0",

  hooks: {
    "after:file:write": async (context) => {
      const { filePath } = context;
      if (filePath.endsWith(".ts")) {
        const { execSync } = require("child_process");
        try {
          execSync(`npx eslint --fix ${filePath}`, { stdio: "pipe" });
        } catch (e) {
          console.log(`[my-linter] Issues in ${filePath}`);
        }
      }
    },
  },
};

6. Plugin Best Practices

Principle Description
Minimalism Only install necessary plugins
Verify source Prefer official; audit community plugins
Test first Validate new plugins on test projects
Regular cleanup Remove unused plugins
Avoid duplicates Same-type plugins may conflict

❓ FAQ

Q Plugin or MCP?
A Use MCP for connecting external services (databases, GitHub); use plugins for modifying Claude Code behavior (auto-lint, custom commands). Both can coexist.
Q Too many plugins slow things down?
A Yes. Each plugin uses load time and memory. Install only what's needed.
Q Are community plugins safe?
A Not guaranteed. Check source code and author reputation before installing.
Q Can I install multiple same-type plugins?
A Possible but may conflict. Two lint plugins may enforce different rules. Keep one per type.

📖 Summary


📝 Exercises

  1. Basic (⭐): Install the official lint plugin, verify auto-lint on file modification.
  2. Intermediate (⭐⭐): Install and configure two plugins ensuring no conflicts.
  3. Advanced (⭐⭐⭐): Develop a custom plugin that auto-runs format and lint after each file modification.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏