Skip to content

Latest commit

ย 

History

History
521 lines (397 loc) ยท 15.8 KB

File metadata and controls

521 lines (397 loc) ยท 15.8 KB

ClaudeCode-Debugger ๐Ÿš€

Version CI Coverage PyPI Python Version License: MIT

AI-powered debugging assistant with seamless Claude Code integration - Transform error messages into actionable solutions with advanced AI analysis, multi-language support, and native Claude Code commands. Let AI understand your bugs instantly!

๐Ÿ†• What's New in v1.5.0

  • ๐ŸŒ Extended Language Support - Now supports 10+ languages including Shell/Bash, Docker, YAML/JSON, Kotlin, Swift, and SQL
  • ๐Ÿณ Docker & Container Analysis - Comprehensive Dockerfile and Docker Compose error detection
  • ๐Ÿ“„ Configuration File Support - Smart YAML/JSON analysis for CI/CD pipelines and Kubernetes
  • ๐Ÿ“ฑ Mobile Development - Full support for Kotlin (Android) and Swift (iOS) error analysis
  • ๐Ÿš€ 60% Faster Pattern Matching - Completely rewritten engine for better performance
  • ๐ŸŽฏ Enhanced Pattern Recognition - 50+ new error patterns per language

โœจ Features

  • ๐ŸŒ Multi-Language Support - Full i18n with Chinese (ไธญๆ–‡) and English interface
  • ๐Ÿง  Advanced Error Analysis - Three intelligent analyzers: Stack Trace, Pattern, and Code Context
  • ๐ŸŽฏ ML-Ready Suggestion Engine - Confidence-scored solutions based on error patterns
  • ๐Ÿ” Deep Stack Trace Analysis - Support for Python, JavaScript, TypeScript, Java, Ruby, Go, Shell/Bash, Docker, YAML/JSON, Kotlin, Swift, SQL
  • ๐Ÿค– Claude Code Integration - Native /ccdebug slash command for seamless workflow
  • ๐Ÿ“‹ Smart Clipboard Integration - Auto-detect and analyze errors from clipboard
  • ๐ŸŽจ Beautiful Terminal UI - Rich, colorful output with progress indicators
  • ๐Ÿ“Š Intelligent Error Patterns - Pre-configured patterns for common errors
  • ๐Ÿ”ง Extensible Architecture - Plugin system for custom analyzers and patterns
  • ๐Ÿ“ˆ Learning System - Improves suggestions based on successful resolutions
  • ๐Ÿš€ Performance Optimized - Direct Python API for faster analysis
  • ๐Ÿ”’ Secure by Default - Safe error handling without exposing sensitive data

๐Ÿš€ Quick Start

Installation

# Install from source
git clone https://github.com/888wing/ClaudeCode-Debugger.git
cd ClaudeCode-Debugger
pip install -e .

# Setup Claude Code integration (NEW!)
python setup_claude_code.py

Basic Usage

# Analyze error with Chinese interface
ccdebug "TypeError: Cannot read property 'name' of undefined" --lang zh

# Deep analysis with suggestions
ccdebug "AttributeError: 'NoneType' object" --analyze-stack --suggest

# Read from clipboard
ccdebug -c --lang zh

# Interactive mode
ccdebug -i

# Claude Code integration
# In Claude Code, when you encounter an error:
/ccdebug --last --zh --deep

Language Support

# Chinese interface (ไธญๆ–‡็•Œ้ข)
cczh "้Œฏ่ชคไฟกๆฏ"  # Quick Chinese analysis
ccfull           # Full analysis in Chinese

# English interface
ccen "error message"  # Quick English analysis
ccdebug --lang en    # Explicit English

Supported Programming Languages (NEW in v1.5)

  • Shell/Bash - Script errors, command not found, syntax issues
  • Docker - Dockerfile syntax, build errors, runtime issues
  • YAML/JSON - Configuration errors, CI/CD pipelines, Kubernetes manifests
  • Kotlin - Null safety, coroutines, Android-specific patterns
  • Swift - Optionals, memory management, SwiftUI errors
  • SQL - Query syntax, joins, performance hints
  • Python - Full stack traces, import errors, type errors
  • JavaScript/TypeScript - Runtime errors, async issues, type mismatches
  • Java - Exceptions, null pointers, classpath issues
  • Ruby - Rails errors, gem conflicts, syntax issues
  • Go - Compilation errors, goroutine panics, interface issues

๐Ÿค– Claude Code Integration (NEW!)

CCDebugger now seamlessly integrates with Claude Code! Errors are automatically detected and analyzed without any manual intervention.

Automatic Error Detection

When you run commands in Claude Code that produce errors, CCDebugger automatically:

  • Detects error patterns in real-time
  • Extracts error context and stack traces
  • Generates AI-powered debugging suggestions
  • Provides instant solutions in Chinese or English

Quick Commands

# Analyze last error
ccdebug last

# View error history
ccdebug history

# Start monitoring mode
ccdebug monitor start

# Configure settings
ccdebug config set defaultLanguage zh

Example Workflow

# When you run code with errors in Claude Code:
result = undefined_function()  # NameError

# CCDebugger automatically shows:
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ ๐Ÿ” CCDebugger ่‡ชๅ‹•้Œฏ่ชคๅˆ†ๆž                                      โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

โš ๏ธ **CCDebugger ้Œฏ่ชคๅˆ†ๆžๅ ฑๅ‘Š**
**้Œฏ่ชค้กžๅž‹**: NameError
**ๅšด้‡็จ‹ๅบฆ**: high

**AI ่ชฟ่ฉฆๆ็คบ**:
ไฝ ้‡ๅˆฐไบ†ไธ€ๅ€‹ NameError๏ผŒ้€™่กจ็คบ Python ็„กๆณ•ๆ‰พๅˆฐๅ็‚บ 'undefined_function' ็š„ๅ‡ฝๆ•ธใ€‚

**๐ŸŽฏ ๆ™บ่ƒฝๅปบ่ญฐ**:
1. ๆชขๆŸฅๆ˜ฏๅฆๆญฃ็ขบๅฐŽๅ…ฅไบ†่ฉฒๅ‡ฝๆ•ธ
2. ็ขบ่ชๅ‡ฝๆ•ธๅ็จฑๆ‹ผๅฏซๆ˜ฏๅฆๆญฃ็ขบ
3. ๆชขๆŸฅๅ‡ฝๆ•ธๆ˜ฏๅฆๅœจ็•ถๅ‰ไฝœ็”จๅŸŸๅ…งๅฎš็พฉ

See CLAUDE_CODE_INTEGRATION.md for full documentation.

๐Ÿ“– Examples

Python AttributeError (Chinese)

$ ccdebug "AttributeError: 'NoneType' object has no attribute 'profile'" --lang zh --suggest

๐Ÿšจ Python ้Œฏ่ชค - HIGH ๅ„ชๅ…ˆ็ดš
ๆชขๆธฌๅˆฐ: AttributeError - NoneType ้Œฏ่ชค

๐Ÿ“Š ๅ †็–Š่ฟฝ่นคๅˆ†ๆž:
- ๆ นๆœฌๅŽŸๅ› : ๅ˜—่ฉฆ่จชๅ• None ๅฐ่ฑก็š„ๅฑฌๆ€ง
- ๅฝฑ้Ÿฟ็ฏ„ๅœ: 1 ๅ€‹ๆ–‡ไปถๅ—ๅฝฑ้Ÿฟ

๐ŸŽฏ ๆ™บ่ƒฝๅปบ่ญฐ (ไฟกๅฟƒๅบฆ: 85%):
1. ๆทปๅŠ  None ๆชขๆŸฅ:
   ```python
   if user and hasattr(user, 'profile'):
       return user.profile.avatar_url
   return None
  1. ไฝฟ็”จ getattr ๅฎ‰ๅ…จ่จชๅ•:

    profile = getattr(user, 'profile', None)
    if profile:
        return profile.avatar_url
  2. ไฝฟ็”จ try-except ่™•็†:

    try:
        return user.profile.avatar_url
    except AttributeError:
        return None

โœ… ๅทฒ่ค‡่ฃฝๅˆฐๅ‰ช่ฒผๆฟ


### JavaScript TypeError with Code Context

```bash
$ ccdebug --last --lang en --analyze-stack --suggest

๐Ÿšจ JavaScript Error - HIGH Priority
TypeError: Cannot read property 'map' of undefined

๐Ÿ” Stack Trace Analysis:
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ at TodoList (TodoList.jsx:15:19)       โ”‚
โ”‚ at renderWithHooks (react-dom.js:14985)โ”‚
โ”‚ at mountComponent (react-dom.js:17441) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“Š Pattern Analysis:
- Error Pattern: undefined_property_access
- Common in: React component props
- Severity: HIGH

๐ŸŽฏ Suggestions (Confidence: 92%):
1. Add default props:
   ```javascript
   function TodoList({ todos = [] }) {
     return <ul>{todos.map(todo => <li>{todo.text}</li>)}</ul>
   }
  1. Add conditional rendering:

    function TodoList({ todos }) {
      if (!todos || !Array.isArray(todos)) {
        return <div>No todos available</div>
      }
      return <ul>{todos.map(todo => <li>{todo.text}</li>)}</ul>
    }
  2. Use optional chaining:

    return <ul>{todos?.map(todo => <li>{todo.text}</li>) || null}</ul>

[โœ“ Analysis complete]


### Claude Code Integration

```bash
# In Claude Code, when you encounter an error:
User: python manage.py runserver
Claude: [Shows Django error]

User: /ccdebug --last --zh --deep
Claude: 
๐Ÿšจ Django ้Œฏ่ชคๅˆ†ๆž
ๆชขๆธฌๅˆฐ: ImproperlyConfigured

๐Ÿ” ๆทฑๅบฆๅˆ†ๆž:
- ้Œฏ่ชคไฝ็ฝฎ: settings.py:89
- ๆ นๆœฌๅŽŸๅ› : DATABASES ้…็ฝฎ็ผบๅคฑ
- ๅฝฑ้Ÿฟ: ๆ‡‰็”จ็จ‹ๅบ็„กๆณ•ๅ•Ÿๅ‹•

๐ŸŽฏ ่งฃๆฑบๆ–นๆกˆ:
1. ๆชขๆŸฅ settings.py ไธญ็š„ DATABASES ้…็ฝฎ
2. ็ขบไฟ็’ฐๅขƒ่ฎŠๆ•ธๆญฃ็ขบ่จญ็ฝฎ
3. ้ฉ—่ญ‰ๆ•ธๆ“šๅบซ้€ฃๆŽฅๅƒๆ•ธ

[่ฉณ็ดฐๆญฅ้ฉŸๅ’Œไปฃ็ขผ็คบไพ‹...]

๐Ÿ†• New Language Support Examples (v1.5)

Shell/Bash Error Analysis

$ ccdebug "./deploy.sh: line 42: syntax error near unexpected token 'fi'" --lang en

๐Ÿšจ Bash Script Error - HIGH Priority
Syntax error detected in shell script

๐Ÿ“Š Error Analysis:
- Error Type: Syntax Error
- Location: deploy.sh, line 42
- Issue: Missing 'then' after 'if' statement

๐ŸŽฏ Solution:
Add 'then' keyword after your if condition:
```bash
if [ "$ENVIRONMENT" = "production" ]; then  # Add 'then' here
    deploy_production
fi

#### Docker Build Error

```bash
$ ccdebug "Service 'web' failed to build: COPY failed: no source files" --lang zh

๐Ÿšจ Docker ๆง‹ๅปบ้Œฏ่ชค - HIGH ๅ„ชๅ…ˆ็ดš
Docker ๆง‹ๅปบ้Ž็จ‹ไธญๆช”ๆกˆ่ค‡่ฃฝๅคฑๆ•—

๐Ÿ“Š ้Œฏ่ชคๅˆ†ๆž:
- ้Œฏ่ชค้กžๅž‹: COPY ๆŒ‡ไปคๅคฑๆ•—
- ๅŽŸๅ› : ๆบๆช”ๆกˆไธๅญ˜ๅœจๆˆ–่ทฏๅพ‘้Œฏ่ชค
- ๅฝฑ้Ÿฟ: Docker ๆ˜ ๅƒ็„กๆณ•ๆง‹ๅปบ

๐ŸŽฏ ่งฃๆฑบๆ–นๆกˆ:
1. ๆชขๆŸฅ Dockerfile ไธญ็š„ COPY ่ทฏๅพ‘:
   ```dockerfile
   # ็ขบไฟ่ทฏๅพ‘็›ธๅฐๆ–ผๆง‹ๅปบไธŠไธ‹ๆ–‡
   COPY ./app /app  # ่€Œ้ž COPY app /app
  1. ้ฉ—่ญ‰ๆง‹ๅปบไธŠไธ‹ๆ–‡ๅŒ…ๅซๆ‰€้œ€ๆช”ๆกˆ:
    docker build -f Dockerfile .  # '.' ๆ˜ฏๆง‹ๅปบไธŠไธ‹ๆ–‡

#### YAML Configuration Error

```bash
$ ccdebug "error validating data: ValidationError(Deployment.spec.replicas): invalid type" --lang en

๐Ÿšจ Kubernetes YAML Error - MEDIUM Priority
Invalid YAML configuration detected

๐Ÿ“Š Error Analysis:
- Error Type: Type Validation Error
- Field: spec.replicas
- Expected: integer, Got: string

๐ŸŽฏ Solution:
Fix the replicas field to use a number:
```yaml
spec:
  replicas: 3    # Not "3" (string)

## ๐Ÿ› ๏ธ Advanced Features

### Intelligent Analyzers

CCDebugger includes three advanced analyzers:

```python
# Stack Trace Analyzer - Multi-language support
from claudecode_debugger.analyzers import StackTraceAnalyzer

analyzer = StackTraceAnalyzer()
result = analyzer.analyze(error_text)
# Returns: language, frames, root_cause, error_type

# Pattern Analyzer - Detects common error patterns
from claudecode_debugger.analyzers import PatternAnalyzer

analyzer = PatternAnalyzer()
patterns = analyzer.analyze(error_text)
# Returns: matched patterns with solutions

# Code Context Analyzer - Extracts code context
from claudecode_debugger.analyzers import CodeContextAnalyzer

analyzer = CodeContextAnalyzer()
context = analyzer.extract_context("app.py", line_number=42)
# Returns: code snippet with surrounding lines

ML-Ready Suggestion Engine

from claudecode_debugger.suggestions import SuggestionEngine

engine = SuggestionEngine()
suggestions = engine.generate_suggestions(
    error_type="AttributeError",
    error_patterns=["null_reference"],
    stack_trace_info=stack_info
)
# Returns: Ranked suggestions with confidence scores

Configuration

Create ~/.ccdebugrc for personal preferences:

{
  "defaultLanguage": "zh",
  "defaultMode": "deep",
  "autoSuggest": true,
  "copyToClipboard": true,
  "contextLines": 10,
  "favoriteFrameworks": ["django", "react", "vue"],
  "customPatterns": {
    "myapp": {
      "errorPattern": "MyAppError:",
      "suggestion": "Check MyApp configuration"
    }
  }
}

Claude Code Integration

The /ccdebug command seamlessly integrates with Claude Code:

# Auto-detection and analysis
/ccdebug --last --zh

# Different analysis modes
/ccdebug --quick   # Fast analysis
/ccdebug --deep    # Detailed analysis with suggestions
/ccdebug --full    # Complete analysis with code context

# Batch processing
/ccdebug --batch --dir logs/

# Watch mode
/ccdebug --watch server.log

Custom Error Patterns

Add your own error patterns:

from claudecode_debugger.analyzers.pattern import ErrorPattern

custom_pattern = ErrorPattern(
    name="custom_api_error",
    pattern=r"API Error: (\d+)",
    description="Custom API error",
    category="api",
    severity="high",
    common_causes=["Invalid API key", "Rate limit exceeded"],
    solutions=["Check API credentials", "Implement retry logic"]
)

๐Ÿ—๏ธ Architecture

CCDebugger is built with a modular, extensible architecture:

claudecode_debugger/
โ”œโ”€โ”€ analyzers/           # Intelligent error analyzers
โ”‚   โ”œโ”€โ”€ stack_trace.py   # Multi-language stack trace analysis
โ”‚   โ”œโ”€โ”€ pattern.py       # Error pattern detection
โ”‚   โ””โ”€โ”€ code_context.py  # Code context extraction
โ”œโ”€โ”€ suggestions/         # ML-ready suggestion engine
โ”‚   โ””โ”€โ”€ engine.py        # Confidence-scored solutions
โ”œโ”€โ”€ i18n/               # Internationalization
โ”‚   โ”œโ”€โ”€ translator.py    # Translation engine
โ”‚   โ””โ”€โ”€ messages/        # Language files (en, zh)
โ”œโ”€โ”€ formatters/         # Output formatters
โ”‚   โ”œโ”€โ”€ console.py      # Rich terminal output
โ”‚   โ””โ”€โ”€ markdown.py     # Markdown formatting
โ””โ”€โ”€ cli_new.py          # Enhanced CLI with full features

Key Components

  1. I18n System: Full internationalization with automatic language detection
  2. Analyzer Framework: Pluggable analyzers for different error types
  3. Suggestion Engine: Knowledge base with confidence scoring
  4. Claude Code Integration: Native slash command support
  5. Rich UI: Beautiful terminal output with progress indicators

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guidelines for details.

Development Setup

# Clone the repository
git clone https://github.com/888wing/ClaudeCode-Debugger.git
cd ClaudeCode-Debugger

# Install in development mode
make dev

# Run tests
make test

# Format code
make format

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built for the Claude Code community
  • Inspired by the need for better debugging workflows
  • Special thanks to all contributors

๐Ÿ“ฌ Support

๐ŸŒŸ What's New

v1.5.0 - Extended Language Support (Latest)

  • ๐ŸŒ Added support for Shell/Bash, Docker, YAML/JSON, Kotlin, Swift, and SQL
  • ๐Ÿš€ 60% performance improvement in pattern matching
  • ๐Ÿ“Š 500+ error patterns across all supported languages
  • ๐Ÿณ Docker and container-specific error analysis
  • ๐Ÿ“„ Configuration file validation for CI/CD pipelines
  • ๐Ÿ“ฑ Mobile development support (Kotlin/Swift)
  • ๐ŸŽฏ Enhanced confidence scoring algorithm

v1.1.0

  • ๐ŸŒ Full internationalization (i18n) with Chinese and English support
  • ๐Ÿง  Three new intelligent analyzers for deep error analysis
  • ๐ŸŽฏ ML-ready suggestion engine with confidence scoring
  • ๐Ÿค– Native Claude Code integration with /ccdebug command
  • ๐Ÿ“Š Advanced error pattern detection
  • ๐Ÿ” Multi-language stack trace analysis
  • โœจ Complete architectural overhaul for extensibility