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
package/install.sh ADDED
@@ -0,0 +1,154 @@
1
+ #!/bin/bash
2
+ # Claude Pro MinMax - Installation Script
3
+ set -e
4
+ echo "🚀 Installing Claude Pro MinMax (CPMM)"
5
+
6
+ # Check for dependencies
7
+ if ! command -v jq &> /dev/null; then
8
+ echo "⚠️ Warning: jq is not installed. Some features (JSON output, cost optimization) may not work."
9
+ echo " Install with: brew install jq"
10
+ fi
11
+
12
+ # Check for mgrep (Critical for output reduction)
13
+ if ! command -v mgrep &> /dev/null; then
14
+ echo "⚠️ Warning: mgrep is not installed. This is critical for 50% output reduction."
15
+ echo " Install with: npm install -g @mixedbread/mgrep && mgrep install-claude-code"
16
+ fi
17
+
18
+ # Backup and Clean existing ~/.claude (True Overwrite)
19
+ if [ -d ~/.claude ]; then
20
+ BACKUP_DIR=~/.claude-backup-$(date +"%Y%m%d-%H%M%S")
21
+ echo "📦 Backing up and clearing existing ~/.claude → $BACKUP_DIR"
22
+ mv ~/.claude "$BACKUP_DIR"
23
+ echo " Clean overwrite enabled. Old settings preserved in backup."
24
+ fi
25
+
26
+ # Create fresh directories
27
+ mkdir -p ~/.claude/{agents,commands,rules,skills/cli-wrappers/references,contexts,sessions,scripts}
28
+
29
+ # Copy configurations
30
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
31
+ cp "$SCRIPT_DIR/.claude/CLAUDE.md" ~/.claude/
32
+ cp "$SCRIPT_DIR/.claude/settings.json" ~/.claude/
33
+ if [ -f "$SCRIPT_DIR/.claudeignore" ]; then
34
+ cp "$SCRIPT_DIR/.claudeignore" ~/.claude/
35
+ fi
36
+ # Copy settings.local.json from example template (users customize after install)
37
+ if [ -f "$SCRIPT_DIR/.claude/settings.local.example.json" ]; then
38
+ cp "$SCRIPT_DIR/.claude/settings.local.example.json" ~/.claude/settings.local.json
39
+ fi
40
+ cp "$SCRIPT_DIR/.claude/agents/"*.md ~/.claude/agents/
41
+ cp "$SCRIPT_DIR/.claude/commands/"*.md ~/.claude/commands/
42
+ for rule in "$SCRIPT_DIR/.claude/rules/"*.md; do
43
+ filename=$(basename "$rule")
44
+ [ "$filename" = "language.md" ] && continue
45
+ cp "$rule" ~/.claude/rules/
46
+ done
47
+ cp -R "$SCRIPT_DIR/.claude/skills/"* ~/.claude/skills/
48
+ cp "$SCRIPT_DIR/.claude/contexts/"*.md ~/.claude/contexts/
49
+ # sessions/ dir created above; example files stay in repo only (not installed)
50
+ cp -R "$SCRIPT_DIR/scripts/"* ~/.claude/scripts/
51
+
52
+ # Clean up documentation files from ~/.claude to prevent parsing errors
53
+ # (The 'find' command below removes all README/USER-MANUAL files from the installed directory)
54
+ find ~/.claude -name "README*" -delete
55
+ find ~/.claude -name "USER-MANUAL*" -delete
56
+
57
+ # Copy MCP Configuration (User Scope - ~/.claude.json)
58
+ if [ -f "$SCRIPT_DIR/.claude.json" ]; then
59
+ if [ -f ~/.claude.json ]; then
60
+ echo "📦 Backing up existing ~/.claude.json → ~/.claude.json.bak"
61
+ cp ~/.claude.json ~/.claude.json.bak
62
+ fi
63
+ cp "$SCRIPT_DIR/.claude.json" ~/.claude.json
64
+ echo "✅ Installed .claude.json to ~/.claude.json (User Scope)"
65
+
66
+ # Create .mcp.json symlink (Force recreate to ensure it's a link)
67
+ if [ -e ~/.mcp.json ] || [ -L ~/.mcp.json ]; then
68
+ rm ~/.mcp.json
69
+ fi
70
+ ln -s ~/.claude.json ~/.mcp.json
71
+ echo "✅ Created .mcp.json → .claude.json symlink (Ensured Link)"
72
+ # Interactive Perplexity Setup (Read from /dev/tty for curl support)
73
+ if [ -t 0 ] || [ -c /dev/tty ]; then
74
+ echo ""
75
+ echo "🔍 Perplexity API Setup (Recommended for /dplan)"
76
+ echo -n " Enter your API Key (Press Enter to skip): "
77
+ read -rs PERPLEXITY_KEY < /dev/tty || PERPLEXITY_KEY=""
78
+ echo "" # Newline for silent read
79
+
80
+ if [ -n "$PERPLEXITY_KEY" ]; then
81
+ # Enable Perplexity (Rename key and inject API Key)
82
+ # Use jq for reliable JSON editing
83
+ jq --arg key "$PERPLEXITY_KEY" \
84
+ '.mcpServers.perplexity = .mcpServers._perplexity_disabled_by_default |
85
+ .mcpServers.perplexity.env.PERPLEXITY_API_KEY = $key |
86
+ del(.mcpServers._perplexity_disabled_by_default)' \
87
+ ~/.claude.json > ~/.claude.json.tmp && mv ~/.claude.json.tmp ~/.claude.json
88
+ echo "✅ Perplexity API Key configured!"
89
+ else
90
+ # Skip: Completely remove the disabled block to keep config clean
91
+ echo "⚠️ Skipping Perplexity setup. Disabling feature..."
92
+ jq 'del(.mcpServers._perplexity_disabled_by_default)' ~/.claude.json > ~/.claude.json.tmp && mv ~/.claude.json.tmp ~/.claude.json
93
+ echo " (Feature removed from config. Add manually to functionality if needed)"
94
+ fi
95
+ # No temp file cleanup needed for jq approach as we mv content
96
+ fi
97
+ fi
98
+
99
+ # Language Selection (Interactive)
100
+ if [ -t 0 ] || [ -c /dev/tty ]; then
101
+ echo ""
102
+ echo "🌍 Output Language"
103
+ echo " 1) English (default)"
104
+ echo " 2) 한국어 (Korean)"
105
+ echo " 3) 日本語 (Japanese)"
106
+ echo " 4) 中文 (Chinese)"
107
+ echo -n " Select [1-4]: "
108
+ read -r LANG_CHOICE < /dev/tty || LANG_CHOICE="1"
109
+
110
+ case $LANG_CHOICE in
111
+ 2)
112
+ cat > ~/.claude/rules/language.md <<'LANGEOF'
113
+ # Language Policy
114
+ Respond in Korean (한국어). Code, commands, technical terms in English.
115
+ LANGEOF
116
+ echo "✅ Output language: Korean"
117
+ ;;
118
+ 3)
119
+ cat > ~/.claude/rules/language.md <<'LANGEOF'
120
+ # Language Policy
121
+ Respond in Japanese (日本語). Code, commands, technical terms in English.
122
+ LANGEOF
123
+ echo "✅ Output language: Japanese"
124
+ ;;
125
+ 4)
126
+ cat > ~/.claude/rules/language.md <<'LANGEOF'
127
+ # Language Policy
128
+ Respond in Chinese (中文). Code, commands, technical terms in English.
129
+ LANGEOF
130
+ echo "✅ Output language: Chinese"
131
+ ;;
132
+ *)
133
+ # English: no language.md needed (Claude defaults to English)
134
+ rm -f ~/.claude/rules/language.md
135
+ echo "✅ Output language: English"
136
+ ;;
137
+ esac
138
+ fi
139
+
140
+ # Make scripts executable (Recursive)
141
+ find ~/.claude/scripts -name "*.sh" -exec chmod +x {} \;
142
+ find ~/.claude/scripts -name "*.js" -exec chmod +x {} \;
143
+
144
+ echo "✅ Installation complete!"
145
+ echo ""
146
+ echo "Quick Start:"
147
+ echo " claude"
148
+ echo " > /plan Design a new feature"
149
+ echo " > /dplan Analyze complex architecture"
150
+ echo " > /do Implement the login page"
151
+ echo ""
152
+ echo "Language:"
153
+ echo " To change language: edit ~/.claude/rules/language.md"
154
+ echo " To use English: rm ~/.claude/rules/language.md"
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "claude-pro-minmax",
3
+ "version": "1.0.0",
4
+ "description": "Quota-first routing and safety layer for Claude Code Pro workflows.",
5
+ "author": "donghoon <move-hoon@users.noreply.github.com>",
6
+ "license": "MIT",
7
+ "type": "commonjs",
8
+ "bin": {
9
+ "cpmm": "bin/cpmm.js"
10
+ },
11
+ "files": [
12
+ "bin",
13
+ ".claude/CLAUDE.md",
14
+ ".claude/settings.json",
15
+ ".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",
23
+ ".claudeignore",
24
+ "install.sh",
25
+ "scripts",
26
+ "README.md",
27
+ "README.ko.md",
28
+ "LICENSE"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "help": "node bin/cpmm.js --help",
35
+ "doctor": "node bin/cpmm.js doctor",
36
+ "test": "node bin/cpmm.js --version && node bin/cpmm.js --help"
37
+ },
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
41
+ "keywords": [
42
+ "claude",
43
+ "claude-code",
44
+ "claude-pro",
45
+ "cpmm",
46
+ "llmops",
47
+ "devtools",
48
+ "agentic-coding",
49
+ "cost-optimization"
50
+ ],
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/move-hoon/claude-pro-minmax.git"
54
+ },
55
+ "bugs": {
56
+ "url": "https://github.com/move-hoon/claude-pro-minmax/issues"
57
+ },
58
+ "homepage": "https://github.com/move-hoon/claude-pro-minmax#readme"
59
+ }
@@ -0,0 +1,150 @@
1
+ > **[English Version](README.md)**
2
+
3
+ # Scripts Directory
4
+
5
+ ## 목적
6
+ "프롬프트"로 처리하는 것이 아니라 "코드"로 처리해야 하는 작업을 위한 결정론적 스크립트를 포함합니다.
7
+
8
+ **철학:** "코드로 할 수 있는 것을 프롬프트하지 마세요."
9
+
10
+ > **경로 안내:** 이 저장소에서는 `scripts/` 아래에 있으며, 설치 후 실행 경로는 `~/.claude/scripts/`입니다.
11
+
12
+ ## 유니버설 스크립트
13
+
14
+ | 스크립트 | 목적 | 이점 |
15
+ |--------|---------|---------|
16
+ | `verify.sh` | 런타임 적응형 검증 (빌드+테스트+린트) | 결정론적 실행, 프롬프팅 불필요 |
17
+ | `build.sh` | 런타임 적응형 빌드 | 런타임 자동 감지, 모델 추측 제거 |
18
+ | `test.sh` | 런타임 적응형 테스트 | 런타임별 명령을 직접 실행 |
19
+ | `lint.sh` | 런타임 적응형 린트 | 로컬 처리, 즉각적 결과 |
20
+
21
+ ## 런타임 감지 레이어
22
+
23
+ ```
24
+ runtime/
25
+ ├── detect.sh # 프로젝트 런타임 자동 감지 (JSON 출력)
26
+ └── adapters/
27
+ ├── _interface.sh # 어댑터 계약 정의
28
+ ├── jvm.sh # Java/Kotlin (Gradle/Maven)
29
+ ├── node.sh # TypeScript/JS (npm/pnpm/yarn/bun)
30
+ ├── go.sh # Go 모듈
31
+ ├── rust.sh # Cargo
32
+ ├── python.sh # pip/poetry/uv
33
+ ├── generic.sh # Makefile 폴백
34
+ └── _template.sh # 새 어댑터용 템플릿
35
+ ```
36
+
37
+ ## 유틸리티 스크립트
38
+
39
+ | 스크립트 | 목적 | 이점 |
40
+ |--------|---------|---------|
41
+ | `scrub-secrets.js` | 텍스트에서 비밀 정보 제거 | 보안 + 토큰 노출 방지 |
42
+ | `analyze-failures.sh` | 도구 실패 로그 분석 및 패턴 추출 | LLM 분석 전 로그 전처리 |
43
+ | `create-branch.sh` | 결정론적 브랜치 생성 | 일관된 명명, 추측 불필요 |
44
+ | `commit.sh` | Conventional Commit 형식 | 컨벤션 자동 적용 |
45
+ | `snapshot.sh` | `/do` 명령의 원자적 롤백 | 결정론적 `git stash` + depth guard + 라벨 안전장치 |
46
+
47
+ ## Hooks 디렉토리
48
+
49
+ | Hook 스크립트 | 이벤트 | 목적 | 실행 비용 |
50
+ |-------------|-------|---------|------------|
51
+ | `hooks/critical-action-check.sh` | PreToolUse | 위험한 명령 차단 | 로컬 (무료), 차단 시 메시지 |
52
+ | `hooks/post-edit-format.sh` | PostToolUse | 편집된 파일 자동 포맷 | 로컬 (무료) |
53
+ | `hooks/compact-suggest.sh` | PostToolUse | 3단계 컴팩션 경고 (25 권고 / 50 경고 / 75 위험) | 로컬 (무료), 티어당 ~30 토큰 |
54
+ | `hooks/notification.sh` | Notification | 데스크톱 알림 | 로컬 (무료) |
55
+ | `hooks/session-start.sh` | SessionStart | 환경변수 설정 + 예산 알림 + 세션 알림 | 로컬 (무료), 예산 컨텍스트 ~40 입력 토큰 |
56
+ | `hooks/session-cleanup.sh` | SessionEnd | 세션에서 비밀 정보 제거 | 로컬 (무료) |
57
+ | `hooks/pre-compact.sh` | PreCompact | 컴팩트 전 상태 저장 | 로컬 (무료) |
58
+ | `hooks/retry-check.sh` | Stop | 연속 2회 실패 시 차단 (builder) | 로컬 (무료), 에스컬레이션 메시지 |
59
+ | `hooks/stop-collect-context.sh` | Stop | 중단 시 실패 컨텍스트 수집 (선택) | 로컬 (무료) |
60
+ | `hooks/readonly-check.sh` | PreToolUse | 읽기 전용 (reviewer) | 로컬 (무료), 차단 시 메시지 |
61
+ | `hooks/tool-failure-log.sh` | PostToolUseFailure | 도구 실패 로깅 | 로컬 (무료) |
62
+
63
+ **비용 설명:** 모든 Hook은 로컬에서 실행되어 API 호출이 없습니다. Hook이 Claude에게 메시지를 표시할 때만(예: 명령 차단, 컴팩션 제안) 해당 메시지가 입력 토큰을 소비하며, 이러한 메시지는 의도적으로 간결합니다.
64
+
65
+ ## scrub-secrets.js
66
+
67
+ **목적:** 15개 이상의 비밀 패턴을 스캔하고 교체합니다.
68
+
69
+ **사용법:**
70
+ ```bash
71
+ # 입력 파이프
72
+ cat session.md | node scrub-secrets.js > clean.md
73
+
74
+ # /session-save에 의해 자동으로 사용됨
75
+ ```
76
+
77
+ **감지된 패턴:**
78
+ - OpenAI, Anthropic, Stripe, GitHub, AWS 키
79
+ - 자격 증명이 포함된 데이터베이스 URL
80
+ - JWT 토큰
81
+ - 비밀번호/비밀 필드
82
+ - 개인 키 (PEM)
83
+
84
+ ## create-branch.sh
85
+
86
+ **목적:** 결정론적 브랜치 명명.
87
+
88
+ **사용법:**
89
+ ```bash
90
+ ./create-branch.sh feature user-profile
91
+ # 생성: feature/user-profile
92
+
93
+ ./create-branch.sh fix login-bug
94
+ # 생성: fix/login-bug
95
+ ```
96
+
97
+ **유형:** feature, fix, hotfix, refactor, chore
98
+
99
+ ## analyze-failures.sh
100
+
101
+ **목적:** 축적된 도구 실패 로그를 분석하고 반복되는 패턴을 추출합니다.
102
+
103
+ **사용법:**
104
+ ```bash
105
+ # 최근 50개 실패 분석
106
+ ./analyze-failures.sh 50
107
+
108
+ # /analyze-failures 명령어에 의해 사용됨
109
+ # LLM 분석 전 로그 전처리
110
+ ```
111
+
112
+ **출력:** LLM 분석을 위해 포맷된 실패 요약
113
+
114
+ ## commit.sh
115
+
116
+ **목적:** Conventional Commit 형식 지정.
117
+
118
+ **사용법:**
119
+ ```bash
120
+ ./commit.sh feat auth "add JWT refresh tokens"
121
+ # 커밋: feat(auth): add JWT refresh tokens
122
+ ```
123
+
124
+ **유형:** feat, fix, docs, style, refactor, perf, test, chore
125
+
126
+ ## 왜 스크립트인가요?
127
+
128
+ | 접근 방식 | 실행 비용 | 신뢰성 | 속도 |
129
+ |----------|----------|----------|-------|
130
+ | Claude 프롬프트 | Quota 소비 | 모델 의존적 | API 왕복 필요 |
131
+ | 쉘 스크립트 | 로컬 (무료) | 규칙 기반 반복 실행 가능 | 즉시 |
132
+
133
+ **장점:** 스크립트는 결정론적 작업을 quota 소비 없이 로컬에서 처리하여, Claude가 창의적/추론 작업에 집중할 수 있게 합니다.
134
+
135
+ ## 커스텀 스크립트 추가
136
+
137
+ ```bash
138
+ #!/bin/bash
139
+ # my-script.sh - Description
140
+
141
+ set -e # 오류 발생 시 종료
142
+
143
+ # 여기에 결정론적 로직 작성
144
+ ```
145
+
146
+ 실행 가능하게 만들기:
147
+ ```bash
148
+ chmod +x scripts/my-script.sh
149
+ # 설치 경로: chmod +x ~/.claude/scripts/my-script.sh
150
+ ```
@@ -0,0 +1,150 @@
1
+ > **[한국어 버전](README.ko.md)**
2
+
3
+ # Scripts Directory
4
+
5
+ ## Purpose
6
+ Contains deterministic scripts for operations that shouldn't be "prompted" - they should be "coded".
7
+
8
+ **Philosophy:** "Don't prompt what you can code."
9
+
10
+ > **Path note:** In this repository, scripts live under `scripts/`. After installation, they run from `~/.claude/scripts/`.
11
+
12
+ ## Universal Scripts
13
+
14
+ | Script | Purpose | Benefit |
15
+ |--------|---------|---------|
16
+ | `verify.sh` | Runtime-adaptive verification (build+test+lint) | Deterministic execution, no prompting needed |
17
+ | `build.sh` | Runtime-adaptive build | Auto-detects runtime, eliminates model guessing |
18
+ | `test.sh` | Runtime-adaptive test | Direct execution with runtime-specific commands |
19
+ | `lint.sh` | Runtime-adaptive lint | Local processing, instant results |
20
+
21
+ ## Runtime Detection Layer
22
+
23
+ ```
24
+ runtime/
25
+ ├── detect.sh # Auto-detect project runtime (JSON output)
26
+ └── adapters/
27
+ ├── _interface.sh # Adapter contract definition
28
+ ├── jvm.sh # Java/Kotlin (Gradle/Maven)
29
+ ├── node.sh # TypeScript/JS (npm/pnpm/yarn/bun)
30
+ ├── go.sh # Go modules
31
+ ├── rust.sh # Cargo
32
+ ├── python.sh # pip/poetry/uv
33
+ ├── generic.sh # Makefile fallback
34
+ └── _template.sh # Template for new adapters
35
+ ```
36
+
37
+ ## Utility Scripts
38
+
39
+ | Script | Purpose | Benefit |
40
+ |--------|---------|---------|
41
+ | `scrub-secrets.js` | Remove secrets from text | Security + no token exposure |
42
+ | `analyze-failures.sh` | Analyze tool failure logs and extract patterns | Preprocesses logs before LLM analysis |
43
+ | `create-branch.sh` | Deterministic branch creation | Consistent naming, no guessing |
44
+ | `commit.sh` | Conventional commit format | Enforces convention automatically |
45
+ | `snapshot.sh` | Atomic rollback for `/do` commands | Deterministic `git stash` with depth guard + label safety |
46
+
47
+ ## Hooks Directory
48
+
49
+ | Hook Script | Event | Purpose | Execution Cost |
50
+ |-------------|-------|---------|----------------|
51
+ | `hooks/critical-action-check.sh` | PreToolUse | Block dangerous commands | Local (zero), blocking message if triggered |
52
+ | `hooks/post-edit-format.sh` | PostToolUse | Auto-format edited files | Local (zero) |
53
+ | `hooks/compact-suggest.sh` | PostToolUse | 3-tier compact warnings (25 advisory / 50 warning / 75 critical) | Local (zero), ~30 tokens per tier |
54
+ | `hooks/notification.sh` | Notification | Desktop alerts | Local (zero) |
55
+ | `hooks/session-start.sh` | SessionStart | Env setup + budget reminder + session notify | Local (zero), ~40 input tokens for budget context |
56
+ | `hooks/session-cleanup.sh` | SessionEnd | Scrub secrets from sessions | Local (zero) |
57
+ | `hooks/pre-compact.sh` | PreCompact | Save state before compaction | Local (zero) |
58
+ | `hooks/retry-check.sh` | Stop | 2-retry cap (builder) | Local (zero), escalation message if triggered |
59
+ | `hooks/stop-collect-context.sh` | Stop | Collect failure context on interruption (optional) | Local (zero) |
60
+ | `hooks/readonly-check.sh` | PreToolUse | Read-only (reviewer) | Local (zero), blocking message if triggered |
61
+ | `hooks/tool-failure-log.sh` | PostToolUseFailure | Log tool failures | Local (zero) |
62
+
63
+ **Note:** Hook execution itself is free (runs locally). Only their output messages (when displayed to Claude) consume minimal input tokens.
64
+
65
+ ## scrub-secrets.js
66
+
67
+ **Purpose:** Scan and replace 15+ secret patterns.
68
+
69
+ **Usage:**
70
+ ```bash
71
+ # Pipe input
72
+ cat session.md | node scrub-secrets.js > clean.md
73
+
74
+ # Used automatically by /session-save
75
+ ```
76
+
77
+ **Patterns detected:**
78
+ - OpenAI, Anthropic, Stripe, GitHub, AWS keys
79
+ - Database URLs with credentials
80
+ - JWT tokens
81
+ - Password/secret fields
82
+ - Private keys (PEM)
83
+
84
+ ## create-branch.sh
85
+
86
+ **Purpose:** Deterministic branch naming.
87
+
88
+ **Usage:**
89
+ ```bash
90
+ ./create-branch.sh feature user-profile
91
+ # Creates: feature/user-profile
92
+
93
+ ./create-branch.sh fix login-bug
94
+ # Creates: fix/login-bug
95
+ ```
96
+
97
+ **Types:** feature, fix, hotfix, refactor, chore
98
+
99
+ ## analyze-failures.sh
100
+
101
+ **Purpose:** Analyze accumulated tool failure logs and extract recurring patterns.
102
+
103
+ **Usage:**
104
+ ```bash
105
+ # Analyze last 50 failures
106
+ ./analyze-failures.sh 50
107
+
108
+ # Used by /analyze-failures command
109
+ # Preprocesses logs before LLM analysis
110
+ ```
111
+
112
+ **Output:** Formatted failure summary ready for LLM analysis
113
+
114
+ ## commit.sh
115
+
116
+ **Purpose:** Conventional commit formatting.
117
+
118
+ **Usage:**
119
+ ```bash
120
+ ./commit.sh feat auth "add JWT refresh tokens"
121
+ # Commits: feat(auth): add JWT refresh tokens
122
+ ```
123
+
124
+ **Types:** feat, fix, docs, style, refactor, perf, test, chore
125
+
126
+ ## Why Scripts?
127
+
128
+ | Approach | Execution Cost | Reliability | Speed |
129
+ |----------|---------------|----------|-------|
130
+ | Prompt Claude | Consumes quota | Model-dependent | Requires API round-trip |
131
+ | Shell script | Local (zero) | Rule-based and repeatable | Instant |
132
+
133
+ **Advantage:** Scripts handle deterministic operations locally without consuming quota, freeing Claude to focus on creative/reasoning tasks.
134
+
135
+ ## Adding Custom Scripts
136
+
137
+ ```bash
138
+ #!/bin/bash
139
+ # my-script.sh - Description
140
+
141
+ set -e # Exit on error
142
+
143
+ # Your deterministic logic here
144
+ ```
145
+
146
+ Make executable:
147
+ ```bash
148
+ chmod +x scripts/my-script.sh
149
+ # Installed path: chmod +x ~/.claude/scripts/my-script.sh
150
+ ```
@@ -0,0 +1,145 @@
1
+ #!/bin/bash
2
+ # analyze-failures.sh
3
+ # Failure log analysis and pattern extraction
4
+ # Usage: bash scripts/analyze-failures.sh [limit]
5
+
6
+ set -euo pipefail
7
+
8
+ LIMIT="${1:-50}"
9
+ LOG_FILE="$HOME/.claude/logs/tool-failures.log"
10
+
11
+ if [ ! -f "$LOG_FILE" ]; then
12
+ echo "✅ No failure logs found. Your tools are working perfectly!"
13
+ exit 0
14
+ fi
15
+
16
+ TOTAL_COUNT=$(wc -l < "$LOG_FILE" | tr -d ' ')
17
+
18
+ if [ "$TOTAL_COUNT" -eq 0 ]; then
19
+ echo "✅ No failure logs found. Your tools are working perfectly!"
20
+ exit 0
21
+ fi
22
+
23
+ echo "## Failure Analysis"
24
+ echo ""
25
+ echo "**Total failures logged**: $TOTAL_COUNT"
26
+ echo "**Analyzing last**: $LIMIT"
27
+ echo ""
28
+
29
+ # Extract and analyze the last N entries
30
+ FAILURES=$(tail -"$LIMIT" "$LOG_FILE")
31
+
32
+ echo "### Top Failures"
33
+ echo ""
34
+
35
+ # Group errors by tool and calculate frequency
36
+ echo "$FAILURES" | awk -F'|' '
37
+ {
38
+ # Extract tool name from first field (after "Tool: ")
39
+ tool = $1
40
+ sub(/.*Tool: /, "", tool)
41
+ gsub(/^[[:space:]]+|[[:space:]]+$/, "", tool)
42
+
43
+ # Extract error from second field (after "Error: ")
44
+ error = $2
45
+ sub(/.*Error: /, "", error)
46
+ gsub(/^[[:space:]]+|[[:space:]]+$/, "", error)
47
+
48
+ # Normalize error messages to find patterns
49
+ if (error ~ /old_string.*not found/) {
50
+ error = "old_string not found"
51
+ } else if (error ~ /pattern.*syntax/) {
52
+ error = "pattern syntax error"
53
+ } else if (error ~ /permission denied/i) {
54
+ error = "permission denied"
55
+ } else if (error ~ /file not found|no such file/i) {
56
+ error = "file not found"
57
+ } else if (error ~ /timeout/i) {
58
+ error = "timeout"
59
+ } else if (error ~ /exceeds maximum.*size/) {
60
+ error = "file size exceeds limit"
61
+ }
62
+
63
+ # Store tool and error separately
64
+ key = NR
65
+ tool_map[key] = tool
66
+ error_map[key] = error
67
+
68
+ # Count occurrences
69
+ combo = tool ":::" error
70
+ count[combo]++
71
+ tool_count[tool]++
72
+ }
73
+ END {
74
+ # Create sorted array by count
75
+ n = 0
76
+ for (c in count) {
77
+ sorted[n] = count[c] ":::" c
78
+ n++
79
+ }
80
+
81
+ # Bubble sort by count (descending)
82
+ for (i = 0; i < n; i++) {
83
+ for (j = i + 1; j < n; j++) {
84
+ split(sorted[i], a, ":::")
85
+ split(sorted[j], b, ":::")
86
+ if (a[1] + 0 < b[1] + 0) {
87
+ temp = sorted[i]
88
+ sorted[i] = sorted[j]
89
+ sorted[j] = temp
90
+ }
91
+ }
92
+ }
93
+
94
+ # Print top 10
95
+ limit = (n < 10) ? n : 10
96
+ for (i = 0; i < limit; i++) {
97
+ split(sorted[i], parts, ":::")
98
+ cnt = parts[1]
99
+ tool = parts[2]
100
+ err = parts[3]
101
+ printf "%d. **%s**: \"%s\" (%d times)\n", i+1, tool, err, cnt
102
+ }
103
+
104
+ print ""
105
+ print "### Most Problematic Tools"
106
+ print ""
107
+
108
+ # Create sorted array for tools
109
+ m = 0
110
+ for (t in tool_count) {
111
+ tool_sorted[m] = tool_count[t] ":::" t
112
+ m++
113
+ }
114
+
115
+ # Bubble sort by tool count (descending)
116
+ for (i = 0; i < m; i++) {
117
+ for (j = i + 1; j < m; j++) {
118
+ split(tool_sorted[i], a, ":::")
119
+ split(tool_sorted[j], b, ":::")
120
+ if (a[1] + 0 < b[1] + 0) {
121
+ temp = tool_sorted[i]
122
+ tool_sorted[i] = tool_sorted[j]
123
+ tool_sorted[j] = temp
124
+ }
125
+ }
126
+ }
127
+
128
+ # Print top 5 tools
129
+ tool_limit = (m < 5) ? m : 5
130
+ for (i = 0; i < tool_limit; i++) {
131
+ split(tool_sorted[i], parts, ":::")
132
+ printf "- **%s**: %d failures\n", parts[2], parts[1]
133
+ }
134
+ }'
135
+
136
+ echo ""
137
+ echo "---"
138
+ echo ""
139
+ echo "💡 **Recommendations**:"
140
+ echo ""
141
+ echo "- Review frequent failures and update your approach"
142
+ echo "- Consider saving learned patterns with \`/learn [pattern]\`"
143
+ echo "- Use \`/do-sonnet\` or \`/plan\` for complex tasks to reduce trial-and-error"
144
+ echo ""
145
+ echo "📝 **Clear logs**: \`rm $LOG_FILE\`"
@@ -0,0 +1,34 @@
1
+ #!/bin/bash
2
+ # build.sh - Universal Build
3
+ # Delegates to runtime-specific adapter
4
+ set -euo pipefail
5
+
6
+ PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ RUNTIME_DIR="$SCRIPT_DIR/runtime"
9
+
10
+ # Detect runtime
11
+ RUNTIME=$("$RUNTIME_DIR/detect.sh" "$@")
12
+
13
+ # Parse JSON - prefer jq, fallback to bash
14
+ parse_json() {
15
+ local key="$1"
16
+ if command -v jq &>/dev/null; then
17
+ echo "$RUNTIME" | jq -r ".$key"
18
+ else
19
+ echo "$RUNTIME" | sed 's/.*"'"$key"'":"\([^"]*\)".*/\1/'
20
+ fi
21
+ }
22
+
23
+ ADAPTER=$(parse_json adapter)
24
+ RUNTIME_NAME=$(parse_json runtime)
25
+ TOOL_NAME=$(parse_json tool)
26
+
27
+ echo "🔍 Detected: $RUNTIME_NAME ($TOOL_NAME)"
28
+
29
+ # Source adapter
30
+ source "$RUNTIME_DIR/adapters/$ADAPTER"
31
+
32
+ # Execute
33
+ echo "🔨 Building..."
34
+ adapter_build