Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@

dailyNote/

.omc/

18 changes: 18 additions & 0 deletions frontend/.claude/hooks/post-compact.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
# PostCompact hook: CLAUDE.md 핵심 컨텍스트를 압축 후 재주입
CLAUDE_MD="/Users/seokyoung-won/Desktop/moadong/frontend/CLAUDE.md"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

절대경로 하드코딩으로 훅이 다른 환경에서 동작하지 않습니다

Line 3의 사용자 로컬 절대경로는 다른 개발자/CI에서 즉시 깨집니다. 스크립트 위치 기준 상대경로(또는 환경변수 우선)로 바꿔주세요.

제안 패치
-CLAUDE_MD="/Users/seokyoung-won/Desktop/moadong/frontend/CLAUDE.md"
+SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
+PROJECT_ROOT="$(cd -- "$SCRIPT_DIR/../.." && pwd)"
+CLAUDE_MD="${CLAUDE_MD:-$PROJECT_ROOT/CLAUDE.md}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/.claude/hooks/post-compact.sh` at line 3, The CLAUDE_MD variable in
frontend/.claude/hooks/post-compact.sh is hardcoded to a user-specific absolute
path; change it to resolve a repository-relative path or accept an environment
override so the hook works for other developers/CI. Specifically, update the
CLAUDE_MD assignment (variable name CLAUDE_MD in post-compact.sh) to prefer an
environment-provided value (e.g., honour $CLAUDE_MD if set) and otherwise
compute the location relative to the script directory (derive the script's
directory and join with the relative path to CLAUDE.md) instead of the current
"/Users/..." literal.


if [ ! -f "$CLAUDE_MD" ]; then
exit 0
fi

# 아키텍처 개요 섹션만 추출 (너무 많은 토큰 방지)
CONTEXT=$(awk '/^## 아키텍처 개요/,/^## [^아]/' "$CLAUDE_MD" | head -60)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

아키텍처 섹션 종료 조건이 불안정합니다

Line 10의 종료 패턴(^## [^아])은 “다음 ## 헤더”를 정확히 의미하지 않아 섹션 경계가 잘못 잡힐 수 있습니다. 시작 헤더 진입 후 다음 ## 에서 종료하도록 상태 기반으로 바꾸는 게 안전합니다.

제안 패치
-CONTEXT=$(awk '/^## 아키텍처 개요/,/^## [^아]/' "$CLAUDE_MD" | head -60)
+CONTEXT=$(
+  awk '
+    /^## 아키텍처 개요$/ { in_section=1; print; next }
+    /^## / && in_section { exit }
+    in_section { print }
+  ' "$CLAUDE_MD" | head -60
+)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
CONTEXT=$(awk '/^## 아키텍처 개요/,/^## [^아]/' "$CLAUDE_MD" | head -60)
CONTEXT=$(
awk '
/^## 아키텍처 개요$/ { in_section=1; print; next }
/^## / && in_section { exit }
in_section { print }
' "$CLAUDE_MD" | head -60
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/.claude/hooks/post-compact.sh` at line 10, The CONTEXT extraction
uses an unstable termination pattern '^## [^아]' which can misidentify the next
section; update the awk invocation that sets CONTEXT (the line using CLAUDE_MD)
to use a stateful approach: match the start header '^## 아키텍처 개요', set a flag,
print lines while the flag is set, and clear the flag when any next header
matching '^## ' is seen so the section reliably ends at the next '##' header;
keep the existing head -60 truncation if desired and ensure the variable names
CONTEXT and CLAUDE_MD are used unchanged.


if [ -z "$CONTEXT" ]; then
exit 0
fi

CONTEXT_JSON=$(printf '%s' "$CONTEXT" | jq -Rs .)

printf '{"hookSpecificOutput":{"hookEventName":"PostCompact","additionalContext":%s}}' "$CONTEXT_JSON"
62 changes: 62 additions & 0 deletions frontend/.claude/hooks/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Hook: Stop
# On session end: stages all changes, generates a conventional commit message
# via Claude headless mode (claude -p), commits, and logs to CHANGELOG.
# Falls back to a generic WIP message if claude -p fails.

set -euo pipefail

# Resolve the git repo root (worktree-safe)
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || REPO_ROOT="$CLAUDE_PROJECT_DIR"
cd "$REPO_ROOT" || exit 0
Comment on lines +10 to +11
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

set -u 환경에서 fallback 변수가 비어 있으면 스크립트가 종료될 수 있습니다

Line 10은 CLAUDE_PROJECT_DIR가 unset일 때 비정상 종료될 수 있습니다. 안전한 기본값 처리 후 REPO_ROOT 유효성 검사를 추가해 주세요.

제안 패치
-REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || REPO_ROOT="$CLAUDE_PROJECT_DIR"
-cd "$REPO_ROOT" || exit 0
+REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
+REPO_ROOT="${REPO_ROOT:-${CLAUDE_PROJECT_DIR:-}}"
+[ -n "$REPO_ROOT" ] || exit 0
+cd "$REPO_ROOT" || exit 0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null) || REPO_ROOT="$CLAUDE_PROJECT_DIR"
cd "$REPO_ROOT" || exit 0
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || true)"
REPO_ROOT="${REPO_ROOT:-${CLAUDE_PROJECT_DIR:-}}"
[ -n "$REPO_ROOT" ] || exit 0
cd "$REPO_ROOT" || exit 0
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/.claude/hooks/stop.sh` around lines 10 - 11, REPO_ROOT assignment
can fail under set -u if CLAUDE_PROJECT_DIR is unset; change the fallback to use
a safe default expansion (use CLAUDE_PROJECT_DIR with a default empty value) and
add an explicit validation after assignment: if REPO_ROOT is empty, log an error
and exit non‑zero; keep the existing cd "$REPO_ROOT" || exit 0 but only after
the emptiness check. Update the assignment that sets REPO_ROOT and add the
post‑assignment check referencing REPO_ROOT and CLAUDE_PROJECT_DIR so the script
won't abort unexpectedly under set -u.


# Stage all changes
git add -A 2>/dev/null || true

Comment on lines +13 to +15
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

세션 종료 시 git add -A는 과도하게 넓은 범위를 커밋합니다

Line 13-15는 추적되지 않은 파일/실수로 생성된 파일까지 포함할 수 있어 사고 위험이 큽니다. 최소 git add -u로 제한하거나 명시적 allowlist가 필요합니다.

제안 패치
-# Stage all changes
-git add -A 2>/dev/null || true
+# Stage tracked changes only (safer default)
+git add -u 2>/dev/null || true
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Stage all changes
git add -A 2>/dev/null || true
# Stage tracked changes only (safer default)
git add -u 2>/dev/null || true
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/.claude/hooks/stop.sh` around lines 13 - 15, The hook currently
stages all changes with "git add -A" in stop.sh which can include untracked or
accidental files; change the staging command to a safer alternative such as "git
add -u" to only update tracked files or implement an explicit allowlist of paths
before staging, and update the stop.sh logic that runs "git add -A" to use the
new command or allowlist check so only intended files are staged.

# Exit if nothing to commit
if git diff-index --quiet HEAD 2>/dev/null; then
exit 0
fi

# Extract diff for commit message generation (truncated to 2000 lines)
DIFF=$(git diff --cached 2>/dev/null | head -2000)

# Generate commit message via Claude headless mode
COMMIT_MSG=""
if command -v claude &>/dev/null; then
COMMIT_MSG=$(echo "$DIFF" | claude -p \
"You are a commit message generator. Based on the following git diff, write a single commit message.
Rules:
- First line MUST start with 'WIP(scope): short summary' (max 72 chars)
- Always use 'WIP' as the type prefix, never feat/fix/refactor/etc.
- If needed, add a blank line then bullet points for details
- Be concise and specific
- Output ONLY the commit message, nothing else" 2>/dev/null) || true
Comment on lines +27 to +34
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

staged diff 전체를 외부 도구로 전송하는 동작은 민감정보 유출 위험이 있습니다

Line 27-34는 코드/비밀값이 포함된 diff를 그대로 전송할 수 있습니다. 기본 비활성화(옵트인) 또는 민감패턴 마스킹이 필요합니다.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/.claude/hooks/stop.sh` around lines 27 - 34, The current COMMIT_MSG
assignment sends the entire staged DIFF to an external tool (claude) via the
COMMIT_MSG=$(echo "$DIFF" | claude ...) pipeline, which can leak secrets; change
stop.sh so sending the full DIFF is opt-in and/or masked: gate the claude call
behind an explicit environment flag (e.g., require ALLOW_SEND_DIFF or similar)
before using COMMIT_MSG and, when enabled, preprocess DIFF to remove or redact
sensitive patterns (e.g., lines containing "password", "secret", "api_key",
"BEGIN PRIVATE KEY", private key blocks, or files like .env) before piping to
claude; update the logic that sets COMMIT_MSG to use the gated+filtered DIFF
instead of raw $DIFF (referencing the COMMIT_MSG assignment and DIFF variable).

fi

# Fallback if claude -p failed or returned empty
if [ -z "$COMMIT_MSG" ]; then
FILE_COUNT=$(git diff --cached --name-only | wc -l | tr -d ' ')
COMMIT_MSG="wip: update $FILE_COUNT files"
fi

# Commit using -F - to safely handle special characters
echo "$COMMIT_MSG" | git commit -F - --no-verify 2>/dev/null || true

# Update CHANGELOG if it exists
CHANGELOG="$REPO_ROOT/docs/CHANGELOG.md"
if [ -f "$CHANGELOG" ]; then
TIMESTAMP=$(date '+%Y-%m-%d %H:%M')
FIRST_LINE=$(echo "$COMMIT_MSG" | head -1)

if grep -q '## \[Unreleased\]' "$CHANGELOG"; then
sed -i '' "/## \[Unreleased\]/a\\
- $TIMESTAMP: $FIRST_LINE" "$CHANGELOG" 2>/dev/null || \
sed -i "/## \[Unreleased\]/a\\- $TIMESTAMP: $FIRST_LINE" "$CHANGELOG" 2>/dev/null || true
fi

git add "$CHANGELOG" 2>/dev/null || true
if ! git diff-index --quiet HEAD 2>/dev/null; then
git commit -m "docs: auto-update changelog" --no-verify 2>/dev/null || true
fi
fi
46 changes: 46 additions & 0 deletions frontend/.claude/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Write|Edit",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path // empty' | { read -r f; [ -n \"$f\" ] && cd /Users/seokyoung-won/Desktop/moadong/frontend && npx prettier --write \"$f\" --ignore-unknown 2>/dev/null; } || true",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

tool_input.file_path 경로 검증이 없어 repo 바깥 파일 대상 실행 가능성이 있습니다

Line 9는 입력 경로를 바로 prettier에 전달합니다. realpath 기준으로 프로젝트 루트 하위인지 확인 후 실행하도록 제한하는 게 안전합니다.

제안 패치(개념)
-"command": "jq -r '.tool_input.file_path // empty' | { read -r f; [ -n \"$f\" ] && cd /Users/seokyoung-won/Desktop/moadong/frontend && npx prettier --write \"$f\" --ignore-unknown 2>/dev/null; } || true",
+"command": "jq -r '.tool_input.file_path // empty' | { read -r f; root=\"${CLAUDE_PROJECT_DIR:-$(pwd)}\"; [ -n \"$f\" ] || exit 0; abs=\"$(realpath \"$f\" 2>/dev/null || true)\"; case \"$abs\" in \"$root\"/*) cd \"$root\" && npx prettier --write \"$abs\" --ignore-unknown 2>/dev/null ;; esac; } || true",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"command": "jq -r '.tool_input.file_path // empty' | { read -r f; [ -n \"$f\" ] && cd /Users/seokyoung-won/Desktop/moadong/frontend && npx prettier --write \"$f\" --ignore-unknown 2>/dev/null; } || true",
"command": "jq -r '.tool_input.file_path // empty' | { read -r f; root=\"${CLAUDE_PROJECT_DIR:-$(pwd)}\"; [ -n \"$f\" ] || exit 0; abs=\"$(realpath \"$f\" 2>/dev/null || true)\"; case \"$abs\" in \"$root\"/*) cd \"$root\" && npx prettier --write \"$abs\" --ignore-unknown 2>/dev/null ;; esac; } || true",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/.claude/settings.json` at line 9, The command currently feeds
tool_input.file_path directly into prettier allowing files outside the repo;
update the shell snippet that builds "command" to resolve the input with
realpath (e.g. realpath "$f") and compare it against the repository root
realpath (resolve the hardcoded project root used in the cd, e.g. realpath
"/Users/seokyoung-won/Desktop/moadong/frontend"); only run npx prettier --write
"$f" if the resolved path is a descendant of the repo root (prefix check),
otherwise skip and return a non-error status or log a warning; ensure the check
is applied where tool_input.file_path is read so the rest of the pipeline
behavior is unchanged.

"statusMessage": "Formatting..."
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "/Users/seokyoung-won/Desktop/moadong/frontend/.claude/hooks/stop.sh"
}
]
}
],
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude가 입력을 기다리고 있어요\" with title \"Claude Code\" sound name \"Ping\"'"
}
]
}
],
"PostCompact": [
{
"hooks": [
{
"type": "command",
"command": "/Users/seokyoung-won/Desktop/moadong/frontend/.claude/hooks/post-compact.sh"
}
]
}
]
}
}
Loading
Loading