Inspiration
Every developer has encountered legacy code — those sprawling functions filled with magic numbers, nested conditionals, and cryptic variable names that everyone's afraid to touch. Refactoring such code is risky, time-consuming, and often avoided until it becomes a critical problem.
We asked: What if AI could safely refactor legacy code automatically?
What it does
Legacy Architect is an autonomous AI agent that transforms messy legacy code into clean, modern, tested software — completely automatically. It uses a 9-step workflow:
- Scans the codebase for target function usage
- Builds an impact map of affected files
- Generates characterization tests to lock in behavior
- Runs tests to verify baseline
- Calls Gemini 3 to analyze and plan refactoring
- Generates clean, refactored code
- Applies changes behind feature flag (zero risk!)
- Runs tests in BOTH modes (old + new)
- Generates an evidence report for code review
How we built it
Gemini 3 Flash Preview — Core AI engine for code analysis, test generation, and refactoring
- Python — Agent implementation
- pytest — Test execution framework
- Streamlit — Beautiful interactive dashboard
- Feature Flags — Safe rollout with BILLING_V2 environment variable
Challenges we ran into
- Getting Gemini 3 to generate syntactically correct Python code consistently
- Building a self-healing loop that automatically fixes failing tests
- Ensuring the refactored code maintains 100% behavioral compatibility
Accomplishments that we're proud of
- 24/24 tests pass in both default and feature flag modes
- Fully autonomous — zero human intervention required
- Production-ready — feature flag enables safe A/B testing
- Beautiful dashboard with sparkly UI and comprehensive evidence reports
What we learned
- Gemini 3's code understanding capabilities are remarkably powerful
- Characterization tests are essential for safe refactoring
- Feature flags transform risky changes into safe experiments
What's next for Legacy Architect
- Support for multiple programming languages
- Integration with CI/CD pipelines
- VS Code extension for one-click refactoring
Log in or sign up for Devpost to join the conversation.