Skip to content

Add Project Initialization Command (/init) to Roocode #6153

@godzail

Description

@godzail

What specific problem does this solve?

Summary

Implement a project initialization command similar to Claude Code's /init functionality that scans the entire codebase and generates comprehensive project documentation and context for improved AI assistance.

Problem Statement

Currently, Roo often makes mistakes when executing terminal commands, particularly due to:

  • Environment differences: Confusion between Windows and Linux command syntax and file paths
  • Virtual environment handling: Incorrect assumptions about Python virtual environments (.venv) activation and usage
  • Project context loss: Lack of comprehensive understanding of project structure, dependencies, and conventions
  • Inconsistent documentation: Missing or outdated project documentation leading to suboptimal code generation

Proposed Solution

Core Feature: /init Command

Add a /init command that performs comprehensive codebase analysis and generates structured project documentation.

Key Capabilities:

  1. Codebase Scanning & Analysis

    • Recursively analyze project directory structure
    • Identify programming languages, frameworks, and technologies used
    • Detect configuration files (package.json, requirements.txt, pom.xml, etc.)
    • Map dependencies and their versions
    • Identify build tools and scripts
  2. Environment Detection

    • Detect operating system (Windows/Linux/macOS)
    • Identify shell type (PowerShell, CMD, Bash, Zsh)
    • Detect virtual environment setup (.venv, conda, pipenv)
    • Map environment-specific command patterns
  3. Project Documentation Generation

    • Generate a ROO.md file (similar to Claude Code's CLAUDE.md)
    • Document project architecture and folder structure
    • List key dependencies and their purposes
    • Include environment-specific command examples
    • Document common development workflows

Generated Documentation Structure (ROO.md):

# Project Context for Roo

## Project Overview
- **Name**: [Project Name]
- **Type**: [Web App/API/Library/etc.]
- **Primary Language**: [Language]
- **Framework**: [Framework/None]

## Environment Setup
- **OS**: [Windows/Linux/macOS]
- **Shell**: [PowerShell/Bash/CMD]
- **Virtual Environment**: [.venv/conda/none]
- **Activation Command**: [environment-specific command]

## Project Structure
[Generated folder tree with descriptions]

## Dependencies
### Production
[Key dependencies with versions and purposes]

### Development
[Dev dependencies and build tools]

## Common Commands
### Environment-Aware Commands
- **Install dependencies**: [OS-specific command]
- **Activate environment**: [Environment-specific command]
- **Run tests**: [Project-specific test command]
- **Start development server**: [Framework-specific command]

## Development Workflows
[Common development patterns and practices]

## Known Patterns & Conventions
- Code style preferences
- Testing patterns
- Directory conventions
- Naming conventions

Enhanced Context Integration

  1. Automatic Context Loading

    • Load ROO.md content into context for every conversation
    • Reference environment-specific commands from documentation
    • Use project patterns for code generation consistency
  2. Smart Command Suggestion

    • Suggest correct commands based on detected environment
    • Provide OS-specific alternatives automatically
    • Include virtual environment activation when needed
  3. Continuous Updates

    • Option to re-run /init to update project documentation
    • Detect changes in dependencies or project structure
    • Maintain documentation freshness

Implementation Considerations

Technical Approach:

  1. File System Analysis

    • Use VS Code's workspace API to traverse project files
    • Implement intelligent file filtering (ignore node_modules, .git, etc.)
    • Parse configuration files for dependency extraction
  2. Environment Detection

    • Detect OS through VS Code's platform API
    • Identify shell through environment variables
    • Check for virtual environment indicators
  3. Documentation Generation

    • Template-based markdown generation
    • Structured data extraction from common config files
    • Environment-specific command mapping

User Experience:

  1. Command Interface

    /init                    # Generate initial project documentation
    /init --update          # Update existing documentation
    /init --minimal         # Generate lightweight documentation
    
  2. Progress Feedback

    • Show scanning progress
    • Display discovered technologies and patterns
    • Confirm documentation generation
  3. Integration Points

    • Auto-suggest running /init for new projects
    • Show notification when project structure changes significantly
    • Integration with existing Roo context management

Expected Benefits

  1. Reduced Command Errors

    • Reduction in environment-specific command mistakes
    • Proper virtual environment handling
    • OS-appropriate file path usage
  2. Improved Code Quality

    • Consistent code generation following project patterns
    • Better dependency management suggestions
    • Framework-aware code recommendations
  3. Enhanced Developer Experience

    • Faster onboarding for new projects
    • Self-documenting project setup
    • Reduced context switching between tools
  4. Continuous Context Awareness

    • Persistent project understanding across sessions
    • Updated documentation reflects project evolution
    • Shared team context through committed documentation

Alternative Approaches Considered

  1. Manual Configuration: Require users to manually configure project settings

    • Pros: Full user control
    • Cons: High friction, prone to outdated information
  2. Real-time Analysis: Analyze project on every request

    • Pros: Always up-to-date
    • Cons: High performance cost, slower responses
  3. Simple Environment Detection: Only detect OS and basic environment

    • Pros: Easier implementation
    • Cons: Limited improvement over current state

Success Metrics

  • Accuracy: Measure reduction in environment-related command errors
  • Adoption: Track usage of /init command across user base
  • Quality: Monitor improvement in code generation relevance and accuracy
  • Performance: Ensure documentation generation completes within acceptable time limits

Future Enhancements

  1. Team Synchronization: Sync project documentation across team members
  2. Integration Plugins: Support for additional build tools and frameworks
  3. Smart Updates: Automatic documentation updates based on file changes
  4. Custom Templates: Allow teams to define custom documentation templates

This feature would significantly improve Roocode's effectiveness by providing the AI with comprehensive, accurate, and up-to-date project context, similar to how Claude Code's /init command enhances development workflows.

Additional context (optional)

No response

Roo Code Task Links (Optional)

No response

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear impact and context

Interested in implementing this?

  • Yes, I'd like to help implement this feature

Implementation requirements

  • I understand this needs approval before implementation begins

How should this be solved? (REQUIRED if contributing, optional otherwise)

No response

How will we know it works? (Acceptance Criteria - REQUIRED if contributing, optional otherwise)

No response

Technical considerations (REQUIRED if contributing, optional otherwise)

No response

Trade-offs and risks (REQUIRED if contributing, optional otherwise)

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Issue [Unassigned]

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions