Gemini Agent Mode and Android skills

How Agent Mode in Android Studio uses AGENTS.md files and on-demand skills, and how to write a SKILL.md that loads at the right time. About 22 minutes.

Why it matters

  • Agent Mode in Android Studio plans multi-step tasks (edit, build, run tests) instead of answering one question. Without a skill or AGENTS.md, it guesses your project conventions and produces diffs that break ./gradlew lint or ./gradlew test.
  • Interviewers at product companies now ask how you integrate AI agents into a team workflow: where project memory lives, how you scope an agent's permissions, and how you review its output. Knowing the SKILL.md format and the open Agent Skills standard shows you can contribute to a shared skill library.
  • Google publishes official Android skills at github.com/android/skills, installable with the Android CLI (android skills add <skill-name>). A senior dev who has read those skills and written a project-specific one is ahead of a candidate who only uses the chat panel.
  • The same open Agent Skills standard is used by Claude Code (.claude/skills/) and other tools. Understanding the mechanism once lets you switch tools without relearning the concept, which matters when a team standardises on one agent and you need to migrate.

The simple explanation

  • AGENTS.md is the whiteboard in the office: always visible, holds the rules everyone must follow.
  • A SKILL.md is a laminated card in a drawer: the agent pulls it out only when the task matches the card's label.
  • Agent Mode is a junior engineer who can read the whiteboard, open the right drawer, run ./gradlew build, and hand you a diff.
  • Without the card, the junior guesses the drawer and may open the wrong one.
  • Reviewing the diff is the code review you would do for any junior: you check every hunk, not just the summary.

Agent Mode in Android Studio replaces the single-turn chat with a loop: the agent reads the repo, plans steps, edits files across modules, builds the project, can deploy to a device and check Logcat, reads the results, and iterates. It waits for you to accept or reject changes as it works. It runs on Gemini, and Android Studio can also plug in other remote models.

Two layers of project memory control what the agent knows:

LayerFile / folderWhen loadedScope
Project rulesAGENTS.md files (root and subfolders)Added to the start of every prompt; the agent picks up files in the current directory and its parentsConventions, forbidden paths, build commands
Skills.agents/skills/<name>/SKILL.md or .android-studio/skills/<name>/SKILL.md (project root or home folder)On demand, when the request matches the skill's description, or when you type @skill-nameOne focused task (e.g. "run Gradle checks", "audit Compose state")

A SKILL.md file has YAML front matter (name, description) and a markdown body with steps and guardrails. The description is the matching signal: the model reads it to decide whether to pull in the full skill. Google's official Android skills live at github.com/android/skills; install with android skills add <skill-name> or download one and save it in a skills folder. Android Studio versions before Quail used .skills/ and .agent/skills/; move skills to the new folders when you upgrade. The format follows the open Agent Skills standard, so the same SKILL.md also works in Claude Code (which looks in .claude/skills/ and reads CLAUDE.md).

The common bug: a skill's description is too vague, so the agent never loads it, or too broad, so it loads for unrelated prompts and injects irrelevant steps. The fix is to write the description as a concrete trigger sentence, not a topic label.

Notes

  • AGENTS.md content is added to the start of every prompt. Keep it short; move detailed procedures into skills so the context window stays small. You can split it with @./file.md imports.
  • Skills live in .agents/skills/<name>/SKILL.md or .android-studio/skills/<name>/SKILL.md, at the project root or in your home folder. The folder name and the name field in the front matter should match.
  • The description field in SKILL.md front matter is what the model reads to decide whether to load the skill. Write it as a trigger sentence: "Use when the user asks to run Gradle build or debug a failing CI task."
  • Google's official Android skills are at github.com/android/skills. Run android skills list to see them and android skills add <name> to install one. Check the repo for the current list; it changes often.
  • The open Agent Skills standard is shared across tools. Claude Code uses .claude/skills/ and CLAUDE.md; Android Studio uses .agents/skills/ or .android-studio/skills/ and AGENTS.md. The SKILL.md format is the same.
  • Agent Mode can build, run, and edit across many files. A skill or AGENTS.md only guides it; it is not a permission system. Review each change it asks you to accept.
  • Never put API keys, signing passwords, or keystore paths in AGENTS.md or any SKILL.md. These files are committed to the repo. Secrets stay on a server or in a local, git-ignored file.
  • Treat every diff the agent produces like a junior's pull request: read every hunk, run the tests yourself, and check that no signing config or local.properties was touched.
  • If a skill does not load, check three things: the folder path, the name field matching the folder, and whether the description actually overlaps with your prompt wording. You can also force it with @skill-name.

Code example

This is a production-style SKILL.md for a Gradle build-check skill. It shows the YAML front matter, the step list, and the guardrails that keep the agent from touching signing config or running clean without permission.

---
name: gradle-build-check
description: >
  Run and interpret Gradle build, test, or lint results for an Android
  project. Use when the user asks to build, run tests, debug a failing
  CI task, or resolve a dependency conflict.
---
 
# Gradle Build Check
 
## When to use
- User asks to run `./gradlew build`, `./gradlew test`, or `./gradlew lint`
- A CI log is pasted and the user asks for a fix
- A dependency conflict appears in `./gradlew dependencies`
 
## Steps
1. Run the task with `--stacktrace` to get the full exception chain.
2. Read the first exception and every `Caused by` line.
3. Identify the failing module (`:app`, `:feature-x`, a library).
4. If the error is a dependency conflict, run
   `./gradlew dependencies --configuration debugRuntimeClasspath`
   and look for duplicate or incompatible versions.
5. Propose the minimal fix. Do not edit `build.gradle` until the
   user confirms the change.
 
## Do NOT
- Do not run `./gradlew clean` unless the user explicitly asks.
- Do not read or edit `signingConfigs`, `keystore` files, or
  `local.properties`.
- Do not paste any credential or key material into the chat.
- Do not change the Kotlin or AGP version without the user's OK.
  • The description field is a trigger sentence, not a topic label. It tells the model exactly when to load this skill, which prevents false positives.
  • The Do NOT section is the guardrail layer. Without it, the agent may run ./gradlew clean or touch signingConfigs in build.gradle, which can break a release build.
  • Step 5 forces a human confirmation before editing build.gradle, matching the "review every diff" principle. The agent proposes; the engineer approves.

Run the idea in plain Kotlin

data class Skill(val name: String, val keywords: List<String>)

fun main() {
  val skills = listOf(
      Skill("gradle-build-check", listOf("build", "test", "gradle", "lint", "ci", "dependency")),
      Skill("compose-state-audit", listOf("compose", "state", "remember", "recomposition", "lifecycle")),
      Skill("networking-review", listOf("retrofit", "okhttp", "network", "api", "http", "coroutine"))
  )

  val prompt = "the gradle build is failing on ci, can you run the tests and check lint"
  val promptWords = prompt.lowercase().split(" ")

  val scored = skills.map { skill ->
      val overlap = skill.keywords.count { kw ->
          promptWords.any { word -> word.contains(kw) || kw.contains(word) }
      }
      skill.name to overlap
  }.sortedByDescending { it.second }

  println("Prompt: " + prompt)
  println("Matched skills (ranked by keyword overlap):")
  scored.forEachIndexed { i, pair ->
      println("  " + (i + 1) + ". " + pair.first + "  overlap=" + pair.second)
  }
  println("")
  println("(Real agents let the model judge relevance; keyword overlap is only a rough picture.)")
  if (scored[0].second > 0) {
      println("Agent would load skill: " + scored[0].first)
  } else {
      println("No skill matched; agent falls back to AGENTS.md only.")
  }
}

In production

Agent rewrote signing config and broke the release build
  • A developer asked Agent Mode to "fix the build" after a lint error. The agent edited build.gradle and replaced the signingConfigs block with a placeholder.
  • The next ./gradlew assembleRelease failed because the keystore path was gone.
  • The diff was merged because the developer trusted the agent's summary and did not read the build.gradle hunk.
The fix
  • Added a Do NOT section to the project's AGENTS.md: "Never edit signingConfigs, keystore files, or local.properties."
  • Created a SKILL.md for build fixes that tells the agent to use ./gradlew lint and ./gradlew test to verify, and to stop before touching build config.
  • Added a pre-commit hook that blocks any diff touching signingConfigs or *.jks / *.keystore files.
Skill never loaded because the description was a topic label
  • A team wrote a SKILL.md with description: Compose best practices. The agent never loaded it for prompts like "why is my Composable recomposing too often?"
  • Developers fell back to the generic chat, which gave generic answers that ignored the project's state-management conventions.
  • The skill sat in .agents/skills/compose-audit/ unused for three sprints.
The fix
  • Rewrote the description as a trigger sentence: "Use when the user asks about recomposition, remember, derivedStateOf, or lifecycle-aware state in Jetpack Compose."
  • Added the keywords recompose, remember, derivedStateOf, Lifecycle to the description so the model matched natural prompts.
  • Verified by running three sample prompts in Agent Mode and confirming the skill loaded each time.

Common mistakes

  • Writing a vague skill description. A description like "Android tips" matches almost everything or nothing. The model needs a concrete trigger sentence so it loads the skill only for the right task. Write "Use when the user asks to run ./gradlew test or debug a failing CI task."
  • Putting secrets in AGENTS.md or SKILL.md. These files are committed to the repo. An API key or keystore path in AGENTS.md is visible to every clone. Secrets must stay on a server or in a git-ignored local file; the skill should reference an environment variable name, not the value.
  • Trusting the agent's summary without reading the diff. Agent Mode can produce a 200-line diff and summarise it as "fixed the lint error." The summary hides side effects: a changed proguard-rules.pro, a new dependency, a deleted test. Read every hunk, run ./gradlew test yourself, and check that no signing or config file was touched.
  • One giant AGENTS.md instead of skills. A 500-line AGENTS.md consumes context window on every turn, leaving less room for the actual task. Keep AGENTS.md to project-wide rules (build commands, forbidden paths, style) and move task-specific procedures into individual SKILL.md files that load on demand.
  • Not giving the agent a way to verify its work. If the skill does not include a verification step (run ./gradlew test, run ./gradlew lint, open the log), the agent cannot confirm its fix. It will stop after the first edit and hand you an untested diff. Always add a "verify" step to every skill.
  • Mixing up skill folders. Android Studio looks in .agents/skills/ or .android-studio/skills/ (older versions used .skills/); Claude Code looks in .claude/skills/. A skill placed in the wrong folder is invisible to the active agent. Check which tool your team uses and put the file in the matching directory, or symlink one to the other.

Interview questions

Answer out loud first. Then reveal the answer and compare it at each depth.

“How does Agent Mode in Android Studio differ from a single-turn chat?”

“What is the difference between AGENTS.md and a SKILL.md, and when do you use each?”

“How do you review code that an AI agent wrote before merging it?”

“A skill you wrote is not loading in Agent Mode. How do you debug it?”

Quiz

Which file does the agent in Android Studio add to every prompt as project instructions?

What is the purpose of the description field in a SKILL.md front matter?

A developer puts a SKILL.md in .claude/skills/ but uses the agent in Android Studio. What happens?

Which of these should NEVER appear in AGENTS.md or a SKILL.md?

0 of 4 answered

Mini task

Write and test a Gradle-check skill for your project (15 min)

  1. Create the folder. In your Android project root, make .agents/skills/gradle-check/ and add a file SKILL.md.

  2. Write the front matter. Add YAML front matter with name: gradle-check and a description that is a trigger sentence: "Use when the user asks to run ./gradlew build, ./gradlew test, ./gradlew lint, or debug a failing CI task."

  3. Write the body. Add a ## Steps section (run the task with --stacktrace, read the exception chain, identify the module, propose a minimal fix) and a ## Do NOT section (no ./gradlew clean, no editing signingConfigs, no reading local.properties, no pasting credentials).

  4. Test the match. Open Android Studio, open the Agent pane, and type: "Run the unit tests and tell me if anything fails." Confirm the skill loads (the agent should reference the steps you wrote). Then type: "Explain how ViewModel works." Confirm the skill does NOT load.

  5. Tune the description. If the skill did not load in step 4, add the words test, unit test, and CI to the description and retry. If it loaded for the ViewModel prompt, narrow the description.

  6. Verify the guardrails. Ask the agent: "Run ./gradlew clean and then build." Check that the agent follows the Do NOT list and asks you first. Remember a skill is guidance, not a hard block.

Done when: the skill loads for a build/test prompt, does not load for an unrelated prompt, and the agent asks before running ./gradlew clean.

Next: Reviewing and testing AI-written code