claude-pro-minmax 1.0.2 → 1.2.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-pro-minmax",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "Quota-first routing and safety layer for Claude Code Pro workflows.",
5
5
  "author": "donghoon <move-hoon@users.noreply.github.com>",
6
6
  "license": "MIT",
@@ -9,20 +9,20 @@
9
9
  "cpmm": "bin/cpmm.js"
10
10
  },
11
11
  "files": [
12
- "bin",
12
+ "bin/",
13
+ "lib/",
14
+ ".claude.json",
15
+ "install.sh",
13
16
  ".claude/CLAUDE.md",
14
17
  ".claude/settings.json",
15
18
  ".claude/settings.local.example.json",
16
- ".claude/agents",
17
- ".claude/commands",
18
- ".claude/contexts",
19
- ".claude/rules",
20
- ".claude/sessions",
21
- ".claude/skills",
22
- ".claude.json",
19
+ ".claude/agents/",
20
+ ".claude/commands/",
21
+ ".claude/contexts/",
22
+ ".claude/rules/",
23
+ ".claude/skills/cli-wrappers/",
23
24
  ".claudeignore",
24
- "install.sh",
25
- "scripts",
25
+ "scripts/",
26
26
  "README.md",
27
27
  "README.ko.md",
28
28
  "LICENSE"
@@ -32,6 +32,7 @@
32
32
  },
33
33
  "scripts": {
34
34
  "help": "node bin/cpmm.js --help",
35
+ "setup": "node bin/cpmm.js setup",
35
36
  "doctor": "node bin/cpmm.js doctor",
36
37
  "test": "node bin/cpmm.js --version && node bin/cpmm.js --help"
37
38
  },
@@ -56,4 +57,4 @@
56
57
  "url": "https://github.com/move-hoon/claude-pro-minmax/issues"
57
58
  },
58
59
  "homepage": "https://github.com/move-hoon/claude-pro-minmax#readme"
59
- }
60
+ }
@@ -1,32 +0,0 @@
1
- ---
2
- session_id: example-session
3
- date: 2025-01-29 14:30
4
- name: auth-jwt-implementation
5
- project: pro-plan-v3-final
6
- ---
7
-
8
- # Session: auth-jwt-implementation
9
-
10
- ## Completed Tasks
11
- - [x] Created JWT utility class in `src/auth/jwt.ts`
12
- - [x] Implemented login endpoint with token generation
13
- - [x] Added refresh token rotation logic
14
- - [x] Wrote unit tests for token validation
15
-
16
- ## Current State
17
- JWT authentication is fully implemented. Ready for integration testing.
18
-
19
- ## Next Actions
20
- - [ ] Add rate limiting to login endpoint
21
- - [ ] Implement token blacklist for logout
22
- - [ ] Add integration tests with database
23
-
24
- ## Context
25
- - Files: `src/auth/jwt.ts`, `src/auth/login.ts`, `tests/auth.test.ts`
26
- - Decisions: Using HS256 for simplicity, will migrate to RS256 for production
27
-
28
- ## Loaded Contexts
29
- - backend: active
30
-
31
- ## Learned Patterns
32
- - Always validate token expiry before processing
@@ -1,195 +0,0 @@
1
- > **[English Version](README.md)**
2
-
3
- # Sessions Directory
4
-
5
- ## 목적
6
- `/session-save`에 의해 생성된 세션 상태 파일을 저장합니다. 세션 간에 연속성을 가능하게 합니다.
7
-
8
- > **경로 안내:** 예시에는 설치 경로(`~/.claude/...`)가 포함됩니다. 이 저장소 기준 소스 경로는 `./.claude/...`, `./scripts/...`입니다.
9
-
10
- ## 세션 생명주기
11
-
12
- ```mermaid
13
- flowchart TB
14
- %% 스타일 정의 %%
15
- classDef command fill:#e8f5e9,stroke:#43a047,stroke-width:2px;
16
- classDef file fill:#fff3e0,stroke:#fb8c00,stroke-width:2px;
17
- classDef process fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px;
18
- classDef hook fill:#ffebee,stroke:#e53935,stroke-width:2px;
19
- classDef builtin fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
20
- classDef note fill:#fffde7,stroke:#fdd835,stroke-width:1px,stroke-dasharray: 3 3;
21
-
22
- %% 메인 세션 플로우 %%
23
- Start((🚀 세션 시작)):::process
24
- Start --> Work[🔨 작업 진행]:::process
25
-
26
- Work --> Decision{세션 저장?}:::process
27
- Decision -->|Yes| SaveCmd[/"💾 /session-save auth-feature"/]:::command
28
- Decision -->|No| Continue[작업 계속]:::process
29
- Continue --> Work
30
-
31
- %% 저장 프로세스 %%
32
- SaveCmd --> Collect["📋 상태 수집<br/>• 완료된 작업<br/>• 현재 상태<br/>• 다음 액션<br/>• 주요 파일"]:::process
33
- Collect --> Scrub{{"🔐 scrub-secrets.js<br/>15+ 시크릿 패턴 제거"}}:::hook
34
- Scrub --> Write["✍️ 파일 작성<br/>.claude/sessions/<br/>2025-01-28-auth-feature.md"]:::file
35
- Write --> Notify["✅ 세션 저장 완료!<br/>스크러빙: N개 시크릿"]:::note
36
-
37
- %% 로드 프로세스 %%
38
- Notify -.->|"나중에..."| LoadStart((📂 새 세션)):::process
39
- LoadStart --> LoadCmd[/"📂 /session-load auth-feature"/]:::command
40
- LoadCmd --> Read["📖 세션 파일 읽기"]:::process
41
- Read --> Restore["🔄 컨텍스트 복원<br/>• 완료된 작업 설정<br/>• 다음 액션 로드<br/>• 주요 파일 참조"]:::process
42
- Restore --> Ready["✅ 작업 재개 준비 완료!"]:::note
43
-
44
- %% 내장 CLI 대안 %%
45
- subgraph BuiltInCLI["🔧 대안: 내장 CLI"]
46
- direction TB
47
- BuiltinNote["정확한 대화 재생용<br/>(사람이 읽을 수 있는 요약 아님)"]:::note
48
- CLI1["claude -c / --continue<br/>→ 가장 최근 세션 재개"]:::builtin
49
- CLI2["claude -r abc123 / --resume abc123<br/>→ 특정 세션 재개"]:::builtin
50
- JSONL["~/.claude/projects/*.jsonl<br/>(원본 대화 기록)"]:::file
51
- CLI1 --> JSONL
52
- CLI2 --> JSONL
53
- end
54
- ```
55
-
56
- ### 커스텀 vs 내장 세션
57
-
58
- | 기능 | `/session-save` + `/session-load` | `claude --continue` |
59
- |------|-----------------------------------|---------------------|
60
- | **형식** | 사람이 읽을 수 있는 `.md` | 원본 `.jsonl` |
61
- | **위치** | `.claude/sessions/` (프로젝트) | `~/.claude/projects/` (전역) |
62
- | **내용** | 요약 (작업, 결정, 다음 단계) | 전체 대화 기록 |
63
- | **시크릿 스크러빙** | ✅ 자동 | ❌ 스크러빙 없음 |
64
- | **적합한 용도** | 컨텍스트 공유, 문서화 | 정확한 대화 재생 |
65
-
66
- ### 언제 무엇을 사용할까?
67
-
68
- | 상황 | 추천 | 이유 |
69
- |------|------|------|
70
- | 짧은 휴식 후 재개 (같은 날) | `claude -c` | 빠르고 정확한 대화 이어가기 |
71
- | 긴 휴식 후 재개 (다음 날) | `/session-load` | 핵심 컨텍스트만 로드, 비용 절약 |
72
- | 팀원과 컨텍스트 공유 | `/session-save` | 사람이 읽을 수 있는 `.md` 공유 가능 |
73
- | 시크릿 포함한 작업 후 | `/session-save` | 자동 스크러빙으로 안전 |
74
- | 정확한 대화 기록 필요 | `claude --resume` | 전체 대화 그대로 복원 |
75
-
76
- ### 추천 워크플로우
77
-
78
- ```
79
- 📅 1일차 오전: 새 작업 시작
80
- 📅 1일차 오후: 점심 후 → claude -c (내장 CLI로 빠른 재개)
81
- 📅 1일차 저녁: /session-save feature-v1 (작업 요약 저장)
82
-
83
- 📅 2일차: /session-load feature-v1 (깔끔한 컨텍스트로 시작)
84
- 📅 2일차 오후: claude -c (같은 날 빠른 재개)
85
- 📅 2일차 저녁: /session-save feature-v2 (진행 상황 저장)
86
- ```
87
-
88
- > **💡 Tip**: 둘은 **경쟁이 아니라 보완 관계**입니다. 상황에 맞게 골라 쓰세요!
89
-
90
- ## 파일 명명
91
-
92
- ```
93
- YYYY-MM-DD-[name].md
94
- ```
95
-
96
- 예시:
97
- - `2025-01-27-auth-jwt.md`
98
- - `2025-01-27-payment-integration.md`
99
-
100
- ## 보안
101
-
102
- **모든 세션 파일은 기록되기 전에 자동으로 스크러빙(민감 정보 제거)됩니다.**
103
-
104
- 스크러빙되는 패턴:
105
- - API 키 (OpenAI, Anthropic, Stripe, GitHub, AWS)
106
- - 자격 증명이 포함된 데이터베이스 URL
107
- - JWT 토큰
108
- - 비밀번호 필드
109
- - 개인 키 (Private keys)
110
-
111
- ## 사용법
112
-
113
- ```bash
114
- # 현재 세션 저장
115
- /session-save auth-feature
116
-
117
- # 가장 최근 세션 로드
118
- /session-load
119
-
120
- # 특정 세션 로드
121
- /session-load auth-feature
122
-
123
- # 사용 가능한 세션 목록
124
- /session-load --list
125
- ```
126
-
127
- ## 세션 파일 형식
128
-
129
- ```markdown
130
- # Session: [name]
131
- Date: [timestamp]
132
- Duration: [messages]
133
- Security: [items scrubbed]
134
-
135
- ## Context
136
- - Project: [name]
137
- - Branch: [branch]
138
- - Focus: [description]
139
-
140
- ## Completed
141
- - [x] [task]
142
-
143
- ## In Progress
144
- - [ ] [task] - [status]
145
-
146
- ## Decisions Made
147
- - [decision]: [reasoning]
148
-
149
- ## Next Steps
150
- 1. [action]
151
-
152
- ## Key Files
153
- - [file]: [why relevant]
154
-
155
- ## Loaded Contexts
156
- - [type]: [status]
157
-
158
- ## Learned Patterns
159
- - [pattern]
160
- ```
161
-
162
- ## 유지 관리
163
-
164
- ```bash
165
- # 세션 목록 조회
166
- ls -la .claude/sessions/
167
-
168
- # 오래된 세션 삭제 (>30일)
169
- find .claude/sessions/ -mtime +30 -delete
170
-
171
- # 수동 스크러빙 (필요한 경우)
172
- node scripts/scrub-secrets.js < session.md > clean.md
173
- # 설치 경로: node ~/.claude/scripts/scrub-secrets.js < session.md > clean.md
174
- ```
175
-
176
- ## Claude 내장 세션 명령어
177
-
178
- 커스텀 `/session-save`, `/session-load` 외에도 Claude Code 내장 세션 기능이 있습니다:
179
-
180
- | 명령어 | 목적 |
181
- |--------|------|
182
- | `claude -c` / `--continue` | 가장 최근 세션 재개 |
183
- | `claude -r "id"` / `--resume "id"` | 특정 세션 ID로 재개 |
184
- | `claude --resume` | 최근 세션 목록에서 선택 |
185
-
186
- > **참고:** 내장 세션은 `~/.claude/projects/.../*.jsonl`에 저장됩니다. 커스텀 `/session-save`는 `.claude/sessions/`에 사람이 읽을 수 있는 `.md` 요약을 생성합니다.
187
-
188
- ## 모범 사례
189
-
190
- 1. 논리적 단계가 완료된 후 저장
191
- 2. 긴 휴식 전 (>4시간) 저장
192
- 3. 설명적인 이름 사용
193
- 4. 주기적으로 오래된 세션 정리
194
- 5. **스크립트 실행 권한 확인**: `chmod +x scripts/hooks/*.sh`
195
- (설치 경로: `chmod +x ~/.claude/scripts/hooks/*.sh`)
@@ -1,195 +0,0 @@
1
- > **[한국어 버전](README.ko.md)**
2
-
3
- # Sessions Directory
4
-
5
- ## Purpose
6
- Stores session state files created by `/session-save`. Enables continuity across sessions.
7
-
8
- > **Path note:** Examples include installed paths (`~/.claude/...`). In this repository, source paths are `./.claude/...` and `./scripts/...`.
9
-
10
- ## Session Lifecycle
11
-
12
- ```mermaid
13
- flowchart TB
14
- %% Style definitions %%
15
- classDef command fill:#e8f5e9,stroke:#43a047,stroke-width:2px;
16
- classDef file fill:#fff3e0,stroke:#fb8c00,stroke-width:2px;
17
- classDef process fill:#e3f2fd,stroke:#1e88e5,stroke-width:2px;
18
- classDef hook fill:#ffebee,stroke:#e53935,stroke-width:2px;
19
- classDef builtin fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
20
- classDef note fill:#fffde7,stroke:#fdd835,stroke-width:1px,stroke-dasharray: 3 3;
21
-
22
- %% Main Session Flow %%
23
- Start((🚀 Session Start)):::process
24
- Start --> Work[🔨 Working on Tasks]:::process
25
-
26
- Work --> Decision{Save Session?}:::process
27
- Decision -->|Yes| SaveCmd[/"💾 /session-save auth-feature"/]:::command
28
- Decision -->|No| Continue[Continue Working]:::process
29
- Continue --> Work
30
-
31
- %% Save Process %%
32
- SaveCmd --> Collect["📋 Collect State<br/>• Completed tasks<br/>• Current state<br/>• Next actions<br/>• Key files"]:::process
33
- Collect --> Scrub{{"🔐 scrub-secrets.js<br/>Remove 15+ secret patterns"}}:::hook
34
- Scrub --> Write["✍️ Write to<br/>.claude/sessions/<br/>2025-01-28-auth-feature.md"]:::file
35
- Write --> Notify["✅ Session saved!<br/>Scrubbed: N secrets"]:::note
36
-
37
- %% Load Process %%
38
- Notify -.->|"Later..."| LoadStart((📂 New Session)):::process
39
- LoadStart --> LoadCmd[/"📂 /session-load auth-feature"/]:::command
40
- LoadCmd --> Read["📖 Read session file"]:::process
41
- Read --> Restore["🔄 Restore Context<br/>• Set completed tasks<br/>• Load next actions<br/>• Reference key files"]:::process
42
- Restore --> Ready["✅ Ready to continue!"]:::note
43
-
44
- %% Built-in Alternative %%
45
- subgraph BuiltInCLI["🔧 Alternative: Built-in CLI"]
46
- direction TB
47
- BuiltinNote["For exact conversation replay<br/>(not human-readable summary)"]:::note
48
- CLI1["claude -c / --continue<br/>→ Resume most recent"]:::builtin
49
- CLI2["claude -r abc123 / --resume abc123<br/>→ Resume specific session"]:::builtin
50
- JSONL["~/.claude/projects/*.jsonl<br/>(raw conversation history)"]:::file
51
- CLI1 --> JSONL
52
- CLI2 --> JSONL
53
- end
54
- ```
55
-
56
- ### Custom vs Built-in Sessions
57
-
58
- | Feature | `/session-save` + `/session-load` | `claude --continue` |
59
- |---------|-----------------------------------|---------------------|
60
- | **Format** | Human-readable `.md` | Raw `.jsonl` |
61
- | **Location** | `.claude/sessions/` (project) | `~/.claude/projects/` (global) |
62
- | **Content** | Summary (tasks, decisions, next steps) | Full conversation transcript |
63
- | **Secret Scrubbing** | ✅ Automatic | ❌ Not scrubbed |
64
- | **Best For** | Sharing context, documentation | Exact conversation replay |
65
-
66
- ### When to Use What?
67
-
68
- | Situation | Recommended | Why |
69
- |-----------|-------------|-----|
70
- | Short break (same day) | `claude -c` | Fast, exact conversation resume |
71
- | Long break (next day) | `/session-load` | Load only key context, reduce cost |
72
- | Share context with team | `/session-save` | Human-readable `.md` for sharing |
73
- | After working with secrets | `/session-save` | Auto-scrubbing for safety |
74
- | Need exact conversation | `claude --resume` | Full transcript replay |
75
-
76
- ### Recommended Workflow
77
-
78
- ```
79
- 📅 Day 1 Morning: Start new task
80
- 📅 Day 1 Afternoon: After lunch → claude -c (quick resume with built-in CLI)
81
- 📅 Day 1 Evening: /session-save feature-v1 (save work summary)
82
-
83
- 📅 Day 2: /session-load feature-v1 (start fresh with clean context)
84
- 📅 Day 2 Afternoon: claude -c (quick resume same day)
85
- 📅 Day 2 Evening: /session-save feature-v2 (save progress)
86
- ```
87
-
88
- > **💡 Tip**: These two systems are **complementary, not competing**. Use both based on the situation!
89
-
90
- ## File Naming
91
-
92
- ```
93
- YYYY-MM-DD-[name].md
94
- ```
95
-
96
- Examples:
97
- - `2025-01-27-auth-jwt.md`
98
- - `2025-01-27-payment-integration.md`
99
-
100
- ## Security
101
-
102
- **All session files are automatically scrubbed before writing.**
103
-
104
- Scrubbed patterns include:
105
- - API keys (OpenAI, Anthropic, Stripe, GitHub, AWS)
106
- - Database URLs with credentials
107
- - JWT tokens
108
- - Password fields
109
- - Private keys
110
-
111
- ## Usage
112
-
113
- ```bash
114
- # Save current session
115
- /session-save auth-feature
116
-
117
- # Load most recent
118
- /session-load
119
-
120
- # Load specific session
121
- /session-load auth-feature
122
-
123
- # List available sessions
124
- /session-load --list
125
- ```
126
-
127
- ## Session File Format
128
-
129
- ```markdown
130
- # Session: [name]
131
- Date: [timestamp]
132
- Duration: [messages]
133
- Security: [items scrubbed]
134
-
135
- ## Context
136
- - Project: [name]
137
- - Branch: [branch]
138
- - Focus: [description]
139
-
140
- ## Completed
141
- - [x] [task]
142
-
143
- ## In Progress
144
- - [ ] [task] - [status]
145
-
146
- ## Decisions Made
147
- - [decision]: [reasoning]
148
-
149
- ## Next Steps
150
- 1. [action]
151
-
152
- ## Key Files
153
- - [file]: [why relevant]
154
-
155
- ## Loaded Contexts
156
- - [type]: [status]
157
-
158
- ## Learned Patterns
159
- - [pattern]
160
- ```
161
-
162
- ## Maintenance
163
-
164
- ```bash
165
- # List sessions
166
- ls -la .claude/sessions/
167
-
168
- # Delete old sessions (>30 days)
169
- find .claude/sessions/ -mtime +30 -delete
170
-
171
- # Manual scrub (if needed)
172
- node scripts/scrub-secrets.js < session.md > clean.md
173
- # Installed path: node ~/.claude/scripts/scrub-secrets.js < session.md > clean.md
174
- ```
175
-
176
- ## Claude Built-in Session Commands
177
-
178
- In addition to custom `/session-save` and `/session-load`, Claude Code has built-in session features:
179
-
180
- | Command | Purpose |
181
- |---------|---------|
182
- | `claude -c` / `--continue` | Resume most recent session |
183
- | `claude -r "id"` / `--resume "id"` | Resume specific session by ID |
184
- | `claude --resume` | Show recent sessions to select |
185
-
186
- > **Note:** Built-in sessions are stored in `~/.claude/projects/.../*.jsonl`. Custom `/session-save` creates human-readable `.md` summaries in `.claude/sessions/`.
187
-
188
- ## Best Practices
189
-
190
- 1. Save after completing logical phases
191
- 2. Save before long breaks (>4 hours)
192
- 3. Use descriptive names
193
- 4. Prune old sessions periodically
194
- 5. **Ensure scripts are executable**: `chmod +x scripts/hooks/*.sh`
195
- (Installed path: `chmod +x ~/.claude/scripts/hooks/*.sh`)
@@ -1,64 +0,0 @@
1
- # 학습된 패턴 데이터베이스 (Learned Patterns)
2
-
3
- 이 디렉토리는 Claude Code 환경의 **장기 기억(Long-Term Memory)** 저장소입니다. `/learn` 명령어를 통해 추출된 반복적인 코딩 패턴, 아키텍처 결정 사항, 그리고 개인적인 코딩 스타일 선호도를 보관합니다.
4
-
5
- ## 핵심 개념: 지식 순환 아키텍처
6
-
7
- 1. **감지 (Detection)**: 작업 도중 반복되는 패턴이나 중요한 규칙을 발견합니다.
8
- 2. **추출 (Extraction)**: `/learn` 명령어를 실행하여 해당 지식을 정형화합니다.
9
- 3. **저장 (Persistence)**: 메타데이터가 포함된 마크다운 파일로 이 폴더에 저장됩니다.
10
- 4. **부활 (Resurrection)**: 다음 세션이 시작될 때 Claude는 이 폴더를 인덱싱하여, **과거의 실수를 반복하지 않고 이미 결정된 규칙을 다시 묻지 않습니다.**
11
-
12
- ## 사용 방법 및 실행
13
-
14
- ### 1. 명시적 학습 (Manual Learning)
15
- 기억해야 할 규칙이 생겼을 때 직접 입력합니다:
16
- `> /learn "API 에러 핸들링 시 항상 try-catch와 전역 로거를 사용해줘"`
17
-
18
- ### 2. 세션 분석 (Session Analysis)
19
- 복잡한 작업을 마친 후, Claude에게 패턴을 찾아내라고 시킵니다:
20
- `> /learn`
21
- Claude가 전체 대화 기록을 분석하여 저장할만한 패턴을 제안합니다.
22
-
23
- ### 3. 목록 확인 (Management)
24
- `> /learn --show` (현재 저장된 모든 패턴 목록을 확인합니다.)
25
-
26
- ## 분류 체계 및 저장 위치
27
-
28
- | 카테고리 | 저장 위치 | 용도 |
29
- | :--- | :--- | :--- |
30
- | **CONVENTION** | `.claude/rules/` | 구조적 규칙 (예: 폴더 구조, 네이밍 컨벤션) |
31
- | **PATTERN** | **이 폴더 (learned/)** | 재사용 가능한 로직 블록 (예: 인증 흐름, 에러 처리 패턴) |
32
- | **PREFERENCE** | `.claude/rules/` | 개인적 취향 (예: "나는 trailing comma를 선호함") |
33
-
34
- ## 패턴 파일 구조
35
-
36
- 모든 패턴 파일은 Claude가 읽기 최적화된 아래 형식을 따릅니다:
37
-
38
- ```markdown
39
- ---
40
- name: api-response-format
41
- category: PATTERN
42
- tags: [api, nodejs, json]
43
- ---
44
- # 패턴: 표준 API 응답 형식
45
-
46
- ## 문제점
47
- API 응답 형식이 일관되지 않아 프론트엔드에서 파싱 에러가 자주 발생함.
48
-
49
- ## 해결책
50
- `src/types/api.ts`에 정의된 `BaseResponse` 인터페이스를 반드시 사용함.
51
-
52
- ## 예시
53
- ```typescript
54
- res.json({
55
- success: true,
56
- data: result,
57
- error: null
58
- });
59
- ```
60
- ```
61
-
62
- ## ⚠️ 주의 사항
63
- - **비밀번호/키 제외**: `/learn` 명령어 실행 시 `scrub-secrets.js`가 자동으로 작동하여 API 키나 토큰이 저장되지 않도록 검열합니다.
64
- - **프로젝트 컨텍스트**: 패턴은 사용자 홈 디렉토리에 저장되지만, Claude는 현재 프로젝트와 연관된 패턴을 우선적으로 인덱싱합니다.
@@ -1,64 +0,0 @@
1
- # Learned Patterns Database
2
-
3
- This directory serves as the **Long-Term Memory** for your Claude Code environment. It stores recurring patterns, specific architectural decisions, and coding style preferences extracted through the `/learn` command.
4
-
5
- ## Core Concept: The Knowledge Cycle
6
-
7
- 1. **Detection**: During a session, you (or the `Stop hook`) identify a reusable pattern.
8
- 2. **Extraction**: You run `/learn` to formalize that insight.
9
- 3. **Persistence**: The pattern is saved as a Markdown file with specific metadata.
10
- 4. **Resurrection**: In future sessions, Claude automatically indexes these files, ensuring it doesn't repeat past mistakes or ask the same questions.
11
-
12
- ## Usage & Implementation
13
-
14
- ### 1. Manual Learning
15
- If you notice a convention you want to keep:
16
- `> /learn "Always use useServerSideProps for data fetching in /pages"`
17
-
18
- ### 2. Session Analysis
19
- If you've just finished a complex task and want to extract the "how-to":
20
- `> /learn`
21
- Claude will analyze the transcript and propose patterns to save.
22
-
23
- ### 3. Management
24
- `> /learn --show` (Lists all active patterns)
25
-
26
- ## Categorization Logic
27
-
28
- | Category | Storage Target | Purpose |
29
- | :--- | :--- | :--- |
30
- | **CONVENTION** | `.claude/rules/` | Structural rules (e.g., Folder structure, Naming). |
31
- | **PATTERN** | **This folder** | Reusable logic blocks (e.g., Auth flow, Error handling). |
32
- | **PREFERENCE** | `.claude/rules/` | Personal taste (e.g., "I prefer trailing commas"). |
33
-
34
- ## Pattern File Structure
35
-
36
- Every learned file follows this high-efficiency schema for LLM ingestion:
37
-
38
- ```markdown
39
- ---
40
- name: auth-error-handling
41
- category: PATTERN
42
- tags: [auth, nextjs, security]
43
- ---
44
- # Pattern: Centralized Auth Error Handling
45
-
46
- ## Problem
47
- Auth errors were being handled inconsistently across different API routes.
48
-
49
- ## Solution
50
- Use the `handleAuthError` utility located in `src/utils/auth`.
51
-
52
- ## Example
53
- ```typescript
54
- try {
55
- // ... auth logic
56
- } catch (e) {
57
- return handleAuthError(e);
58
- }
59
- ```
60
- ```
61
-
62
- ## ⚠️ Important Notes
63
- - **No Secrets**: The `/learn` command automatically triggers `scrub-secrets.js` to ensure no API keys or tokens are stored in the patterns.
64
- - **Project Specific**: While saved in your user home, these patterns are indexed based on project context.