jun-claude-code 0.0.16 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -40,6 +40,7 @@ exports.initContext = initContext;
40
40
  const fs = __importStar(require("fs"));
41
41
  const path = __importStar(require("path"));
42
42
  const readline = __importStar(require("readline"));
43
+ const crypto = __importStar(require("crypto"));
43
44
  const chalk_1 = __importDefault(require("chalk"));
44
45
  /**
45
46
  * Get the templates/project directory path (from package installation)
@@ -63,6 +64,13 @@ function askConfirmation(question) {
63
64
  });
64
65
  });
65
66
  }
67
+ /**
68
+ * Calculate SHA-256 hash of a file
69
+ */
70
+ function getFileHash(filePath) {
71
+ const content = fs.readFileSync(filePath);
72
+ return crypto.createHash('sha256').update(content).digest('hex');
73
+ }
66
74
  /**
67
75
  * Initialize context auto-generation with GitHub Actions
68
76
  */
@@ -74,13 +82,20 @@ async function initContext() {
74
82
  const workflowDest = path.join(cwd, '.github', 'workflows', 'context-gen.yml');
75
83
  fs.mkdirSync(path.dirname(workflowDest), { recursive: true });
76
84
  if (fs.existsSync(workflowDest)) {
77
- const shouldOverwrite = await askConfirmation(chalk_1.default.yellow(' ⚠ .github/workflows/context-gen.yml already exists. Overwrite? (y/N): '));
78
- if (shouldOverwrite) {
79
- fs.copyFileSync(templateSrc, workflowDest);
80
- console.log(chalk_1.default.green(' Replaced .github/workflows/context-gen.yml'));
85
+ const sourceHash = getFileHash(templateSrc);
86
+ const destHash = getFileHash(workflowDest);
87
+ if (sourceHash === destHash) {
88
+ console.log(chalk_1.default.gray(' [unchanged] .github/workflows/context-gen.yml'));
81
89
  }
82
90
  else {
83
- console.log(chalk_1.default.gray(' Skipped: .github/workflows/context-gen.yml'));
91
+ const shouldOverwrite = await askConfirmation(chalk_1.default.yellow(' .github/workflows/context-gen.yml has changes. Overwrite? (y/N): '));
92
+ if (shouldOverwrite) {
93
+ fs.copyFileSync(templateSrc, workflowDest);
94
+ console.log(chalk_1.default.green(' ✓ Replaced .github/workflows/context-gen.yml'));
95
+ }
96
+ else {
97
+ console.log(chalk_1.default.gray(' Skipped: .github/workflows/context-gen.yml'));
98
+ }
84
99
  }
85
100
  }
86
101
  else {
@@ -92,13 +107,20 @@ async function initContext() {
92
107
  const agentDest = path.join(cwd, '.claude', 'agents', 'context-generator.md');
93
108
  fs.mkdirSync(path.dirname(agentDest), { recursive: true });
94
109
  if (fs.existsSync(agentDest)) {
95
- const shouldOverwrite = await askConfirmation(chalk_1.default.yellow(' ⚠ .claude/agents/context-generator.md already exists. Overwrite? (y/N): '));
96
- if (shouldOverwrite) {
97
- fs.copyFileSync(agentSrc, agentDest);
98
- console.log(chalk_1.default.green(' Replaced .claude/agents/context-generator.md'));
110
+ const sourceHash = getFileHash(agentSrc);
111
+ const destHash = getFileHash(agentDest);
112
+ if (sourceHash === destHash) {
113
+ console.log(chalk_1.default.gray(' [unchanged] .claude/agents/context-generator.md'));
99
114
  }
100
115
  else {
101
- console.log(chalk_1.default.gray(' Skipped: .claude/agents/context-generator.md'));
116
+ const shouldOverwrite = await askConfirmation(chalk_1.default.yellow(' .claude/agents/context-generator.md has changes. Overwrite? (y/N): '));
117
+ if (shouldOverwrite) {
118
+ fs.copyFileSync(agentSrc, agentDest);
119
+ console.log(chalk_1.default.green(' ✓ Replaced .claude/agents/context-generator.md'));
120
+ }
121
+ else {
122
+ console.log(chalk_1.default.gray(' Skipped: .claude/agents/context-generator.md'));
123
+ }
102
124
  }
103
125
  }
104
126
  else {
@@ -110,13 +132,20 @@ async function initContext() {
110
132
  const skillDest = path.join(cwd, '.claude', 'skills', 'ContextGeneration', 'SKILL.md');
111
133
  fs.mkdirSync(path.dirname(skillDest), { recursive: true });
112
134
  if (fs.existsSync(skillDest)) {
113
- const shouldOverwrite = await askConfirmation(chalk_1.default.yellow(' ⚠ .claude/skills/ContextGeneration/SKILL.md already exists. Overwrite? (y/N): '));
114
- if (shouldOverwrite) {
115
- fs.copyFileSync(skillSrc, skillDest);
116
- console.log(chalk_1.default.green(' Replaced .claude/skills/ContextGeneration/SKILL.md'));
135
+ const sourceHash = getFileHash(skillSrc);
136
+ const destHash = getFileHash(skillDest);
137
+ if (sourceHash === destHash) {
138
+ console.log(chalk_1.default.gray(' [unchanged] .claude/skills/ContextGeneration/SKILL.md'));
117
139
  }
118
140
  else {
119
- console.log(chalk_1.default.gray(' Skipped: .claude/skills/ContextGeneration/SKILL.md'));
141
+ const shouldOverwrite = await askConfirmation(chalk_1.default.yellow(' .claude/skills/ContextGeneration/SKILL.md has changes. Overwrite? (y/N): '));
142
+ if (shouldOverwrite) {
143
+ fs.copyFileSync(skillSrc, skillDest);
144
+ console.log(chalk_1.default.green(' ✓ Replaced .claude/skills/ContextGeneration/SKILL.md'));
145
+ }
146
+ else {
147
+ console.log(chalk_1.default.gray(' Skipped: .claude/skills/ContextGeneration/SKILL.md'));
148
+ }
120
149
  }
121
150
  }
122
151
  else {
@@ -174,8 +203,12 @@ description: 비즈니스 도메인 참조 목록
174
203
  // 6. 안내 메시지
175
204
  console.log(chalk_1.default.bold('\n✅ Context auto-generation setup complete!\n'));
176
205
  console.log(chalk_1.default.cyan('Next steps:'));
177
- console.log(chalk_1.default.cyan(' 1. Add CLAUDE_CODE_OAUTH_TOKEN to your repository secrets'));
206
+ console.log(chalk_1.default.cyan(' 1. Enable GitHub Actions permissions:'));
207
+ console.log(chalk_1.default.cyan(' → Repository > Settings > Actions > General'));
208
+ console.log(chalk_1.default.cyan(' → Workflow permissions: "Read and write permissions"'));
209
+ console.log(chalk_1.default.cyan(' → ✅ "Allow GitHub Actions to create and approve pull requests"'));
210
+ console.log(chalk_1.default.cyan(' 2. Add CLAUDE_CODE_OAUTH_TOKEN to your repository secrets'));
178
211
  console.log(chalk_1.default.cyan(' → Settings > Secrets and variables > Actions > New repository secret'));
179
- console.log(chalk_1.default.cyan(' 2. Create a PR to trigger context auto-generation'));
212
+ console.log(chalk_1.default.cyan(' 3. Create a PR to trigger context auto-generation'));
180
213
  console.log('');
181
214
  }
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Merge StartSession hook into settings.json.
3
+ * Appends the task-loader hook if not already present (duplicate detection via getHookKey).
4
+ */
5
+ export declare function mergeProjectSettingsJson(destDir: string): void;
1
6
  /**
2
7
  * Initialize GitHub Project integration in current directory
3
8
  */
@@ -36,11 +36,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.mergeProjectSettingsJson = mergeProjectSettingsJson;
39
40
  exports.initProject = initProject;
40
41
  const fs = __importStar(require("fs"));
41
42
  const path = __importStar(require("path"));
42
43
  const readline = __importStar(require("readline"));
43
44
  const chalk_1 = __importDefault(require("chalk"));
45
+ const utils_1 = require("./utils");
44
46
  /**
45
47
  * Prompt user for input using readline
46
48
  */
@@ -112,9 +114,10 @@ function copyProjectFile(srcRelative, destDir) {
112
114
  console.log(chalk_1.default.green(` ✓ ${path.relative(process.cwd(), destPath)}`));
113
115
  }
114
116
  /**
115
- * Merge StartSession hook into settings.json
117
+ * Merge StartSession hook into settings.json.
118
+ * Appends the task-loader hook if not already present (duplicate detection via getHookKey).
116
119
  */
117
- function mergeSettingsJson(destDir) {
120
+ function mergeProjectSettingsJson(destDir) {
118
121
  const settingsPath = path.join(destDir, 'settings.json');
119
122
  let settings = {};
120
123
  if (fs.existsSync(settingsPath)) {
@@ -129,12 +132,21 @@ function mergeSettingsJson(destDir) {
129
132
  if (!settings.hooks) {
130
133
  settings.hooks = {};
131
134
  }
132
- settings.hooks.StartSession = [
133
- {
134
- type: 'command',
135
- command: 'bash .claude/hooks/task-loader.sh',
136
- },
137
- ];
135
+ if (!settings.hooks.StartSession) {
136
+ settings.hooks.StartSession = [];
137
+ }
138
+ const newEntry = {
139
+ hooks: [
140
+ {
141
+ type: 'command',
142
+ command: 'bash .claude/hooks/task-loader.sh',
143
+ },
144
+ ],
145
+ };
146
+ const existingKeys = new Set(settings.hooks.StartSession.map((e) => (0, utils_1.getHookKey)(e)));
147
+ if (!existingKeys.has((0, utils_1.getHookKey)(newEntry))) {
148
+ settings.hooks.StartSession.push(newEntry);
149
+ }
138
150
  fs.mkdirSync(destDir, { recursive: true });
139
151
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf-8');
140
152
  console.log(chalk_1.default.green(` ✓ ${path.relative(process.cwd(), settingsPath)} (StartSession hook 추가)`));
@@ -152,7 +164,7 @@ async function initProject() {
152
164
  copyProjectFile('hooks/task-loader.sh', destDir);
153
165
  copyProjectFile('agents/project-task-manager.md', destDir);
154
166
  // 3. settings.json merge
155
- mergeSettingsJson(destDir);
167
+ mergeProjectSettingsJson(destDir);
156
168
  console.log(chalk_1.default.cyan('\n✅ GitHub Project 설정 완료!'));
157
169
  console.log(chalk_1.default.gray(` Owner: ${config.owner}`));
158
170
  console.log(chalk_1.default.gray(` Project: #${config.projectNumber}`));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Extract a command-based key from a hook entry for duplicate detection.
3
+ * Includes the matcher field so that entries with the same command but different matchers
4
+ * are treated as distinct items.
5
+ *
6
+ * Type 1 (nested): { matcher?: "...", hooks: [{ type: "command", command: "..." }, ...] }
7
+ * -> returns "[matcher]type:command\ntype:command" (sorted) or "type:command\ntype:command" if no matcher
8
+ *
9
+ * Type 2 (flat): { type: "command", command: "..." }
10
+ * -> returns "type:command"
11
+ */
12
+ export declare const getHookKey: (entry: any) => string;
package/dist/utils.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHookKey = void 0;
4
+ /**
5
+ * Extract a command-based key from a hook entry for duplicate detection.
6
+ * Includes the matcher field so that entries with the same command but different matchers
7
+ * are treated as distinct items.
8
+ *
9
+ * Type 1 (nested): { matcher?: "...", hooks: [{ type: "command", command: "..." }, ...] }
10
+ * -> returns "[matcher]type:command\ntype:command" (sorted) or "type:command\ntype:command" if no matcher
11
+ *
12
+ * Type 2 (flat): { type: "command", command: "..." }
13
+ * -> returns "type:command"
14
+ */
15
+ const getHookKey = (entry) => {
16
+ const matcher = entry.matcher || '';
17
+ if (entry.hooks && Array.isArray(entry.hooks)) {
18
+ const hooksKey = entry.hooks
19
+ .map((h) => `${h.type || ''}:${h.command || ''}`)
20
+ .sort()
21
+ .join('\n');
22
+ return matcher ? `[${matcher}]${hooksKey}` : hooksKey;
23
+ }
24
+ return `${entry.type || ''}:${entry.command || ''}`;
25
+ };
26
+ exports.getHookKey = getHookKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jun-claude-code",
3
- "version": "0.0.16",
3
+ "version": "0.1.0",
4
4
  "description": "Claude Code configuration template - copy .claude settings to your project",
5
5
  "main": "dist/index.js",
6
6
  "bin": "dist/cli.js",
@@ -10,6 +10,7 @@
10
10
  ],
11
11
  "scripts": {
12
12
  "build": "tsc",
13
+ "test": "vitest run",
13
14
  "prepublishOnly": "yarn build"
14
15
  },
15
16
  "packageManager": "yarn@3.8.7",
@@ -19,7 +20,8 @@
19
20
  },
20
21
  "devDependencies": {
21
22
  "@types/node": "^20.10.0",
22
- "typescript": "^5.5.3"
23
+ "typescript": "^5.5.3",
24
+ "vitest": "^4.0.18"
23
25
  },
24
26
  "keywords": [
25
27
  "claude",
@@ -1,177 +1,48 @@
1
1
  # Claude Code 작업 가이드
2
2
 
3
- 파일은 Claude Code의 작업 워크플로우와 규칙을 정의합니다.
4
-
5
- ## Context 절약 원칙 (최우선)
6
-
7
- Main Agent의 Context Window는 제한적입니다.
8
- **Subagent가 할 수 있는 작업은 Subagent에 위임하세요.**
9
-
10
- ### 필수 위임 작업 (Subagent 전담)
11
-
12
- | 작업 | Agent | 이유 |
13
- |------|-------|------|
14
- | 코드베이스 탐색/검색 | `explore` | 파일 내용이 Main Context에 쌓이지 않음 |
15
- | 여러 파일 읽기 | `explore`, `context-collector` | 탐색 결과만 요약해서 받음 |
16
- | .claude/context/ 문서 수집 | `project-context-collector` | 프로젝트 배경 정보만 요약해서 받음 |
17
- | 코드 패턴/구조 파악 | `context-collector` | 분석 결과만 받음 |
18
- | 복잡한 계획 수립 | `task-planner` | 계획 결과만 받음 |
19
- | 영향 분석 | `impact-analyzer` | 분석 결과만 받음 |
20
- | 코드 리뷰 | `code-reviewer` | 리뷰 결과만 받음 |
21
- | 테스트/빌드 검증 | `qa-tester` | 검증 결과만 받음 |
22
- | 단순 수정 (lint/build 오류, 오타, 설정값) | `simple-code-writer` | Main Context 보존 |
23
- | 여러 파일 코드 작성 | `code-writer` | 구현 결과만 받음 |
24
- | Git 작업 | `git-manager` | 커밋/PR 결과만 받음 |
25
- | Context 문서 정리 | `context-manager` | 파일 분리, 토큰 최적화 |
3
+ ## Context 절약 원칙
4
+
5
+ Main Agent의 Context Window는 제한적입니다. Subagent가 할 수 있는 작업은 Subagent에 위임합니다.
26
6
 
27
7
  <delegation_rules>
28
8
 
29
- ### Subagent 전용 작업
9
+ ### 위임 규칙
30
10
 
31
11
  | 작업 | 전담 Agent |
32
12
  |------|-----------|
33
- | 파일 탐색 (Glob/Grep) | explore Agent가 전담 |
34
- | .claude/context/ 문서 탐색 | project-context-collector 전담 |
35
- | 소스 코드 패턴/구조 파악 | context-collector 전담 |
36
- | 2개 이상 파일 읽기 | explore/context-collector 전담 |
37
- | 복잡한 분석/계획 | task-planner 위임 |
38
- | 파일 수정 | code-writer가 전담 |
39
- | Git 명령어 실행 (git add, commit, push 등) | git-manager에 위임 |
40
- | 코드 수정 (Edit/Write) | code-writer/simple-code-writer에 위임 |
41
-
42
- ### Main Agent 전담 작업
13
+ | 코드베이스 탐색/검색 | `explore` |
14
+ | 여러 파일 읽기 | `explore`, `context-collector` |
15
+ | .claude/context/ 문서 수집 | `project-context-collector` |
16
+ | 코드 패턴/구조 파악 | `context-collector` |
17
+ | 복잡한 계획 수립 | `task-planner` |
18
+ | 영향 분석 | `impact-analyzer` |
19
+ | 코드 리뷰 | `code-reviewer` |
20
+ | 테스트/빌드 검증 | `qa-tester` |
21
+ | 단순 수정 (lint, 오타, 설정값) | `simple-code-writer` (haiku) |
22
+ | 로직 작성, 기능 구현, 리팩토링 | `code-writer` (opus) |
23
+ | Git 작업 (commit, PR, branch) | `git-manager` |
24
+ | Context 문서 정리 | `context-manager` |
25
+
26
+ ### Main Agent 전담
43
27
 
44
28
  - 사용자와 대화/질문 응답
45
29
  - Task 흐름 관리 (TaskCreate, TaskUpdate, TaskList)
46
30
  - Subagent 호출 및 결과 전달
47
- - 단순 명령 실행 (Bash) - **Git/코드수정은 Subagent 전담**
48
31
 
49
32
  </delegation_rules>
50
33
 
51
- ### 코드 수정 위임 규칙
52
-
53
- 모든 코드 수정은 Subagent가 전담합니다.
54
-
55
- | 수정 유형 | Agent | 모델 |
56
- |----------|-------|------|
57
- | lint/build 오류 수정, 오타, 설정값 변경 등 단순 수정 | `simple-code-writer` | haiku |
58
- | 로직 작성, 기능 구현, 리팩토링 (파일 수 무관) | `code-writer` | opus |
59
-
60
- ### Git 작업은 Subagent 전담
61
-
62
- **모든 Git 작업은 `git-manager` Agent에 위임하세요.**
63
-
64
- ```
65
- Task(subagent_type="git-manager", prompt="현재 변경사항을 커밋해줘")
66
- Task(subagent_type="git-manager", prompt="PR을 생성해줘")
67
- ```
68
-
69
- ### 왜 Subagent를 사용해야 하는가?
70
-
71
- 1. **Context 절약**: Subagent의 탐색/분석 결과는 요약되어 Main에 전달
72
- 2. **대화 지속성**: Main Context가 절약되어 더 긴 대화 가능
73
- 3. **전문성**: 각 Agent는 특정 작업에 최적화됨
74
- 4. **병렬 처리**: 여러 Agent를 동시에 실행 가능
75
-
76
- ### 코드 작성 위임 기준
77
-
78
- | 상황 | 처리 |
79
- |------|------|
80
- | lint/build 오류, 오타, 설정값 등 단순 수정 | `simple-code-writer` Agent에 위임 |
81
- | 로직 작성, 기능 구현, 리팩토링 | `code-writer` Agent에 위임 |
82
-
83
34
  <workflow>
84
35
 
85
- ## 작업 워크플로우 (필수)
86
-
87
- 모든 코드 작업은 아래 순서를 따릅니다:
88
-
89
- <phase name="계획">
90
-
91
- ### Phase 1: 계획 (Planning)
92
-
93
- ```
94
- 1. Context 수집
95
- - EnterPlanMode 진입
96
- - 관련 Context 문서 확인 (.claude/context/)
97
- - 필요한 Skill 활성화 (.claude/skills/)
98
- - 기존 코드 탐색 (Explore Agent)
99
-
100
- 2. TaskList 생성
101
- - 작업을 작은 단위로 분해
102
- - 각 Task에 명확한 완료 조건 정의
103
- - Task 간 의존성 설정
104
-
105
- 3. 코드 수정 계획 작성
106
- - 수정할 파일 목록
107
- - 각 파일의 변경 내용 요약
108
- - 예상되는 영향 범위
109
-
110
- 4. 작성된 내용을 사용자에게 Confirm 받음 **필수**
111
- ```
112
-
113
- </phase>
114
-
115
- <phase name="검증">
116
-
117
- ### Phase 2: 검증 (Validation)
118
-
119
- ```
120
- 4. 사이드이펙트 검증
121
- - 코드 Flow 분석: 변경이 다른 모듈에 미치는 영향
122
- - UI/UX UserFlow 분석: 사용자 경험에 미치는 영향
123
- - Breaking Change 여부 확인
124
- ```
125
-
126
- </phase>
127
-
128
- <phase name="구현">
129
-
130
- ### Phase 3: 구현 (Implementation)
131
-
132
- ```
133
- 5. 작은 단위로 코드 수정
134
- - 독립적으로 빌드 가능한 단위로 작업
135
- - 한 번에 하나의 기능/수정만 진행
136
- - 빌드 가능 상태를 유지
137
-
138
- 6. 단위별 커밋
139
- - 수정한 파일만 개별 지정하여 git add
140
- - 명확한 커밋 메시지 작성
141
- - 커밋 단위: 하나의 논리적 변경
142
- ```
143
-
144
- </phase>
145
-
146
- <phase name="리뷰">
147
-
148
- ### Phase 4: 리뷰 (Review)
149
-
150
- ```
151
- 7. Self Code Review
152
- - 작성한 코드가 프로젝트 규칙을 준수하는지 확인
153
- - lint 실행
154
-
155
- 8. Task 완료 검증
156
- - 원래 요청사항이 모두 충족되었는지 확인
157
- - 예상한 동작이 구현되었는지 확인
158
- - 모든 엣지케이스가 처리되었는지 점검
159
- ```
160
-
161
- </phase>
162
-
163
- ### 워크플로우 요약
36
+ ## 작업 워크플로우
164
37
 
165
38
  ```
166
- ┌─────────────────────────────────────────────────────────────┐
167
- │ 1. Context 수집 → 2. TaskList → 3. 수정 계획 │
168
- │ ↓ │
169
- │ 4. 사이드이펙트 검증 (Code Flow, UserFlow) │
170
- │ ↓ │
171
- │ 5. 코드 수정 (작은 단위) → 6. git add & commit (단위별) │
172
- │ ↓ │
173
- │ 7. Self Code Review → 8. Task 완료 검증 │
174
- └─────────────────────────────────────────────────────────────┘
39
+ 1. Context 수집 → 2. TaskList 생성 → 3. 수정 계획 (사용자 Confirm 필수)
40
+
41
+ 4. 사이드이펙트 검증 (Code Flow, UserFlow, Breaking Change)
42
+
43
+ 5. 코드 수정 (작은 단위) → 6. 단위별 커밋
44
+
45
+ 7. Self Code Review (lint) → 8. Task 완료 검증
175
46
  ```
176
47
 
177
48
  </workflow>
@@ -180,33 +51,11 @@ Task(subagent_type="git-manager", prompt="PR을 생성해줘")
180
51
 
181
52
  <reference>
182
53
 
183
- ### Context (사실/배경) - "우리 프로젝트는 이렇다"
184
-
185
- 프로젝트별로 `.claude/context/` 에 작성
186
-
187
- ### Skills (방법/절차) - "이렇게 해라"
188
-
189
- | 작업 | 위치 |
190
- |-----|------|
54
+ | 유형 | 위치 |
55
+ |------|------|
56
+ | 프로젝트 배경 정보 | `.claude/context/` |
191
57
  | 공통 코딩 원칙 | `.claude/skills/Coding/SKILL.md` |
192
- | Git 커밋/PR 생성 | `.claude/skills/Git/SKILL.md` |
193
- | PR 리뷰 | `.claude/skills/Git/pr-review.md` |
194
- | PR 피드백 적용 | `.claude/skills/Git/pr-apply.md` |
58
+ | Git 규칙 | `.claude/skills/Git/SKILL.md` |
59
+ | 문서 작성 가이드 | `.claude/skills/Documentation/SKILL.md` |
195
60
 
196
61
  </reference>
197
-
198
- ---
199
-
200
- ## .claude 문서 작성 가이드
201
-
202
- `.claude/skills/Documentation/SKILL.md` 참조
203
-
204
- ### 핵심 요약
205
-
206
- | 항목 | 내용 |
207
- |------|------|
208
- | 디렉토리 | `context/` (사실), `skills/` (방법), `agents/` (역할) |
209
- | 파일 길이 | ~500줄 권장, 1000줄 초과 시 분리 |
210
- | 필수 작성 | YAML frontmatter (name, description, keywords) |
211
-
212
- 상세 내용은 **Documentation Skill**을 참조하세요.
@@ -121,6 +121,14 @@ estimated_tokens: ~200
121
121
  - 다른 문서와 중복되는 내용
122
122
  - 더 이상 사용하지 않는 패턴
123
123
 
124
+ **Hook/프롬프트 출력 최적화:** (Context 문서 외 추가 대상)
125
+ - Hook 스크립트의 cat/echo 출력물도 최적화 대상
126
+ - 중복 텍스트 제거 (CLAUDE.md와 Hook 간 중복)
127
+ - 테이블 축약 (불필요한 컬럼 제거)
128
+ - 설명문 → 키워드 변환
129
+ - 예시 코드 블록 최소화
130
+ - 참조: `~/.claude/skills/PromptStructuring/output-optimization.md`
131
+
124
132
  </instructions>
125
133
 
126
134
  ---
@@ -132,6 +140,7 @@ estimated_tokens: ~200
132
140
  - "이 문서 너무 긴데 분리해줘"
133
141
  - "context 토큰 사용량 줄여줘"
134
142
  - "중복된 내용 정리해줘"
143
+ - "Hook 출력을 최적화해줘"
135
144
  ```
136
145
 
137
146
  ---
@@ -0,0 +1,67 @@
1
+ #!/bin/bash
2
+
3
+ # .claude/hooks/dangerous-command-blocker.sh
4
+ # Dangerous Command Blocker - PreToolUse Hook
5
+ # Bash 도구 실행 전 위험한 명령어를 감지하여 차단합니다.
6
+
7
+ INPUT=$(cat)
8
+
9
+ # jq가 있으면 jq로, 없으면 grep/sed로 command 추출
10
+ if command -v jq &>/dev/null; then
11
+ COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')
12
+ else
13
+ # jq 없이 JSON에서 command 값 추출 (fallback)
14
+ COMMAND=$(echo "$INPUT" | sed -n 's/.*"command"[[:space:]]*:[[:space:]]*"\(.*\)"/\1/p' | head -1)
15
+ # 이스케이프된 따옴표 복원
16
+ COMMAND=$(echo "$COMMAND" | sed 's/\\"/"/g')
17
+ fi
18
+
19
+ # command가 비어있으면 허용
20
+ if [ -z "$COMMAND" ]; then
21
+ exit 0
22
+ fi
23
+
24
+ # 차단 함수
25
+ block() {
26
+ echo "{\"decision\": \"block\", \"reason\": \"$1\"}"
27
+ exit 0
28
+ }
29
+
30
+ # 1. 위험한 rm 명령어 (루트/홈/현재 디렉토리 전체 삭제)
31
+ if echo "$COMMAND" | grep -qE 'rm\s+(-[a-zA-Z]*r[a-zA-Z]*f|(-[a-zA-Z]*f[a-zA-Z]*r))\s+/[[:space:]]*($|;|\||&)'; then
32
+ block "rm -rf / 는 시스템 전체를 삭제합니다. 이 명령어는 차단됩니다."
33
+ fi
34
+ if echo "$COMMAND" | grep -qE 'rm\s+(-[a-zA-Z]*r[a-zA-Z]*f|(-[a-zA-Z]*f[a-zA-Z]*r))\s+~/?\s*($|;|\||&)'; then
35
+ block "rm -rf ~ 는 홈 디렉토리 전체를 삭제합니다. 이 명령어는 차단됩니다."
36
+ fi
37
+ if echo "$COMMAND" | grep -qE 'rm\s+(-[a-zA-Z]*r[a-zA-Z]*f|(-[a-zA-Z]*f[a-zA-Z]*r))\s+\./?\s*($|;|\||&)'; then
38
+ block "rm -rf . 는 현재 디렉토리 전체를 삭제합니다. 이 명령어는 차단됩니다."
39
+ fi
40
+
41
+ # 2. sudo 명령어 (명시적 요청 없이 권한 상승)
42
+ if echo "$COMMAND" | grep -qE '(^|;|\||&&)\s*sudo\s'; then
43
+ block "sudo 명령어는 명시적 요청 없이 사용할 수 없습니다. 사용자에게 확인하세요."
44
+ fi
45
+
46
+ # 3. git push --force / -f (강제 푸시)
47
+ if echo "$COMMAND" | grep -qE 'git\s+push\s+.*(-f|--force)'; then
48
+ block "git push --force 는 원격 히스토리를 덮어씁니다. 이 명령어는 차단됩니다."
49
+ fi
50
+
51
+ # 4. git reset --hard (하드 리셋)
52
+ if echo "$COMMAND" | grep -qE 'git\s+reset\s+--hard'; then
53
+ block "git reset --hard 는 커밋되지 않은 변경사항을 모두 삭제합니다. 이 명령어는 차단됩니다."
54
+ fi
55
+
56
+ # 5. chmod 777 (과도한 권한)
57
+ if echo "$COMMAND" | grep -qE 'chmod\s+777'; then
58
+ block "chmod 777 은 과도한 권한을 부여합니다. 보안상 차단됩니다."
59
+ fi
60
+
61
+ # 6. 원격 스크립트 직접 실행 (curl/wget | sh/bash)
62
+ if echo "$COMMAND" | grep -qE '(curl|wget)\s+.*\|\s*(sh|bash)'; then
63
+ block "원격 스크립트를 직접 실행하는 것은 보안 위험이 있습니다. 이 명령어는 차단됩니다."
64
+ fi
65
+
66
+ # 모든 체크 통과 시 허용
67
+ exit 0
@@ -12,22 +12,11 @@ PROJECT_CLAUDE_DIR="$(pwd)/.claude"
12
12
  echo "✅ [Hook] Subagent Skill 평가 프로토콜 실행됨"
13
13
 
14
14
  cat << 'EOF'
15
- MANDATORY SKILL EVALUATION PROTOCOL (Subagent)
16
-
17
- 작업을 시작하기 전에 아래 단계를 완료하세요:
15
+ SKILL EVALUATION (Subagent)
18
16
 
19
17
  <phase name="Skill 평가">
20
18
 
21
- ## Skill 평가
22
-
23
- Step 1 - Skill 평가: 각 Skill에 대해 다음을 명시하세요:
24
- - Skill 이름
25
- - YES 또는 NO (이 작업에 해당 Skill이 필요한가?)
26
- - 한 줄 이유
27
-
28
- Step 2 - Skill 활성화: YES로 표시된 모든 Skill의 SKILL.md를 읽으세요.
29
-
30
- ---
19
+ Skill YES/NO로 평가하고, YES인 Skill의 SKILL.md를 읽으세요.
31
20
 
32
21
  ### 사용 가능한 Skills (자동 탐색됨)
33
22
 
@@ -70,13 +59,5 @@ done
70
59
 
71
60
  cat << 'EOF'
72
61
 
73
- <phase name="구현">
74
-
75
- ## 구현
76
-
77
- Step 3 - 구현: 관련 Skill을 확인한 후 작업을 시작하세요.
78
-
79
- Skill의 규칙과 체크리스트를 준수하며 작업을 수행하세요.
80
-
81
- </phase>
62
+ 관련 Skill 확인 후 작업을 시작하세요. Skill 규칙을 준수하세요.
82
63
  EOF