@kood/claude-code 0.6.5 → 0.6.7

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.
Files changed (137) hide show
  1. package/dist/index.js +255 -149
  2. package/package.json +1 -1
  3. package/templates/.claude/agents/researcher.md +8 -1
  4. package/templates/.claude/instructions/sourcing/reliable-search.md +49 -2
  5. package/templates/.claude/scripts/deploy/build-run.sh +36 -0
  6. package/templates/.claude/scripts/deploy/deploy-check.sh +38 -0
  7. package/templates/.claude/scripts/git/git-all.sh +57 -0
  8. package/templates/.claude/scripts/git/git-clean-check.sh +31 -0
  9. package/templates/.claude/scripts/git/git-commit.sh +51 -0
  10. package/templates/.claude/scripts/git/git-info.sh +34 -0
  11. package/templates/.claude/scripts/git/git-push.sh +50 -0
  12. package/templates/.claude/scripts/lint/lint-check.sh +56 -0
  13. package/templates/.claude/scripts/lint/lint-file.sh +41 -0
  14. package/templates/.claude/scripts/pm/pm-detect.sh +25 -0
  15. package/templates/.claude/scripts/pm/pm-run.sh +41 -0
  16. package/templates/.claude/scripts/version/version-bump.sh +54 -0
  17. package/templates/.claude/scripts/version/version-find.sh +49 -0
  18. package/templates/.claude/skills/docs-fetch/SKILL.md +5 -4
  19. package/templates/.claude/skills/project-optimizer/AGENTS.md +275 -0
  20. package/templates/.claude/skills/project-optimizer/SKILL.md +374 -0
  21. package/templates/.claude/skills/project-optimizer/rules/arch-config-centralize.md +66 -0
  22. package/templates/.claude/skills/project-optimizer/rules/arch-hot-path.md +35 -0
  23. package/templates/.claude/skills/project-optimizer/rules/arch-interface-segregation.md +51 -0
  24. package/templates/.claude/skills/project-optimizer/rules/arch-module-boundary.md +42 -0
  25. package/templates/.claude/skills/project-optimizer/rules/build-cache.md +57 -0
  26. package/templates/.claude/skills/project-optimizer/rules/build-code-split.md +56 -0
  27. package/templates/.claude/skills/project-optimizer/rules/build-incremental.md +65 -0
  28. package/templates/.claude/skills/project-optimizer/rules/build-minify.md +61 -0
  29. package/templates/.claude/skills/project-optimizer/rules/build-tree-shake.md +60 -0
  30. package/templates/.claude/skills/project-optimizer/rules/code-complexity.md +65 -0
  31. package/templates/.claude/skills/project-optimizer/rules/code-dead-elimination.md +32 -0
  32. package/templates/.claude/skills/project-optimizer/rules/code-duplication.md +54 -0
  33. package/templates/.claude/skills/project-optimizer/rules/code-error-handling.md +75 -0
  34. package/templates/.claude/skills/project-optimizer/rules/code-naming.md +52 -0
  35. package/templates/.claude/skills/project-optimizer/rules/concurrency-defer-await.md +54 -0
  36. package/templates/.claude/skills/project-optimizer/rules/concurrency-parallel.md +90 -0
  37. package/templates/.claude/skills/project-optimizer/rules/concurrency-pipeline.md +68 -0
  38. package/templates/.claude/skills/project-optimizer/rules/concurrency-pool.md +68 -0
  39. package/templates/.claude/skills/project-optimizer/rules/deps-lightweight-alt.md +37 -0
  40. package/templates/.claude/skills/project-optimizer/rules/deps-peer-align.md +44 -0
  41. package/templates/.claude/skills/project-optimizer/rules/deps-security-audit.md +45 -0
  42. package/templates/.claude/skills/project-optimizer/rules/deps-unused-removal.md +25 -0
  43. package/templates/.claude/skills/project-optimizer/rules/deps-version-pin.md +40 -0
  44. package/templates/.claude/skills/project-optimizer/rules/dx-ci-speed.md +47 -0
  45. package/templates/.claude/skills/project-optimizer/rules/dx-dev-server.md +35 -0
  46. package/templates/.claude/skills/project-optimizer/rules/dx-lint-config.md +36 -0
  47. package/templates/.claude/skills/project-optimizer/rules/dx-test-coverage.md +34 -0
  48. package/templates/.claude/skills/project-optimizer/rules/dx-type-safety.md +49 -0
  49. package/templates/.claude/skills/project-optimizer/rules/io-batch-queries.md +67 -0
  50. package/templates/.claude/skills/project-optimizer/rules/io-cache-layer.md +67 -0
  51. package/templates/.claude/skills/project-optimizer/rules/io-connection-reuse.md +67 -0
  52. package/templates/.claude/skills/project-optimizer/rules/io-serialize-minimal.md +61 -0
  53. package/templates/.claude/skills/project-optimizer/rules/io-stream.md +75 -0
  54. package/templates/.claude/skills/project-optimizer/rules/memory-bounded-cache.md +65 -0
  55. package/templates/.claude/skills/project-optimizer/rules/memory-large-data.md +64 -0
  56. package/templates/.claude/skills/project-optimizer/rules/memory-lazy-init.md +78 -0
  57. package/templates/.claude/skills/project-optimizer/rules/memory-leak-prevention.md +79 -0
  58. package/templates/.claude/skills/project-optimizer/rules/memory-pool-reuse.md +70 -0
  59. package/templates/.claude/skills/sql-optimizer/SKILL.md +437 -0
  60. package/templates/.claude/skills/sql-optimizer/orm-patterns.md +218 -0
  61. package/templates/.claude/skills/tanstack-start-react-best-practices/AGENTS.md +53 -14
  62. package/templates/.claude/skills/tanstack-start-react-best-practices/SKILL.md +93 -27
  63. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/bundle-defer-third-party.md +42 -19
  64. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/client-optimistic-updates.md +109 -0
  65. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/client-suspense-query.md +74 -0
  66. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/client-use-hook.md +81 -0
  67. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/rerender-react-compiler.md +81 -0
  68. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-beforeload-auth.md +121 -0
  69. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-file-conventions.md +104 -0
  70. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-link-navigation.md +119 -0
  71. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-nested-layouts.md +155 -0
  72. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-path-params.md +89 -0
  73. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-pending-component.md +110 -0
  74. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-preload-strategy.md +91 -0
  75. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-router-context.md +120 -0
  76. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/routing-search-params.md +114 -0
  77. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/server-deferred-data.md +1 -1
  78. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/server-error-boundaries.md +79 -0
  79. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/server-middleware.md +85 -0
  80. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/server-serialization.md +56 -21
  81. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/server-streaming.md +84 -0
  82. package/templates/.claude/skills/tanstack-start-react-best-practices/rules/server-validator.md +71 -0
  83. package/templates/.claude/skills/tauri-react-best-practices/AGENTS.md +527 -0
  84. package/templates/.claude/skills/tauri-react-best-practices/SKILL.md +570 -0
  85. package/templates/.claude/skills/tauri-react-best-practices/rules/bundle-barrel-imports.md +140 -0
  86. package/templates/.claude/skills/tauri-react-best-practices/rules/bundle-cargo-profile.md +96 -0
  87. package/templates/.claude/skills/tauri-react-best-practices/rules/bundle-frontend-treeshake.md +242 -0
  88. package/templates/.claude/skills/tauri-react-best-practices/rules/bundle-lazy-components.md +255 -0
  89. package/templates/.claude/skills/tauri-react-best-practices/rules/bundle-remove-unused-commands.md +160 -0
  90. package/templates/.claude/skills/tauri-react-best-practices/rules/deploy-ci-pipeline.md +269 -0
  91. package/templates/.claude/skills/tauri-react-best-practices/rules/deploy-signing.md +207 -0
  92. package/templates/.claude/skills/tauri-react-best-practices/rules/deploy-updater.md +226 -0
  93. package/templates/.claude/skills/tauri-react-best-practices/rules/ipc-async-commands.md +172 -0
  94. package/templates/.claude/skills/tauri-react-best-practices/rules/ipc-batch-commands.md +133 -0
  95. package/templates/.claude/skills/tauri-react-best-practices/rules/ipc-binary-response.md +198 -0
  96. package/templates/.claude/skills/tauri-react-best-practices/rules/ipc-channel-streaming.md +186 -0
  97. package/templates/.claude/skills/tauri-react-best-practices/rules/ipc-error-handling.md +250 -0
  98. package/templates/.claude/skills/tauri-react-best-practices/rules/ipc-type-safe.md +227 -0
  99. package/templates/.claude/skills/tauri-react-best-practices/rules/perf-derived-state.md +231 -0
  100. package/templates/.claude/skills/tauri-react-best-practices/rules/perf-functional-setstate.md +191 -0
  101. package/templates/.claude/skills/tauri-react-best-practices/rules/perf-index-maps.md +276 -0
  102. package/templates/.claude/skills/tauri-react-best-practices/rules/perf-lazy-state-init.md +196 -0
  103. package/templates/.claude/skills/tauri-react-best-practices/rules/plugin-lifecycle.md +265 -0
  104. package/templates/.claude/skills/tauri-react-best-practices/rules/plugin-mobile-compat.md +199 -0
  105. package/templates/.claude/skills/tauri-react-best-practices/rules/plugin-permission-scope.md +193 -0
  106. package/templates/.claude/skills/tauri-react-best-practices/rules/react-error-boundary.md +239 -0
  107. package/templates/.claude/skills/tauri-react-best-practices/rules/react-event-listener.md +151 -0
  108. package/templates/.claude/skills/tauri-react-best-practices/rules/react-file-src.md +155 -0
  109. package/templates/.claude/skills/tauri-react-best-practices/rules/react-invoke-hook.md +139 -0
  110. package/templates/.claude/skills/tauri-react-best-practices/rules/react-optimistic-update.md +211 -0
  111. package/templates/.claude/skills/tauri-react-best-practices/rules/security-capability-split.md +205 -0
  112. package/templates/.claude/skills/tauri-react-best-practices/rules/security-csp.md +207 -0
  113. package/templates/.claude/skills/tauri-react-best-practices/rules/security-least-privilege.md +106 -0
  114. package/templates/.claude/skills/tauri-react-best-practices/rules/security-no-wildcard.md +253 -0
  115. package/templates/.claude/skills/tauri-react-best-practices/rules/security-scope-paths.md +160 -0
  116. package/templates/.claude/skills/tauri-react-best-practices/rules/state-async-mutex.md +270 -0
  117. package/templates/.claude/skills/tauri-react-best-practices/rules/state-mutex-pattern.md +265 -0
  118. package/templates/.claude/skills/tauri-react-best-practices/rules/state-react-sync.md +375 -0
  119. package/templates/.claude/skills/tauri-react-best-practices/rules/state-single-container.md +275 -0
  120. package/templates/tanstack-start/docs/architecture.md +238 -167
  121. package/templates/tanstack-start/docs/library/tanstack-router/error-handling.md +777 -38
  122. package/templates/tanstack-start/docs/library/tanstack-router/hooks.md +549 -37
  123. package/templates/tanstack-start/docs/library/tanstack-router/index.md +895 -111
  124. package/templates/tanstack-start/docs/library/tanstack-router/navigation.md +641 -43
  125. package/templates/tanstack-start/docs/library/tanstack-router/route-context.md +889 -38
  126. package/templates/tanstack-start/docs/library/tanstack-router/search-params.md +891 -29
  127. package/templates/tanstack-start/docs/library/tanstack-start/auth-patterns.md +972 -36
  128. package/templates/tanstack-start/docs/library/tanstack-start/index.md +1525 -881
  129. package/templates/tanstack-start/docs/library/tanstack-start/middleware.md +1099 -20
  130. package/templates/tanstack-start/docs/library/tanstack-start/routing.md +796 -30
  131. package/templates/tanstack-start/docs/library/tanstack-start/server-functions.md +953 -35
  132. package/templates/tanstack-start/docs/library/tanstack-start/setup.md +371 -15
  133. package/templates/tauri/CLAUDE.md +189 -0
  134. package/templates/tauri/docs/guides/distribution.md +261 -0
  135. package/templates/tauri/docs/guides/getting-started.md +302 -0
  136. package/templates/tauri/docs/guides/mobile.md +288 -0
  137. package/templates/tauri/docs/library/tauri/index.md +510 -0
@@ -0,0 +1,66 @@
1
+ ---
2
+ title: Centralize Configuration and Environment Variables
3
+ impact: LOW-MEDIUM
4
+ impactDescription: Single source of truth, easier deployment management
5
+ tags: arch, config, env, centralize, validation
6
+ languages: all
7
+ related: [code-error-handling, dx-type-safety]
8
+ ---
9
+
10
+ ## 설정/환경변수 중앙 관리
11
+
12
+ 코드 전체에 흩어진 `process.env`, `os.environ` 접근을 하나의 설정 모듈로 통합합니다.
13
+
14
+ **❌ 잘못된 예시 (분산된 환경변수 접근):**
15
+
16
+ ```typescript
17
+ // file_a.ts
18
+ const dbUrl = process.env.DATABASE_URL! // 누락 시 런타임 에러
19
+
20
+ // file_b.ts
21
+ const port = parseInt(process.env.PORT || '3000') // 중복 파싱
22
+
23
+ // file_c.ts
24
+ if (process.env.NODE_ENV === 'production') { ... }
25
+ ```
26
+
27
+ **✅ 올바른 예시 (중앙 관리):**
28
+
29
+ ```typescript
30
+ // config.ts - 단일 설정 모듈
31
+ import { z } from 'zod'
32
+
33
+ const envSchema = z.object({
34
+ DATABASE_URL: z.string().url(),
35
+ PORT: z.coerce.number().default(3000),
36
+ NODE_ENV: z.enum(['development', 'production', 'test']).default('development'),
37
+ })
38
+
39
+ export const config = envSchema.parse(process.env)
40
+ // 시작 시 검증, 누락/잘못된 값 즉시 감지
41
+ ```
42
+
43
+ ```python
44
+ # Python (pydantic-settings)
45
+ from pydantic_settings import BaseSettings
46
+
47
+ class Config(BaseSettings):
48
+ database_url: str
49
+ port: int = 3000
50
+ debug: bool = False
51
+
52
+ config = Config() # .env + 환경변수 자동 로드
53
+ ```
54
+
55
+ ```go
56
+ // Go (envconfig)
57
+ type Config struct {
58
+ DatabaseURL string `envconfig:"DATABASE_URL" required:"true"`
59
+ Port int `envconfig:"PORT" default:"3000"`
60
+ }
61
+
62
+ var cfg Config
63
+ envconfig.Process("", &cfg)
64
+ ```
65
+
66
+ **원칙:** 환경변수는 애플리케이션 시작 시 한 번 파싱/검증하고, 이후 타입 안전한 config 객체로 접근.
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Identify and Optimize Hot Paths
3
+ impact: LOW-MEDIUM
4
+ impactDescription: Targeted optimization on code that matters most
5
+ tags: arch, hot-path, profiling, optimization, bottleneck
6
+ languages: all
7
+ related: [concurrency-parallel, io-batch-queries, memory-pool-reuse]
8
+ ---
9
+
10
+ ## 핫 패스 식별 및 집중 최적화
11
+
12
+ 전체 코드의 80%는 최적화 불필요. 실행 빈도가 높은 20% (핫 패스)를 프로파일링으로 식별하고 집중 최적화합니다.
13
+
14
+ **프로파일링 도구:**
15
+
16
+ | 언어 | 도구 | 명령어 |
17
+ |------|------|--------|
18
+ | **JS/TS** | Node.js `--prof` | `node --prof app.js` + `node --prof-process` |
19
+ | **JS/TS** | Chrome DevTools | Performance 탭 |
20
+ | **Python** | cProfile / py-spy | `python -m cProfile -s cumtime app.py` |
21
+ | **Go** | pprof (내장) | `go tool pprof http://localhost:6060/debug/pprof/profile` |
22
+ | **Rust** | flamegraph | `cargo flamegraph` |
23
+ | **Java** | async-profiler | `-agentpath:libasyncProfiler.so` |
24
+
25
+ **최적화 순서:**
26
+
27
+ ```
28
+ 1. 측정 (프로파일링) → 핫 패스 식별
29
+ 2. 알고리즘 개선 (O(n²) → O(n log n))
30
+ 3. I/O 최적화 (이 스킬의 io-* 규칙 적용)
31
+ 4. 메모리 최적화 (이 스킬의 memory-* 규칙 적용)
32
+ 5. 마이크로 최적화 (마지막 수단)
33
+ ```
34
+
35
+ **원칙:** "추측하지 말고, 측정하라." 프로파일링 없는 최적화는 시간 낭비. 핫 패스가 아닌 코드의 최적화는 ROI가 낮음.
@@ -0,0 +1,51 @@
1
+ ---
2
+ title: Segregate Large Interfaces
3
+ impact: LOW-MEDIUM
4
+ impactDescription: Reduced coupling, easier testing and mocking
5
+ tags: arch, interface, segregation, coupling
6
+ languages: [ts, go, rust, java, csharp]
7
+ related: [arch-module-boundary, code-duplication]
8
+ ---
9
+
10
+ ## 큰 인터페이스를 작은 단위로 분리
11
+
12
+ 하나의 거대한 인터페이스 대신 용도별 작은 인터페이스를 사용합니다.
13
+
14
+ **❌ 잘못된 예시:**
15
+
16
+ ```typescript
17
+ interface UserService {
18
+ getUser(id: string): User
19
+ createUser(data: CreateUserData): User
20
+ deleteUser(id: string): void
21
+ sendEmail(userId: string, subject: string): void
22
+ generateReport(userId: string): Report
23
+ uploadAvatar(userId: string, file: File): string
24
+ }
25
+ // 이메일만 보내려는 컴포넌트도 전체 인터페이스에 의존
26
+ ```
27
+
28
+ **✅ 올바른 예시:**
29
+
30
+ ```typescript
31
+ interface UserReader { getUser(id: string): User }
32
+ interface UserWriter { createUser(data: CreateUserData): User; deleteUser(id: string): void }
33
+ interface EmailSender { sendEmail(userId: string, subject: string): void }
34
+ // 각 소비자는 필요한 인터페이스만 의존
35
+ ```
36
+
37
+ ```go
38
+ // Go - 암시적 인터페이스 (소비자 쪽에서 정의)
39
+ // reader.go - 이 패키지에서 필요한 것만 정의
40
+ type UserGetter interface {
41
+ GetUser(ctx context.Context, id string) (*User, error)
42
+ }
43
+ ```
44
+
45
+ ```rust
46
+ // Rust - trait 분리
47
+ trait Readable { fn read(&self, id: &str) -> Result<User>; }
48
+ trait Writable { fn write(&self, user: &User) -> Result<()>; }
49
+ ```
50
+
51
+ **원칙:** "클라이언트는 자신이 사용하지 않는 메서드에 의존하지 않아야 한다" (ISP).
@@ -0,0 +1,42 @@
1
+ ---
2
+ title: Enforce Clear Module Boundaries
3
+ impact: LOW-MEDIUM
4
+ impactDescription: Prevents spaghetti dependencies, enables parallel work
5
+ tags: arch, module, boundary, circular, dependency
6
+ languages: all
7
+ related: [arch-interface-segregation, code-complexity]
8
+ ---
9
+
10
+ ## 모듈 경계 명확화
11
+
12
+ 모듈 간 순환 의존을 제거하고 명확한 의존 방향을 유지합니다.
13
+
14
+ **순환 의존 감지:**
15
+
16
+ | 언어 | 도구 |
17
+ |------|------|
18
+ | **JS/TS** | `madge --circular src/` |
19
+ | **Python** | `pydeps --no-show` |
20
+ | **Go** | 컴파일러 (순환 import = 컴파일 에러) |
21
+ | **Rust** | 컴파일러 (순환 crate = 컴파일 에러) |
22
+ | **Java** | ArchUnit, JDepend |
23
+
24
+ **해결 패턴:**
25
+
26
+ ```
27
+ ❌ 순환: A → B → C → A
28
+
29
+ ✅ 의존성 역전:
30
+ A → Interface ← B → C
31
+ (A는 인터페이스에 의존, B가 구현)
32
+
33
+ ✅ 이벤트/메시지:
34
+ A → EventBus ← B
35
+ (A가 이벤트 발행, B가 구독)
36
+
37
+ ✅ 추출:
38
+ A → D ← B → C
39
+ (공통 부분을 D로 추출)
40
+ ```
41
+
42
+ **원칙:** 의존 방향은 상위(추상) → 하위(구체). 도메인 모듈이 인프라에 의존하지 않음.
@@ -0,0 +1,57 @@
1
+ ---
2
+ title: Leverage Build Cache in CI and Local
3
+ impact: HIGH
4
+ impactDescription: 40-80% CI pipeline time reduction
5
+ tags: build, cache, ci, pipeline
6
+ languages: all
7
+ related: [build-incremental, dx-ci-speed]
8
+ ---
9
+
10
+ ## 빌드 캐시 활용
11
+
12
+ CI와 로컬 환경에서 빌드 아티팩트, 의존성, 컴파일 캐시를 재사용합니다.
13
+
14
+ **✅ GitHub Actions 캐시:**
15
+
16
+ ```yaml
17
+ # Node.js
18
+ - uses: actions/cache@v4
19
+ with:
20
+ path: node_modules
21
+ key: node-${{ hashFiles('yarn.lock') }}
22
+
23
+ # Rust
24
+ - uses: actions/cache@v4
25
+ with:
26
+ path: |
27
+ ~/.cargo/registry
28
+ ~/.cargo/git
29
+ target
30
+ key: rust-${{ hashFiles('Cargo.lock') }}
31
+
32
+ # Go
33
+ - uses: actions/cache@v4
34
+ with:
35
+ path: |
36
+ ~/go/pkg/mod
37
+ ~/.cache/go-build
38
+ key: go-${{ hashFiles('go.sum') }}
39
+
40
+ # Python
41
+ - uses: actions/cache@v4
42
+ with:
43
+ path: ~/.cache/pip
44
+ key: pip-${{ hashFiles('requirements.txt') }}
45
+ ```
46
+
47
+ **모노레포 캐시 도구:**
48
+
49
+ | 도구 | 특징 |
50
+ |------|------|
51
+ | **Turborepo** | 원격 캐시, 태스크 그래프 |
52
+ | **Nx** | 영향 받은 프로젝트만 빌드 |
53
+ | **Bazel** | 세밀한 캐시, 원격 실행 |
54
+ | **sccache** | Rust/C/C++ 컴파일 캐시 |
55
+ | **ccache** | C/C++ 컴파일 캐시 |
56
+
57
+ **핵심:** 캐시 키에 lockfile 해시 포함, 의존성 변경 시에만 캐시 무효화.
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: Code Splitting by Entry Point
3
+ impact: HIGH
4
+ impactDescription: 30-70% initial load reduction
5
+ tags: build, code-splitting, lazy-loading, bundle
6
+ languages: [js, ts]
7
+ related: [build-tree-shake, memory-lazy-init]
8
+ ---
9
+
10
+ ## 진입점/라우트별 코드 분할
11
+
12
+ 단일 거대 번들 대신 진입점/라우트/기능별로 분할하여 초기 로딩 크기를 줄입니다.
13
+
14
+ **❌ 잘못된 예시 (단일 번들):**
15
+
16
+ ```typescript
17
+ // 모든 페이지가 하나의 번들에 포함
18
+ import { Dashboard } from './pages/Dashboard'
19
+ import { Settings } from './pages/Settings'
20
+ import { Admin } from './pages/Admin' // 대부분 사용자에게 불필요
21
+ ```
22
+
23
+ **✅ 올바른 예시 (동적 import):**
24
+
25
+ ```typescript
26
+ // JS/TS - 라우트별 코드 분할
27
+ const Dashboard = lazy(() => import('./pages/Dashboard'))
28
+ const Settings = lazy(() => import('./pages/Settings'))
29
+ const Admin = lazy(() => import('./pages/Admin'))
30
+ ```
31
+
32
+ ```python
33
+ # Python - 무거운 모듈 지연 로딩
34
+ def analyze():
35
+ import pandas as pd # 필요 시점에만 로드 (import 시간 ~200ms)
36
+ return pd.read_csv("data.csv")
37
+ ```
38
+
39
+ ```go
40
+ // Go - 플러그인 시스템으로 런타임 로딩
41
+ p, _ := plugin.Open("analytics.so")
42
+ analyze, _ := p.Lookup("Analyze")
43
+ ```
44
+
45
+ **프레임워크별 패턴:**
46
+
47
+ | 프레임워크 | 코드 분할 방법 |
48
+ |-----------|-------------|
49
+ | React | `React.lazy()` + `Suspense` |
50
+ | Vue | `defineAsyncComponent()` |
51
+ | Svelte | `import()` in routes |
52
+ | Next.js | `next/dynamic` |
53
+ | TanStack Router | `.lazy.tsx` 파일 컨벤션 |
54
+ | Angular | `loadChildren` (lazy routes) |
55
+
56
+ **적용 기준:** 50KB+ 모듈, 조건부 표시 UI, 관리자 전용 기능.
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: Enable Incremental Builds
3
+ impact: CRITICAL
4
+ impactDescription: 50-90% build time reduction on repeat builds
5
+ tags: build, incremental, cache, compile
6
+ languages: all
7
+ related: [build-cache, dx-ci-speed]
8
+ ---
9
+
10
+ ## 증분 빌드 활성화
11
+
12
+ 전체 재빌드 대신 변경된 파일만 컴파일하여 빌드 시간을 대폭 줄입니다.
13
+
14
+ **❌ 잘못된 예시 (매번 전체 빌드):**
15
+
16
+ ```json
17
+ // tsconfig.json - incremental 비활성화
18
+ { "compilerOptions": { "incremental": false } }
19
+ ```
20
+
21
+ ```toml
22
+ # Cargo.toml - release에서 증분 비활성화
23
+ [profile.release]
24
+ incremental = false
25
+ ```
26
+
27
+ **✅ 올바른 예시:**
28
+
29
+ ```json
30
+ // TypeScript
31
+ { "compilerOptions": { "incremental": true, "tsBuildInfoFile": ".tsbuildinfo" } }
32
+ ```
33
+
34
+ ```toml
35
+ # Rust
36
+ [profile.dev]
37
+ incremental = true
38
+ ```
39
+
40
+ ```python
41
+ # Python (mypy)
42
+ [tool.mypy]
43
+ incremental = true
44
+ cache_dir = ".mypy_cache"
45
+ ```
46
+
47
+ ```gradle
48
+ // Gradle
49
+ org.gradle.caching=true
50
+ org.gradle.parallel=true
51
+ ```
52
+
53
+ ```yaml
54
+ # CI 캐시 (GitHub Actions)
55
+ - uses: actions/cache@v4
56
+ with:
57
+ path: |
58
+ node_modules/.cache
59
+ .tsbuildinfo
60
+ target/
61
+ ~/.cargo/registry
62
+ key: ${{ runner.os }}-build-${{ hashFiles('**/lockfile') }}
63
+ ```
64
+
65
+ **효과:** TypeScript 50-70% 감소, Rust dev 40-60% 감소, Gradle 30-50% 감소.
@@ -0,0 +1,61 @@
1
+ ---
2
+ title: Minify and Compress Production Output
3
+ impact: HIGH
4
+ impactDescription: 30-50% output size reduction
5
+ tags: build, minify, compression, production
6
+ languages: [js, ts, css]
7
+ related: [build-tree-shake, build-code-split]
8
+ ---
9
+
10
+ ## 프로덕션 출력 최소화
11
+
12
+ 프로덕션 빌드에서 minification, compression을 활성화하여 배포 크기를 줄입니다.
13
+
14
+ **✅ 올바른 예시:**
15
+
16
+ ```typescript
17
+ // Vite
18
+ export default defineConfig({
19
+ build: {
20
+ minify: 'terser', // 또는 'esbuild' (빠름)
21
+ cssMinify: true,
22
+ rollupOptions: {
23
+ output: { manualChunks: { vendor: ['react', 'react-dom'] } }
24
+ }
25
+ }
26
+ })
27
+ ```
28
+
29
+ ```toml
30
+ # Rust
31
+ [profile.release]
32
+ opt-level = "z" # 크기 최적화 (또는 "3" 속도 최적화)
33
+ lto = "thin" # LTO
34
+ strip = "symbols"
35
+ panic = "abort" # unwind 코드 제거
36
+ codegen-units = 1 # 최적화 극대화 (빌드 느려짐)
37
+ ```
38
+
39
+ ```go
40
+ // Go
41
+ // go build -ldflags="-s -w" -trimpath ./cmd/app
42
+ // -s: 심볼 테이블 제거, -w: DWARF 제거, -trimpath: 경로 정보 제거
43
+ ```
44
+
45
+ ```dockerfile
46
+ # Docker 멀티스테이지 빌드
47
+ FROM golang:1.22 AS builder
48
+ RUN CGO_ENABLED=0 go build -ldflags="-s -w" -o /app
49
+
50
+ FROM scratch
51
+ COPY --from=builder /app /app
52
+ ENTRYPOINT ["/app"]
53
+ ```
54
+
55
+ **서버 압축:**
56
+
57
+ | 방법 | 감소율 | 도구 |
58
+ |------|--------|------|
59
+ | gzip | ~70% | Nginx, CDN 기본 |
60
+ | Brotli | ~80% | Nginx, Cloudflare |
61
+ | 빌드 시 사전 압축 | 서버 CPU 절약 | `vite-plugin-compression` |
@@ -0,0 +1,60 @@
1
+ ---
2
+ title: Enable Tree Shaking / Dead Code Elimination
3
+ impact: CRITICAL
4
+ impactDescription: 20-60% bundle size reduction
5
+ tags: build, tree-shaking, dead-code, bundle-size
6
+ languages: [js, ts, rust, go]
7
+ related: [build-code-split, code-dead-elimination, deps-unused-removal]
8
+ ---
9
+
10
+ ## 미사용 코드 자동 제거
11
+
12
+ 번들러/컴파일러의 dead code elimination을 활성화하여 실제 사용하는 코드만 출력에 포함합니다.
13
+
14
+ **❌ 잘못된 예시:**
15
+
16
+ ```json
17
+ // package.json - sideEffects 미지정
18
+ { "name": "my-lib" }
19
+ // 번들러가 어떤 코드가 부작용 있는지 몰라서 전부 포함
20
+ ```
21
+
22
+ ```typescript
23
+ // 배럴 파일에서 전체 import
24
+ import { oneUtil } from './utils' // utils/index.ts가 50개 모듈 re-export
25
+ ```
26
+
27
+ **✅ 올바른 예시:**
28
+
29
+ ```json
30
+ // package.json - sideEffects 지정
31
+ { "name": "my-lib", "sideEffects": false }
32
+ // 또는 특정 파일만: "sideEffects": ["*.css", "./src/polyfill.js"]
33
+ ```
34
+
35
+ ```typescript
36
+ // 직접 import (배럴 파일 우회)
37
+ import { oneUtil } from './utils/oneUtil'
38
+ ```
39
+
40
+ ```toml
41
+ # Rust - release 최적화
42
+ [profile.release]
43
+ lto = "thin" # Link-Time Optimization
44
+ strip = "symbols" # 심볼 제거
45
+ opt-level = "z" # 크기 최적화
46
+ ```
47
+
48
+ ```go
49
+ // Go - 기본 활성화. 추가 최적화:
50
+ // go build -ldflags="-s -w" # 심볼 테이블, DWARF 디버그 정보 제거
51
+ ```
52
+
53
+ **도구별 설정:**
54
+
55
+ | 빌드 도구 | 설정 |
56
+ |-----------|------|
57
+ | Vite/Rollup | 기본 활성화 (`build.rollupOptions`) |
58
+ | webpack | `mode: 'production'`, `usedExports: true` |
59
+ | esbuild | `--tree-shaking=true` (기본) |
60
+ | tsup | `treeshake: true` |
@@ -0,0 +1,65 @@
1
+ ---
2
+ title: Reduce Cyclomatic Complexity
3
+ impact: MEDIUM
4
+ impactDescription: Easier testing, fewer bugs, better readability
5
+ tags: code, complexity, early-return, guard-clause, extract
6
+ languages: all
7
+ related: [code-duplication, code-error-handling]
8
+ ---
9
+
10
+ ## 순환 복잡도 감소
11
+
12
+ 깊은 중첩, 긴 if-else 체인, 복잡한 조건문을 단순화합니다.
13
+
14
+ **❌ 잘못된 예시 (깊은 중첩):**
15
+
16
+ ```python
17
+ def process(request):
18
+ if request:
19
+ if request.user:
20
+ if request.user.is_active:
21
+ if request.data:
22
+ return do_work(request.data)
23
+ else:
24
+ return Error("no data")
25
+ else:
26
+ return Error("inactive")
27
+ else:
28
+ return Error("no user")
29
+ else:
30
+ return Error("no request")
31
+ ```
32
+
33
+ **✅ 올바른 예시 (guard clause + early return):**
34
+
35
+ ```python
36
+ def process(request):
37
+ if not request:
38
+ return Error("no request")
39
+ if not request.user:
40
+ return Error("no user")
41
+ if not request.user.is_active:
42
+ return Error("inactive")
43
+ if not request.data:
44
+ return Error("no data")
45
+ return do_work(request.data)
46
+ ```
47
+
48
+ **✅ 올바른 예시 (table-driven):**
49
+
50
+ ```python
51
+ # ❌ 긴 if-else 체인
52
+ def get_discount(tier):
53
+ if tier == "bronze": return 0.05
54
+ elif tier == "silver": return 0.10
55
+ elif tier == "gold": return 0.15
56
+ elif tier == "platinum": return 0.20
57
+ else: return 0
58
+
59
+ # ✅ 맵/딕셔너리
60
+ DISCOUNTS = {"bronze": 0.05, "silver": 0.10, "gold": 0.15, "platinum": 0.20}
61
+ def get_discount(tier):
62
+ return DISCOUNTS.get(tier, 0)
63
+ ```
64
+
65
+ **목표:** 함수당 순환 복잡도 10 이하, 중첩 깊이 3 이하.
@@ -0,0 +1,32 @@
1
+ ---
2
+ title: Remove Dead Code and Unused Imports
3
+ impact: MEDIUM-HIGH
4
+ impactDescription: Cleaner codebase, smaller bundles, faster comprehension
5
+ tags: code, dead-code, unused, imports, cleanup
6
+ languages: all
7
+ related: [build-tree-shake, deps-unused-removal]
8
+ ---
9
+
10
+ ## 미사용 코드/변수/import 제거
11
+
12
+ 사용되지 않는 코드는 혼란을 주고 번들 크기를 증가시킵니다. 도구로 감지하고 즉시 제거합니다.
13
+
14
+ **감지 도구:**
15
+
16
+ | 언어 | 도구 | 명령어 |
17
+ |------|------|--------|
18
+ | **JS/TS** | `knip` | `npx knip` |
19
+ | **JS/TS** | ESLint `no-unused-vars` | 자동 |
20
+ | **Python** | `vulture` | `vulture src/` |
21
+ | **Python** | `autoflake` | `autoflake --remove-all-unused-imports` |
22
+ | **Go** | 컴파일러 (내장) | 미사용 import/변수 = 컴파일 에러 |
23
+ | **Rust** | 컴파일러 (내장) | `#[warn(dead_code)]` 기본 활성화 |
24
+ | **Java** | IntelliJ / SonarQube | 자동 감지 |
25
+
26
+ **제거 대상:**
27
+ - 미사용 import/require
28
+ - 미사용 변수/상수
29
+ - 호출되지 않는 함수/메서드
30
+ - 도달 불가능한 코드 (unreachable after return/throw)
31
+ - 주석 처리된 코드 블록 (Git 히스토리에 보존됨)
32
+ - 미사용 타입/인터페이스 정의
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: Extract Duplicated Code (Rule of Three)
3
+ impact: MEDIUM
4
+ impactDescription: Reduced maintenance burden, single source of truth
5
+ tags: code, duplication, dry, extract, refactor
6
+ languages: all
7
+ related: [code-complexity, arch-interface-segregation]
8
+ ---
9
+
10
+ ## 중복 코드 추출 (3회 이상부터)
11
+
12
+ 동일/유사 코드가 3회 이상 반복되면 함수/모듈로 추출합니다. 2회까지는 허용 (premature abstraction 방지).
13
+
14
+ **❌ 잘못된 예시 (3곳에서 반복):**
15
+
16
+ ```python
17
+ # file_a.py
18
+ data = json.loads(response.text)
19
+ if "error" in data:
20
+ logger.error(f"API error: {data['error']}")
21
+ raise ApiError(data["error"])
22
+
23
+ # file_b.py (동일 패턴 반복)
24
+ data = json.loads(response.text)
25
+ if "error" in data:
26
+ logger.error(f"API error: {data['error']}")
27
+ raise ApiError(data["error"])
28
+ ```
29
+
30
+ **✅ 올바른 예시 (추출):**
31
+
32
+ ```python
33
+ # utils/api.py
34
+ def parse_api_response(response: Response) -> dict:
35
+ data = response.json()
36
+ if "error" in data:
37
+ logger.error(f"API error: {data['error']}")
38
+ raise ApiError(data["error"])
39
+ return data
40
+
41
+ # file_a.py, file_b.py
42
+ data = parse_api_response(response)
43
+ ```
44
+
45
+ **감지 도구:**
46
+
47
+ | 언어 | 도구 |
48
+ |------|------|
49
+ | **범용** | `jscpd` (Copy/Paste Detector) |
50
+ | **Python** | `pylint --disable=all --enable=duplicate-code` |
51
+ | **Java** | PMD CPD |
52
+ | **Go** | `dupl` |
53
+
54
+ **주의:** 비슷해 보이지만 다른 의도의 코드는 추출하지 않음. 추상화 비용 > 중복 비용이면 중복 허용.