๐Ÿ› ๏ธ AI Tools for Android Developers

How to Write Better Prompts for AI Coding Tools

The difference between a frustrating AI coding session and a productive one is usually the prompt. Good prompts read like a good ticket: context, goal, constraints and a definition of done. Here are patterns and templates that work for Android development.

โœ๏ธ Yunok Tech ๐Ÿ“… Updated โฑ 3 min read ๐ŸŽฏ Beginner
On this page
  1. Anatomy of a good coding prompt
  2. Templates for common tasks
  3. Techniques that improve results
  4. Persistent rules files
  5. Before and after
  6. Situations
  7. Frequently asked questions
  8. Conclusion

"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

Components of a good coding prompt Five parts: context such as files, versions and conventions; the goal; constraints such as what not to change; acceptance criteria such as tests passing and states covered; and the requested output format, such as plan first, then a diff. Contextfiles, versions,conventions Goalone outcome Constraintswhat not totouch or add Done whentests, states,builds Outputplan first,then small diff
These are the same five things a good engineering ticket contains.

Templates for common tasks

Feature templateText
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 templateText
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 templateText
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

VagueSpecific
Fix this crashHere's the full trace and the class. List likely causes ranked, then propose the smallest fix and a test that reproduces it.
Add cachingAdd 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 fasterThis 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.

See all our apps โ†’

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.

Share: LinkedIn X / Twitter WhatsApp