Skip to content

Commit ed93e0b

Browse files
committed
Fix Claude CLI usage by adding debug mode and proper flags
1 parent 1d8bbf7 commit ed93e0b

3 files changed

Lines changed: 30 additions & 15 deletions

File tree

.github/workflows/claude-issue-fix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
git config --global user.email "claude-bot@example.com"
3030
3131
- name: Process issue with Claude Code
32-
uses: fractureinc/claude-code-github-action@v0.3.2
32+
uses: fractureinc/claude-code-github-action@v0.3.3
3333
with:
3434
mode: 'issue-fix'
3535
issue-number: ${{ github.event.issue.number }}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "claude-code-github-action",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "GitHub action for Claude Code Integration in PR comments, reviews, inline code suggestions, and issue-based fixes",
55
"main": "index.js",
66
"scripts": {

scripts/issue-fix-mode.sh

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,30 @@ If you need to see specific files first, indicate which ones you need to examine
117117
EOF
118118
)
119119

120-
# Run Claude CLI to analyze the issue using a temp file for the prompt
120+
# Run Claude CLI to analyze the issue
121121
echo "Sending request to Claude for issue analysis..."
122122

123-
# Create a temporary file for the prompt
123+
# Create a temporary file for the prompt for debugging
124124
PROMPT_FILE=$(mktemp)
125125
echo "$ANALYZE_PROMPT" > "$PROMPT_FILE"
126+
echo "Prompt saved to $PROMPT_FILE for debugging"
126127

127-
# Use claude with the -f flag to read from a file
128-
if ! claude -f "$PROMPT_FILE" > "$RESPONSE_FILE"; then
128+
# Use claude with the -p flag (print) and -d (debug) and pipe input
129+
echo "Running: cat prompt | claude -p -d"
130+
if ! cat "$PROMPT_FILE" | claude -p -d > "$RESPONSE_FILE" 2>/tmp/claude_error_$ISSUE_NUMBER.log; then
129131
echo "Error: Claude API request failed. Check your API key and connectivity."
130-
cat "$PROMPT_FILE" | head -20 # Show part of the prompt for debugging
132+
echo "Claude CLI version:"
133+
claude --version || echo "Failed to get version"
134+
echo "Error log (if available):"
135+
cat /tmp/claude_error_$ISSUE_NUMBER.log || echo "No error log available"
136+
echo "Prompt (first 20 lines):"
137+
cat "$PROMPT_FILE" | head -20
131138
exit 1
132139
fi
133140

134-
# Clean up the prompt file
135-
rm -f "$PROMPT_FILE"
141+
# Keep prompt file for debugging
142+
echo "Prompt saved to $PROMPT_FILE for debugging"
143+
echo "Response saved to $RESPONSE_FILE"
136144

137145
# Parse Claude's response to extract files to examine
138146
FILES_TO_EXAMINE=$(grep -Eo "Files Involved:.*" -A 20 "$RESPONSE_FILE" | grep -v "Proposed Changes:" | grep -v "Testing Plan:" | grep "/" | sed -E 's/^[ -]*([^ ].*)/\1/' | sed -E 's/ *$//' | grep -v "^$")
@@ -182,21 +190,28 @@ If you need to create a completely new file, specify the full file path and prov
182190
EOF
183191
)
184192

185-
# Run Claude CLI to implement the fix using a temp file for the prompt
193+
# Run Claude CLI to implement the fix
186194
echo "Sending request to Claude for implementation details..."
187195

188-
# Create a temporary file for the prompt
196+
# Create a temporary file for the prompt for debugging
189197
IMPL_PROMPT_FILE=$(mktemp)
190198
echo "$IMPLEMENT_PROMPT" > "$IMPL_PROMPT_FILE"
199+
echo "Implementation prompt saved to $IMPL_PROMPT_FILE for debugging"
191200

192-
# Use claude with the -f flag to read from a file
193-
if ! claude -f "$IMPL_PROMPT_FILE" > "$FIX_DETAILS_FILE"; then
201+
# Use claude with the -p flag (print) and -d (debug) and pipe input
202+
echo "Running: cat prompt | claude -p -d for implementation details"
203+
if ! cat "$IMPL_PROMPT_FILE" | claude -p -d > "$FIX_DETAILS_FILE" 2>/tmp/claude_impl_error_$ISSUE_NUMBER.log; then
194204
echo "Error: Claude API request failed when generating implementation details."
205+
echo "Error log (if available):"
206+
cat /tmp/claude_impl_error_$ISSUE_NUMBER.log || echo "No implementation error log available"
207+
echo "Implementation prompt (first 20 lines):"
208+
cat "$IMPL_PROMPT_FILE" | head -20
195209
exit 1
196210
fi
197211

198-
# Clean up the prompt file
199-
rm -f "$IMPL_PROMPT_FILE"
212+
# Keep prompt file for debugging
213+
echo "Implementation prompt saved to $IMPL_PROMPT_FILE for debugging"
214+
echo "Implementation response saved to $FIX_DETAILS_FILE"
200215

201216
# Parse Claude's response to extract file paths and changes
202217
FILES_TO_MODIFY=$(grep -o "For file [^ ]*:" "$FIX_DETAILS_FILE" | sed -E 's/For file ([^:]*):$/\1/')

0 commit comments

Comments
 (0)