# Teaching AI to Write Android Code Your Way: A Team Playbook Approach

How we trained AI to generate Kotlin code that matches our team's exact standards

- **Source:** [Medium Engineering](https://medium.com/medium-eng)
- **Published:** 2026-03-17
- **Topic:** [Software & Engineering](https://brifing.si/c/engineering)
- **Original article:** <https://medium.engineering/making-ai-write-android-code-our-way-a-practical-guide-to-agent-skills-4e7b085d8e50?source=rss----2817475205d3---4>
- **On Brifing:** https://brifing.si/s/c6f81424-fa93-461c-99f1-0bc0fed6a41e

## Problem: Generic AI Outputs

Medium's small Android team faced issues with AI assistants producing generic Kotlin code. The AI didn't understand their Clean Architecture principles, Jetpack Compose standards, or testing approach. They needed to centralize knowledge scattered across PR comments and Slack threads.

## Solution: The AGENTS.md File

This document at the project root serves as an AI playbook. It contains 30+ critical standards including module structure, Hilt injection, and StateFlow usage. Now AI automatically uses @HiltViewModel and sealed interfaces when creating ViewModels.

## Deep Learning with Skill Files

13 Markdown files in .agents/skills/ teach step-by-step workflows. For example, the create-compose-screen skill automatically generates 6-8 files for a new screen, including both ViewModel-injected and test-friendly composable versions.

## Scaffolding Skills

These automate 30-60 minute tasks like creating new screens or modules. create-feature-module handles everything from Gradle configuration to dependency wiring. create-use-case implements Clean Architecture layers with operator functions returning Result<T>.

## AI in Migration Processes

For long migrations like Material 2 to 3, AI uses a 60+ component mapping table. The compose-viewmodel-migration skill transforms Fragment-based structures to modern hiltViewModel composables, minimizing human error in complex transitions.

## Pattern Enforcement Skills

Skills like viewmodel-flags-usage mandate critical rules such as checking feature flags only during ViewModel initialization. This prevents repetitive flag checks in composables and potential bugs.

## Dynamic Context Management

While AGENTS.md is passive reference, skill files provide proactive instructions. Details like using the safeExecuteNotNull Apollo wrapper or analytics event logging are automatically applied.

## Maintaining Test Standards

The AI now uses MockK instead of Mockito, Turbine instead of LiveData for tests. Test tags and @VisibleForTesting annotations are added automatically, eliminating ViewModel dependency issues in UI tests.

## 6-Month Transformation

PR review times decreased by 40%. New engineers learned coding standards in 2 days instead of 2 weeks. 85% of AI-generated code gets merged on first attempt, showing significant quality improvement.

## Scalable Knowledge Management

This system preserves institutional memory as teams grow. The 'how do we do this?' question from new engineers became obsolete. The AI now writes not just Kotlin, but Medium's Kotlin - a revolutionary approach for large codebases.

## Sources covering this story

- https://medium.engineering/making-ai-write-android-code-our-way-a-practical-guide-to-agent-skills-4e7b085d8e50?source=rss----2817475205d3---4 — 

---

_Summary written by Brifing from the original reporting. Copyright in the original article belongs to its publisher; read the full piece at the link above._
