Skip to main content

Anatomy of Plugins

Plugin anatomy, types, security, and distribution patterns.

Plugins

Package, distribute, and standardize your Claude Code superpowers across teams and repos.


TL;DRโ€‹

  • A plugin bundles skills + commands + hooks + agents + templates + docs into one shareable unit.
  • Distributed via npm, Git, or your internal registry.
  • Versioned with SemVer; installs with one command.
  • Best for org-wide standards and community packs.

Why this mattersโ€‹

Plugins are App Store apps for your AI workflow. Instead of every repo reinventing hooks and skills, install a plugin and inherit a proven setup.

Bottom line: Plugins turn local hacks into reusable assets.


The Big Pictureโ€‹

Bottom line: Bundle once, install everywhere.


Plugin Structureโ€‹

plugins/my-plugin/
โ”œโ”€โ”€ manifest.json # Plugin metadata
โ”œโ”€โ”€ README.md # Overview & setup
โ”œโ”€โ”€ skills/
โ”‚ โ””โ”€โ”€ code-review/ # Bundled skills
โ”œโ”€โ”€ commands/
โ”‚ โ””โ”€โ”€ review.md # Slash commands
โ”œโ”€โ”€ hooks/
โ”‚ โ”œโ”€โ”€ pre-tool.sh
โ”‚ โ””โ”€โ”€ post-tool.sh # Hook scripts
โ”œโ”€โ”€ agents/
โ”‚ โ””โ”€โ”€ code-reviewer.yml
โ”œโ”€โ”€ templates/
โ”‚ โ””โ”€โ”€ pr-template.md
โ””โ”€โ”€ scripts/
โ”œโ”€โ”€ install.sh
โ”œโ”€โ”€ post-install.sh
โ””โ”€โ”€ uninstall.sh

manifest.json Exampleโ€‹

{
"name": "acme-dev-tools",
"version": "1.2.0",
"description": "Essential dev tools for Claude Code at Acme",
"author": "Acme Engineering",
"license": "MIT",
"category": "developer-tools",
"dependencies": {
"claude-code": ">=0.6.0"
},
"includes": {
"skills": ["code-review", "test-writer"],
"commands": ["review", "deploy"],
"hooks": ["pre-tool", "post-tool"],
"agents": ["code-reviewer"]
},
"hooks": {
"install": "./scripts/install.sh",
"post_install": "./scripts/post-install.sh",
"uninstall": "./scripts/uninstall.sh"
}
}

Step-by-Step Setupโ€‹

1. Scaffold the pluginโ€‹

mkdir -p plugins/my-plugin/{skills,commands,hooks,agents,templates,scripts}
touch plugins/my-plugin/{manifest.json,README.md}

2. Write manifest.json (see example above)โ€‹

3. Add the install scriptโ€‹

cat > plugins/my-plugin/scripts/install.sh <<'EOF'
#!/usr/bin/env bash
echo "Installing my-plugin..."
mkdir -p .claude/commands
cp -r commands/* .claude/commands/
chmod +x hooks/*.sh
echo "โœ… Done!"
EOF
chmod +x plugins/my-plugin/scripts/install.sh

4. Publish (one of):โ€‹

# npm
npm publish

# Private Git registry
git tag v1.2.0 && git push --tags

5. Install in another repoโ€‹

claude plugin install acme-dev-tools

Variants for Different Team Settingsโ€‹

๐Ÿ‘ค Soloโ€‹

Keep plugins as local folders; no publishing needed.

๐Ÿ‘ฅ Small teamโ€‹

Host on a private GitHub repo + tag releases.

claude plugin install github:acme/my-plugin#v1.2.0

๐Ÿข Enterpriseโ€‹

  • Private npm registry (Verdaccio / Artifactory).
  • Sign packages & verify SHA before install.
  • Pin versions in every repo's .claude/plugins.json.
  • Run plugin install in CI to catch drift.

๐ŸŒ Open-sourceโ€‹

  • Publish on npm with clear README.
  • Provide a demo repo showing usage.
  • Use SemVer; document breaking changes.

Bottom line: Same package, escalating distribution rigor.


Publishing Checklistโ€‹

  • โœ… manifest.json is valid
  • โœ… README.md with clear setup
  • โœ… No secrets in any file
  • โœ… All paths are relative
  • โœ… Version follows SemVer
  • โœ… License included
  • โœ… Tested in clean environment

Example: Simple Plugin (skeleton)โ€‹

my-plugin/
โ”œโ”€โ”€ manifest.json
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ commands/
โ”‚ โ””โ”€โ”€ review.md
โ”œโ”€โ”€ hooks/
โ”‚ โ””โ”€โ”€ pre-tool.sh
โ””โ”€โ”€ scripts/
โ””โ”€โ”€ install.sh

scripts/install.sh:

#!/usr/bin/env bash
echo "Installing my-plugin..."
mkdir -p .claude/commands
cp -r commands/* .claude/commands/
chmod +x hooks/*.sh
echo "โœ… Done!"

Common Plugin Use Casesโ€‹

Use caseWhat it bundles
Team standardsShared CLAUDE.md, hooks, conventions
Security guardrailsPre-commit secret scans, audit hooks
Automation pipelinesCI/CD scripts, deploy commands
Domain workflowsE.g. healthcare HIPAA checks
Starter kits / templatesBoilerplate for a new service
Organization toolboxCatch-all of common helpers

Common Patterns & Recipesโ€‹

Pattern 1 โ€” Idempotent installโ€‹

[ -d .claude/commands ] || mkdir -p .claude/commands
cp -n commands/* .claude/commands/ # -n = no clobber

Pattern 2 โ€” Plugin with auto-updateโ€‹

"hooks": { "update": "./scripts/update.sh" }

Pattern 3 โ€” Plugin compositionโ€‹

"dependencies": {
"@acme/security-pack": "^1.0.0",
"@acme/devops-pack": "^2.0.0"
}

Pattern 4 โ€” Uninstall safelyโ€‹

rm -rf .claude/commands/{review,deploy}.md
echo "โœ… Cleaned up."

Best Practices โœ…โ€‹

  • Bundle only what you need.
  • Pin compatible versions.
  • Make install idempotent.
  • Document everything.
  • Test in a clean environment before publishing.
  • SemVer religiously.

Anti-Patterns โŒโ€‹

  • Plugins that silently overwrite user files.
  • Hard-coded absolute paths.
  • Secrets baked into the manifest.
  • No uninstall script.
  • Mixing unrelated capabilities into one "kitchen-sink" plugin.

Troubleshootingโ€‹

SymptomCauseFix
Install failsMissing dependencyCheck manifest.json deps
Files not appearingWrong relative pathUse ./ everywhere
Conflicts with existing configNo conflict checkUse cp -n or merge logic
Breaks on updateNon-SemVer bumpTag a major version
Can't uninstallNo uninstall.shAdd one; list every file created

Starter Templateโ€‹

{
"name": "my-plugin",
"version": "0.1.0",
"description": "What it does",
"includes": { "skills": [], "commands": [], "hooks": [] },
"hooks": { "install": "./scripts/install.sh" }
}

๐Ÿ’ก Tip: Ship value fast. Iterate based on adoption.


Glossaryโ€‹

  • Plugin โ€” A bundled, distributable Claude Code extension.
  • Manifest โ€” manifest.json describing the plugin.
  • SemVer โ€” Semantic Versioning (MAJOR.MINOR.PATCH).
  • Idempotent โ€” Safe to run multiple times with same result.

Further Readingโ€‹

  • Search: "Claude Code plugins documentation"
  • Search: "npm publish private registry"
  • Search: "SemVer specification"