claude-commit 0.1.1__tar.gz → 0.3.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-commit
3
- Version: 0.1.1
3
+ Version: 0.3.0
4
4
  Summary: AI-powered git commit message generator using Claude Agent SDK
5
5
  Author-email: Johannlai <johannli666@gmail.com>
6
6
  License: MIT
@@ -27,7 +27,7 @@ Requires-Dist: black>=23.0.0; extra == "dev"
27
27
  Requires-Dist: mypy>=1.0.0; extra == "dev"
28
28
  Dynamic: license-file
29
29
 
30
- # claude-commit
30
+ # claude-commit [![PyPI version](https://badge.fury.io/py/claude-commit.svg)](https://badge.fury.io/py/claude-commit)
31
31
 
32
32
  🤖 AI-powered git commit message generator using Claude Agent SDK and Claude Code CLI
33
33
 
@@ -35,23 +35,9 @@ Dynamic: license-file
35
35
 
36
36
  `claude-commit` uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
37
37
 
38
- ## Quick Start
38
+ ## Demo
39
39
 
40
- **Install:**
41
- ```bash
42
- pip install claude-commit
43
-
44
- # Required dependency
45
- npm install -g @anthropic-ai/claude-code
46
- ```
47
-
48
- **Use:**
49
- ```bash
50
- git add .
51
- claude-commit --commit
52
- ```
53
-
54
- That's it! Claude will analyze your changes and create a commit.
40
+ [![asciicast](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L.svg)](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L?autoplay=1&speed=3)
55
41
 
56
42
  ## Installation
57
43
 
@@ -61,19 +47,44 @@ That's it! Claude will analyze your changes and create a commit.
61
47
  - Node.js
62
48
  - Git
63
49
 
64
- ### Install Steps
50
+ ### Recommended: pipx (for CLI tools)
51
+
52
+ `pipx` is the **best way to install Python CLI tools**. It creates isolated environments automatically:
65
53
 
66
54
  ```bash
67
- # 1. Install Claude Code CLI (required)
68
- npm install -g @anthropic-ai/claude-code
55
+ # 1. Install pipx
56
+ brew install pipx # macOS
57
+ # or
58
+ pip install --user pipx # Linux/Windows
59
+ pipx ensurepath
69
60
 
70
- # 2. Install claude-commit
71
- pip install claude-commit
61
+ # 2. Install Claude Code CLI (required)
62
+ npm install -g @anthropic-ai/claude-code
72
63
 
73
- # Or use pipx for isolation
64
+ # 3. Install claude-commit
74
65
  pipx install claude-commit
75
66
  ```
76
67
 
68
+ ### Alternative: pip
69
+
70
+ If you prefer pip, use one of these methods:
71
+
72
+ **Option 1: User installation (no admin rights needed)**
73
+ ```bash
74
+ # Install to user directory
75
+ pip install --user claude-commit
76
+
77
+ # Make sure ~/.local/bin is in your PATH
78
+ export PATH="$HOME/.local/bin:$PATH"
79
+ ```
80
+
81
+ **Option 2: Virtual environment**
82
+ ```bash
83
+ python3 -m venv ~/.venvs/claude-commit
84
+ source ~/.venvs/claude-commit/bin/activate
85
+ pip install claude-commit
86
+ ```
87
+
77
88
  ### Authentication
78
89
 
79
90
  `claude-commit` supports two ways to authenticate with Claude:
@@ -138,7 +149,7 @@ Create shortcuts for common commands:
138
149
  # Install to your shell config
139
150
  claude-commit alias install
140
151
 
141
- # Activate in current terminal
152
+ # Activate in current terminal. Very important!
142
153
  source ~/.zshrc # zsh
143
154
  source ~/.bashrc # bash
144
155
  ```
@@ -238,28 +249,103 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
238
249
 
239
250
  ## Troubleshooting
240
251
 
241
- **Claude Code not found?**
252
+ ### Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
253
+
254
+ ```
255
+ Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
256
+ Error output: Check stderr output for details
257
+ Traceback (most recent call last):
258
+ ```
259
+
260
+ **Solution**: This error means you haven't authenticated with Claude. Choose one method:
261
+
262
+ **Method A: Official Claude Code login (recommended)**
263
+ ```bash
264
+ claude
265
+ ```
266
+
267
+ **Method B: Set custom API endpoint**
268
+ ```bash
269
+ export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"
270
+ export ANTHROPIC_AUTH_TOKEN="your-auth-token"
271
+ # model name (optional)
272
+ export ANTHROPIC_MODEL="your-model-name"
273
+
274
+ # Add to ~/.zshrc or ~/.bashrc to persist
275
+ echo 'export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"' >> ~/.zshrc
276
+ echo 'export ANTHROPIC_AUTH_TOKEN="your-auth-token"' >> ~/.zshrc
277
+ ```
278
+
279
+ ### "externally-managed-environment" error (macOS/Linux)
280
+
281
+ If you see this error when using `pip install`:
282
+
283
+ ```
284
+ error: externally-managed-environment
285
+ ```
286
+
287
+ **Solution**: Use `pipx` (recommended for CLI tools):
288
+ ```bash
289
+ brew install pipx
290
+ pipx install claude-commit
291
+ ```
292
+
293
+ Or use `pip install --user`:
294
+ ```bash
295
+ pip install --user claude-commit
296
+ ```
297
+
298
+ **Why this happens**: Modern Python installations (Python 3.11+) protect the system Python to prevent conflicts. This is not a bug in `claude-commit`.
299
+
300
+ ### Claude Code not found
301
+
242
302
  ```bash
243
303
  npm install -g @anthropic-ai/claude-code
244
304
  ```
245
305
 
246
- **No changes detected?**
306
+ ### No changes detected
307
+
247
308
  ```bash
248
309
  git add . # stage changes
249
310
  # or
250
311
  claude-commit --all # include unstaged
251
312
  ```
252
313
 
253
- **Analysis too slow?**
314
+ ### Analysis too slow
315
+
254
316
  ```bash
255
317
  claude-commit --max-diff-lines 200
256
318
  ```
257
319
 
320
+ ### Command not found after installation
321
+
322
+ If `claude-commit` is not found after installation:
323
+
324
+ **With pipx:**
325
+ ```bash
326
+ pipx ensurepath
327
+ # Restart your terminal
328
+ ```
329
+
330
+ **With pip --user:**
331
+ ```bash
332
+ # Add to ~/.zshrc or ~/.bashrc
333
+ export PATH="$HOME/.local/bin:$PATH"
334
+ source ~/.zshrc # or ~/.bashrc
335
+ ```
336
+
337
+ ### Aliases not working
338
+
339
+ ```bash
340
+ claude-commit alias install
341
+ source ~/.zshrc # or ~/.bashrc
342
+ ```
343
+
258
344
  ## Development
259
345
 
260
346
  ```bash
261
347
  # Clone and setup
262
- git clone https://github.com/yourusername/claude-commit.git
348
+ git clone https://github.com/JohannLai/claude-commit.git
263
349
  cd claude-commit
264
350
  python -m venv venv
265
351
  source venv/bin/activate
@@ -285,7 +371,9 @@ MIT License - see [LICENSE](LICENSE) file
285
371
 
286
372
  - [Claude Agent SDK](https://docs.anthropic.com/en/docs/claude-code/agent-sdk)
287
373
  - [Conventional Commits](https://www.conventionalcommits.org/)
288
- - [Issue Tracker](https://github.com/yourusername/claude-commit/issues)
374
+ - [GitHub Repository](https://github.com/JohannLai/claude-commit)
375
+ - [PyPI Package](https://pypi.org/project/claude-commit/)
376
+ - [Issue Tracker](https://github.com/JohannLai/claude-commit/issues)
289
377
 
290
378
  ---
291
379
 
@@ -1,4 +1,4 @@
1
- # claude-commit
1
+ # claude-commit [![PyPI version](https://badge.fury.io/py/claude-commit.svg)](https://badge.fury.io/py/claude-commit)
2
2
 
3
3
  🤖 AI-powered git commit message generator using Claude Agent SDK and Claude Code CLI
4
4
 
@@ -6,23 +6,9 @@
6
6
 
7
7
  `claude-commit` uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
8
8
 
9
- ## Quick Start
9
+ ## Demo
10
10
 
11
- **Install:**
12
- ```bash
13
- pip install claude-commit
14
-
15
- # Required dependency
16
- npm install -g @anthropic-ai/claude-code
17
- ```
18
-
19
- **Use:**
20
- ```bash
21
- git add .
22
- claude-commit --commit
23
- ```
24
-
25
- That's it! Claude will analyze your changes and create a commit.
11
+ [![asciicast](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L.svg)](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L?autoplay=1&speed=3)
26
12
 
27
13
  ## Installation
28
14
 
@@ -32,19 +18,44 @@ That's it! Claude will analyze your changes and create a commit.
32
18
  - Node.js
33
19
  - Git
34
20
 
35
- ### Install Steps
21
+ ### Recommended: pipx (for CLI tools)
22
+
23
+ `pipx` is the **best way to install Python CLI tools**. It creates isolated environments automatically:
36
24
 
37
25
  ```bash
38
- # 1. Install Claude Code CLI (required)
39
- npm install -g @anthropic-ai/claude-code
26
+ # 1. Install pipx
27
+ brew install pipx # macOS
28
+ # or
29
+ pip install --user pipx # Linux/Windows
30
+ pipx ensurepath
40
31
 
41
- # 2. Install claude-commit
42
- pip install claude-commit
32
+ # 2. Install Claude Code CLI (required)
33
+ npm install -g @anthropic-ai/claude-code
43
34
 
44
- # Or use pipx for isolation
35
+ # 3. Install claude-commit
45
36
  pipx install claude-commit
46
37
  ```
47
38
 
39
+ ### Alternative: pip
40
+
41
+ If you prefer pip, use one of these methods:
42
+
43
+ **Option 1: User installation (no admin rights needed)**
44
+ ```bash
45
+ # Install to user directory
46
+ pip install --user claude-commit
47
+
48
+ # Make sure ~/.local/bin is in your PATH
49
+ export PATH="$HOME/.local/bin:$PATH"
50
+ ```
51
+
52
+ **Option 2: Virtual environment**
53
+ ```bash
54
+ python3 -m venv ~/.venvs/claude-commit
55
+ source ~/.venvs/claude-commit/bin/activate
56
+ pip install claude-commit
57
+ ```
58
+
48
59
  ### Authentication
49
60
 
50
61
  `claude-commit` supports two ways to authenticate with Claude:
@@ -109,7 +120,7 @@ Create shortcuts for common commands:
109
120
  # Install to your shell config
110
121
  claude-commit alias install
111
122
 
112
- # Activate in current terminal
123
+ # Activate in current terminal. Very important!
113
124
  source ~/.zshrc # zsh
114
125
  source ~/.bashrc # bash
115
126
  ```
@@ -209,28 +220,103 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
209
220
 
210
221
  ## Troubleshooting
211
222
 
212
- **Claude Code not found?**
223
+ ### Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
224
+
225
+ ```
226
+ Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
227
+ Error output: Check stderr output for details
228
+ Traceback (most recent call last):
229
+ ```
230
+
231
+ **Solution**: This error means you haven't authenticated with Claude. Choose one method:
232
+
233
+ **Method A: Official Claude Code login (recommended)**
234
+ ```bash
235
+ claude
236
+ ```
237
+
238
+ **Method B: Set custom API endpoint**
239
+ ```bash
240
+ export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"
241
+ export ANTHROPIC_AUTH_TOKEN="your-auth-token"
242
+ # model name (optional)
243
+ export ANTHROPIC_MODEL="your-model-name"
244
+
245
+ # Add to ~/.zshrc or ~/.bashrc to persist
246
+ echo 'export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"' >> ~/.zshrc
247
+ echo 'export ANTHROPIC_AUTH_TOKEN="your-auth-token"' >> ~/.zshrc
248
+ ```
249
+
250
+ ### "externally-managed-environment" error (macOS/Linux)
251
+
252
+ If you see this error when using `pip install`:
253
+
254
+ ```
255
+ error: externally-managed-environment
256
+ ```
257
+
258
+ **Solution**: Use `pipx` (recommended for CLI tools):
259
+ ```bash
260
+ brew install pipx
261
+ pipx install claude-commit
262
+ ```
263
+
264
+ Or use `pip install --user`:
265
+ ```bash
266
+ pip install --user claude-commit
267
+ ```
268
+
269
+ **Why this happens**: Modern Python installations (Python 3.11+) protect the system Python to prevent conflicts. This is not a bug in `claude-commit`.
270
+
271
+ ### Claude Code not found
272
+
213
273
  ```bash
214
274
  npm install -g @anthropic-ai/claude-code
215
275
  ```
216
276
 
217
- **No changes detected?**
277
+ ### No changes detected
278
+
218
279
  ```bash
219
280
  git add . # stage changes
220
281
  # or
221
282
  claude-commit --all # include unstaged
222
283
  ```
223
284
 
224
- **Analysis too slow?**
285
+ ### Analysis too slow
286
+
225
287
  ```bash
226
288
  claude-commit --max-diff-lines 200
227
289
  ```
228
290
 
291
+ ### Command not found after installation
292
+
293
+ If `claude-commit` is not found after installation:
294
+
295
+ **With pipx:**
296
+ ```bash
297
+ pipx ensurepath
298
+ # Restart your terminal
299
+ ```
300
+
301
+ **With pip --user:**
302
+ ```bash
303
+ # Add to ~/.zshrc or ~/.bashrc
304
+ export PATH="$HOME/.local/bin:$PATH"
305
+ source ~/.zshrc # or ~/.bashrc
306
+ ```
307
+
308
+ ### Aliases not working
309
+
310
+ ```bash
311
+ claude-commit alias install
312
+ source ~/.zshrc # or ~/.bashrc
313
+ ```
314
+
229
315
  ## Development
230
316
 
231
317
  ```bash
232
318
  # Clone and setup
233
- git clone https://github.com/yourusername/claude-commit.git
319
+ git clone https://github.com/JohannLai/claude-commit.git
234
320
  cd claude-commit
235
321
  python -m venv venv
236
322
  source venv/bin/activate
@@ -256,7 +342,9 @@ MIT License - see [LICENSE](LICENSE) file
256
342
 
257
343
  - [Claude Agent SDK](https://docs.anthropic.com/en/docs/claude-code/agent-sdk)
258
344
  - [Conventional Commits](https://www.conventionalcommits.org/)
259
- - [Issue Tracker](https://github.com/yourusername/claude-commit/issues)
345
+ - [GitHub Repository](https://github.com/JohannLai/claude-commit)
346
+ - [PyPI Package](https://pypi.org/project/claude-commit/)
347
+ - [Issue Tracker](https://github.com/JohannLai/claude-commit/issues)
260
348
 
261
349
  ---
262
350
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "claude-commit"
7
- version = "0.1.1"
7
+ version = "0.3.0"
8
8
  description = "AI-powered git commit message generator using Claude Agent SDK"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -6,29 +6,28 @@ Analyzes your git repository changes and generates a meaningful commit message
6
6
  using Claude's AI capabilities.
7
7
  """
8
8
 
9
- import sys
10
- import asyncio
11
9
  import argparse
10
+ import asyncio
11
+ import sys
12
+ import time
12
13
  from pathlib import Path
13
14
  from typing import Optional
14
- import time
15
15
 
16
- from rich.console import Console
17
- from rich.panel import Panel
18
- from rich.progress import Progress, SpinnerColumn, TextColumn
19
16
  import pyperclip
20
-
21
17
  from claude_agent_sdk import (
22
- query,
23
- ClaudeAgentOptions,
24
18
  AssistantMessage,
25
- TextBlock,
26
- ToolUseBlock,
27
- ToolResultBlock,
28
- ResultMessage,
19
+ ClaudeAgentOptions,
29
20
  CLINotFoundError,
30
21
  ProcessError,
22
+ ResultMessage,
23
+ TextBlock,
24
+ ToolResultBlock,
25
+ ToolUseBlock,
26
+ query,
31
27
  )
28
+ from rich.console import Console
29
+ from rich.panel import Panel
30
+ from rich.progress import Progress, SpinnerColumn, TextColumn
32
31
 
33
32
  from .config import Config, resolve_alias
34
33
 
@@ -40,10 +39,42 @@ SYSTEM_PROMPT = """You are an expert software engineer tasked with analyzing cod
40
39
  Your goal: Generate a clear, accurate, and meaningful commit message that captures the essence of the changes.
41
40
 
42
41
  Available tools you can use:
43
- - Bash: Run git commands (git diff, git status, git log, etc.) and other shell commands
44
- - Read: Read any file in the repository to understand context
45
- - Grep: Search for patterns across files to understand relationships
46
- - Glob: Find files matching patterns
42
+
43
+ 1. **Bash**: Run git commands and shell commands
44
+ - `git log`, `git status`, `git diff`, `git show`
45
+ - Any shell commands for system inspection
46
+
47
+ 2. **Read**: Read file contents to understand context
48
+ - Read modified files to understand their purpose
49
+ - Read related files to understand dependencies
50
+ - Can specify line ranges for large files: `{"file_path": "file.py", "offset": 10, "limit": 50}`
51
+ - Supports images (returns base64 encoded data)
52
+
53
+ 3. **Grep** (⭐ POWERFUL - use extensively!): Search patterns across files
54
+ - Search for function/class definitions: `grep -n "def function_name"` or `grep -n "class ClassName"`
55
+ - Find where functions are called: `grep -n "function_name("`
56
+ - Search for imports: `grep -n "from module import"` or `grep -n "import package"`
57
+ - Find variable usage: `grep -n "variable_name"`
58
+ - Search with context: use -A (after), -B (before), -C (context) flags
59
+ - Case-insensitive search: use -i flag
60
+ - Search in specific file types: use --type flag (e.g., `--type py`)
61
+ - Count occurrences: use --output_mode count
62
+ - Limit results: use head_limit parameter
63
+ - **Why Grep is powerful**: It helps you understand code relationships WITHOUT reading entire files
64
+ * See where a modified function is called (usage impact)
65
+ * Find related functions or classes (context)
66
+ * Understand dependencies (imports and references)
67
+ * Discover patterns across the codebase
68
+
69
+ 4. **Glob**: Find files matching patterns
70
+ - `*.py`, `**/*.js`, `**/test_*.py`
71
+ - Useful to find related files (e.g., test files, config files)
72
+
73
+ 5. **Edit** (⭐ USEFUL for analysis): Make precise edits
74
+ - **NOTE**: You won't actually edit files, but you can use this tool's pattern matching to understand complex changes
75
+ - Helps identify exact strings in files when git diff is unclear
76
+ - Can search for specific code patterns: `{"file_path": "file.py", "old_string": "pattern to find"}`
77
+ - Useful when you need to understand multi-line changes or context around changes
47
78
 
48
79
  Analysis approach (you decide what's necessary):
49
80
  1. IMPORTANT: First check recent commit history (git log -10 --oneline or git log -10 --pretty=format:"%s") to understand the existing commit message style
@@ -56,12 +87,35 @@ Analysis approach (you decide what's necessary):
56
87
  - The purpose and context of changed functions/classes
57
88
  - How the changes fit into the larger codebase
58
89
  - The intent behind the modifications
59
- 4. Search for related code (grep) to understand dependencies and impacts
90
+ 4. **USE GREP extensively** to understand code relationships (examples):
91
+ - Modified function `process_data()`? → `grep -n "process_data("` to see where it's called
92
+ - New class `UserManager`? → `grep -n "class.*Manager"` to find similar patterns
93
+ - Imports changed? → `grep -n "from new_module import"` to see usage
94
+ - Refactoring? → `grep --output_mode count "old_pattern"` to understand scope
95
+ - Want context? → `grep -C 5 "function_name"` to see surrounding code
96
+ - Find test files? → `grep -n "test_function_name"` or use glob `**/test_*.py`
60
97
  5. Consider the scope: is this a feature, fix, refactor, docs, chore, etc.?
61
98
 
99
+ **Pro tip**: Grep is faster than reading entire files. Use it to quickly assess impact before deciding which files to read in detail.
100
+
62
101
  Commit message guidelines:
63
- - **FOLLOW THE EXISTING FORMAT**: Match the style, language, and conventions used in recent commits
102
+ - **MUST FOLLOW THE EXISTING FORMAT**: Match the style, language, and conventions used in recent commits
64
103
  - If no clear pattern exists in history, use conventional commits format (feat:, fix:, docs:, refactor:, test:, chore:, style:, perf:)
104
+ - feat: for new features
105
+ - fix: for bug fixes
106
+ - docs: for documentation changes
107
+ - refactor: for code refactoring
108
+ - test: for test changes
109
+ - chore: for chore changes
110
+ - style: for style changes
111
+ - perf: for performance improvements
112
+ - build: for build changes
113
+ - ci: for CI/CD changes
114
+ - revert: for reverting changes
115
+ - feat!: for breaking changes
116
+ - fix!: for breaking bug fixes
117
+ - perf!: for breaking performance improvements
118
+ - chore!: for breaking chore changes
65
119
  - First line: < 50 chars (or follow existing convention), imperative mood, summarize the main change
66
120
  - **IMPORTANT**: Use multi-line format with bullet points for detailed changes:
67
121
  ```
@@ -77,15 +131,23 @@ Commit message guidelines:
77
131
 
78
132
  Examples of excellent commit messages (multi-line format):
79
133
 
80
- Conventional commits style:
134
+ Conventional commits style(Remember to follow the existing format):
81
135
  ```
136
+ # for new features
82
137
  feat: add user authentication system
83
138
 
84
139
  - Implement JWT-based authentication with refresh tokens
85
140
  - Add login and registration endpoints
86
141
  - Create user session management
87
142
  - Add password hashing with bcrypt
88
- ```
143
+
144
+ # for bug fixes
145
+ fix: correct formatting issue
146
+
147
+ - Preserve empty lines in commit messages
148
+
149
+ # for document changes
150
+ docs: update README.md
89
151
 
90
152
  ```
91
153
  fix: prevent memory leak in connection pool
@@ -95,7 +157,7 @@ fix: prevent memory leak in connection pool
95
157
  - Improve error handling for failed connections
96
158
  ```
97
159
 
98
- With gitmoji:
160
+ With gitmoji,(✨, 🐛, ♻️, etc. ✨ for feature, 🐛 for bug, ♻️ for refactor)
99
161
  ```
100
162
  ✨ add user authentication system
101
163
 
@@ -154,7 +216,7 @@ async def generate_commit_message(
154
216
  Context:
155
217
  - Working directory: {repo_path.absolute()}
156
218
  - Analysis scope: {"staged changes only (git diff --cached)" if staged_only else "all uncommitted changes (git diff)"}
157
- - You have access to: Bash, Read, Grep, and Glob tools
219
+ - You have access to: Bash, Read, Grep, Glob, and Edit tools
158
220
 
159
221
  Your task:
160
222
  1. **FIRST**: Check the recent commit history (e.g., `git log -3 --oneline` or `git log -3 --pretty=format:"%s"`) to understand the commit message format/style used in this project
@@ -182,7 +244,12 @@ Recommendations (not requirements - use your judgment):
182
244
  - Start with `git log -3 --oneline` to check the commit message style
183
245
  - Then use `git status` and `git diff {"--cached" if staged_only else ""}` to see what changed
184
246
  - For non-trivial changes, READ the modified files to understand their purpose
185
- - Use grep to find related code or understand how functions are used
247
+ - **USE GREP extensively** to understand impact and context:
248
+ * If a function was modified, grep for its usage: `grep -n "function_name("`
249
+ * If a class was added/changed, find related classes: `grep -n "class.*Base"` or similar patterns
250
+ * If imports changed, see where they're used: `grep -n "imported_module"`
251
+ * To understand scope, count usages: `grep --output_mode count "pattern"`
252
+ * Get context around matches: `grep -C 3 "pattern"` (3 lines before/after)
186
253
  - Consider the broader context of the codebase
187
254
 
188
255
  When you're confident you understand the changes, output your commit message in this exact format:
@@ -196,7 +263,13 @@ Begin your analysis now.
196
263
  try:
197
264
  options = ClaudeAgentOptions(
198
265
  system_prompt=SYSTEM_PROMPT,
199
- allowed_tools=["Bash", "Read", "Grep", "Glob"],
266
+ allowed_tools=[
267
+ "Bash", # Run shell commands
268
+ "Read", # Read file contents
269
+ "Grep", # Search patterns in files (POWERFUL!)
270
+ "Glob", # Find files by pattern
271
+ "Edit", # Make precise edits to files (useful for analyzing multi-line changes)
272
+ ],
200
273
  permission_mode="acceptEdits",
201
274
  cwd=str(repo_path.absolute()),
202
275
  max_turns=10,
@@ -442,8 +515,8 @@ def handle_alias_command(args):
442
515
  print("📋 No aliases configured")
443
516
  return
444
517
 
445
- import platform
446
518
  import os
519
+ import platform
447
520
 
448
521
  # Detect shell and platform
449
522
  shell = os.environ.get("SHELL", "")
@@ -609,8 +682,8 @@ def handle_alias_command(args):
609
682
 
610
683
  elif args[0] == "uninstall":
611
684
  # Remove shell aliases
612
- import platform
613
685
  import os
686
+ import platform
614
687
 
615
688
  shell = os.environ.get("SHELL", "")
616
689
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-commit
3
- Version: 0.1.1
3
+ Version: 0.3.0
4
4
  Summary: AI-powered git commit message generator using Claude Agent SDK
5
5
  Author-email: Johannlai <johannli666@gmail.com>
6
6
  License: MIT
@@ -27,7 +27,7 @@ Requires-Dist: black>=23.0.0; extra == "dev"
27
27
  Requires-Dist: mypy>=1.0.0; extra == "dev"
28
28
  Dynamic: license-file
29
29
 
30
- # claude-commit
30
+ # claude-commit [![PyPI version](https://badge.fury.io/py/claude-commit.svg)](https://badge.fury.io/py/claude-commit)
31
31
 
32
32
  🤖 AI-powered git commit message generator using Claude Agent SDK and Claude Code CLI
33
33
 
@@ -35,23 +35,9 @@ Dynamic: license-file
35
35
 
36
36
  `claude-commit` uses Claude AI to analyze your code changes and write meaningful commit messages. Claude reads your files, understands the context, and generates commit messages following best practices.
37
37
 
38
- ## Quick Start
38
+ ## Demo
39
39
 
40
- **Install:**
41
- ```bash
42
- pip install claude-commit
43
-
44
- # Required dependency
45
- npm install -g @anthropic-ai/claude-code
46
- ```
47
-
48
- **Use:**
49
- ```bash
50
- git add .
51
- claude-commit --commit
52
- ```
53
-
54
- That's it! Claude will analyze your changes and create a commit.
40
+ [![asciicast](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L.svg)](https://asciinema.org/a/ZubvhPFyP7hPFLsqZiZUc930L?autoplay=1&speed=3)
55
41
 
56
42
  ## Installation
57
43
 
@@ -61,19 +47,44 @@ That's it! Claude will analyze your changes and create a commit.
61
47
  - Node.js
62
48
  - Git
63
49
 
64
- ### Install Steps
50
+ ### Recommended: pipx (for CLI tools)
51
+
52
+ `pipx` is the **best way to install Python CLI tools**. It creates isolated environments automatically:
65
53
 
66
54
  ```bash
67
- # 1. Install Claude Code CLI (required)
68
- npm install -g @anthropic-ai/claude-code
55
+ # 1. Install pipx
56
+ brew install pipx # macOS
57
+ # or
58
+ pip install --user pipx # Linux/Windows
59
+ pipx ensurepath
69
60
 
70
- # 2. Install claude-commit
71
- pip install claude-commit
61
+ # 2. Install Claude Code CLI (required)
62
+ npm install -g @anthropic-ai/claude-code
72
63
 
73
- # Or use pipx for isolation
64
+ # 3. Install claude-commit
74
65
  pipx install claude-commit
75
66
  ```
76
67
 
68
+ ### Alternative: pip
69
+
70
+ If you prefer pip, use one of these methods:
71
+
72
+ **Option 1: User installation (no admin rights needed)**
73
+ ```bash
74
+ # Install to user directory
75
+ pip install --user claude-commit
76
+
77
+ # Make sure ~/.local/bin is in your PATH
78
+ export PATH="$HOME/.local/bin:$PATH"
79
+ ```
80
+
81
+ **Option 2: Virtual environment**
82
+ ```bash
83
+ python3 -m venv ~/.venvs/claude-commit
84
+ source ~/.venvs/claude-commit/bin/activate
85
+ pip install claude-commit
86
+ ```
87
+
77
88
  ### Authentication
78
89
 
79
90
  `claude-commit` supports two ways to authenticate with Claude:
@@ -138,7 +149,7 @@ Create shortcuts for common commands:
138
149
  # Install to your shell config
139
150
  claude-commit alias install
140
151
 
141
- # Activate in current terminal
152
+ # Activate in current terminal. Very important!
142
153
  source ~/.zshrc # zsh
143
154
  source ~/.bashrc # bash
144
155
  ```
@@ -238,28 +249,103 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
238
249
 
239
250
  ## Troubleshooting
240
251
 
241
- **Claude Code not found?**
252
+ ### Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
253
+
254
+ ```
255
+ Fatal error in message reader: Command failed with exit code 1 (exit code: 1)
256
+ Error output: Check stderr output for details
257
+ Traceback (most recent call last):
258
+ ```
259
+
260
+ **Solution**: This error means you haven't authenticated with Claude. Choose one method:
261
+
262
+ **Method A: Official Claude Code login (recommended)**
263
+ ```bash
264
+ claude
265
+ ```
266
+
267
+ **Method B: Set custom API endpoint**
268
+ ```bash
269
+ export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"
270
+ export ANTHROPIC_AUTH_TOKEN="your-auth-token"
271
+ # model name (optional)
272
+ export ANTHROPIC_MODEL="your-model-name"
273
+
274
+ # Add to ~/.zshrc or ~/.bashrc to persist
275
+ echo 'export ANTHROPIC_BASE_URL="https://your-endpoint.com/api/v1"' >> ~/.zshrc
276
+ echo 'export ANTHROPIC_AUTH_TOKEN="your-auth-token"' >> ~/.zshrc
277
+ ```
278
+
279
+ ### "externally-managed-environment" error (macOS/Linux)
280
+
281
+ If you see this error when using `pip install`:
282
+
283
+ ```
284
+ error: externally-managed-environment
285
+ ```
286
+
287
+ **Solution**: Use `pipx` (recommended for CLI tools):
288
+ ```bash
289
+ brew install pipx
290
+ pipx install claude-commit
291
+ ```
292
+
293
+ Or use `pip install --user`:
294
+ ```bash
295
+ pip install --user claude-commit
296
+ ```
297
+
298
+ **Why this happens**: Modern Python installations (Python 3.11+) protect the system Python to prevent conflicts. This is not a bug in `claude-commit`.
299
+
300
+ ### Claude Code not found
301
+
242
302
  ```bash
243
303
  npm install -g @anthropic-ai/claude-code
244
304
  ```
245
305
 
246
- **No changes detected?**
306
+ ### No changes detected
307
+
247
308
  ```bash
248
309
  git add . # stage changes
249
310
  # or
250
311
  claude-commit --all # include unstaged
251
312
  ```
252
313
 
253
- **Analysis too slow?**
314
+ ### Analysis too slow
315
+
254
316
  ```bash
255
317
  claude-commit --max-diff-lines 200
256
318
  ```
257
319
 
320
+ ### Command not found after installation
321
+
322
+ If `claude-commit` is not found after installation:
323
+
324
+ **With pipx:**
325
+ ```bash
326
+ pipx ensurepath
327
+ # Restart your terminal
328
+ ```
329
+
330
+ **With pip --user:**
331
+ ```bash
332
+ # Add to ~/.zshrc or ~/.bashrc
333
+ export PATH="$HOME/.local/bin:$PATH"
334
+ source ~/.zshrc # or ~/.bashrc
335
+ ```
336
+
337
+ ### Aliases not working
338
+
339
+ ```bash
340
+ claude-commit alias install
341
+ source ~/.zshrc # or ~/.bashrc
342
+ ```
343
+
258
344
  ## Development
259
345
 
260
346
  ```bash
261
347
  # Clone and setup
262
- git clone https://github.com/yourusername/claude-commit.git
348
+ git clone https://github.com/JohannLai/claude-commit.git
263
349
  cd claude-commit
264
350
  python -m venv venv
265
351
  source venv/bin/activate
@@ -285,7 +371,9 @@ MIT License - see [LICENSE](LICENSE) file
285
371
 
286
372
  - [Claude Agent SDK](https://docs.anthropic.com/en/docs/claude-code/agent-sdk)
287
373
  - [Conventional Commits](https://www.conventionalcommits.org/)
288
- - [Issue Tracker](https://github.com/yourusername/claude-commit/issues)
374
+ - [GitHub Repository](https://github.com/JohannLai/claude-commit)
375
+ - [PyPI Package](https://pypi.org/project/claude-commit/)
376
+ - [Issue Tracker](https://github.com/JohannLai/claude-commit/issues)
289
377
 
290
378
  ---
291
379
 
File without changes
File without changes