> Markdown version of [/videos/100224-pair-programming-with-generative-agents-refactoring-legacy-android-at-speed?t=996](https://www.wearedevelopers.com/videos/100224-pair-programming-with-generative-agents-refactoring-legacy-android-at-speed?t=996). Every page supports `.md` or `Accept: text/markdown`. Links point to the HTML versions so they work for humans too. Agent guide: [/agents.md](https://www.wearedevelopers.com/agents.md). --- # Pair Programming with Generative Agents: Refactoring Legacy Android at Speed Shift from writing code to architectural director. Discover how pair programming with autonomous generative AI systematically overhauled a tangled legacy Android architecture at speed. - **Speakers:** [Ahmed Tikiwa](https://www.wearedevelopers.com/@ahmed-tikiwa) - **Event:** World Congress 2026 Europe - **Published:** July 10, 2026 - **Duration:** 30:34 - **URL:** https://www.wearedevelopers.com/videos/100224-pair-programming-with-generative-agents-refactoring-legacy-android-at-speed ## Summary Software modernization often stalls due to accumulated architectural debt, but advanced agentic AI is fundamentally changing the refactoring lifecycle. In the real-world Jetpack Compose application 'Upnext', a tangled web of legacy technical debt—ranging from a brittle three-way dependency lock between Kotlin, Hilt, and KSP to heavily manual release systems—was systematically overhauled. Using the autonomous AI agent Antigravity as a collaborative pair programmer, the codebase was modernized entirely within branch isolation. Rather than blind code generation or trial-and-error, the agent traced complex dependency graphs, parsed compiler error outputs, and iterated on implementations, shifting the developer’s role from writing every line of code to acting as the architectural director. The refactor tackled complex paradigm shifts, most notably migrating from a third-party navigation library to the highly dynamic Compose Navigation 3. Because Navigation 3 treats the backstack as an owned mutable snapshot state list rather than a managed black box, the migration exposed framework-level crashing. The agent resolved this natively by implementing assisted injection for Hilt to replace missing SavedStateHandle arguments, alongside scoping ViewModel lifecycles directly to the backstack entry. Furthermore, the application UI was adapted into responsive multi-pane layouts utilizing both `NavigationSuiteScaffold` and `ListDetailPaneScaffold`. This dual-layer adaptation allowed seamless user experiences across mobile portrait, mobile landscape, and tablet environments, bridging complete layout transitions with single-line reactive state derivations. Effectively directing an AI agent requires progressive disclosure and explicit boundary setting, achieved by codifying architectural rules into portable `skill.md` files pushed directly to the repository. Without explicit rules, agents will hallucinate disparate patterns from training data, making codified context an essential industry standard. Most critically, an AI agent's work cannot be trusted unconditionally; ‘YOLO mode’ without human oversight is dangerous. Output must be validated by requiring the agent to build its own comprehensive verification layer. By expanding the test suite with 55 new files, the agent constructed robust GitHub Actions workflows integrating Ktlint, Fastlane deployments triggered by smart stateless cron gates, and automated smoke tests traversing the full backstack on a headless API 30 emulator. Ultimately, true modernization happens when the human defines the guardrails and pipelines, allowing the AI to successfully orchestrate the heavy lifting of execution. **Keywords:** jetpack compose refactoring, agentic AI pair programming, hilt KSP dependency resolution, compose navigation 3 migration, assisted injection implementation, listdetailpanescaffold adaptive layouts, automated fastlane deployment, calver versioning strategy, headless emulator smoke testing, skill.md architectural constraints, AI progressive disclosure, legacy codebase modernization, CI/CD pipeline automation, github actions workflows ## Chapters 1. **Exploring the Jetpack Compose architecture of Upnext** (03:25) — The Upnext TV tracking app utilizes a multimodule architecture built entirely in Jetpack Compose. 1. **Identifying accumulated architectural debt in a modern codebase** (05:51) — Manual deployments, tight navigation coupling, and locked dependencies created a fragile development environment. 1. **Adopting the Antigravity AI agent for complex refactoring** (08:07) — Using an autonomous AI collaborator instead of simple autocomplete requires defining target architectures and reviewing implementation plans. 1. **Shifting developer roles in autonomous pair programming loops** (10:12) — Developers focus on directing, reviewing, and approving implementations while the agent compiles, debugs, and tests in branch isolation. 1. **Enforcing architectural consistency using markdown agent skills** (12:08) — Portable skill files guide the AI framework effectively by applying progressive disclosure and custom modular constraints. 1. **Resolving a three-way dependency lock in legacy code** (14:35) — Tracing the conceptual dependency graph resolved compatibility issues between the Kotlin language level, KSP, and Hilt versions. 1. **Executing a structural migration to Jetpack Navigation 3** (16:36) — The transition required explicitly passing route objects with assisted injection and scoping view model lifecycles accurately. 1. **Implementing adaptive app layouts across diverse screen sizes** (19:47) — Independent scaffold navigation systems are bridged with reactive state tracking to automatically reveal split views on tablets. 1. **Constructing comprehensive continuous integration and deployment pipelines** (22:21) — Replacing manual uploads with GitHub Actions, Fastlane scripts, and smart staleness gates ensures reliable automated releases. 1. **Validating autonomous code generation with robust automated testing** (24:30) — The AI agent proved its reliability by autonomously writing comprehensive unit and instrumented tests for emulators. 1. **Directing the AI symphony and avoiding unmonitored deployments** (26:24) — Successful AI collaboration requires setting explicit rules, demanding strict test verifications, and monitoring output rigorously. 1. **Comparing Antigravity and Claude Code for complex tasks** (29:01) — Practical experiences show tailored AI agents effectively navigating full workflows without running into restrictive token constraints. ## Related Moments - [Shifting developer workloads and realistic AI productivity gains](https://www.wearedevelopers.com/videos/1830-wearedevelopers-live-speculaitions) (from "WeAreDevelopers LIVE - SpeculAItions") - [Rethinking team structures around AI agent capabilities](https://www.wearedevelopers.com/videos/1539-agentic-devops-how-ai-powered-automation-transforms-software-delivery-on-github-and-azure) (from "Agentic DevOps: How AI-Powered Automation Transforms Software Delivery on GitHub and Azure") - [Shifting from chat interfaces to autonomous agentic co-piloting](https://www.wearedevelopers.com/videos/2097-ai-code-then-vs-now-from-complex-rubbish-to-co-piloting-in-12-months) (from "AI Code then vs now: From Complex rubbish to co-piloting in 12 months") - [Transitioning software engineering teams to AI-native development workflows](https://www.wearedevelopers.com/videos/100087-ai-ready-what-enterprise-transformation-actually-takes) (from "AI-Ready? What Enterprise Transformation Actually Takes") - [The evolution of AI programming and agentic workflows](https://www.wearedevelopers.com/videos/100032-under-the-hood-of-building-on-lovable) (from "Under the Hood of Building on Lovable") - [Using AI copilots to explain and debug legacy codebases](https://www.wearedevelopers.com/videos/1302-wearedevelopers-live-dishonest-charts-britcss-debugging-with-ai) (from "WeAreDevelopers LIVE - Dishonest Charts, BritCSS, Debugging with AI") ## Related Articles - [What is Agentic Programming and Why Should Developers Care?](https://www.wearedevelopers.com/magazine/625-what-is-agentic-programming-and-why-should-developers-care) - [Never delegate the understanding](https://www.wearedevelopers.com/magazine/749-never-delegate-the-understanding) - [How we Build The Software of Tomorrow](https://www.wearedevelopers.com/magazine/120-how-we-build-the-software-of-tomorrow) - [Dev Digest 108 - Git off my cloud!](https://www.wearedevelopers.com/magazine/407-dev-digest-108-git-off-my-cloud) ## Related Jobs - [Staff Software Engineer, Copilot Experiences](https://www.wearedevelopers.com/jobs/ext/164361-staff-software-engineer-copilot-experiences) at **GitHub** - [Principal Product Manager, Agent Platform](https://www.wearedevelopers.com/jobs/ext/277541-principal-product-manager-agent-platform) at **GitHub** - [AI Software Engineer (Germany)](https://www.wearedevelopers.com/jobs/48317-ai-software-engineer-germany) at **Sunhat** - [Founding Mobile Engineer (iOS)](https://www.wearedevelopers.com/jobs/ext/1648532-founding-mobile-engineer-ios) at **Almedia** - [Senior AI Agent Software Engineer (Go, Python) (m/f/x)](https://www.wearedevelopers.com/jobs/48277-senior-ai-agent-software-engineer-go-python-m-f-x) at **Dynatrace** - [Senior Engineer, Infrastructure Platform](https://www.wearedevelopers.com/jobs/ext/328836-senior-engineer-infrastructure-platform) at **Intercom, Inc.**