plugin-best-practices
Original:🇺🇸 English
Translated
Validates Claude Code plugins against architectural best practices for Agents, Skills, MCP, and Progressive Disclosure. Use when validating plugin structure, reviewing manifest files, checking frontmatter compliance, or verifying tool invocation patterns.
11installs
Sourcefradser/dotclaude
Added on
NPX Install
npx skill4agent add fradser/dotclaude plugin-best-practicesTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Plugin Validation & Best Practices
Validate Claude Code plugins against architectural standards. SKILL.md serves as a navigation guide; detailed content lives in .
references/Quick Start
Run validation on a plugin:
bash
python3 plugin-optimizer/scripts/validate-plugin.py <plugin-path>For specific checks only:
bash
python3 plugin-optimizer/scripts/validate-plugin.py <plugin-path> --check=manifest,frontmatterComponent Selection Guide
| Component | When to Use | Key Requirements |
|---|---|---|
| Instruction-type Skills | User-invoked workflows, linear process | Imperative voice, phase-based, declared in |
| Knowledge-type Skills | Reference knowledge for agents | Declarative voice, topic-based, declared in |
| Agents | Isolated, specialized decision-making | Restricted tools, 2-4 |
| MCP Servers | External tool/data integration | stdio/http/sse transport, ${CLAUDE_PLUGIN_ROOT} paths |
| LSP Servers | IDE features (go to definition) | Language server binary, extension mapping |
| Hooks | Event-driven automation | PreToolUse/PostToolUse events, command/prompt/agent types |
See for detailed selection criteria and for implementation guides.
./references/component-model.md./references/components/Progressive Disclosure
Three-tier token structure ensures efficient context usage:
| Level | Content | Token Budget | Loading |
|---|---|---|---|
| 1 | Metadata (name + description) | ~100 tokens | Always (at startup) |
| 2 | SKILL.md body | Under 5k tokens | When skill triggered |
| 3 | References/ files | Effectively unlimited | On-demand via bash |
Implementation Pattern:
- SKILL.md: Overview and navigation to reference files
- References/: Detailed specs, examples, patterns
- Scripts/: Executable utilities (no context cost until executed)
See for complete token budget guidelines.
./references/component-model.mdValidation Workflow
- Structure: File patterns, directory layout, kebab-case naming
- Manifest: plugin.json required fields and schema compliance
- Frontmatter: YAML frontmatter in components, third-person descriptions
- Tool Invocations: Anti-pattern detection (implicit vs explicit tool calls)
- Token Budget: Progressive disclosure compliance (under 5k tokens for SKILL.md)
Run validation with flag for verbose output showing all passing checks.
-vSee for complete criteria.
./references/validation-checklist.mdRequirement Levels (RFC 2119)
MUST: Absolute requirement - plugin will not function correctly without it
- Use only, avoid
MUSTorREQUIREDSHALL
MUST NOT: Absolute prohibition - behavior is forbidden
- Use only, avoid
MUST NOTSHALL NOT
SHOULD: Recommended practice - valid reasons to ignore exist, but implications MUST be understood
- Use only, avoid
SHOULDRECOMMENDED - Consider security implications before choosing different course
SHOULD NOT: Discouraged but may be valid in specific circumstances
- Use only, avoid
SHOULD NOTNOT RECOMMENDED - Weigh full implications before implementing
MAY: Truly optional - vendor choice
- Use only, avoid
MAYOPTIONAL - Implementations without a feature MUST interoperate with those that include it
See for complete RFC 2119 specification.
./references/rfc-2119.mdCritical Patterns
Tool Invocation Rules
| Tool | Style | Example |
|---|---|---|
| Read, Write, Edit, Glob, Grep | Implicit | "Find files matching..." |
| Bash | Implicit | "Run |
| Task | Implicit | "Launch |
| Skill | Explicit | "Load |
| TaskCreate | Explicit | "Use TaskCreate tool to track progress" |
| AskUserQuestion | Explicit | "Use |
Qualified names: MUST use format for plugin components.
plugin-name:component-nameallowed-tools: NEVER use bare - always use filters like .
BashBash(git:*)Inline Bash: Use inline syntax (exclamation + backtick + command + backtick) for dynamic context.
See for complete patterns and anti-patterns.
./references/tool-invocations.mdSkill Frontmatter (Official Best Practices)
Required fields:
- : Max 64 chars, lowercase letters/numbers/hyphens only
name - : Max 1024 chars, third-person voice, includes trigger phrases like "Use when..."
description
Additional fields are supported but affect progressive disclosure alignment.
Agent Frontmatter
Required fields:
- : 3-50 chars, kebab-case
name - : inherit, sonnet, opus, or haiku
model - : blue, cyan, green, yellow, magenta, or red
color - blocks: 2-4 required for router-friendliness
<example>
CO-STAR Framework:
- Context: Background info
- Objective: What to achieve
- Style: Tone/Format
- Tone: Attitude
- Audience: Who is this for?
- Response: Format of output
See for complete agent design guidelines.
./references/components/agents.mdTask Management
Use TaskCreate for:
- Tasks with 3+ distinct steps
- Multi-file/multi-component work
- Sequential dependencies
Don't use TaskCreate for:
- Single file edits
- 1-2 step operations
- Pure research/reading
Core Requirements:
- Dual form naming: subject ("Run tests") + activeForm ("Running tests")
- Real-time updates: mark BEFORE starting,
in_progressAFTER finishingcompleted - Single active task at any time
- Honest status: only mark when FULLY done
completed
See for complete patterns and examples.
./references/task-management.mdMCP Server Configuration
Transport Types:
- stdio: Local CLI tools (git, docker, npm) - uses ,
command,argsenv - http: Remote APIs (SaaS, cloud) - uses ,
urlheaders - sse: Real-time streaming (monitoring, live updates) - uses ,
urlheaders
Security:
- NEVER hardcode secrets - always use syntax
${ENV_VAR} - Document required environment variables
- Provide template
.env.example
See for complete MCP integration patterns.
./references/mcp-patterns.mdFrontmatter Requirements (Complete)
Skill Frontmatter:
- Required: (max 64 chars, lowercase/hyphens),
name(max 1024 chars, third-person)description - Optional: ,
argument-hint,allowed-tools,model,disable-model-invocation,user-invocable,context,agenthooks
Agent Frontmatter:
- Required: (3-50 chars, kebab-case),
name,model, 2-4colorblocks<example>
Command Frontmatter:
- Required: ,
description(MUST be empty/omitted if no arguments)argument-hint - Optional: ,
allowed-toolsdisable-model-invocation
See , , and for complete frontmatter specifications.
./references/components/skills.md./references/components/agents.md./references/components/commands.mdDirectory Structure
Standard Layout:
plugin-name/
├── .claude-plugin/plugin.json # Manifest (declare components here)
├── skills/ # Agent Skills (RECOMMENDED)
│ └── skill-name/
│ ├── SKILL.md
│ └── references/
├── commands/ # Legacy commands (optional)
├── agents/ # Subagent definitions
├── hooks/hooks.json # Hook configuration
├── .mcp.json # MCP server definitions
├── .lsp.json # LSP server configurations
└── scripts/ # Executable scriptsCritical Rules:
- Components live at plugin root, NOT inside
.claude-plugin/ - Scripts MUST be executable with shebangs
- Scripts MUST use for paths
${CLAUDE_PLUGIN_ROOT} - All paths MUST be relative and start with
./
See for complete layout guidelines.
./references/directory-structure.mdHook Configuration
Available Events:
- PreToolUse, PostToolUse, PostToolUseFailure
- PermissionRequest, UserPromptSubmit, Notification
- Stop, SubagentStart, SubagentStop
- SessionStart, SessionEnd, PreCompact
Hook Types:
- : Execute shell commands or scripts
command - : Evaluate with LLM (uses
promptplaceholder)$ARGUMENTS - : Run agentic verifier with tools
agent
Best Practices:
- Validate inputs strictly in bash hooks
- Always quote bash variables (e.g., )
"$CLAUDE_PROJECT_DIR" - Return valid JSON for decisions (/
allow) and messagesdeny - Exit codes: 0 (success), 1 (non-blocking), 2 (blocking error)
See for complete hook patterns and templates.
./references/components/hooks.mdAgent Teams vs Subagents
Subagents
Plugin-defined autonomous subprocesses with isolated context and restricted tools.
When to Use:
- Isolated, specialized decision-making with dedicated system prompt
- Sequential or single-direction workflow
- Focused tasks where only the result matters
- Lower token cost preferred
Characteristics:
- Defined as files in
.mddirectoryagents/ - Isolated context, restricted tool allowlists
- 2-4 blocks for router-friendliness
<example> - Results summarized back to main context
Usage:
markdown
Launch `plugin-name:agent-name` agent to handle this task.Agent Teams (Experimental)
Multiple Claude Code sessions with shared task list and direct inter-agent communication. Can spawn plugin subagents or built-in agent types as teammates.
When to Use:
- Research and review: Parallel investigation with shared findings and challenges
- New modules/features: Each teammate owns separate piece
- Debugging: Competing hypotheses tested in parallel
- Cross-layer coordination: Frontend, backend, tests split across teammates
When NOT to Use:
- Sequential tasks, same-file edits, high-dependency work
- Coordination overhead exceeds benefit
- Routine tasks (single session more cost-effective)
Comparison:
| Subagents | Agent Teams | |
|---|---|---|
| Context | Returns to caller | Fully independent |
| Communication | To main agent only | Direct peer-to-peer |
| Coordination | Managed by main agent | Shared task list |
| Token cost | Lower (summarized) | Higher (full instances) |
Usage:
Plugin subagents as teammates:
markdown
Create an agent team with plugin-defined agents:
- plugin-name:specialist-a for aspect A
- plugin-name:specialist-b for aspect BBuilt-in agent types:
markdown
Create an agent team with specialized reviewers:
- Explore agent focused on dimension 1
- Explore agent focused on dimension 2
- general-purpose agent for synthesisEnable:
bash
export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1Best Practices:
- Give teammates specific context and avoid file conflicts
- Size tasks appropriately (self-contained units with clear deliverables)
- Tell lead to "Wait for teammates to finish" if coordination needed
- Start with research/review tasks before parallel implementation
Limitations: No resumption, one team per session, no nesting, fixed lead, slow shutdown.
See for complete guide and for agent usage patterns.
./references/agent-teams.md./references/component-model.mdParallel Agent Execution
When to Use:
- Tasks are independent and results can be merged afterward
- Multiple analyses can run simultaneously
Request Patterns:
- Explicit: "Launch all agents simultaneously: X agent, Y agent, Z agent"
- Phrasing: "Launch 3 parallel agents to process different aspects independently"
Best Practices:
- "parallel" or "simultaneously" appears explicitly in the request
- Descriptive style names the agent and intent
- Consolidation merges findings and resolves conflicts
Common Pattern:
- Sequential setup (if needed)
- Launch specialized analyses in parallel
- Consolidate results and present unified output
See for parallel coordination patterns.
./references/parallel-execution.mdReference Directory
Validation & Quality
- - Complete quality checklist
./references/validation-checklist.md - - Requirement levels (MUST/SHOULD/MAY)
./references/rfc-2119.md
Component Implementation
- - Component types, selection criteria, token budgets
./references/component-model.md - - Skill structure, frontmatter, progressive disclosure
./references/components/skills.md - - Agent design, CO-STAR framework, example blocks
./references/components/agents.md - - Command frontmatter, dynamic context
./references/components/commands.md - - Hook events, types, bash templates
./references/components/hooks.md - - MCP configuration, stdio/http/sse
./references/components/mcp-servers.md - - LSP setup, binary requirements
./references/components/lsp-servers.md
Configuration & Integration
- - Plugin layout, naming conventions
./references/directory-structure.md - - plugin.json schema, required fields
./references/manifest-schema.md - - MCP transport types, security best practices
./references/mcp-patterns.md
Development Patterns
- - Tool usage patterns and anti-patterns
./references/tool-invocations.md - - TaskCreate patterns, dual-form naming
./references/task-management.md - - CLI commands for plugin management
./references/cli-commands.md
Advanced Topics
- - Parallelizable tasks, multi-perspective analysis
./references/agent-teams.md - - Parallel agent coordination patterns
./references/parallel-execution.md - - Common issues, error messages, troubleshooting
./references/debugging.md