Refactor an Existing Codebase Using Prompt-Driven Development with GitHub Copilot
Visual Studio Code, featuring Gwyneth Peña-Siguenza, guides developers through prompt-driven development and AI-powered codebase refactoring using GitHub Copilot with a FastAPI + Cosmos DB project.
Refactor an Existing Codebase Using Prompt-Driven Development with GitHub Copilot
Featuring: Gwyneth Peña-Siguenza (@madebygps)
**Produced by Visual Studio Code
**
This session demonstrates how to leverage GitHub Copilot to refactor an e-commerce inventory management app written with FastAPI and Azure Cosmos DB. The walkthrough covers recognizing code smells, building contextually-rich prompts, running Copilot in Agent Mode for refactoring tasks, and reviewing AI-generated improvements step by step. The approach emphasizes best practices for integrating AI assistance into real-world development workflows.
Video Chapters
- Intro (00:00)
- Getting Started (00:36)
- Choosing Directory & file: product_crud_batch.py (02:25)
- Writing Custom Instructions (03:50)
- Creating Effective Prompts (05:25)
- Running Prompts with Copilot Agent Mode (09:58)
- Testing Changes (19:11)
- Summary & Key Takeaways (23:39)
- Wrap Up (24:14)
Key Topics Covered
- Refactoring real-world Python code for an e-commerce scenario
- Identifying and addressing code smells in an inventory system
- Constructing targeted instructions and prompts for Copilot
- Using Copilot’s Agent Mode for iterative improvements
- Reviewing, testing, and validating AI-suggested code
- Best practices for making AI-driven refactoring reliable and maintainable
Demo Project
Best Practices Highlighted
- Develop focused, stepwise prompts for each refactor target
- Validate Copilot’s output through tests and code reviews
- Iterate rapidly, integrating manual and AI changes
- Leverage Agent Mode for continual improvement and prompt experimentation
Connect with Visual Studio Code
- Twitter: @code
- Bluesky: vscode.dev
- YouTube: youtube.com/code
- LinkedIn: Visual Studio Code
- GitHub: microsoft/vscode
For developers looking to enhance productivity and code quality using Copilot, this video offers actionable insights and hands-on techniques that can be applied to similar Python and Azure-based projects.