Skip to main content

สำรวจ .claude directory

ที่ที่ Claude Code อ่าน CLAUDE.md, settings.json, hooks, skills, commands, subagents, workflows, rules และ auto memory สำรวจ .claude directory ในโปรเจกต์และ ~/.claude ใน home directory

Claude Code อ่านการกำหนดค่าจากสองสถานที่หลัก:

  • .claude/ ในไดเรกทอรีโปรเจกต์ (การกำหนดค่าระดับโปรเจกต์)
  • ~/.claude/ ในไดเรกทอรี home (การกำหนดค่าระดับผู้ใช้)

โครงสร้าง .claude ระดับโปรเจกต์

your-project/
├── CLAUDE.md # คำสั่งโปรเจกต์ที่ Claude อ่านทุก session
├── .mcp.json # MCP servers ระดับโปรเจกต์ แชร์กับทีม
├── .worktreeinclude # ไฟล์ gitignored ที่จะ copy เข้า worktrees ใหม่
└── .claude/
├── settings.json # Permissions, hooks และการกำหนดค่า
├── settings.local.json # Personal settings overrides (gitignored)
├── rules/ # คำสั่งที่กำหนดขอบเขตตาม topic
│ ├── testing.md
│ └── api-design.md
├── skills/ # Reusable prompts ที่เรียกใช้ด้วยชื่อ
│ └── security-review/
│ ├── SKILL.md
│ └── checklist.md
├── commands/ # Single-file prompts (legacy, ใช้ skills แทน)
│ └── fix-issue.md
├── output-styles/ # Output styles ระดับโปรเจกต์
├── agents/ # Subagents พิเศษที่มี context window ของตัวเอง
│ └── code-reviewer.md
├── workflows/ # Dynamic workflow scripts
└── agent-memory/ # Subagent persistent memory

ไฟล์ระดับโปรเจกต์

CLAUDE.md

เมื่อไหร่โหลด: โหลดเข้า context ตอนเริ่ม session ทุกครั้ง

วัตถุประสงค์: คำสั่งเฉพาะโปรเจกต์ที่กำหนดวิธีที่ Claude ทำงานใน repository นี้ ใส่ conventions, commands ที่ใช้บ่อย และ architectural context ที่นี่

ตัวอย่าง:

# Project conventions

## Commands
- Build: `npm run build`
- Test: `npm test`
- Lint: `npm run lint`

## Stack
- TypeScript with strict mode
- React 19, functional components only

## Rules
- Named exports, never default exports
- Tests live next to source: `foo.ts` -> `foo.test.ts`
- All API routes return `{ data, error }` shape

เคล็ดลับ: มุ่งหมายให้ต่ำกว่า 200 บรรทัด ไฟล์ที่ยาวกว่ายังคงโหลดแบบเต็ม แต่อาจลดประสิทธิภาพ

.mcp.json

วัตถุประสงค์: กำหนดค่า MCP servers ที่ทีมทั้งหมดใช้ ไฟล์นี้เก็บ servers ระดับโปรเจกต์ Servers ส่วนตัวที่คุณต้องการเก็บไว้คนเดียวอยู่ใน ~/.claude.json

ตัวอย่าง:

{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}

.worktreeinclude

วัตถุประสงค์: แสดงรายการไฟล์ gitignored ที่จะ copy จาก main repository เข้า worktree ใหม่แต่ละอัน

ตัวอย่าง:

# Local environment
.env
.env.local

# API credentials
config/secrets.json

ไฟล์ใน .claude/

settings.json

วัตถุประสงค์: Settings ที่ Claude Code นำไปใช้โดยตรง Permissions ควบคุมว่า Claude สามารถใช้ commands และ tools อะไรได้ hooks รัน scripts ของคุณในจุดเฉพาะใน session

ตัวอย่าง:

{
"permissions": {
"allow": [
"Bash(npm test *)",
"Bash(npm run *)"
],
"deny": [
"Bash(rm -rf *)"
]
},
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs npx prettier --write"
}]
}]
}
}

settings.local.json

วัตถุประสงค์: Personal settings ที่มีความสำคัญเหนือกว่า project defaults รูปแบบ JSON เดียวกับ settings.json แต่ไม่ได้ commit ใช้เมื่อคุณต้องการ permissions หรือ defaults ที่แตกต่างจาก team config

ตัวอย่าง:

{
"permissions": {
"allow": [
"Bash(docker *)"
]
}
}

rules/

วัตถุประสงค์: คำสั่งโปรเจกต์ที่แบ่งเป็น topic files ที่โหลด conditionally ตาม file paths

Rule ที่ไม่มี paths: frontmatter โหลดตอนเริ่ม session เหมือน CLAUDE.md rule ที่มี paths: โหลดเฉพาะเมื่อ Claude อ่านไฟล์ที่ตรงกัน

ตัวอย่าง rule ที่กำหนดขอบเขตตาม file paths:

---
paths:
- "**/*.test.ts"
- "**/*.test.tsx"
---

# Testing Rules

- Use descriptive test names: "should [expected] when [condition]"
- Mock external dependencies, not internal modules
- Clean up side effects in afterEach

skills/

วัตถุประสงค์: แต่ละ skill คือ folder ที่มีไฟล์ SKILL.md บวกกับ supporting files ที่ต้องการ

คำสั่ง invocation: /skill-name หรือเมื่อ Claude จับคู่ task กับ skill

Skills รับ arguments: /deploy staging ส่ง "staging" เป็น $ARGUMENTS

ตัวอย่าง SKILL.md:

---
description: Reviews code changes for security vulnerabilities, authentication gaps, and injection risks
disable-model-invocation: true
argument-hint: <branch-or-path>
---

## Diff to review

!`git diff $ARGUMENTS`

Audit the changes above for:

1. Injection vulnerabilities (SQL, XSS, command)
2. Authentication and authorization gaps
3. Hardcoded secrets or credentials

Use checklist.md in this skill directory for the full review checklist.

Report findings with severity ratings and remediation steps.

commands/

Skills directory เป็น legacy แต่ยังรองรับอยู่ ตอนนี้คำสั่งใน commands/ และ skills ใน skills/ ทำงานเหมือนกัน สำหรับ workflows ใหม่ ใช้ skills/ แทน

ตัวอย่าง:

---
argument-hint: <issue-number>
---

!`gh issue view $ARGUMENTS`

Investigate and fix the issue above.

1. Trace the bug to its root cause
2. Implement the fix
3. Write or update tests
4. Summarize what you changed and why

agents/

วัตถุประสงค์: แต่ละ markdown file กำหนด subagent ที่มี system prompt, tool access และ model เป็นของตัวเองได้

ตัวอย่าง:

---
name: code-reviewer
description: Reviews code for correctness, security, and maintainability
tools: Read, Grep, Glob
---

You are a senior code reviewer. Review for:

1. Correctness: logic errors, edge cases, null handling
2. Security: injection, auth bypass, data exposure
3. Maintainability: naming, complexity, duplication

Every finding must include a concrete fix.

โครงสร้าง ~/.claude ระดับ Global

~/.claude/
├── CLAUDE.md # คำสั่งส่วนตัวที่โหลดทุก session
├── settings.json # การกำหนดค่า user-level
├── skills/ # Skills ส่วนตัว
├── agents/ # Agents ส่วนตัว
├── workflows/ # Workflows ส่วนตัว
├── output-styles/ # Output styles ส่วนตัว
├── themes/ # Custom themes
└── projects/ # Auto memory ต่อโปรเจกต์

ล้างข้อมูล local

หากต้องการลบข้อมูล Claude Code local ทั้งหมดสำหรับโปรเจกต์:

claude project purge ~/work/repo --dry-run

Flags:

  • --dry-run เพื่อดูตัวอย่างก่อน
  • -y/--yes เพื่อข้าม confirmation
  • --all สำหรับทุกโปรเจกต์