refactor: Claude 설정 구조 재편 및 API 응답 형식 통일#32
Conversation
fix: JoinRoom 비밀번호 검증 조건 및 응답 형식 개선
There was a problem hiding this comment.
Code Review
This pull request significantly updates the project's development workflow and standardizes API communication. It introduces a suite of Claude-specific hooks and rules to automate code formatting, builds, and tests, while also enforcing commit message conventions. Key implementation changes include refactoring Auth and Room controllers to return CommonApiResponse, updating the UserRepository to utilize EF Core's tracking instead of raw SQL, and fixing password validation logic in the JoinRoomService. Feedback identifies a mismatch in allowed commit types within the pre-commit hook, suggests relaxing the dangerous command filter to allow standard directory cleanup, and recommends using the synchronous Add method in EF Core for improved performance.
| PATTERN="^(feat|fix|update|docs): .+" | ||
|
|
||
| if [[ ! "$COMMAND" =~ dotnet[[:space:]]+(build|run|publish) ]]; then | ||
| exit 0 | ||
| if [[ ! "$COMMIT_MSG" =~ $PATTERN ]]; then | ||
| echo "[Hook] ✗ Invalid commit message format" | ||
| echo "" | ||
| echo "Expected:" | ||
| echo " {type}: {Korean description}" | ||
| echo "" | ||
| echo "Types:" | ||
| echo " feat — new feature" | ||
| echo " fix — bug fix or missing DI/config" | ||
| echo " update — modification to existing code" | ||
| echo " docs — documentation changes" | ||
| echo "" | ||
| echo "Examples:" | ||
| echo " feat: 방 생성 API 추가" | ||
| echo " fix: 세션 DI 누락 수정" | ||
| echo " update: Room 엔터티 수정" | ||
| exit 1 |
There was a problem hiding this comment.
preCommit.sh의 커밋 메시지 검증 패턴(PATTERN)과 도움말 메시지가 프로젝트의 다른 문서(commit/SKILL.md, pr/SKILL.md) 및 실제 사용 사례(PR 제목의 refactor 등)와 일치하지 않습니다. 특히 refactor와 chore 타입이 누락되어 있어, 해당 타입으로 커밋을 시도할 경우 훅에 의해 차단될 수 있습니다.
PATTERN="^(feat|fix|update|docs|refactor|chore): .+"
if [[ ! "$COMMIT_MSG" =~ $PATTERN ]]; then
echo "[Hook] ✗ Invalid commit message format"
echo ""
echo "Expected:"
echo " {type}: {Korean description}"
echo ""
echo "Types:"
echo " feat — new feature"
echo " fix — bug fix or missing DI/config"
echo " update — modification to existing code"
echo " docs — documentation changes"
echo " refactor — code refactoring"
echo " chore — tooling, config, etc."
echo ""
echo "Examples:"
echo " feat: 방 생성 API 추가"
echo " fix: 세션 DI 누락 수정"
echo " update: Room 엔터티 수정"
exit 1| DANGEROUS_KEYWORDS=( | ||
| "rm -rf" | ||
| "mkfs" | ||
| "curl .*\| .*sh" | ||
| "curl .*\| .*bash" | ||
| "wget .*\| .*sh" | ||
| "wget .*\| .*bash" | ||
| "dd if=" | ||
| "shutdown" | ||
| "reboot" | ||
| "kill -9 -1" | ||
| ":(){" | ||
| "> /dev/sda" | ||
| "chmod -R 777 /" | ||
| "chown -R root" | ||
| ) |
There was a problem hiding this comment.
DANGEROUS_KEYWORDS에 "rm -rf"가 포함되어 있어, 개발 중 빈번하게 발생하는 일반적인 디렉토리 삭제 명령(예: rm -rf bin/, rm -rf obj/)까지 모두 차단됩니다. 하단(35-38행)에서 루트(/)나 와일드카드(*)를 사용한 위험한 삭제 명령을 이미 별도로 검사하고 있으므로, 키워드 목록에서 "rm -rf"를 제거하여 개발 편의성을 높이는 것이 좋습니다.
| DANGEROUS_KEYWORDS=( | |
| "rm -rf" | |
| "mkfs" | |
| "curl .*\| .*sh" | |
| "curl .*\| .*bash" | |
| "wget .*\| .*sh" | |
| "wget .*\| .*bash" | |
| "dd if=" | |
| "shutdown" | |
| "reboot" | |
| "kill -9 -1" | |
| ":(){" | |
| "> /dev/sda" | |
| "chmod -R 777 /" | |
| "chown -R root" | |
| ) | |
| DANGEROUS_KEYWORDS=( | |
| "mkfs" | |
| "dd if=" | |
| "shutdown" | |
| "reboot" | |
| "kill -9 -1" | |
| ":(){" | |
| "> /dev/sda" | |
| "chmod -R 777 /" | |
| "chown -R root" | |
| ) |
| await _context.Users.AddAsync(user, ct); | ||
| await _context.SaveChangesAsync(ct); |
There was a problem hiding this comment.
EF Core에서 AddAsync는 특별한 상황(예: 특정 데이터베이스 제공자의 값 생성기가 비동기 작업을 필요로 하는 경우)이 아니면 권장되지 않습니다. 일반적인 관계형 데이터베이스(PostgreSQL 등)에서는 동기 메서드인 Add를 사용하는 것이 성능상 유리합니다. Add 메서드는 단순히 엔터티를 추적 상태로 변경할 뿐 실제 I/O를 발생시키지 않으며, SaveChangesAsync 호출 시점에 비동기로 저장됩니다.
_context.Users.Add(user);
await _context.SaveChangesAsync(ct);
📚작업 내용
.claude/commands/하위 command 파일들을.claude/skills/구조로 마이그레이션 (commit, migrate, test, pr, build).claude/rules/디렉터리 신설 및 아키텍처, 코드 스타일, 컨벤션, 도메인 패턴, 플로우, 테스트, 검증 규칙 문서 추가CLAUDE.md인라인 규칙 제거 후rules/파일 참조 방식으로 간소화postToolUse.sh훅 추가: C# 파일 수정 시 자동 빌드 및 테스트 실행preCommit.sh,preToolUse.sh훅 재구성;commit-msg.sh제거AuthController,RoomController응답 형식을CommonApiResponse로 통일UserRepository신규 사용자 생성 로직을 EF CoreAddAsync로 교체RoomSummary제거 및GetRoomResponse로 대체,MaxPlayers상수화JoinRoomService비밀번호 검증 조건 수정 및IsNullOrWhiteSpace강화JoinRoomServiceTests테스트 케이스 추가Claude Code 설정 구조를 commands → skills 방식으로 전환하고, 프로젝트 규칙을 별도 파일로 분리했습니다. 프로덕션 코드 변경은 이전 PR에서 미처 반영되지 않았던 응답 형식 통일 및 버그 수정 사항을 포함합니다.
✅체크리스트