Skip to content

Guide · Agent skill

How to use the R8 Keep Rule Analyzer agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The R8 Keep Rule Analyzer is an agent skill that inspects an Android project's Gradle build files and R8 keep rules, then writes a report on which rules are redundant, too broad, or already covered by library rules. It is aimed at Android developers who want a smaller app build and at teams who inherited long ProGuard or R8 rule files. After this guide you will know what the skill does, how to install it, how to ask for it in plain language, and what it needs before it runs.

R8 Keep Rule Analyzerandroid/skills · Apache-2.0

Quick start

  1. 1Download and unzip the skill. Download the r8-analyzer ZIP from this page and unzip it. Keep the folder structure intact.
  2. 2Place it in a skills folder. Move the folder into ~/.claude/skills/ for personal use or into your project's .claude/skills/ directory. Alternatively, upload it under Settings → Capabilities → Skills in the Claude apps.
  3. 3Install protobuf. Run pip install "protobuf>=6.33.4" with Python 3 available on your machine.
  4. 4Open your Android project. Start your agent from the project root that contains the Gradle wrapper, so ./gradlew works.
  5. 5Ask for the analysis. Describe your goal, such as reducing app size or finding redundant keep rules.
  6. 6Review the report. Read each flagged rule and its impact metrics before editing anything.
  7. 7Test a release build. Apply changes you agree with and run a careful release build test, since a bad rule can break the build.

What is an agent skill and what does r8-analyzer do?

An agent skill is a folder of instructions and helper files that an AI coding agent loads when a task matches the skill's description. The r8-analyzer skill covers one job: finding keep rules that keep more code than necessary in an Android app.

R8 is the code shrinker in Android builds. Keep rules tell it what not to remove or rename. When the skill runs, it runs Google's R8 tooling to measure how many classes, fields and methods each rule protects, then writes a Markdown report flagging redundant rules, overly broad package-wide rules, and rules already covered by library consumer rules. It only recommends changes; a person has to verify and apply them.

  • Flags redundant keep rules
  • Flags broad package-wide rules
  • Flags rules that subsume library consumer keep rules
  • Reports impact metrics such as classes, fields and methods protected per rule

Install the r8-analyzer skill

Download the ZIP for the skill from this page and unzip it. Place the resulting folder in your personal skills directory, ~/.claude/skills/, or in a project's .claude/skills/ directory if you want the skill to apply only to that project.

If you use the Claude apps, you can instead upload the skill under Settings → Capabilities → Skills.

  • Personal install: unzip into ~/.claude/skills/
  • Project install: unzip into your project's .claude/skills/
  • Claude apps: Settings → Capabilities → Skills, then upload

Check the requirements before you run it

The skill needs Python 3 and the protobuf Python package, version 6.33.4 or later. Install it with the command below. Your project must be an Android Gradle Plugin project that includes the Gradle wrapper (./gradlew).

If your AGP version is below 9.3, the skill's build-based path temporarily changes the R8 classpath in settings.gradle or settings.gradle.kts. That change must be reverted afterward. The skill is designed to ask for your confirmation before editing those files when it runs interactively.

  • Python 3
  • protobuf Python package 6.33.4 or later
  • Android Gradle Plugin project with the Gradle wrapper
  • For AGP below 9.3: a temporary R8 classpath change in settings.gradle(.kts) that must be reverted
pip install "protobuf>=6.33.4"

Ask for the analysis in plain language

You do not need to type a command. Describe what you want from the agent while it has access to your project. The skill is meant to trigger when you want to reduce app size, remove redundant or overly broad keep rules, or troubleshoot ProGuard configurations.

Phrase requests around your goal. Examples include asking the agent to review your R8 keep rules for redundancies, to find keep rules that are too broad for your app size, or to work out why R8 keeps more code than you expect.

The skill does not handle general Gradle build errors, Compose UI performance, or runtime CPU profiling. Ask about those and it will not be the right tool.

  • "Review the keep rules in this Android project and tell me which ones are redundant."
  • "My release APK is too big. Check whether our R8 keep rules are too broad."
  • "Why is R8 keeping so much code in our release build?"

Run the analysis and read the report

The skill chooses a path based on your AGP version. With AGP 9.3.0 or later, it runs a standalone Gradle task, converts the output to JSON, then analyzes it. With AGP below 9.3.0, it temporarily updates R8 in your settings file, generates the report, analyzes it and reverts the change.

The report is a Markdown document. It lists the rules it found, their impact metrics and guidance from the skill's rule reference. Review every suggested change and test your release build carefully before applying it.

  • Analysis output is written under the project's tmp/ folder
  • The report is shown in the chat and is not saved to a file by the skill
  • Verify each recommendation with a release build and testing before changing rules

Safety notes: scripts and network

The skill runs Python scripts from its scripts/ directory, including analyze.py and convert_pb_to_json.py. It also runs Gradle commands in your project. According to its metadata, it does not use the network. Review the scripts yourself if your organisation requires it.

The skill is designed to create files only under tmp/ and to leave your project files unchanged, apart from the temporary settings change described above. If you do not want build files edited, tell the agent before it runs; the skill then reports rule-level findings without scores.

  • Runs scripts: yes
  • Uses network: no
  • Writes to tmp/ only, apart from the temporary R8 settings change for AGP below 9.3

What people use it for

  • Trimming an inherited ProGuard rule file that nobody fully understands
  • Finding package-wide keep rules that protect far more code than the app uses
  • Checking whether your rules duplicate keep rules that a library already ships
  • Investigating why a release build keeps classes you expected R8 to remove

Frequently asked questions

How do I install the R8 Keep Rule Analyzer skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or into a project's .claude/skills/ folder. In the Claude apps you can instead upload it under Settings → Capabilities → Skills.

What do I need to run the r8-analyzer skill?

You need Python 3, the protobuf Python package version 6.33.4 or later, and an Android Gradle Plugin project with the Gradle wrapper. For AGP below 9.3 the skill also needs a temporary R8 classpath change that must be reverted.

Is the R8 Keep Rule Analyzer free?

The skill is licensed under Apache-2.0, according to the item details. Check the LICENSE.txt included with the skill for the complete terms.

Does the skill change my project files?

The skill is designed to only recommend changes and to write analysis output under tmp/. The one exception is the temporary R8 settings change for AGP below 9.3, which it reverts afterward.

Does the skill work with Jetpack Compose performance problems?

No. Its scope excludes Compose UI performance, runtime CPU profiling, and general Gradle build errors.

What should I do if the protobuf step fails?

The skill's instructions say versions lower than 6.33.4 fail on import with a VersionError or ImportError. Upgrade with pip install "protobuf>=6.33.4" and run the analysis again.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you maintain an Android app with long or inherited R8 keep rules and want a measured list of redundant and overly broad rules. Pick something else if your problem is a Gradle build error, Compose UI jank, or CPU profiling, or if you cannot test release builds carefully before changing rules.

Download the skill