AgentSkillsCN

execute-skill

执行技能

SKILL.md
--- frontmatter
name: execute-skill
triggers:
  - "execute implementation"
  - "create component"
  - "generate files"

Execute Skill

This skill provides exact templates and file locations for creating Claude Code plugin components.

Two Distribution Models

Model A: Standalone Plugin (Local Development)

For plugins installed via local path or symlink.

code
my-plugin/
├── plugin.json           # At root
├── agents/
├── commands/
├── skills/
└── hooks/

Model B: Marketplace (GitHub Distribution)

For plugins distributed via /plugin add github:owner/repo.

code
my-marketplace/
├── .claude-plugin/
│   └── marketplace.json  # In .claude-plugin/ directory
├── README.md
├── LICENSE
└── plugins/
    └── my-plugin/
        └── .claude-plugin/
            ├── plugin.json
            ├── agents/
            ├── commands/
            ├── skills/
            └── hooks/

CRITICAL:

  • marketplace.json goes in .claude-plugin/ directory
  • Plugin content goes inside plugins/<name>/.claude-plugin/
  • source in marketplace.json points to ./plugins/<name> (NOT including .claude-plugin)

File Location Rules

For Standalone Plugin (Model A)

ComponentLocationExample
plugin.json<root>/plugin.jsonmy-plugin/plugin.json
Agent<root>/agents/<name>.mdmy-plugin/agents/my-agent.md
Command<root>/commands/<name>.mdmy-plugin/commands/my-command.md
Skill<root>/skills/<name>/SKILL.mdmy-plugin/skills/my-skill/SKILL.md
Hook config<root>/hooks/hooks.jsonmy-plugin/hooks/hooks.json
Hook script<root>/hooks/<name>.pymy-plugin/hooks/my-hook.py

For Marketplace (Model B)

ComponentLocationExample
marketplace.json<repo>/.claude-plugin/marketplace.jsonmy-marketplace/.claude-plugin/marketplace.json
plugin.json<repo>/plugins/<name>/.claude-plugin/plugin.jsonmy-marketplace/plugins/my-plugin/.claude-plugin/plugin.json
Agent<repo>/plugins/<name>/.claude-plugin/agents/<agent>.md.../agents/my-agent.md
Command<repo>/plugins/<name>/.claude-plugin/commands/<cmd>.md.../commands/my-cmd.md
Skill<repo>/plugins/<name>/.claude-plugin/skills/<skill>/SKILL.md.../skills/my-skill/SKILL.md
Hooks<repo>/plugins/<name>/.claude-plugin/hooks/.../hooks/hooks.json

Exact Templates

plugin.json

Location: <plugin-root>/plugin.json (REQUIRED)

json
{
  "name": "my-plugin",
  "version": "1.0.0",
  "description": "What this plugin does",
  "author": {
    "name": "Author Name"
  },
  "license": "MIT",
  "repository": "https://github.com/owner/repo",
  "keywords": ["keyword1", "keyword2"]
}

❌ WRONG - Do NOT create like this:

json
{
  "name": "my-plugin",
  "author": "Author Name"  // ❌ Must be object: { "name": "..." }
}

marketplace.json

Location: <repo>/.claude-plugin/marketplace.json (in .claude-plugin/ directory)

IMPORTANT: Use this ONLY for Model B (Marketplace distribution).

json
{
  "$schema": "https://claude.ai/schemas/marketplace.json",
  "name": "my-marketplace",
  "owner": {
    "name": "Owner Name"
  },
  "metadata": {
    "description": "Marketplace description",
    "version": "1.0.0"
  },
  "plugins": [
    {
      "name": "my-plugin",
      "source": "./plugins/my-plugin",
      "description": "Plugin description",
      "version": "1.0.0"
    }
  ]
}

❌ WRONG - Do NOT create like this:

json
// WRONG #1: marketplace.json at repo root (wrong location)
// ❌ my-marketplace/marketplace.json              (WRONG - at root)
// ✅ my-marketplace/.claude-plugin/marketplace.json  (CORRECT)

// WRONG #2: source pointing to root instead of plugin directory
{
  "plugins": [{
    "name": "my-plugin",
    "source": "./"  // ❌ WRONG - use "./plugins/my-plugin"
  }]
}

// WRONG #3: source including .claude-plugin path
{
  "plugins": [{
    "name": "my-plugin",
    "source": "./plugins/my-plugin/.claude-plugin"  // ❌ WRONG - don't include .claude-plugin
  }]
}

// WRONG #3: Using "author" instead of "owner"
{
  "name": "my-marketplace",
  "author": "Name",  // ❌ Use "owner": { "name": "Name" }
  "plugins": []
}

// WRONG #4: Using "path" instead of "source"
{
  "plugins": [{
    "path": ".",  // ❌ Use "source": "plugins/name/.claude-plugin"
    "config": {}  // ❌ "config" not allowed
  }]
}

// WRONG #5: Adding fields not in schema
{
  "displayName": "...",  // ❌ Not in schema
  "license": "MIT",      // ❌ Not in schema
  "repository": "...",   // ❌ Not in schema
  "keywords": [],        // ❌ Not in schema
  "categories": [],      // ❌ Not in schema
  "requirements": {},    // ❌ Not in schema
  "installation": {}     // ❌ Not in schema
}

Agent

Location: <plugin-root>/agents/<agent-name>.md (NOT in subdirectory!)

yaml
---
name: my-agent
description: Use this agent when you need to analyze code quality
tools:
  - Read
  - Grep
  - Glob
model: haiku
color: blue
---

# My Agent

You are a specialized agent for...

## Your Responsibilities

1. Task one
2. Task two

## Important Rules

- Rule one
- Rule two

❌ WRONG locations:

code
agents/my-agent/agent.md     ❌ Wrong: subdirectory
agents/my-agent/AGENT.md     ❌ Wrong: subdirectory
agents/my-agent.md           ✅ Correct

❌ WRONG frontmatter:

yaml
---
name: my-agent
allowed_tools:  # ❌ Use "tools" not "allowed_tools"
  - Read
---

Command

Location: <plugin-root>/commands/<command-name>.md (NOT in subdirectory!)

yaml
---
name: my-command
description: What this command does
allowed-tools:
  - Read
  - Write
  - Bash
argument-hint: "<file-path>"
---

# /my-command

Instructions for implementing this command...

❌ WRONG locations:

code
commands/my-command/command.md  ❌ Wrong: subdirectory
commands/my-command.md          ✅ Correct

❌ WRONG frontmatter:

yaml
---
name: my-command
allowed_tools:  # ❌ Use "allowed-tools" (kebab-case with hyphen)
  - Read
---

Skill

Location: <plugin-root>/skills/<skill-name>/SKILL.md (MUST be in subdirectory, MUST be named SKILL.md)

yaml
---
name: my-skill
triggers:
  - "use my skill"
  - "my skill please"
  - "activate skill"
---

# My Skill

Skill content goes here...

## Section One

Content...

## Section Two

Content...

❌ WRONG locations:

code
skills/my-skill.md            ❌ Wrong: not in subdirectory
skills/my-skill/skill.md      ❌ Wrong: lowercase filename
skills/my-skill/index.md      ❌ Wrong: wrong filename
skills/my-skill/SKILL.md      ✅ Correct

❌ WRONG frontmatter:

yaml
---
name: my-skill
triggers: "single trigger"  # ❌ Must be array
---

hooks.json

Location: <plugin-root>/hooks/hooks.json

IMPORTANT: hooks must be an object keyed by event name, NOT an array!

json
{
  "$schema": "https://claude.ai/schemas/hooks.json",
  "description": "My plugin hooks",
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "^Bash$",
        "hooks": [
          {
            "type": "command",
            "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/validate.py",
            "timeout": 10
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "matcher": "^/my-command",
        "hooks": [
          {
            "type": "command",
            "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/init.py",
            "timeout": 10
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/stop.py",
            "timeout": 10
          }
        ]
      }
    ]
  }
}

Available events: PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification

❌ WRONG - These patterns are INVALID:

json
// WRONG #1: hooks as array (VERY COMMON MISTAKE!)
{
  "hooks": [  // ❌ WRONG: Must be object, not array
    {
      "event": "PreToolUse",
      "command": "..."
    }
  ]
}

// WRONG #2: Missing nested "hooks" array and "type"
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "^Bash$",
        "command": "..."  // ❌ Must be inside hooks array with type: command
      }
    ]
  }
}

// WRONG #3: Hardcoded path
{
  "hooks": {
    "PreToolUse": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "python3 /home/user/hooks/script.py"  // ❌ Use ${CLAUDE_PLUGIN_ROOT}
          }
        ]
      }
    ]
  }
}

Hook Script (Python)

Location: <plugin-root>/hooks/<hook-name>.py

python
#!/usr/bin/env python3
"""Hook script for [purpose]."""
import json
import sys

def main():
    """Main hook handler."""
    try:
        input_data = json.load(sys.stdin)

        # Process input_data...
        # input_data contains event-specific fields

        # Exit codes:
        # 0 = allow (continue)
        # 2 = block (prevent action)
        sys.exit(0)

    except Exception as e:
        print(json.dumps({"error": str(e)}), file=sys.stderr)
        sys.exit(0)  # Allow on error (fail-open)

if __name__ == "__main__":
    main()

Directory Structure

Model A: Standalone Plugin

✅ CORRECT structure:

code
my-plugin/
├── plugin.json                      # REQUIRED at root
├── agents/
│   ├── agent-one.md                 # Direct .md file
│   └── agent-two.md
├── commands/
│   ├── command-one.md               # Direct .md file
│   └── command-two.md
├── skills/
│   ├── skill-one/
│   │   └── SKILL.md                 # MUST be SKILL.md
│   └── skill-two/
│       └── SKILL.md
└── hooks/
    ├── hooks.json                   # Hook configuration
    ├── hook-one.py
    └── hook-two.py

Model B: Marketplace (GitHub Distribution)

✅ CORRECT structure:

code
my-marketplace/                      # Repository root
├── .claude-plugin/
│   └── marketplace.json             # In .claude-plugin/ directory
├── README.md
├── LICENSE
└── plugins/
    └── my-plugin/
        └── .claude-plugin/          # Plugin content HERE
            ├── plugin.json          # Required
            ├── agents/
            │   └── my-agent.md
            ├── commands/
            │   └── my-cmd.md
            ├── skills/
            │   └── my-skill/
            │       └── SKILL.md
            └── hooks/
                ├── hooks.json
                └── my-hook.py

❌ WRONG marketplace structures:

code
# WRONG: marketplace.json at repo root (should be in .claude-plugin/)
my-marketplace/
├── marketplace.json                 # ❌ Should be in .claude-plugin/
└── plugins/

# WRONG: Plugin content at repo root (not in plugins/ directory)
my-marketplace/
├── .claude-plugin/
│   └── marketplace.json
├── plugin.json                      # ❌ Should be in plugins/<name>/.claude-plugin/
├── agents/                          # ❌ Should be in plugins/<name>/.claude-plugin/
└── skills/                          # ❌ Should be in plugins/<name>/.claude-plugin/

# WRONG: Missing .claude-plugin directory for plugin
my-marketplace/
├── .claude-plugin/
│   └── marketplace.json
└── plugins/
    └── my-plugin/
        ├── plugin.json              # ❌ Missing .claude-plugin/ wrapper
        └── agents/

❌ General WRONG structures:

code
# Agent in subdirectory
agents/my-agent/agent.md             # ❌ Wrong
agents/my-agent.md                   # ✅ Correct

# Command in subdirectory
commands/my-cmd/command.md           # ❌ Wrong
commands/my-cmd.md                   # ✅ Correct

# Skill as direct file
skills/my-skill.md                   # ❌ Wrong
skills/my-skill/SKILL.md             # ✅ Correct

# Skill with wrong filename
skills/my-skill/skill.md             # ❌ Wrong (lowercase)
skills/my-skill/index.md             # ❌ Wrong (wrong name)
skills/my-skill/SKILL.md             # ✅ Correct

Quick Reference: Common Mistakes

WrongCorrectComponent
marketplace.json at repo root.claude-plugin/marketplace.jsonmarketplace location
"source": "./" (for marketplace)"source": "./plugins/name"marketplace.json
"source": "plugins/name/.claude-plugin""source": "./plugins/name"marketplace.json
Plugin content at repo rootInside plugins/<name>/.claude-plugin/marketplace structure
"author": "Name""owner": { "name": "Name" }marketplace.json
"path": ".""source": "./plugins/name"marketplace.json
"config": { ... }Not allowedmarketplace.json
displayName, license, repository in marketplaceRemove themmarketplace.json
allowed_tools:allowed-tools:commands
agents/x/agent.mdagents/x.mdagents
commands/x/cmd.mdcommands/x.mdcommands
skills/x.mdskills/x/SKILL.mdskills
skills/x/skill.mdskills/x/SKILL.mdskills
tools: Read, Greptools: [Read, Grep]agents
triggers: "phrase"triggers: ["phrase"]skills
Hardcoded paths in hooks${CLAUDE_PLUGIN_ROOT}/...hooks
"hooks": [...] (array)"hooks": { "EventName": [...] }hooks.json
Missing "type": "command"Required in hook command objecthooks.json

Execution Process

  1. Check location rules - Use correct file paths
  2. Use exact templates - Copy and modify
  3. Avoid wrong patterns - Check the ❌ examples
  4. Verify before completing - Use verify-skill