On this page
"Make a login screen" gets you a generic screen with hard-coded colours and fake validation. "Create a stateless LoginContent composable for our existing LoginUiState, using AppTheme tokens and string resources, with previews for error and loading states" gets you something you can use. Specificity is the skill.
Anatomy of a good coding prompt
Templates for common tasks
Context: [module/file paths], we use [Compose, Hilt, Room, StateFlow UiState pattern], see AGENTS.md.
Goal: Add [feature] to [screen].
Constraints: no new dependencies; don't change public APIs of [X]; follow existing [Y] pattern.
Done when: unit tests for the ViewModel cover [cases]; previews for [states]; ./gradlew :feature:x:testDebugUnitTest passes.
Output: first a short plan (files to change + why). Wait for my OK, then implement.Refactor [Class] to [goal, e.g. inject dispatchers / remove GlobalScope].
Behaviour must not change. Keep the diff minimal; no renames outside this class.
List any behaviour you are unsure about instead of guessing. Update/add tests to prove equivalence.Explain what [file/function] does step by step, including threading and lifecycle implications.
Then list 3 risks or bugs you see, with line references. Don't rewrite the code.Techniques that improve results
- Plan, then code: ask for a plan first and correct it before any code is written. Cheaper than fixing a wrong implementation.
- Small steps: one screen, one class, one migration step at a time.
- Show an example: "follow the pattern in
OrdersViewModel.kt" beats describing the pattern. - Ask for uncertainty: "list assumptions" or "say if you're unsure" reduces confident guessing.
- Iterate with evidence: paste the failing test output or compiler error back, instead of "it doesn't work".
Persistent rules files
Put conventions you'd otherwise repeat into a rules file such as AGENTS.md, which Android Studio and other tools can read. Keep it short, specific and versioned. See Gemini in Android Studio for an example.
Before and after
| Vague | Specific |
|---|---|
| Fix this crash | Here's the full trace and the class. List likely causes ranked, then propose the smallest fix and a test that reproduces it. |
| Add caching | Add stale-while-revalidate caching to ProfileRepository using the existing Room DAO, 10-minute TTL, invalidate on profile update. Tests for stale and fresh paths. |
| Make it faster | This LazyColumn janks on scroll (trace summary attached). Suggest changes to reduce recomposition; don't change the visual design. |
Situations
New to a codebase
Explain templates first, then small feature templates with "follow pattern X".
Agent mode
Clear definitions of done plus commands to run (build, tests), and permission to stop and ask.
Code review help
"Review this diff for lifecycle, threading, security and test gaps. Cite lines."
Frequently asked questions
Are longer prompts always better?
No. Relevant context and clear constraints matter. Irrelevant files and walls of text dilute attention and cost tokens.
Should I keep a prompt library?
Yes. Store team templates in the repository or your IDE's prompt library, and refine them as you learn what works.
Why does the AI ignore my conventions?
It may not have seen them. Add a rules file, reference example files, and state constraints explicitly in the prompt.
Conclusion
Write prompts like tickets: context, goal, constraints, definition of done and output format. Plan before code, work in small steps, reference real examples, iterate with concrete evidence, and keep conventions in a shared rules file.
Next step: use AI on the reviewing side in AI Code Review: Benefits, Risks and Limitations.
Official references
๐ฑ Apps built by Yunok Tech
Real Android apps on Google Play, free to download.
Walzi4K wallpapers for lock and home screenGet it โธ
NotiVaultNotification history: recover dismissed notificationsGet it โธ
Ready to build real Android applications?
AI coding tools multiply what you already know. The stronger your Kotlin, Compose and architecture foundation, the better you can judge, fix and ship what these tools suggest.
Move beyond theory and strengthen your Android development skills with Yunoktech's Android course. Learn core concepts, practical implementation, modern Android development techniques, and the reasoning behind building maintainable applications.
Explore the Android course and take your next step as an Android developer.