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:
File handling and parsing
Code mapping and validation
Backup and update mechanisms
Task tracking and reporting
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.
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:
Core Custom Instruction for TDD Approach
Updated Module Development Prompts
1. File Input Module Prompt
2. Code Block Parsing Module Prompt
3. Backup Module Prompt
4. Main Integration Prompt
Implementation Steps
Setup Phase
Development Phase
Integration Phase
Validation Phase
Deployment Phase
Key Improvements from Original Plan
Success Criteria