oneaiguru / chat2code

0 stars 0 forks source link

PROMPTS final calude #3

Open oneaiguru opened 6 hours ago

oneaiguru commented 6 hours ago

Code Update Automation Plan & Prompts

High-Level Summary

The goal is to create an automated tool that updates codebases using LLM-generated outputs, with minimal manual intervention. The plan consists of several key components:

  1. File handling and parsing
  2. Code mapping and validation
  3. Backup and update mechanisms
  4. Task tracking and reporting
  5. Error handling and logging

Core Custom Instruction for TDD Approach

# Test-Driven Development (TDD) Custom Instruction for Code Generation

You are a Python developer following strict Test-Driven Development practices. For each request:

1. FIRST: Write comprehensive test cases that cover:
   - Happy path scenarios
   - Edge cases
   - Error conditions
   - Input validation
   - Expected outputs

2. THEN: Implement the actual code to pass these tests, following:
   - PEP 8 standards
   - Type hints
   - Comprehensive docstrings
   - Clear error handling
   - Logging for important operations

3. ALWAYS:
   - Think step-by-step
   - Document assumptions
   - Include example usage
   - Explain your TDD process
   - Note any potential improvements

4. NEVER:
   - Skip test writing
   - Leave error handling for later
   - Ignore edge cases
   - Write code without type hints
   - Skip documentation

Example Format:
"""
Step 1: Writing Tests
[Write tests first]

Step 2: Implementation
[Write actual code]

Step 3: Validation
[Explain how tests verify the implementation]

Step 4: Documentation
[Add comprehensive documentation]
"""

Updated Module Development Prompts

1. File Input Module Prompt

Following TDD principles, help me develop a Python module for handling LLM-generated code files.

Requirements:
1. Read and extract code from numbered .py files (0.py to 9.py)
2. Parse file content to identify code blocks and their target locations
3. Support both single and multi-file code blocks
4. Handle malformed or incomplete files gracefully

Start by writing comprehensive tests that cover:
- Reading valid numbered files
- Handling missing files
- Processing multi-file code blocks
- Error cases (malformed files, invalid content)

Then implement the module ensuring all tests pass. Include:
- Type hints
- Comprehensive error handling
- Detailed logging
- Clear documentation

Example input files:
[Provide 2-3 example file contents]

Begin with the test cases first, then proceed with implementation.

2. Code Block Parsing Module Prompt

Using TDD, help me create a Python module for parsing code blocks and identifying their target locations.

Requirements:
1. Extract code blocks from raw file content
2. Identify target file paths from comments
3. Handle incomplete code blocks with placeholders
4. Support multiple code blocks per file

Start by writing tests for:
- Clean code block extraction
- Comment-based path identification
- Placeholder detection
- Multi-block parsing
- Error cases

Then implement the parser ensuring all tests pass. Include:
- Robust regex patterns
- Clear error messages
- Detailed logging
- Type hints
- Documentation

Example input:
[Provide 2-3 example code blocks with different formats]

Begin with test cases first, following TDD principles.

3. Backup Module Prompt

Following TDD, create a Python module for safely backing up files before updates.

Requirements:
1. Create timestamped backups
2. Maintain directory structure
3. Verify backup integrity
4. Handle backup failures gracefully

Start with tests covering:
- Successful backup creation
- Directory structure preservation
- Backup verification
- Error handling
- Cleanup procedures

Then implement the backup system ensuring all tests pass. Include:
- File system safety checks
- Atomic operations where possible
- Detailed logging
- Recovery mechanisms
- Clear documentation

Begin with test cases, following TDD principles.

4. Main Integration Prompt

Using TDD, help me create the main orchestration module that integrates all components.

Requirements:
1. Coordinate all module operations
2. Handle the complete workflow
3. Provide progress feedback
4. Manage error recovery

Start with integration tests covering:
- Complete workflow execution
- Error handling at each stage
- Recovery mechanisms
- Progress tracking
- Result reporting

Then implement the main module ensuring all tests pass. Include:
- Clear workflow stages
- Comprehensive error handling
- Detailed logging
- Progress indicators
- Documentation

Begin with test cases, following TDD principles.

Implementation Steps

  1. Setup Phase

    • Create virtual environment
    • Install dependencies
    • Setup test framework
    • Configure logging
  2. Development Phase

    • Develop each module following TDD
    • Start with tests
    • Implement features
    • Validate and refine
  3. Integration Phase

    • Combine modules
    • Write integration tests
    • Implement main workflow
    • Test end-to-end functionality
  4. Validation Phase

    • Comprehensive testing
    • Error handling verification
    • Performance testing
    • Documentation review
  5. Deployment Phase

    • Package the tool
    • Create user documentation
    • Setup CI/CD pipeline
    • Release management

Key Improvements from Original Plan

  1. Stronger emphasis on TDD
  2. More detailed test requirements
  3. Better error handling specifications
  4. Clearer integration guidelines
  5. More comprehensive documentation requirements

Success Criteria

  1. All tests pass (unit and integration)
  2. Code coverage > 90%
  3. No critical bugs
  4. Complete documentation
  5. Successful end-to-end runs