Initialize fe-common-rules repository with common Claude guidelines and scripts for frontend projects

This commit is contained in:
hyeonggil
2026-04-11 19:27:29 +09:00
commit 2def6f705d
8 changed files with 530 additions and 0 deletions

93
scripts/install.sh Executable file
View File

@@ -0,0 +1,93 @@
#!/usr/bin/env bash
#
# fe-common-rules installer
# 현재 Git 프로젝트의 .claude/common 경로에 fe-common-rules 저장소를
# submodule 로 추가하고 루트 CLAUDE.md 템플릿을 생성합니다.
#
# 사용법:
# bash scripts/install.sh [<repo-url>] [<branch>]
#
# 예:
# bash scripts/install.sh git@github.com:our-team/fe-common-rules.git main
#
set -euo pipefail
REPO_URL="${1:-}"
BRANCH="${2:-main}"
TARGET_PATH=".claude/common"
if [[ -z "$REPO_URL" ]]; then
echo "❌ 사용법: bash scripts/install.sh <repo-url> [branch]" >&2
echo " 예: bash scripts/install.sh git@github.com:our-team/fe-common-rules.git main" >&2
exit 1
fi
# Git 프로젝트인지 확인
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "❌ 현재 디렉토리는 Git 저장소가 아닙니다. 먼저 'git init' 후 실행해주세요." >&2
exit 1
fi
# 이미 submodule 이 존재하는지 확인
if [[ -d "$TARGET_PATH" ]]; then
echo "⚠️ '$TARGET_PATH' 경로가 이미 존재합니다. 설치를 건너뜁니다."
else
echo "📦 fe-common-rules 를 submodule 로 추가합니다..."
git submodule add -b "$BRANCH" "$REPO_URL" "$TARGET_PATH"
git submodule update --init --recursive
echo "✅ submodule 추가 완료: $TARGET_PATH"
fi
# 프로젝트 지침 폴더 생성
mkdir -p .claude/project
# CLAUDE.md 템플릿 생성 (없을 때만)
if [[ ! -f "CLAUDE.md" ]]; then
cat > CLAUDE.md <<'EOF'
# <프로젝트 이름>
## 공통 지침
@.claude/common/CLAUDE.md
## 프로젝트 지침
@.claude/project/overview.md
@.claude/project/conventions.md
EOF
echo "✅ CLAUDE.md 템플릿을 생성했습니다."
else
echo " 기존 CLAUDE.md 가 이미 존재합니다. 아래 블록을 수동으로 추가하세요:"
echo ""
echo " ## 공통 지침"
echo " @.claude/common/CLAUDE.md"
echo ""
fi
# 프로젝트 지침 샘플 파일
if [[ ! -f ".claude/project/overview.md" ]]; then
cat > .claude/project/overview.md <<'EOF'
# 프로젝트 개요
- 서비스명:
- 기술 스택:
- 주요 기능:
- 주의사항:
EOF
fi
if [[ ! -f ".claude/project/conventions.md" ]]; then
cat > .claude/project/conventions.md <<'EOF'
# 프로젝트 전용 컨벤션
공통 지침 외에 이 프로젝트에서만 적용되는 규칙을 작성하세요.
EOF
fi
echo ""
echo "🎉 설치가 완료되었습니다."
echo " - 공통 지침: .claude/common/CLAUDE.md"
echo " - 프로젝트 지침: .claude/project/"
echo " - 엔트리 파일: CLAUDE.md"
echo ""
echo "변경 사항을 커밋해 주세요:"
echo " git add .gitmodules .claude CLAUDE.md"
echo " git commit -m 'chore: add fe-common-rules submodule'"

36
scripts/update.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# fe-common-rules updater
# 현재 프로젝트에 설치된 .claude/common submodule 을 최신 버전으로 갱신합니다.
#
# 사용법:
# bash .claude/common/scripts/update.sh
#
set -euo pipefail
TARGET_PATH=".claude/common"
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "❌ 현재 디렉토리는 Git 저장소가 아닙니다." >&2
exit 1
fi
if [[ ! -d "$TARGET_PATH" ]]; then
echo "❌ '$TARGET_PATH' 가 존재하지 않습니다. 먼저 install.sh 로 설치하세요." >&2
exit 1
fi
echo "🔄 fe-common-rules 를 최신 버전으로 업데이트합니다..."
git submodule update --remote --merge "$TARGET_PATH"
# 변경 사항 확인
if git diff --quiet -- "$TARGET_PATH"; then
echo "✅ 이미 최신 상태입니다."
exit 0
fi
echo ""
echo "✅ 업데이트가 완료되었습니다. 변경된 submodule 포인터를 커밋하세요:"
echo ""
echo " git add $TARGET_PATH"
echo " git commit -m 'chore: update fe-common-rules submodule'"