Claude Code

Customization

Slash Commands • Agents • Skills • MCP

5 วิธี Customize

/commands — Reusable prompts

agents — Specialized AI personalities

skills — Autonomous capabilities

MCP — External integrations

hooks — Event-triggered actions

.claude/ Structure

.claude/
├── commands/        # Slash commands
│   ├── wip.md
│   └── recap.md
├── agents/          # Subagents
│   ├── executor.md
│   └── context-finder.md
├── skills/          # Skills
│   └── pdf/
│       └── SKILL.md
└── knowledge/       # Reference docs

.mcp.json            # MCP servers

Slash Commands

พิมพ์ /command → Claude ทำตาม

# .claude/commands/review.md
---
description: "Review code for issues"
allowed-tools: Read, Grep
---

Check this code for:
- Security vulnerabilities
- Performance issues
- Best practices

Usage: /review

Commands + Arguments

# .claude/commands/pr.md
---
description: "Review pull request"
argument-hint: "[PR number]"
---

Review PR #$ARGUMENTS
Check: code quality, tests, security

Usage: /pr 123

$ARGUMENTS = all args | $1 $2 = specific

Subagents

AI ผู้เชี่ยวชาญเฉพาะด้าน

แยก context window (ไม่รก main)

กำหนด tools ที่ใช้ได้

Auto-invoke ตาม task

ตัวอย่าง: code-reviewer, debugger, test-runner

Agent Example

# .claude/agents/reviewer.md
---
name: code-reviewer
description: "Review code after changes"
tools: Read, Grep, Glob, Bash
model: sonnet
---

You are a senior code reviewer.
1. Run git diff to see changes
2. Check for:
   - Code clarity
   - Security issues
   - Test coverage
3. Report: Critical → Warnings → Suggestions

Skills

Autonomous capabilities (auto-discover)

Slash Command
Manual /invoke
Single file

Skill
Auto discovery
Multi-file + scripts

.claude/skills/pdf/
├── SKILL.md          # Main instructions
├── REFERENCE.md      # Detailed docs
└── scripts/
    └── extract.py

Skill Example

# .claude/skills/pdf/SKILL.md
---
name: pdf-processing
description: "Extract text and fill PDF forms.
Use when working with PDF files."
allowed-tools: Read, Bash
---

## What You Can Do
1. Extract text from PDFs
2. Fill PDF forms
3. Merge documents

## Usage
python scripts/extract.py document.pdf

MCP Servers

Model Context Protocol — External integrations

Connect Claude to external tools & databases

Tools appear automatically

GitHub Sentry Jira PostgreSQL Slack Figma Playwright

MCP Configuration

// .mcp.json
{
  "mcpServers": {
    "github": {
      "type": "http",
      "url": "https://api.github.com/mcp/"
    },
    "database": {
      "type": "stdio",
      "command": "python",
      "args": ["db-server.py"],
      "env": {
        "DB_URL": "postgresql://localhost/mydb"
      }
    }
  }
}

MCP Commands

claude mcp add github https://...

claude mcp list — ดู servers ทั้งหมด

claude mcp remove github

/mcp — Authenticate & manage in Claude Code

Hooks

Run commands when events happen

EventWhen
SessionStartเริ่ม session ใหม่
StopClaude หยุดทำงาน
PreToolUseก่อนใช้ tool
PostToolUseหลังใช้ tool
Notificationแจ้งเตือน

Hooks Configuration

// ~/.claude/settings.json
{
  "hooks": {
    "SessionStart": [{
      "hooks": [{
        "type": "command",
        "command": "say 'สวัสดีค่ะ พร้อมทำงานแล้ว'"
      }]
    }],
    "Stop": [{
      "hooks": [{
        "type": "command",
        "command": "say 'เสร็จแล้วค่ะ'"
      }]
    }]
  }
}

Hooks ที่มีประโยชน์

SessionStart — Load context, play sound

Stop — Notify done, play sound

PreToolUse — Block dangerous commands

PostToolUse — Log actions, auto-format

เปรียบเทียบ

FeatureLocationInvocationComplexity
Slash Command.claude/commands/Manual /cmdSingle file
Agent.claude/agents/Auto/explicitSystem prompt
Skill.claude/skills/Auto discoveryMulti-file
MCP Server.mcp.jsonAuto (tools)External
Hookssettings.jsonAuto (events)JSON config

เลือกใช้เมื่อไหร่?

Command — Prompt ง่ายๆ ที่ใช้บ่อย

Agent — Task เฉพาะทางที่ต้องการ expertise

Skill — Workflow ซับซ้อน + scripts + templates

MCP — Connect external services

Hooks — Automate on events (start, stop, tool use)

Hands-on

สร้าง Slash Command ของคุณเอง:

mkdir -p .claude/commands
cat > .claude/commands/hello.md << 'EOF'
---
description: "Say hello in Thai"
---
ทักทายเป็นภาษาไทยแบบเป็นกันเอง
EOF

ลอง: /hello

ตัวอย่างจาก Workshop นี้

/recap — Fresh start context

/trace — Search git + files

/rrr — Session retrospective

context-finder agent — Fast search

executor agent — Run specs

playwright MCP — Browser automation

สรุป

Claude Code = Highly Customizable

ทุกอย่างอยู่ใน .claude/ + settings.json

/commands agents skills MCP hooks