Claude Code의 커스텀 슬래시 명령어를 알면 혼자서도 팀 개발하는 느낌이 나요. 정말이에요.
/tdd 치면 테스트 주도 개발 모드로 들어가요. RED-GREEN-IMPROVE 사이클 돌면서 테스트 먼저 짜고 코드 구현하거든요. /plan은 작업 계획 세우고, /e2e는 E2E 테스트 만들어주고, /code-review는 코드 리뷰 돌려줘요.
자주 쓰는 워크플로우를 명령어 하나로 실행할 수 있어요.
TL;DR
- 커스텀 명령어 = 저장된 프롬프트를 한 번에 실행
- 위치: .claude/commands/ (프로젝트) 또는 ~/.claude/commands/ (전역)
- 파일명 = 명령어 이름 (tdd.md → /tdd)
- $ARGUMENTS로 인자 전달 가능
- frontmatter로 도구 제한, 모델 지정 가능
커스텀 명령어란?
"Custom slash commands are essentially saved prompts that you can invoke with a simple /command_name syntax." — cloudartisan.com
매번 같은 프롬프트 치는 거 귀찮잖아요. "테스트 먼저 작성하고, 실패하는지 확인하고, 그 다음 구현해줘"를 매번 타이핑하는 대신, /tdd만 치면 끝이에요.
왜 필요한가?
- 반복 제거: 자주 쓰는 프롬프트 저장
- 일관성: 항상 같은 방식으로 작업
- 팀 공유: Git으로 명령어 공유 가능
- 워크플로우 자동화: 복잡한 작업을 명령어 하나로
"I don't think about naming conventions, commit messages, or PR descriptions anymore. The commands handle it." — alexop.dev
명령어 저장 위치
위치 범위 Git 커밋
| .claude/commands/ | 프로젝트 전용 | ✅ 팀 공유 |
| ~/.claude/commands/ | 모든 프로젝트 | ❌ 개인용 |
# 프로젝트 명령어 생성
mkdir -p .claude/commands
echo "Analyze this code for performance issues:" > .claude/commands/optimize.md
# 전역 명령어 생성
mkdir -p ~/.claude/commands
echo "Review this code for security vulnerabilities:" > ~/.claude/commands/security.md
기본 문법
가장 간단한 형태
파일명이 곧 명령어 이름이에요:
<!-- .claude/commands/optimize.md -->
Analyze this code for performance issues and suggest optimizations.
Focus on:
- Time complexity
- Memory usage
- Database queries
이제 /optimize만 치면 됩니다!
인자 받기
$ARGUMENTS로 사용자 입력을 받을 수 있어요:
<!-- .claude/commands/fix-issue.md -->
Fix GitHub issue #$ARGUMENTS
1. Read the issue details
2. Find relevant code
3. Implement the fix
4. Write tests
5. Create a commit
사용법:
> /fix-issue 123
# → "Fix GitHub issue #123" 으로 실행됨
여러 인자 받기
$1, $2, $3으로 개별 인자를 받을 수 있어요:
<!-- .claude/commands/pr-review.md -->
Review PR #$1 with priority $2 and assign to $3.
Focus on security, performance, and code style.
사용법:
> /pr-review 42 high @alice
Frontmatter로 고급 설정
YAML frontmatter로 더 세밀하게 제어할 수 있어요:
---
description: Create a git commit with conventional message
allowed-tools: Bash(git add:*), Bash(git commit:*)
argument-hint: [message]
model: haiku
---
# Commit Changes
<git_diff>
!`git diff --cached`
</git_diff>
Create a commit message following Conventional Commits.
If $ARGUMENTS is provided, use it as the commit message.
Frontmatter 옵션
옵션 설명 예시
| description | 명령어 설명 (/help에 표시) | "Run tests with coverage" |
| allowed-tools | 사용 가능한 도구 제한 | Read, Grep, Glob |
| model | 사용할 모델 지정 | haiku, sonnet, opus |
| argument-hint | 인자 힌트 | [file] [options] |
모델 선택 팁
"Add model: haiku and commands run almost instantly." — alexop.dev
- haiku: 간단한 작업 (커밋 메시지, 파일 정리) → 빠름
- sonnet: 일반 작업 (코드 리뷰, 리팩토링) → 균형
- opus: 복잡한 작업 (아키텍처 설계, 디버깅) → 강력
실전 명령어 예시
/tdd - 테스트 주도 개발
---
description: Test-driven development workflow
allowed-tools: Read, Write, Edit, Bash
---
# TDD Workflow
Follow the RED-GREEN-IMPROVE cycle:
## 1. RED - Write Failing Test
- Write a test that describes the expected behavior
- Run the test and confirm it FAILS
- Do NOT write implementation yet
## 2. GREEN - Make It Pass
- Write the MINIMUM code to pass the test
- Do NOT optimize yet
- Run tests to confirm they PASS
## 3. IMPROVE - Refactor
- Clean up the code
- Remove duplication
- Improve naming
- Run tests to ensure they still PASS
## Rules
- Never modify tests to make them pass
- Aim for 80%+ test coverage
- One test at a time
Start with: $ARGUMENTS
/plan - 작업 계획
---
description: Create implementation plan for a feature
allowed-tools: Read, Grep, Glob
model: opus
---
# Feature Planning
Create a detailed implementation plan for: $ARGUMENTS
## Steps
1. Analyze the current codebase structure
2. Identify affected files and components
3. Break down into small, testable tasks
4. Estimate complexity for each task
5. Identify potential risks and edge cases
## Output Format
```markdown
# Implementation Plan: [Feature Name]
## Overview
[Brief description]
## Tasks
- [ ] Task 1 (complexity: low/medium/high)
- [ ] Task 2
...
## Files to Modify
- path/to/file1.ts - reason
- path/to/file2.ts - reason
## Risks
- Risk 1 and mitigation
Save the plan to PLAN.md
### /e2e - E2E 테스트 생성
```markdown
---
description: Generate end-to-end tests with Playwright
allowed-tools: Read, Write, Bash
---
# E2E Test Generation
Generate Playwright E2E tests for: $ARGUMENTS
## Guidelines
1. Analyze the user flow
2. Write tests that cover happy path AND edge cases
3. Use proper selectors (data-testid preferred)
4. Include assertions for:
- UI elements visible
- Network requests completed
- State changes reflected
## Structure
```typescript
import { test, expect } from '@playwright/test';
test.describe('[Feature Name]', () => {
test.beforeEach(async ({ page }) => {
// Setup
});
test('should [expected behavior]', async ({ page }) => {
// Arrange
// Act
// Assert
});
});
After Writing
- Run tests to verify they work
- Add to CI pipeline if not already
### /code-review - 코드 리뷰
```markdown
---
description: Comprehensive code review
allowed-tools: Read, Grep, Glob, Bash(git diff:*)
model: sonnet
---
# Code Review
## Changed Files
!`git diff --name-only HEAD~1`
## Detailed Changes
!`git diff HEAD~1`
## Review Checklist
### 1. Code Quality
- [ ] Clear naming conventions
- [ ] No code duplication
- [ ] Functions are small and focused
- [ ] Comments explain "why" not "what"
### 2. Security
- [ ] No hardcoded secrets
- [ ] Input validation present
- [ ] SQL injection prevention
- [ ] XSS protection
### 3. Performance
- [ ] No N+1 queries
- [ ] Efficient algorithms
- [ ] Proper caching
### 4. Testing
- [ ] Tests cover new functionality
- [ ] Edge cases handled
- [ ] No flaky tests
## Output Format
For each issue found:
1. **File:Line** - Severity (Critical/High/Medium/Low)
2. Description
3. Suggested fix with code
/commit - 자동 커밋 메시지
---
description: Create conventional commit message
allowed-tools: Bash(git add:*), Bash(git commit:*), Bash(git diff:*)
model: haiku
---
# Git Commit
<staged_changes>
!`git diff --cached`
</staged_changes>
Create a commit message following Conventional Commits:
- feat: new feature
- fix: bug fix
- docs: documentation
- style: formatting
- refactor: code restructure
- test: adding tests
- chore: maintenance
Format: type(scope): description
If $ARGUMENTS provided, use as commit message.
Otherwise, generate from staged changes.
/branch - 브랜치 생성
---
description: Create a properly named git branch
allowed-tools: Bash(git checkout:*), Bash(git branch:*)
model: haiku
---
# Create Branch
Create a new branch for: $ARGUMENTS
## Naming Convention
- feature/description-here
- fix/issue-description
- refactor/what-is-changing
- docs/what-documenting
## Steps
1. Determine appropriate prefix based on work type
2. Convert description to kebab-case
3. Create and checkout branch
Example: "add user authentication" → feature/add-user-authentication
폴더로 정리하기
명령어가 많아지면 폴더로 정리할 수 있어요:
.claude/commands/
├── git/
│ ├── commit.md → /project:git/commit
│ ├── branch.md → /project:git/branch
│ └── pr.md → /project:git/pr
├── testing/
│ ├── tdd.md → /project:testing/tdd
│ ├── e2e.md → /project:testing/e2e
│ └── unit.md → /project:testing/unit
└── review/
├── code.md → /project:review/code
└── security.md → /project:review/security
"The subdirectory appears in the command description but doesn't affect the command name itself." — Claude Code Docs
빌트인 명령어
Claude Code에 기본 내장된 명령어들:
명령어 설명
| /help | 모든 명령어 목록 |
| /compact | 컨텍스트 압축 |
| /clear | 컨텍스트 초기화 |
| /context | 컨텍스트 사용량 확인 |
| /init | CLAUDE.md 자동 생성 |
| /model | 모델 변경 |
| /agents | 서브에이전트 관리 |
| /config | 설정 변경 |
| /add-dir | 작업 디렉토리 추가 |
| /install-github-app | GitHub PR 리뷰 앱 설치 |
추천 명령어 컬렉션
everything-claude-code
affaan-m/everything-claude-code에 실전 검증된 명령어들이 있어요:
commands/
├── tdd.md # /tdd - 테스트 주도 개발
├── plan.md # /plan - 작업 계획
├── e2e.md # /e2e - E2E 테스트
├── code-review.md # /code-review - 코드 리뷰
├── security-review.md # /security-review - 보안 검토
└── refactor.md # /refactor - 리팩토링
wshobson/commands
더 방대한 컬렉션: wshobson/commands
- 57개 명령어 (15 workflows + 42 tools)
- 워크플로우: feature-development, smart-fix 등
- 도구: api-scaffold, security-scan, docker-optimize 등
설치 방법
# everything-claude-code에서 복사
git clone https://github.com/affaan-m/everything-claude-code.git
cp -r everything-claude-code/commands/* .claude/commands/
# 또는 전역으로
cp -r everything-claude-code/commands/* ~/.claude/commands/
명령어 vs Skills vs Agents
구분 슬래시 명령어 Skills Agents
| 호출 | 명시적 (/tdd) | 자동 (필요 시) | 자동 또는 명시적 |
| 용도 | 특정 작업 실행 | 지식/방법론 제공 | 독립적 작업 수행 |
| 컨텍스트 | 메인과 공유 | 메인과 공유 | 별도 격리 |
| 비유 | 매크로 버튼 | 참고 매뉴얼 | 전문가 팀원 |
"Slash commands and Agent Skills serve different purposes in Claude Code... Both can coexist." — Claude Code Docs
언제 뭘 쓸까?
- 명령어: "이 작업 지금 해줘" → /tdd, /commit
- Skills: "이 방법론 참고해서 해줘" → TDD workflow skill
- Agents: "이 전문가한테 맡겨줘" → code-reviewer agent
명령어에 Hooks 추가하기
명령어 실행 중 특정 시점에 스크립트를 실행할 수 있어요:
---
description: Deploy to staging with validation
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/validate-deploy.sh"
once: true
---
Deploy the current branch to staging environment.
once: true는 한 세션에 한 번만 실행됩니다.
팁
1. 작은 것부터 시작
# 가장 자주 치는 명령어부터
echo "Run all tests and show coverage" > ~/.claude/commands/test.md
2. Git으로 팀 공유
# .claude/commands/ 를 Git에 커밋
git add .claude/commands/
git commit -m "Add team slash commands"
3. /help로 확인
> /help
# 모든 명령어 목록 + 설명 표시
4. 어디서든 / 입력
"Slash command autocomplete works anywhere in your input, not just at the beginning." — Claude Code Docs
> Fix the login bug using /tdd approach
# 문장 중간에도 명령어 사용 가능
체크리스트
시작하기
- [ ] .claude/commands/ 폴더 생성
- [ ] 가장 자주 쓰는 프롬프트 → 명령어로 저장
- [ ] /help로 확인
확장하기
- [ ] everything-claude-code 명령어 복사
- [ ] 팀 워크플로우에 맞게 커스터마이징
- [ ] Git 커밋으로 팀 공유
고급
- [ ] frontmatter로 모델/도구 제한
- [ ] 폴더로 카테고리 정리
- [ ] Hooks 추가로 자동화 강화
마무리
커스텀 명령어는 반복을 제거하고 워크플로우를 자동화하는 가장 쉬운 방법이에요.
기억하세요:
- 파일 하나 = 명령어 하나
- .claude/commands/에 저장 → /명령어명으로 실행
- $ARGUMENTS로 인자 전달
- frontmatter로 세부 설정
- 팀과 Git으로 공유
"I was wasting time. Every commit message, every branch name, every PR description. I typed the same things over and over. Then I discovered Slash Commands." — alexop.dev
/tdd, /plan, /code-review... 이런 명령어들 세팅해두면 정말 혼자서도 팀처럼 개발할 수 있어요.
참고 자료
Anthropic 공식
- Slash Commands — Claude Code Docs
- Slash Commands in the SDK — Claude Docs
커뮤니티
- everything-claude-code — 실전 검증 명령어
- wshobson/commands — 57개 명령어 컬렉션
- awesome-claude-code — 명령어 모음
- How I use Claude Code — Builder.io
'Programmer > AI' 카테고리의 다른 글
| Claude Code 컨테이너 격리와 병렬 개발: devcontainer & git worktree (0) | 2026.01.21 |
|---|---|
| Claude Code Thinking Mode: ultrathink로 깊게 생각시키기 (0) | 2026.01.21 |
| Claude Code Skills & Agents: 전문가 팀을 내 손안에 (0) | 2026.01.21 |
| Claude Code Hooks: 자동화로 실수를 원천 차단하기 (0) | 2026.01.21 |
| Claude Code 환경 설정: CLAUDE.md로 10분 투자해서 수 시간 절약하기 (0) | 2026.01.21 |