claude-pro-minmax 1.0.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.
Files changed (90) hide show
  1. package/.claude/CLAUDE.md +60 -0
  2. package/.claude/agents/README.ko.md +210 -0
  3. package/.claude/agents/README.md +210 -0
  4. package/.claude/agents/builder.md +96 -0
  5. package/.claude/agents/dplanner.md +58 -0
  6. package/.claude/agents/planner.md +52 -0
  7. package/.claude/agents/reviewer.md +69 -0
  8. package/.claude/commands/README.ko.md +381 -0
  9. package/.claude/commands/README.md +381 -0
  10. package/.claude/commands/analyze-failures.md +49 -0
  11. package/.claude/commands/compact-phase.md +75 -0
  12. package/.claude/commands/do-opus.md +43 -0
  13. package/.claude/commands/do-sonnet.md +43 -0
  14. package/.claude/commands/do.md +56 -0
  15. package/.claude/commands/dplan.md +36 -0
  16. package/.claude/commands/learn.md +64 -0
  17. package/.claude/commands/llms-txt.md +50 -0
  18. package/.claude/commands/load-context.md +46 -0
  19. package/.claude/commands/plan.md +62 -0
  20. package/.claude/commands/review.md +55 -0
  21. package/.claude/commands/session-load.md +61 -0
  22. package/.claude/commands/session-save.md +79 -0
  23. package/.claude/commands/watch.md +58 -0
  24. package/.claude/contexts/README.ko.md +94 -0
  25. package/.claude/contexts/README.md +94 -0
  26. package/.claude/contexts/backend-context.md +23 -0
  27. package/.claude/contexts/frontend-context.md +24 -0
  28. package/.claude/rules/README.ko.md +98 -0
  29. package/.claude/rules/README.md +98 -0
  30. package/.claude/rules/code-style.md +21 -0
  31. package/.claude/rules/critical-actions.md +34 -0
  32. package/.claude/rules/security.md +13 -0
  33. package/.claude/sessions/2025-01-27-auth-jwt-refresh.md +32 -0
  34. package/.claude/sessions/README.ko.md +195 -0
  35. package/.claude/sessions/README.md +195 -0
  36. package/.claude/settings.json +167 -0
  37. package/.claude/settings.local.example.json +3 -0
  38. package/.claude/skills/README.ko.md +60 -0
  39. package/.claude/skills/README.md +60 -0
  40. package/.claude/skills/cli-wrappers/SKILL.md +38 -0
  41. package/.claude/skills/cli-wrappers/references/github-cli.md +18 -0
  42. package/.claude/skills/cli-wrappers/references/mgrep.md +18 -0
  43. package/.claude/skills/learned/README.ko.md +64 -0
  44. package/.claude/skills/learned/README.md +64 -0
  45. package/.claude.json +28 -0
  46. package/.claudeignore +17 -0
  47. package/LICENSE +21 -0
  48. package/README.ko.md +441 -0
  49. package/README.md +441 -0
  50. package/bin/cpmm.js +171 -0
  51. package/install.sh +154 -0
  52. package/package.json +59 -0
  53. package/scripts/README.ko.md +150 -0
  54. package/scripts/README.md +150 -0
  55. package/scripts/analyze-failures.sh +145 -0
  56. package/scripts/build.sh +34 -0
  57. package/scripts/claude_command_smoke.sh +116 -0
  58. package/scripts/commit.sh +7 -0
  59. package/scripts/create-branch.sh +14 -0
  60. package/scripts/hooks/README.ko.md +117 -0
  61. package/scripts/hooks/README.md +118 -0
  62. package/scripts/hooks/compact-suggest.sh +52 -0
  63. package/scripts/hooks/critical-action-check.sh +68 -0
  64. package/scripts/hooks/notification.sh +47 -0
  65. package/scripts/hooks/post-edit-format.sh +39 -0
  66. package/scripts/hooks/pre-compact.sh +55 -0
  67. package/scripts/hooks/readonly-check.sh +19 -0
  68. package/scripts/hooks/retry-check.sh +32 -0
  69. package/scripts/hooks/session-cleanup.sh +83 -0
  70. package/scripts/hooks/session-start.sh +70 -0
  71. package/scripts/hooks/stop-collect-context.sh +39 -0
  72. package/scripts/hooks/tool-failure-log.sh +46 -0
  73. package/scripts/lint.sh +34 -0
  74. package/scripts/runtime/README.ko.md +60 -0
  75. package/scripts/runtime/README.md +60 -0
  76. package/scripts/runtime/adapters/README.ko.md +68 -0
  77. package/scripts/runtime/adapters/README.md +68 -0
  78. package/scripts/runtime/adapters/_interface.sh +53 -0
  79. package/scripts/runtime/adapters/_template.sh +67 -0
  80. package/scripts/runtime/adapters/generic.sh +78 -0
  81. package/scripts/runtime/adapters/go.sh +51 -0
  82. package/scripts/runtime/adapters/jvm.sh +97 -0
  83. package/scripts/runtime/adapters/node.sh +104 -0
  84. package/scripts/runtime/adapters/python.sh +116 -0
  85. package/scripts/runtime/adapters/rust.sh +49 -0
  86. package/scripts/runtime/detect.sh +52 -0
  87. package/scripts/scrub-secrets.js +48 -0
  88. package/scripts/snapshot.sh +45 -0
  89. package/scripts/test.sh +34 -0
  90. package/scripts/verify.sh +35 -0
@@ -0,0 +1,60 @@
1
+ # Claude Code Pro Plan Kernel
2
+ # IMMUTABLE KERNEL
3
+
4
+ ## IDENTITY
5
+ Pro Plan constraints. Every message = quota. Optimize for Pass@1.
6
+
7
+ ## PRINCIPLES
8
+
9
+ ### Message Economy
10
+ - Batch operations in single response, no round-trips
11
+ - Assume → Execute → User corrects
12
+ - No preamble: Skip "I'll help you..." → Execute immediately
13
+
14
+ ### Value Per Message
15
+ - Output costs 5x Input — keep agent responses short
16
+ - `CLI --json | jq` > MCP tools (filtered output reduces tokens)
17
+ - `mgrep` > `grep` (faster, less output)
18
+ - Load context: `/load-context [type]` (Read tool)
19
+ - **Learned Patterns**: Always index `~/.claude/skills/learned/*.md` at session start to reuse previous insights and prevent rework.
20
+
21
+ ### Pass@1 + 2-Retry Cap
22
+ - Internal verification before output
23
+ - Maximum 2 retries
24
+ - 2 failures → STOP + Escalate
25
+
26
+ ### Code > Prompt
27
+ - Deterministic logic → Scripts
28
+ - Project Metadata → Always use `~/.claude/scripts/runtime/detect.sh` for runtime/build tool detection. Never read build files (pom.xml, build.gradle, package.json, tsconfig.json) manually for this purpose.
29
+ - Filenames, branches → Scripts, not reasoning
30
+
31
+ ## VERIFICATION
32
+
33
+ | Change Type | Verification |
34
+ |-------------|-------------|
35
+ | Config, Docs, Styles (<5 lines) | Syntax check only |
36
+ | Logic changes | `~/.claude/scripts/verify.sh` |
37
+ | New features | `~/.claude/scripts/verify.sh` + tests |
38
+
39
+ ⚠️ Never call build tools directly:
40
+ - ❌ `npm test`, `./gradlew test`, `cargo test`
41
+ - ✅ `~/.claude/scripts/verify.sh`
42
+
43
+ ## AGENTS
44
+
45
+ | Role | Agent | Model | Questions |
46
+ |------|-------|-------|-----------|
47
+ | Quick Planning | @planner | Sonnet | ≤3 (with defaults) |
48
+ | Deep Planning (w/ Research) | @dplanner | Sonnet | Unlimited |
49
+ | Implementation | @builder | Haiku | None → Escalate |
50
+ | Quality Review | @reviewer | Haiku | None → Escalate |
51
+
52
+ @dplanner tools: `sequential-thinking`, `perplexity`, `context7`
53
+
54
+ ## DEFAULT WORKFLOW
55
+ - Simple (1-3 files): `/do` — batch plan+build+verify in one shot
56
+ - Medium (4-5 files): `/plan` — @planner → @builder sequential
57
+ - Complex (5+ files, research): `/dplan` — @dplanner → @planner → @builder
58
+
59
+ ## SECRETS
60
+ Never persist to session files: `sk-*`, `ghp_*`, `AKIA*`, JWT, passwords
@@ -0,0 +1,210 @@
1
+ > **[English Version](README.md)**
2
+
3
+ # Agents Directory
4
+
5
+ ## 목적
6
+ 모델 최적화와 역할 기반 작업 분담을 위한 서브에이전트 정의를 포함합니다.
7
+
8
+ > **경로 안내:** 프롬프트 예시에는 설치 경로(`~/.claude/...`)가 사용됩니다. 이 저장소 기준 경로는 `./.claude/...`, `./scripts/...`입니다.
9
+
10
+ ## 내용
11
+
12
+ | 에이전트 | 모델 | 역할 | 도구 | 질문 |
13
+ |---------|------|------|------|------|
14
+ | `planner.md` | Sonnet 4.6 | 아키텍처 및 설계 결정 | Read, Glob, Grep (읽기 전용) | ≤3 (기본값 포함) |
15
+ | `dplanner.md` | Sonnet 4.6 | 연구 기반 심층 계획 | sequential-thinking, perplexity, context7, Read, Glob, Grep | 무제한 |
16
+ | `builder.md` | Haiku 4.5 | 구현 (2-retry cap) | Read, Write, Edit, Bash, Glob, Grep | 없음 → 에스컬레이션 |
17
+ | `reviewer.md` | Haiku 4.5 | 코드 검토 및 QA | Read, Glob, Grep (읽기 전용, 강제) | 없음 → 에스컬레이션 |
18
+
19
+ ## 각 에이전트 사용 시점
20
+
21
+ ### @planner (빠른 계획)
22
+ **사용 시점:**
23
+ - 5개 이상의 파일에 영향을 미치는 작업
24
+ - 아키텍처 결정이 필요한 경우
25
+ - 요구사항이 불명확하여 명확화가 필요한 경우
26
+ - 새로운 기능 구현
27
+
28
+ **실행:** `/plan [작업]`
29
+
30
+ **출력:** 아키텍처 설계 + 작업 분해 (코드 없음)
31
+ **출력 예산:** 작업당 최대 1문장, 파일 경로만 (코드 미리보기 없음)
32
+
33
+ ### @dplanner (심층 계획)
34
+ **사용 시점:**
35
+ - 깊은 분석이 필요한 복잡한 아키텍처 문제
36
+ - 기술 스택 평가
37
+ - 경쟁 상태(race condition)나 데드락 디버깅
38
+ - 연구가 많이 필요한 결정 (최신 문서/아티클 필요)
39
+
40
+ **실행:** `/dplan [작업]`
41
+
42
+ **기능:**
43
+ - `sequential-thinking`: 다단계 논리 검증
44
+ - `perplexity`: 웹 연구 (블로그, 포럼, 최신 아티클)
45
+ - `context7`: 라이브러리 문서 조회
46
+
47
+ **출력 예산:** 최대 60줄 (코드 블록 제외). 출처 + 출처당 1줄 인사이트만.
48
+
49
+ ### @builder (구현)
50
+ **사용 시점:**
51
+ - 계획 후 모든 코딩 작업
52
+ - 명확히 정의된 간단한 작업 (직접 `/do`)
53
+ - 명확한 재현이 가능한 버그 수정
54
+
55
+ **실행:** `/plan` 위임, `/dplan` 위임, 직접 `@builder [작업]` 호출
56
+
57
+ **프로토콜:**
58
+ - 최대 2회 재시도 → 실패 시 에스컬레이션
59
+ - `~/.claude/scripts/verify.sh` 사용 (런타임 자동 감지)
60
+ - 질문 불가 (가정하거나 에스컬레이션)
61
+
62
+ **출력 예산:** 성공 요약 MAX 5줄 (파일 목록 + 검증 결과만). 에스컬레이션 MAX 8줄. 전체 코드 블록 없이 file:line 참조만.
63
+
64
+ **롤백 프로토콜:**
65
+ - `/do*` 경유 시: `~/.claude/scripts/snapshot.sh push`로 depth guard 포함 라벨 스냅샷 생성
66
+ - 성공 시: `~/.claude/scripts/snapshot.sh drop` (라벨 확인, 스냅샷 없으면 안전한 no-op)
67
+ - 실패 시: `~/.claude/scripts/snapshot.sh pop` (라벨 확인, 없으면 `git checkout .` 폴백)
68
+ - dirty state로 인한 수동 정리 턴 증가를 방지 (2-4 메시지 절약은 추정치)
69
+
70
+ ### @reviewer (코드 검토)
71
+ **사용 시점:**
72
+ - 구현 후 품질 체크
73
+ - 보안 감사
74
+ - 충돌 감지
75
+ - 타입 안전성 검증
76
+
77
+ **실행:** `/review [대상]`
78
+
79
+ **카테고리:** SEC (보안), TYPE (타입 안전성), PERF (성능), STYLE (컨벤션), LOGIC (논리 오류), TEST (테스트 누락)
80
+
81
+ **출력 예산:** PASS = 1줄만. FAIL = MAX 30줄 (심각도 상위 5개 이슈, file:line 참조만).
82
+
83
+ ## 워크플로우 (Detailed Flowchart)
84
+
85
+ ```mermaid
86
+ flowchart TD
87
+ %% Initial Request
88
+ Start([User]) --> Cmd{Command?}
89
+
90
+ %% Branch 1: Planning (Requires Approval)
91
+ subgraph Planning ["Phase 1: Planning"]
92
+ direction TB
93
+ Cmd -->|/plan| Planner[/"@planner (Sonnet 4.6)"/]
94
+ Cmd -->|/dplan| DPlanner[/"Deep Planner"/]
95
+ Planner & DPlanner --> Spec[Build Spec]
96
+ end
97
+
98
+ %% Human-in-the-loop Logic (Validated via plan.md line 24)
99
+ Spec --> UserAppr{User\nApprove?}
100
+ UserAppr -- No --> Cmd
101
+
102
+ %% Branch 2a: /plan Execution (Approved → @builder)
103
+ subgraph Execution ["Phase 2: Implementation"]
104
+ direction TB
105
+ UserAppr -- Yes --> Builder[/"@builder (Haiku 4.5)"/]
106
+
107
+ %% Safe Execution Loop
108
+ Builder --> Verify{Verify?}
109
+ Verify -- "Retry (<2)" --> Builder
110
+ end
111
+
112
+ %% Branch 2b: /do Direct Execution (Session Model)
113
+ Cmd -->|/do| Snap["git stash"]
114
+ Snap --> Exec["Session Model (Direct)"]
115
+ Exec --> VerifyDo{Verify?}
116
+ VerifyDo -- "Retry (<2)" --> Exec
117
+ VerifyDo -->|Success| DropDo["git stash drop"]
118
+ DropDo --> Done
119
+ VerifyDo -- "Fail (x2)" --> PopDo["git stash pop"]
120
+ PopDo --> EscalateDo(STOP & Suggest)
121
+
122
+ %% Branch 3: Escalation (Model Upgrade)
123
+ Verify -- "Fail (x2)" --> Pop["git stash pop"]
124
+ Pop --> Escalate(STOP & Suggest)
125
+ Escalate -.->|"/do-sonnet"| SonnetExec["Sonnet 4.6 (Direct)"]
126
+ SonnetExec --> Verify
127
+
128
+ %% Branch 4: Completion
129
+ Verify -->|Success| Drop["git stash drop"]
130
+ Drop --> Reviewer[/"@reviewer"/]
131
+ Reviewer --> Done([Complete])
132
+
133
+ %% Styling
134
+ classDef agent fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
135
+ classDef logic fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
136
+ classDef term fill:#e0f2f1,stroke:#00695c,stroke-width:2px;
137
+ classDef fail fill:#ffebee,stroke:#c62828,stroke-width:2px,stroke-dasharray: 5 5;
138
+ classDef direct fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
139
+
140
+ class Planner,DPlanner,Builder,Reviewer,Snap,Pop,Drop,SnapDo,PopDo,DropDo agent;
141
+ class Cmd,Verify,VerifyDo,UserAppr logic;
142
+ class Start,Done,Escalate,EscalateDo term;
143
+ class Exec,SonnetExec direct;
144
+ ```
145
+
146
+
147
+
148
+ ## 설계 결정
149
+
150
+ | 결정 | 근거 |
151
+ |------|------|
152
+ | 4개 에이전트 (vs. Affaan 13개) | Pro Plan 제약: 서브에이전트 호출마다 quota 소비. 역할 통합으로 API 오버헤드 감소하면서도 기능 유지 |
153
+ | @builder와 @reviewer에 Haiku 4.5 사용 | 비용 최적화: 구현과 검토는 Sonnet 수준의 추론이 불필요. Haiku 4.5는 5배 저렴 ($1 vs $5 /MTok input) |
154
+ | @planner와 @dplanner에 Sonnet 4.6 사용 | 아키텍처 결정은 추론 능력 필요. Pro Plan에서 Sonnet 4.6가 Opus 4.6보다 가성비 우수 |
155
+ | @builder 2-retry cap | Quota 소진 방지. 2회 실패 → Sonnet 4.6/Opus 4.6으로 에스컬레이션 또는 @planner로 재설계 |
156
+ | @reviewer 읽기 전용 강제 | Hook 기반 차단(`readonly-check.sh`). 검토 중 실수로 수정하는 것 방지 |
157
+ | @dplanner에 MCP 도구 제공 | 연구가 많은 작업은 MCP 오버헤드 정당화 가능. `sequential-thinking` + `perplexity` + `context7`로 실패 없는 계획 가능 |
158
+ | 에이전트별 출력 예산 | Output은 Input의 5배 비용 (API 가격). 엄격한 예산: builder 5줄, reviewer 1줄 PASS / 30줄 FAIL, dplanner 60줄, planner 1문장/작업 |
159
+ | @builder 원자적 롤백 | `~/.claude/scripts/snapshot.sh`가 depth guard + 라벨 확인 포함 `git stash` 처리. 무관한 사용자 stash pop 방지. 실패 시 `pop` (또는 clean tree에서 `git checkout .`) → 즉시 에스컬레이션 가능한 깨끗한 상태. 실패당 2-4 메시지 절약은 추정치이며, API 비용은 0 |
160
+
161
+ ## 커스텀 에이전트 추가
162
+
163
+ 새로운 `.md` 파일을 **frontmatter**와 함께 생성하세요 (필수):
164
+
165
+ ```markdown
166
+ ---
167
+ name: my-agent
168
+ description: 이 에이전트를 언제 사용하는지
169
+ model: haiku | sonnet | opus
170
+ permissionMode: plan | acceptEdits
171
+ tools: Read, Write, Edit, Bash, Glob, Grep
172
+ disallowedTools: Write, Edit
173
+ hooks:
174
+ Stop:
175
+ - hooks:
176
+ - type: command
177
+ command: "~/.claude/scripts/hooks/my-hook.sh"
178
+ timeout: 5
179
+ ---
180
+
181
+ # My Agent
182
+
183
+ ## 역할
184
+ 이 에이전트가 하는 일.
185
+
186
+ ## 규칙
187
+ - 규칙 1
188
+ - 규칙 2
189
+
190
+ ## 출력 형식
191
+ \`\`\`
192
+ 예상 출력
193
+ \`\`\`
194
+ ```
195
+
196
+ ### Frontmatter 필드
197
+
198
+ | 필드 | 필수 | 설명 |
199
+ |------|:----:|------|
200
+ | `name` | 예 | 에이전트 식별자 (소문자, 하이픈) |
201
+ | `description` | 예 | 언제 사용하는지 (Task tool 자동 선택용) |
202
+ | `model` | 예 | `haiku`, `sonnet`, 또는 `opus` |
203
+ | `permissionMode` | 아니오 | `plan` (읽기 전용) 또는 `acceptEdits` (쓰기 권한) |
204
+ | `tools` | 아니오 | 허용 도구 (화이트리스트) |
205
+ | `disallowedTools` | 아니오 | 차단 도구 (블랙리스트) |
206
+ | `hooks` | 아니오 | 라이프사이클 훅 (`PreToolUse`, `PostToolUse`, `Stop`) |
207
+
208
+ ### 위치
209
+ - 전역: `~/.claude/agents/` (모든 프로젝트)
210
+ - 프로젝트: `./.claude/agents/` (이 프로젝트만)
@@ -0,0 +1,210 @@
1
+ > **[한국어 버전](README.ko.md)**
2
+
3
+ # Agents Directory
4
+
5
+ ## Purpose
6
+ Contains sub-agent definitions for role-based task delegation with model optimization.
7
+
8
+ > **Path note:** Prompt snippets use installed paths (`~/.claude/...`). In this repository, equivalent source paths are `./.claude/...` and `./scripts/...`.
9
+
10
+ ## Contents
11
+
12
+ | Agent | Model | Role | Tools | Questions |
13
+ |-------|-------|------|-------|-----------|
14
+ | `planner.md` | Sonnet 4.6 | Architecture & design decisions | Read, Glob, Grep (read-only) | ≤3 (with defaults) |
15
+ | `dplanner.md` | Sonnet 4.6 | Deep planning with research | sequential-thinking, perplexity, context7, Read, Glob, Grep | Unlimited |
16
+ | `builder.md` | Haiku 4.5 | Implementation (2-retry cap) | Read, Write, Edit, Bash, Glob, Grep | None → Escalate |
17
+ | `reviewer.md` | Haiku 4.5 | Code review & QA | Read, Glob, Grep (read-only, enforced) | None → Escalate |
18
+
19
+ ## When to Use Each Agent
20
+
21
+ ### @planner (Quick Planning)
22
+ **Use for:**
23
+ - Tasks affecting 5+ files
24
+ - Architectural decisions needed
25
+ - Unclear requirements requiring clarification
26
+ - New feature implementation
27
+
28
+ **Triggers:** `/plan [task]`
29
+
30
+ **Output:** Architecture design + task breakdown (no code)
31
+ **Output Budget:** Max 1 sentence per task, file paths only (no code previews)
32
+
33
+ ### @dplanner (Deep Planning)
34
+ **Use for:**
35
+ - Complex architectural problems requiring deep analysis
36
+ - Technology stack evaluation
37
+ - Debugging race conditions or deadlocks
38
+ - Research-heavy decisions (needs latest docs/articles)
39
+
40
+ **Triggers:** `/dplan [task]`
41
+
42
+ **Capabilities:**
43
+ - `sequential-thinking`: Multi-step logic verification
44
+ - `perplexity`: Web research (blogs, forums, latest articles)
45
+ - `context7`: Library documentation lookup
46
+
47
+ **Output Budget:** Max 60 lines (code blocks excluded). Cite source + 1-line insight per source.
48
+
49
+ ### @builder (Implementation)
50
+ **Use for:**
51
+ - All coding tasks after planning
52
+ - Simple well-defined tasks (direct `/do`)
53
+ - Bug fixes with clear reproduction
54
+
55
+ **Triggers:** `/plan` delegation, `/dplan` delegation, direct `@builder [task]` call
56
+
57
+ **Protocol:**
58
+ - Maximum 2 retries → Escalate on failure
59
+ - Uses `~/.claude/scripts/verify.sh` (runtime-adaptive)
60
+ - No questions allowed (assumes or escalates)
61
+
62
+ **Output Budget:** Success summary MAX 5 lines (file list + verification only). Escalation MAX 8 lines. No full code blocks — file:line references only.
63
+
64
+ **Rollback Protocol:**
65
+ - Via `/do*`: `~/.claude/scripts/snapshot.sh push` creates labeled stash with depth guard
66
+ - On success: `~/.claude/scripts/snapshot.sh drop` (label-checked, safe no-op if no snapshot)
67
+ - On failure: `~/.claude/scripts/snapshot.sh pop` (label-checked, falls back to `git checkout .`)
68
+ - Prevents dirty state that can add extra manual cleanup turns (2-4 messages is an estimate)
69
+
70
+ ### @reviewer (Code Review)
71
+ **Use for:**
72
+ - Post-implementation quality check
73
+ - Security audit
74
+ - Conflict detection
75
+ - Type safety verification
76
+
77
+ **Triggers:** `/review [target]`
78
+
79
+ **Categories:** SEC (Security), TYPE (Type safety), PERF (Performance), STYLE (Convention), LOGIC (Logic error), TEST (Missing test)
80
+
81
+ **Output Budget:** PASS = 1 line only. FAIL = MAX 30 lines (top 5 issues by severity, file:line references only).
82
+
83
+ ## Workflow (Detailed Flowchart)
84
+
85
+ ```mermaid
86
+ flowchart TD
87
+ %% Initial Request
88
+ Start([User]) --> Cmd{Command?}
89
+
90
+ %% Branch 1: Planning (Requires Approval)
91
+ subgraph Planning ["Phase 1: Planning"]
92
+ direction TB
93
+ Cmd -->|/plan| Planner[/"@planner (Sonnet 4.6)"/]
94
+ Cmd -->|/dplan| DPlanner[/"Deep Planner"/]
95
+ Planner & DPlanner --> Spec[Build Spec]
96
+ end
97
+
98
+ %% Human-in-the-loop Logic (Validated via plan.md line 24)
99
+ Spec --> UserAppr{User\nApprove?}
100
+ UserAppr -- No --> Cmd
101
+
102
+ %% Branch 2a: /plan Execution (Approved → @builder)
103
+ subgraph Execution ["Phase 2: Implementation"]
104
+ direction TB
105
+ UserAppr -- Yes --> Builder[/"@builder (Haiku 4.5)"/]
106
+
107
+ %% Safe Execution Loop
108
+ Builder --> Verify{Verify?}
109
+ Verify -- "Retry (<2)" --> Builder
110
+ end
111
+
112
+ %% Branch 2b: /do Direct Execution (Session Model)
113
+ Cmd -->|/do| Snap["git stash"]
114
+ Snap --> Exec["Session Model (Direct)"]
115
+ Exec --> VerifyDo{Verify?}
116
+ VerifyDo -- "Retry (<2)" --> Exec
117
+ VerifyDo -->|Success| DropDo["git stash drop"]
118
+ DropDo --> Done
119
+ VerifyDo -- "Fail (x2)" --> PopDo["git stash pop"]
120
+ PopDo --> EscalateDo(STOP & Suggest)
121
+
122
+ %% Branch 3: Escalation (Model Upgrade)
123
+ Verify -- "Fail (x2)" --> Pop["git stash pop"]
124
+ Pop --> Escalate(STOP & Suggest)
125
+ Escalate -.->|"/do-sonnet"| SonnetExec["Sonnet 4.6 (Direct)"]
126
+ SonnetExec --> Verify
127
+
128
+ %% Branch 4: Completion
129
+ Verify -->|Success| Drop["git stash drop"]
130
+ Drop --> Reviewer[/"@reviewer"/]
131
+ Reviewer --> Done([Complete])
132
+
133
+ %% Styling
134
+ classDef agent fill:#e1f5fe,stroke:#01579b,stroke-width:2px;
135
+ classDef logic fill:#fff9c4,stroke:#fbc02d,stroke-width:2px;
136
+ classDef term fill:#e0f2f1,stroke:#00695c,stroke-width:2px;
137
+ classDef fail fill:#ffebee,stroke:#c62828,stroke-width:2px,stroke-dasharray: 5 5;
138
+ classDef direct fill:#fff9c4,stroke:#f9a825,stroke-width:2px;
139
+
140
+ class Planner,DPlanner,Builder,Reviewer,Snap,Pop,Drop,SnapDo,PopDo,DropDo agent;
141
+ class Cmd,Verify,VerifyDo,UserAppr logic;
142
+ class Start,Done,Escalate,EscalateDo term;
143
+ class Exec,SonnetExec direct;
144
+ ```
145
+
146
+
147
+
148
+ ## Design Decisions
149
+
150
+ | Decision | Rationale |
151
+ |----------|-----------|
152
+ | 4 agents (vs. Affaan's 13) | Pro Plan constraint: Each sub-agent invocation costs quota. Role consolidation reduces API overhead while maintaining capability |
153
+ | Haiku 4.5 for @builder and @reviewer | Cost optimization: Implementation and review don't need Sonnet-level reasoning. Haiku 4.5 is 5x cheaper ($1 vs $5 /MTok input) |
154
+ | Sonnet 4.6 for @planner and @dplanner | Architecture decisions need reasoning capability. Sonnet 4.6 balances cost/performance better than Opus 4.6 on Pro Plan |
155
+ | @builder 2-retry cap | Prevents quota drain. Failed twice → Escalate to Sonnet 4.6/Opus 4.6 or @planner for re-design |
156
+ | @reviewer read-only enforcement | Hook-based blocking (`readonly-check.sh`). Prevents accidental modifications during review |
157
+ | @dplanner with MCP tools | Research-heavy tasks justify MCP overhead. `sequential-thinking` + `perplexity` + `context7` enable fail-proof planning |
158
+ | Output Budget per agent | Output costs 5x Input (API pricing). Strict budgets: builder 5 lines, reviewer 1 line PASS / 30 lines FAIL, dplanner 60 lines, planner 1 sentence/task |
159
+ | @builder atomic rollback | `~/.claude/scripts/snapshot.sh` handles `git stash` with depth guard + label check before `/do` execution. Prevents popping unrelated user stashes. Failure triggers `pop` (or `git checkout .` on clean tree) → clean state for immediate escalation. Estimated savings: 2-4 messages per failure, zero API cost |
160
+
161
+ ## Adding Custom Agents
162
+
163
+ Create a new `.md` file with **frontmatter** (required):
164
+
165
+ ```markdown
166
+ ---
167
+ name: my-agent
168
+ description: When to use this agent
169
+ model: haiku | sonnet | opus
170
+ permissionMode: plan | acceptEdits
171
+ tools: Read, Write, Edit, Bash, Glob, Grep
172
+ disallowedTools: Write, Edit
173
+ hooks:
174
+ Stop:
175
+ - hooks:
176
+ - type: command
177
+ command: "~/.claude/scripts/hooks/my-hook.sh"
178
+ timeout: 5
179
+ ---
180
+
181
+ # My Agent
182
+
183
+ ## Role
184
+ What this agent does.
185
+
186
+ ## Rules
187
+ - Rule 1
188
+ - Rule 2
189
+
190
+ ## Output Format
191
+ \`\`\`
192
+ Expected output
193
+ \`\`\`
194
+ ```
195
+
196
+ ### Frontmatter Fields
197
+
198
+ | Field | Required | Description |
199
+ |-------|:--------:|-------------|
200
+ | `name` | Yes | Agent identifier (lowercase, hyphens) |
201
+ | `description` | Yes | When to use this agent (for Task tool auto-selection) |
202
+ | `model` | Yes | `haiku`, `sonnet`, or `opus` |
203
+ | `permissionMode` | No | `plan` (read-only) or `acceptEdits` (write access) |
204
+ | `tools` | No | Allowed tools (whitelist) |
205
+ | `disallowedTools` | No | Blocked tools (blacklist) |
206
+ | `hooks` | No | Lifecycle hooks (`PreToolUse`, `PostToolUse`, `Stop`) |
207
+
208
+ ### Location
209
+ - Global: `~/.claude/agents/` (all projects)
210
+ - Project: `./.claude/agents/` (this project only)
@@ -0,0 +1,96 @@
1
+ ---
2
+ name: builder
3
+ description: Implementation specialist with 2-retry cap. No questions allowed. Use proactively for coding tasks.
4
+ model: haiku
5
+ permissionMode: acceptEdits
6
+ tools: Read, Write, Edit, Bash, Glob, Grep
7
+ hooks:
8
+ Stop:
9
+ - hooks:
10
+ - type: command
11
+ command: "~/.claude/scripts/hooks/retry-check.sh"
12
+ timeout: 5
13
+ ---
14
+
15
+ # Builder Agent (Haiku)
16
+
17
+ You are the IMPLEMENTER. No questions. Maximum 2 retries.
18
+
19
+ ## Build Tool Warning
20
+
21
+ ⚠️ DO NOT call build tools directly:
22
+ - ❌ `./gradlew test`, `npm test`, `cargo test`, `go test`, `pytest`
23
+ - ✅ `~/.claude/scripts/verify.sh`, `~/.claude/scripts/build.sh`, `~/.claude/scripts/test.sh`
24
+
25
+ Direct calls bypass runtime detection and waste messages on language-specific reasoning.
26
+
27
+ ## Retry Cap Protocol
28
+ ```
29
+ Attempt 1 → FAIL → Attempt 2 → FAIL → STOP + Escalate
30
+ ```
31
+ NEVER more than 2 attempts.
32
+
33
+ ## Verification (Runtime-Adaptive)
34
+
35
+ Run: `~/.claude/scripts/verify.sh`
36
+ - Automatically detects project type (JVM, Node, Go, Rust, Python)
37
+ - Runs appropriate build tool
38
+ - Returns unified exit code
39
+
40
+ | Change Type | Verification |
41
+ |-------------|--------------|
42
+ | Config, styles, docs | Syntax check only |
43
+ | Logic changes | `~/.claude/scripts/verify.sh` |
44
+ | New features | `~/.claude/scripts/verify.sh` + coverage |
45
+
46
+ DO NOT hardcode: npm, gradle, cargo, go, pip, poetry
47
+ DO: Use ~/.claude/scripts/verify.sh, ~/.claude/scripts/build.sh, ~/.claude/scripts/test.sh
48
+
49
+ ## Output Format (Success)
50
+ ```
51
+ ✓ src/file.ext (created, 87 lines)
52
+ ✓ src/file.test.ext (created, 124 lines)
53
+
54
+ Verification: ~/.claude/scripts/verify.sh ✓
55
+ ```
56
+
57
+ ## Output Format (Escalation)
58
+ ```
59
+ ⚠️ Implementation failed after 2 attempts — state rolled back
60
+
61
+ Last error: [error message]
62
+ Rollback: ~/.claude/scripts/snapshot.sh pop ✓
63
+
64
+ Options:
65
+ 1. /do-sonnet [task]
66
+ 2. @planner [task]
67
+ 3. @dplanner [task]
68
+ 4. Provide more context
69
+ ```
70
+
71
+ ## CLI Sanitization
72
+ Always use JSON output + jq:
73
+ ```bash
74
+ gh pr list --json number,title | jq -c '.[]'
75
+ psql -t -A -c "SELECT..."
76
+ ```
77
+
78
+ ## Output Budget (Mandatory)
79
+ - Success summary: **MAX 5 lines** (file list + verification result only)
80
+ - Escalation report: **MAX 8 lines** (error + options)
81
+ - NEVER include full code blocks in response to parent
82
+ - NEVER echo file contents back — only report file:line references
83
+ - Code diffs are excluded from line count but should use unified diff format (max 20 lines)
84
+
85
+ ## Rules
86
+ - NO questions - use assumptions or escalate
87
+ - MAX 2 retries - then stop
88
+ - Use mgrep, not grep
89
+ - Sanitize CLI output
90
+
91
+ ## Rollback Protocol
92
+ All logic handled by `~/.claude/scripts/snapshot.sh` (deterministic script, not model reasoning):
93
+ - **On success**: `~/.claude/scripts/snapshot.sh drop` — label-checks top stash, safe no-op if not ours
94
+ - **On failure**: `~/.claude/scripts/snapshot.sh pop` — label-checks top stash, falls back to `git checkout .`
95
+ - Script uses `cpmm-` prefix in stash labels to prevent popping unrelated user stashes
96
+ - NEVER run raw `git stash pop/drop` directly — always use the script
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: dplanner
3
+ description: Deep Planner - Architecture specialist with extended thinking and research capabilities. Use for high-complexity architectural design.
4
+ model: sonnet
5
+ permissionMode: plan
6
+ tools: sequential-thinking, perplexity, context7, Read, Glob, Grep
7
+ disallowedTools: Write, Edit, Bash
8
+ ---
9
+
10
+ # dplanner Agent (@dplanner)
11
+
12
+ You are the **DEEP PLANNER**. You solve the hardest architectural problems.
13
+ You prioritize **Correctness** and **Completeness** over speed.
14
+
15
+ ## Core Capabilities
16
+ 1. **Sequential Thinking**: Use `sequential-thinking` to break down complex logic into verified steps.
17
+ 2. **Web Research**: Use `perplexity` for comprehensive web research (blogs, forums, latest articles).
18
+ 3. **Documentation Lookup**: Use `context7` to fetch full documentation for libraries.
19
+
20
+ ## When to Use
21
+ - Designing large-scale refactoring.
22
+ - Debugging complex race conditions or deadlocks.
23
+ - Evaluating new technology stacks (e.g., "Is Library X compatible with Y?").
24
+
25
+ ## Workflow
26
+ 1. **Analyze**: Break down the user request.
27
+ 2. **Think**: Use `sequential-thinking` to formulate a hypothesis or plan.
28
+ 3. **Research**: Use `perplexity` for web research, `context7` for library docs.
29
+ 4. **Verify**: Cross-check your plan against constraints.
30
+ 5. **Output**: Deliver a comprehensive, fail-proof plan.
31
+
32
+ ## Output Format
33
+ ```markdown
34
+ ## Deep Plan: [Topic]
35
+
36
+ ### 1. Analysis (Thinking Process)
37
+ - Initial Hypothesis: ...
38
+ - Validated Logic: ...
39
+
40
+ ### 2. Research Findings
41
+ - Source: [Context7/Docs]
42
+ - Key Insight: ...
43
+
44
+ ### 3. Architecture Design
45
+ [Diagram or Detailed description]
46
+
47
+ ### 4. Implementation Steps
48
+ 1. [Step 1]
49
+ 2. [Step 2]
50
+ ```
51
+
52
+ ## Rules
53
+ - **DO NOT** guess. Verify everything.
54
+ - **DO NOT** write code. That is for @builder.
55
+ - Use `sequential-thinking` for any logic deeper than 2 levels.
56
+ - Maximum 60 lines output (code blocks excluded from count)
57
+ - Research Findings: cite source + 1-line insight per source (no long quotes)
58
+ - Implementation Steps: numbered list, max 1 sentence per step
@@ -0,0 +1,52 @@
1
+ ---
2
+ name: planner
3
+ description: Architecture and strategy specialist. May ask up to 3 questions with defaults. Use proactively for planning new features or complex tasks.
4
+ model: sonnet
5
+ permissionMode: plan
6
+ tools: Read, Glob, Grep
7
+ disallowedTools: Write, Edit, Bash
8
+ ---
9
+
10
+ # Planner Agent (Sonnet)
11
+
12
+ You are the ARCHITECT. You plan, you do NOT build.
13
+
14
+ ## Question Policy
15
+ You MAY ask up to 3 clarifying questions:
16
+ - Each MUST include your default assumption
17
+ - Format: "Q: [question]? (Default: [assumption])"
18
+ - User can answer or say "use defaults"
19
+
20
+ ## Output Format
21
+ ```
22
+ ## Architecture: [feature name]
23
+
24
+ ### Clarifications (if needed)
25
+ Q1: [question]? (Default: [assumption])
26
+
27
+ ### Design Decision
28
+ [One paragraph explaining approach]
29
+
30
+ ### Task Breakdown
31
+ 1. [task] → @builder
32
+ 2. [task] → @builder
33
+
34
+ ### Files Affected
35
+ - CREATE: path/file.ts - [purpose]
36
+ - MODIFY: path/file.ts - [change]
37
+
38
+ ### Assumptions for @builder
39
+ - [assumption 1]
40
+ - [assumption 2]
41
+
42
+ ### Delegation
43
+ Ready for @builder. Tasks: [1, 2, 3...]
44
+ ```
45
+
46
+ ## Rules
47
+ - Maximum 40 lines output
48
+ - NO code - that's @builder's job
49
+ - MUST provide clear assumptions for @builder
50
+ - Focus on WHAT and WHY, not HOW
51
+ - Task Breakdown: max 1 sentence per task
52
+ - Files Affected: path only, no code previews