Hooks 및 settings.json 레시피
settings.json, 권한, hooks를 위한 바로 쓰는 레시피입니다. 명령은 여러분의 스택에 맞게 조정하세요.
스타터 프로젝트 settings.json
.claude/settings.json (커밋되어 팀 전체에 적용):
{
"permissions": {
"allow": [
"Read",
"Bash(npm run test:*)",
"Bash(npm run lint)",
"Bash(git status)",
"Bash(git diff:*)"
],
"ask": ["Bash(npm install:*)", "Write"],
"deny": ["Read(./.env)", "Read(./**/*.pem)", "Bash(git push --force:*)"]
}
}
개인/머신별 재정의는 .claude/settings.local.json(git-ignore)에 두세요.
편집 후 자동 포맷
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{ "type": "command", "command": "npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true" }
]
}
]
}
}
완료 전 품질 게이트
테스트가 통과할 때까지 "완료"를 차단합니다(개념적 — 문서에 따라 Stop/완료 전 이벤트에 연결하세요):
{
"hooks": {
"Stop": [
{ "hooks": [ { "type": "command", "command": "npm test --silent" } ] }
]
}
}
안전 가드 (보호된 경로 편집 차단)
{
"hooks": {
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{ "type": "command", "command": "case \"$CLAUDE_FILE_PATH\" in *secrets*|*.env|*/vendor/*) echo 'blocked: protected path'; exit 1;; esac" }
]
}
]
}
}
:::tip hooks는 빠르고 멱등하게 유지하세요 hooks는 끊임없이 실행됩니다. 빠르고, 다시 실행해도 안전하며, 진짜 문제일 때만 시끄럽게 만드세요. :::