Plugin Authoring
Canonical guide for building Claude Code plugins. Default to read-only: diagnose
the repo layout, then propose vetted commands or PR-style diffs rather than
writing files directly. Ask before edits.
Official best-practices reference:
https://docs.claude.com/en/docs/agents-and-tools/agent-skills/best-practices
When to use
Activate whenever context includes any of: .claude-plugin/, plugin.json,
marketplace.json, commands/, agents/, skills/, or hooks/ — or when the
user wants to scaffold a plugin, add a component, validate, or troubleshoot one
that won't load.
Flow
- Diagnose current repo layout (read-only).
- Propose the minimal safe action (scaffold, validate, or review).
- Execute via
/plugin-development:... commands once the user agrees.
- Escalate to the
plugin-reviewer agent for deep audits.
Plugin structure rules (the part everyone gets wrong)
.claude-plugin/plugin.json is required and is the ONLY thing inside
.claude-plugin/.
- Component dirs (
commands/, agents/, skills/, hooks/) live at the
plugin root, NOT inside .claude-plugin/.
- These standard directories are auto-discovered. Do NOT add
"commands": "./commands/" (or agents/skills/hooks) fields to plugin.json —
declaring standard paths breaks discovery.
- Hooks must reference scripts via
${CLAUDE_PLUGIN_ROOT}/scripts/foo.sh, never
relative paths like ./scripts/foo.sh (works in dev, breaks on install).
- All hook scripts must be
chmod +x (otherwise they silently fail).
Component checklist
□ .claude-plugin/plugin.json exists (required: name, version, keywords)
□ Component dirs at plugin root (not inside .claude-plugin/)
□ No standard-dir fields in plugin.json (auto-discovered)
□ Commands use kebab-case naming
□ Hooks use ${CLAUDE_PLUGIN_ROOT}; scripts are chmod +x
□ Skills have valid frontmatter (see below)
Skill frontmatter requirements
name (required): lowercase letters, numbers, hyphens only; max 64 chars;
must match the directory name; no reserved words anthropic/claude; no XML
tags.
description (required): include BOTH what the skill does AND when to use it;
max 1024 chars; no XML tags. This string drives auto-detection.
model (optional): e.g. model: claude-sonnet-4-6; defaults to conversation
model.
allowed-tools (optional): comma-separated; tools listed skip permission
prompts when the skill is active. Omit to leave tools unrestricted.
- Keep SKILL.md under ~500 lines; push detail into sibling files
(reference.md, examples.md, scripts/).
Commands
- Scaffold:
/plugin-development:init <name>
- Add components:
/plugin-development:add-command|add-skill|add-agent|add-hook
- Validate:
/plugin-development:validate (schema + structure; catches ~90% of
issues before you start debugging)
- Test locally:
/plugin-development:test-local (dev marketplace)
Common workflows
New plugin: init <name> → edit .claude-plugin/plugin.json → add
components → validate → test-local.
Add a slash command: add-command <name> <desc> → edit commands/<name>.md
→ add frontmatter (description, argument-hint) → /plugin install, then
run /<name>.
Add a skill: add-skill <name> <when-to-use> → edit skills/<name>/SKILL.md
with the frontmatter rules above.
Troubleshooting
- Plugin not loading → check plugin.json; remove any standard-dir fields;
paths relative to plugin root.
- Commands not showing → confirm
commands/ exists at plugin root with
.md files; do NOT add a commands field.
- Hooks not running → scripts
chmod +x; use ${CLAUDE_PLUGIN_ROOT}.
- Skill not triggering →
name matches dir, lowercase/numbers/hyphens, ≤64
chars; description covers what + when, ≤1024 chars; no XML tags in either.
Why validation matters
| Skip |
Failure mode |
| Validate manifest |
Plugin won't load, no error |
| chmod +x scripts |
Hooks silently fail |
| ${CLAUDE_PLUGIN_ROOT} |
Works in dev, breaks on install |
| Standard-dir rules |
Components not discovered |
All of these cause silent failures. When in doubt, validate first.
Notes
- Prefer templates and scripts over freeform generation for deterministic tasks.
- If writes are needed, propose a command or a PR-style diff first.
- Source repo ships reference files alongside the original SKILL.md:
schemas/{plugin-manifest,hooks-schema,marketplace-schema}.md, templates/,
examples/, best-practices/common-mistakes.md — fetch from the source URL if
deeper schema detail is needed.
1---2name: plugin-authoring3description: "Use when creating, modifying, validating, or debugging a Claude Code plugin — triggers on .claude-plugin/, plugin.json, marketplace.json, commands/, agents/, skills/, hooks/, scaffolding a plugin, adding a slash command/skill/agent/hook, or 'plugin not loading'."4version: 1.0.05license: MIT6tags: [claude-code, plugin, plugin-json, marketplace, slash-commands, skills, hooks, agents, scaffolding, validation]7source: https://github.com/ivan-magda/claude-code-plugin-template/tree/main/plugins/plugin-development/skills/plugin-authoring8derived_from: awesomeclaude9metadata:10 source: https://skillmd.com/skills/aashutosh396/plugin-authoring11---1213# Plugin Authoring1415Canonical guide for building Claude Code plugins. Default to read-only: diagnose16the repo layout, then propose vetted commands or PR-style diffs rather than17writing files directly. Ask before edits.1819Official best-practices reference:20https://docs.claude.com/en/docs/agents-and-tools/agent-skills/best-practices2122## When to use2324Activate whenever context includes any of: `.claude-plugin/`, `plugin.json`,25`marketplace.json`, `commands/`, `agents/`, `skills/`, or `hooks/` — or when the26user wants to scaffold a plugin, add a component, validate, or troubleshoot one27that won't load.2829## Flow30311. **Diagnose** current repo layout (read-only).322. **Propose** the minimal safe action (scaffold, validate, or review).333. **Execute** via `/plugin-development:...` commands once the user agrees.344. **Escalate** to the `plugin-reviewer` agent for deep audits.3536## Plugin structure rules (the part everyone gets wrong)3738- `.claude-plugin/plugin.json` is **required** and is the ONLY thing inside39 `.claude-plugin/`.40- Component dirs (`commands/`, `agents/`, `skills/`, `hooks/`) live at the41 **plugin root**, NOT inside `.claude-plugin/`.42- These standard directories are **auto-discovered**. Do NOT add43 `"commands": "./commands/"` (or agents/skills/hooks) fields to plugin.json —44 declaring standard paths breaks discovery.45- Hooks must reference scripts via `${CLAUDE_PLUGIN_ROOT}/scripts/foo.sh`, never46 relative paths like `./scripts/foo.sh` (works in dev, breaks on install).47- All hook scripts must be `chmod +x` (otherwise they silently fail).4849## Component checklist5051```52□ .claude-plugin/plugin.json exists (required: name, version, keywords)53□ Component dirs at plugin root (not inside .claude-plugin/)54□ No standard-dir fields in plugin.json (auto-discovered)55□ Commands use kebab-case naming56□ Hooks use ${CLAUDE_PLUGIN_ROOT}; scripts are chmod +x57□ Skills have valid frontmatter (see below)58```5960## Skill frontmatter requirements6162- `name` (required): lowercase letters, numbers, hyphens only; max 64 chars;63 must match the directory name; no reserved words `anthropic`/`claude`; no XML64 tags.65- `description` (required): include BOTH what the skill does AND when to use it;66 max 1024 chars; no XML tags. This string drives auto-detection.67- `model` (optional): e.g. `model: claude-sonnet-4-6`; defaults to conversation68 model.69- `allowed-tools` (optional): comma-separated; tools listed skip permission70 prompts when the skill is active. Omit to leave tools unrestricted.71- Keep SKILL.md under ~500 lines; push detail into sibling files72 (reference.md, examples.md, scripts/).7374## Commands7576- Scaffold: `/plugin-development:init <name>`77- Add components: `/plugin-development:add-command|add-skill|add-agent|add-hook`78- Validate: `/plugin-development:validate` (schema + structure; catches ~90% of79 issues before you start debugging)80- Test locally: `/plugin-development:test-local` (dev marketplace)8182## Common workflows8384**New plugin**: `init <name>` → edit `.claude-plugin/plugin.json` → add85components → `validate` → `test-local`.8687**Add a slash command**: `add-command <name> <desc>` → edit `commands/<name>.md`88→ add frontmatter (`description`, `argument-hint`) → `/plugin install`, then89run `/<name>`.9091**Add a skill**: `add-skill <name> <when-to-use>` → edit `skills/<name>/SKILL.md`92with the frontmatter rules above.9394## Troubleshooting9596- **Plugin not loading** → check plugin.json; remove any standard-dir fields;97 paths relative to plugin root.98- **Commands not showing** → confirm `commands/` exists at plugin root with99 `.md` files; do NOT add a `commands` field.100- **Hooks not running** → scripts `chmod +x`; use `${CLAUDE_PLUGIN_ROOT}`.101- **Skill not triggering** → `name` matches dir, lowercase/numbers/hyphens, ≤64102 chars; `description` covers what + when, ≤1024 chars; no XML tags in either.103104## Why validation matters105106| Skip | Failure mode |107|-----------------|---------------------------------------|108| Validate manifest | Plugin won't load, no error |109| chmod +x scripts | Hooks silently fail |110| ${CLAUDE_PLUGIN_ROOT} | Works in dev, breaks on install |111| Standard-dir rules | Components not discovered |112113All of these cause **silent** failures. When in doubt, validate first.114115## Notes116117- Prefer templates and scripts over freeform generation for deterministic tasks.118- If writes are needed, propose a command or a PR-style diff first.119- Source repo ships reference files alongside the original SKILL.md:120 `schemas/{plugin-manifest,hooks-schema,marketplace-schema}.md`, `templates/`,121 `examples/`, `best-practices/common-mistakes.md` — fetch from the source URL if122 deeper schema detail is needed.