An agent only knows what is in its context. Good context engineering gives it the rules and background that a new teammate would need.
Repository instructions
Many agent tools read an instruction file from the repository root. Use it to document how to build and test the project, the architecture and module layout, naming and style conventions, and things the agent must never do, such as editing generated files.
Keep it short and specific
Long, vague guidance gets ignored or crowds out useful context. Prefer concrete rules: "ViewModels expose state as StateFlow and never reference the Android context."
Architecture decisions as context
Short decision records explain why choices were made. They help the agent follow the intended design instead of inventing its own.
Decompose tasks
Large requests perform poorly. Split them into steps the agent can complete and verify: define the model, add the repository, wire the view model, build the screen, write tests.
Retrieval and examples
Point the agent to existing files that show the pattern you want. A reference implementation of one screen teaches more than a paragraph of description.
Maintain it
Update instruction files when conventions change, and review them like code. Outdated guidance causes confident mistakes.
Takeaway
Treat context as part of the codebase. Time spent writing clear instructions pays back on every task.
Continue with the book
Explore the full treatment, worked examples, and exercises in Agentic Android App Development.
Adapted from Agentic Android App Development, published by Choral Software. Article text and original examples © 2026 Choral Software. All rights reserved.
