Skip to content

Implement /oden:bug contextual diagnosis system #9

Description

@israads

Task: Contextual Bug Diagnosis System

Description

Implement the /oden:bug command that provides contextual diagnosis and automatic fixing of common development issues. This system should analyze project structure, identify error patterns, and apply solutions with user confirmation.

Functional Requirements

  • Project Type Detection: Automatically detect React, Next.js, Node.js, React Native project types
  • Error Pattern Matching: Database of 50+ common development issues with solutions
  • Environment Analysis: Check OS, Node version, package manager compatibility
  • Solution Application: Apply fixes automatically with rollback capability
  • Success Validation: Verify solution works before completing

Technical Implementation

Files to Create/Modify:

  • .claude/commands/oden/bug.md - Command definition
  • lib/commands/bug.js - Main command implementation
  • lib/diagnosis/pattern-matcher.js - Error pattern recognition
  • lib/diagnosis/solution-applier.js - Solution application system
  • lib/diagnosis/project-analyzer.js - Project type and environment detection
  • data/bug-patterns.json - Error pattern database

Architecture:

  1. Pattern Matching Engine: SQLite database with error signatures
  2. Project Context Analysis: Package.json, lock files, config files analysis
  3. Solution Pipeline: Staged application with rollback support
  4. Validation System: Post-fix verification of solution effectiveness

Acceptance Criteria

Core Functionality:

  • /oden:bug "project won't start" analyzes common startup issues
  • Detects project type (React/Next.js/Node.js) from file structure
  • Identifies port conflicts, missing dependencies, env variable issues
  • Shows diagnosis results with confidence scores
  • Applies fixes automatically with user confirmation
  • Provides rollback option if solution fails
  • Success rate >80% for common development issues

Error Patterns Coverage:

  • Port already in use (3000, 3001, 8080, etc.)
  • Missing .env files or variables
  • Node version compatibility issues
  • Package dependency conflicts
  • Missing global packages (npm, yarn, pnpm)
  • Permission errors (EACCES, EPERM)
  • Package-lock.json conflicts
  • Build tool configuration issues

Performance:

  • Complete diagnosis in <2 minutes for 90% of cases
  • Pattern matching completes in <30 seconds
  • Solution application with validation in <1 minute
  • Graceful handling of unknown issues

User Experience:

  • Clear progress indicators during analysis
  • Descriptive error messages with actionable suggestions
  • Confirmation prompts before applying fixes
  • Detailed log of actions taken for debugging

Dependencies

  • Internal: Oden command infrastructure
  • External: Node.js filesystem APIs, child_process for command execution
  • Tools: Package manager detection (npm, yarn, pnpm)

Implementation Notes

  • Build pattern database incrementally, starting with most common issues
  • Use child_process.spawn for running diagnostic commands
  • Implement solution templates for each error type
  • Ensure all file system changes are reversible
  • Test with multiple project types and error scenarios

Risks

  • High: Solution application could break working projects
  • Medium: Pattern matching might miss edge cases
  • Low: Performance impact on large codebases

Mitigation Strategies

  • Comprehensive backup system before applying fixes
  • Staged rollout with manual approval for each solution type
  • Extensive testing on various project configurations
  • Clear documentation of what each solution does

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions