Skip to content

About

Claude Code and Codex plugin that analyzes and optimizes Android phones over adb: storage, cleanup, performance, apps. No app installed on the phone.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

mobile-optimizer

Android phone connected by USB to a computer showing storage usage

A plugin for Claude Code and Codex that analyzes and optimizes a phone from your computer. You plug the phone in, ask in your own language, and the agent measures, explains, and changes only what you approve.

Android is supported today. Nothing is installed on the phone.

Leggi questa guida in italiano: LEGGIMI.md.

Contents

What it does

Command What you get Changes the phone
/mobile-doctor Checks adb, the cable connection and the authorization no
/mobile-storage Where the space went: totals, space by kind, heaviest folders, largest files no
/mobile-cleanup Junk that can be deleted, by group: app caches, temporary files, installers, sent-media copies, empty folders only the groups you approve
/mobile-performance Memory and CPU, top 5 apps for each, then cache trim, background cleanup, shorter animations, app recompilation only the actions you approve
/mobile-apps Apps by size and last use, preinstalled apps that can be removed, uninstall and data reset only the apps you approve
/mobile-offload Moves photos and videos to a folder on the computer or NAS, in year/month, verifying every copy before deleting it from the phone only after a verified copy exists
/mobile-health Signs of tampering, missing security updates, risky settings, battery wear no

The plugin is written in English, and the agent answers in the language you write in.

Why not a cleaner app from the store

Cleaner and booster apps run inside the phone, as ordinary apps, so Android limits what they may do. This plugin runs outside it, through the debugging interface Android provides for exactly this kind of work. The differences below are properties of the two approaches that you can check, not opinions.

Cleaner app from the store mobile-optimizer
Installed on the phone Yes, and it uses storage, memory and battery itself Nothing is installed on the phone
Ads, tracking, account Common in free apps; paid tiers remove ads None. No network calls at all: read the code
Permissions you grant Often "all files access", usage access, accessibility, notifications One: USB debugging for your own computer, which you can turn off afterwards
Other apps' caches Since Android 6 an app cannot clear another app's cache; it can only send you to Settings Clears all app caches with Android's own pm trim-caches
Files under Android/data Out of reach for apps since Android 11 Listed and measured
Preinstalled apps Cannot be removed by an app Removed from your profile, with the command that brings each one back
"RAM boost" Kills processes that Android often restarts at once, sometimes on a timer Closes cached apps once, when you ask, and shows memory before and after
Photos and videos Suggests deleting "similar" or "large" items Moves them to your disk and deletes a file only after an identical SHA-256 copy exists
Before deleting A total, and a button The exact list, saved as a plan; only that plan can be applied
Afterwards Usually nothing A journal of every change, with the undo command where one exists
Explanations Fixed screens An agent that reads the numbers with you, in your language
Source code Closed Open, MIT license

One more difference: this plugin has nothing to sell you after the scan, so it has no reason to make the phone look worse than it is. When nothing needs cleaning, it says so.

What it cannot do

  • It needs a computer and a cable, and an agent (Claude Code or Codex) to drive it. The scripts are free; the agent you use may not be.
  • No root. System partitions and the private data of other apps (/data/data) are out of reach. So are the Secure Folder and work profiles.
  • Deleted files do not come back. There is no recycle bin behind cleanup or apps clear-data.
  • It is not an antivirus. /mobile-health reports indicators; a clean table does not prove a clean phone.
  • No miracle speed-ups. A phone that is slow because its storage is nearly full, or because one app misbehaves, can be helped. A phone that is slow because its hardware is old cannot. The plugin reports measured numbers and promises no percentage.
  • Android only, for now. iOS exposes far less to a computer; support is not written yet.
  • Brand-specific suggestions exist for Samsung only. Every other brand gets the generic Android features, which are most of them.

What adb is

adb, the Android Debug Bridge, is Google's official command line tool for talking to an Android device from a computer. It is part of the Android developer kit, in a package called "SDK Platform-Tools". Developers use it every day to install and inspect apps; Android Studio uses it under the hood.

Three facts matter here:

  • It is opt-in. adb talks only to a phone on which you turned on USB debugging, an option hidden behind the Developer options menu.
  • It is per computer. The first time you connect, the phone shows the fingerprint of the computer's key and asks whether to trust it. No approval, no access.
  • It is not root. Through adb the computer acts as the shell user: more than an app can do (list all files in shared storage, ask the package manager to remove an app, read system statistics), far less than the system itself.

This plugin sends adb commands on your behalf. Without adb installed on the computer it cannot do anything.

Requirements

Where What
Computer macOS, Linux or Windows
Computer adb (Android SDK Platform-Tools): see step 1
Computer Python 3.10 or later; no extra packages
Computer Claude Code or Codex
Phone Android with USB debugging on: see steps 2 to 4
Between them A USB cable that carries data; many cheap cables only charge

Step 1: install adb on the computer

macOS (with Homebrew):

brew install --cask android-platform-tools

Debian, Ubuntu:

sudo apt install adb

Fedora:

sudo dnf install android-tools

Arch:

sudo pacman -S android-tools

Windows (PowerShell):

winget install Google.PlatformTools

Any system, by hand: download "SDK Platform-Tools" from https://developer.android.com/tools/releases/platform-tools, unzip it, and add the folder to your PATH.

Check that it works:

adb version
python3 --version

The first prints Android Debug Bridge version ...; the second must print 3.10 or later. On Windows the Python command may be python or py -3.

Step 2: turn on Developer options on the phone

Developer options is a settings menu that Android hides until you ask for it.

  1. Open Settings and go to About phone.
  2. Find Build number:
    • Samsung: About phone > Software information > Build number
    • Google Pixel, Motorola: About phone > Build number
    • Xiaomi, Redmi, POCO: About phone > OS version (older phones: MIUI version)
    • OnePlus, OPPO, realme: About device > Version > Build number
  3. Tap it seven times in a row. The phone counts down ("You are 3 steps away from being a developer"), asks for your PIN, and confirms with Developer mode has been turned on.

Step 3: turn on USB debugging

  1. Open Developer options. It is a new entry at the bottom of Settings (Samsung), under Settings > System (Pixel), or under Settings > Additional settings (Xiaomi).
  2. Scroll to USB debugging, turn it on, and accept the warning.

Two brand-specific obstacles:

  • Samsung, One UI 6 and later: when Auto Blocker is on, USB debugging is greyed out. Turn it off in Settings > Security and privacy > Auto Blocker, then come back.
  • Xiaomi, Redmi, POCO: also turn on USB debugging (Security settings) in the same menu. Without it the phone refuses changes to settings and app removal.

Step 4: connect and authorize the computer

  1. Plug the phone into the computer and unlock the screen.

  2. The phone shows Allow USB debugging? with the fingerprint of the computer's key.

  3. Tick Always allow from this computer and tap Allow.

  4. On the computer, run:

    adb devices

    You should see one line with a serial number followed by device:

    List of devices attached
    R58N12ABCDE    device
    

If the second column says unauthorized, the prompt on the phone was not accepted yet. If the list is empty, see Troubleshooting. /mobile-doctor runs these checks for you and tells you which step is missing.

When you are done, turn USB debugging off again unless you use it regularly: it gives a trusted computer broad control of the phone.

Step 5: install the plugin

Claude Code (inside a session):

/plugin marketplace add CodeGeeksAI/mobile-optimizer
/plugin install mobile-optimizer@codegeeks-mobile-optimizer

Codex:

codex plugin marketplace add CodeGeeksAI/mobile-optimizer
codex plugin add mobile-optimizer@codegeeks-mobile-optimizer

Start a new session after installing. In Claude Code the commands appear as /mobile-doctor and so on (or with the plugin prefix, /mobile-optimizer:mobile-doctor, when another plugin uses the same name). In Codex they are skills: $mobile-doctor.

Commands

You can type a command, or simply say what you want: "why is my phone full?", "move my old videos to the NAS". The examples below show the command, a sentence that triggers the same work, and what comes back. The figures are illustrative.

/mobile-doctor

Run this first. It checks that adb is installed, that the phone is attached and authorized, and prints the model, Android version, security patch level, battery and free space. When something is missing it names the step.

/mobile-doctor

"Is my phone connected correctly?"

Item Value
Manufacturer samsung
Model SM-G998B
Android version 15
Security patch 2026-10-01
Battery 85%

/mobile-storage

A read-only report in five tables: totals, space by kind as Android accounts for it, files by type, heaviest folders, and the largest files.

/mobile-storage
/mobile-storage 50

"Show me the 50 largest files on the phone." · "How much space do videos take?"

Type Files Size
Videos 1,127 48.0 GB
Images 18,420 21.4 GB
Audio 310 0.8 GB
File Type Modified Size
/sdcard/DCIM/Camera/20240815_101500.mp4 Videos 2024-08-15 3.9 GB
/sdcard/DCIM/Camera/20230710_183000.mp4 Videos 2023-07-10 2.7 GB

/mobile-cleanup

Finds what can be deleted and groups it. You choose the groups; you can ask what is inside a group before deciding.

/mobile-cleanup

"What can I delete safely?" · "Show me what is in the whatsapp-sent group."

Group What Items Size Holds media
app-caches App caches - 1.0 GB no
whatsapp-sent WhatsApp copies of sent media 3,769 1.9 GB yes
app-installers App installer files 4 310.0 MB no
temp-files Temporary files 7 12.4 MB no
empty-folders Empty folders 5 0 B no

Groups:

  • app-caches: the cache of every app. Apps rebuild what they need.
  • temp-files: .tmp and .temp leftovers.
  • thumbnail-cache: preview images the gallery rebuilds.
  • gallery-bin: items already in the gallery's recycle bin.
  • app-installers: .apk files left after installing.
  • whatsapp-sent: the copies WhatsApp keeps of what you sent.
  • empty-folders: folders with nothing inside.

A group that holds photos, videos or audio is deleted only when you ask for that group explicitly, after the agent warned you that those files may exist nowhere else. The private folders of apps (Android/data, Android/obb) are never touched.

/mobile-performance

Measures first: memory, swap, the five processes using the most memory, the five using the most CPU, animation settings, battery temperature. Then proposes only the actions the numbers justify, applies the ones you approve, and measures again.

/mobile-performance

"The phone feels slow, can you check?" · "Halve the animations."

RAM total RAM available Swap total Swap free
10.3 GB 2.9 GB 4.0 GB 0.8 GB
Process Memory
system 601.4 MB
com.google.android.gms 463.7 MB
com.android.systemui 384.8 MB

Actions:

Action What it does Undo
kill-background Closes cached background apps. Apps with an active service keep running, so notifications keep arriving not needed
trim-caches Drops every app cache not needed; caches are rebuilt
animations Sets the three animation scales to 0.5, 0 or 1.0 recorded in the journal
compile Recompiles apps from their usage profile; useful when Android did not do it while charging not needed

/mobile-apps

Lists the apps you installed by size and by how long ago you last opened them, the preinstalled apps that are known to be removable, and the preinstalled apps holding the most data.

/mobile-apps
/mobile-apps 90

"Which apps haven't I opened in three months?" · "Remove the news feed that came with the phone."

Package Total Data Last opened Days idle
com.example.news 652.0 MB 498.1 MB 2026-03-02 14:10:09 271
com.example.game 118.3 MB 22.0 MB never -

Three operations, each for one app at a time and only after you approve:

  • Uninstall an app you installed. The app and its data are deleted.
  • Remove a preinstalled app from your profile. The factory copy stays on the system partition, so the report prints the single command that restores it.
  • Clear the data of an app. The app returns to its just-installed state.

The plugin refuses to touch what the phone needs to work: the system interface, the phone and messaging apps, Google services, and the keyboard and home screen currently in use.

/mobile-offload

Moves photos and videos off the phone into a folder you choose: a local disk, an external drive, or a mounted NAS share. Files land in year/month folders, dated from the file name or, failing that, from the modification time.

/mobile-offload /Volumes/nas/photos
/mobile-offload ~/Pictures/phone video before 2026

"Move every video older than 2026 to /Volumes/nas/photos, then delete them from the phone."

For each file the tool:

  1. computes its SHA-256 on the phone;
  2. looks in the destination for a file of the same size and the same SHA-256, under any name: if one exists, the file counts as archived and is not copied again;
  3. otherwise copies it under a temporary name, computes the SHA-256 of the copy, and keeps it only if the two match;
  4. deletes the file from the phone only after step 2 or 3 succeeded.
Outcome Files Size
ALREADY-ARCHIVED 365 41.2 GB
COPIED 15 2.8 GB

A file whose name is taken in the destination by a different file is kept on the phone and reported; nothing is ever overwritten. Media received in chat apps is left alone unless you name its folder. Say "copy only" to keep the originals on the phone.

/mobile-health

A quick, read-only look at the state of the phone.

/mobile-health

"Is there anything strange on this phone?"

Check Value Status
Verified boot green ok
Bootloader locked ok
Security patch 2026-10-01 (59 days old) ok
Accessibility services none ok
Wireless debugging off ok
Apps installed outside a store com.example.byhand info
Battery health good ok
Free storage 54% ok
Days since restart 20 info

How changes are kept safe

  • Dry run by default. Every operation that changes the phone only describes what it would do, unless it is run with --confirm. The agent adds that flag after you approve, never before.
  • Plans. Cleanup and offload first write a plan file with the exact list of files. The step that deletes takes the plan as input: it cannot delete anything that was not shown. A plan made for one phone is refused on another.
  • Per-group approval. You approve groups, not single files, and you can look inside a group first.
  • Media needs more. Photos, videos and audio are deleted only with a verified copy elsewhere or on your explicit request.
  • Guard rails in code. Paths outside shared storage are refused. Protected packages are refused. These checks are in the scripts, not in the agent's goodwill.
  • Journal. Every applied change is recorded with the command that undoes it, when one exists. Ask "what did you change on my phone?" to see it.

Where reports are stored

Plans, per-file reports and the journal are written on the computer, under:

~/.mobile-optimizer/<device serial>/<date-time>/

Nothing is written to the phone, and nothing leaves the computer. These files list your file names and installed apps: keep them out of shared folders and repositories. Set MOBILE_OPTIMIZER_HOME to use another folder.

Use it without an agent

The scripts work on their own:

git clone https://github.com/CodeGeeksAI/mobile-optimizer.git
cd mobile-optimizer/plugins/mobile-optimizer/scripts
python3 mobile_optimizer.py doctor
python3 mobile_optimizer.py storage --top 50
python3 mobile_optimizer.py cleanup plan
python3 mobile_optimizer.py --help

Add --json before the command for machine-readable output.

Troubleshooting

Symptom Cause Fix
adb not found on PATH adb is not installed, or the terminal was opened before installing it Step 1, then open a new terminal
adb devices lists nothing Charge-only cable, USB debugging off, or locked screen Try another cable and port; repeat step 3; unlock the phone
unauthorized The prompt on the phone was not accepted Unlock and accept. No prompt: Developer options > Revoke USB debugging authorizations, then plug again
offline Stale connection Unplug, run adb kill-server, plug again
no permissions on Linux udev rules missing Install the Android udev rules of your distribution (android-sdk-platform-tools-common on Debian and Ubuntu, android-udev on Arch), then plug again
USB debugging is greyed out (Samsung) Auto Blocker is on Turn it off in Security and privacy
Changes refused on Xiaomi USB debugging (Security settings) is off Turn it on in Developer options
several devices attached More than one phone or emulator Tell the agent which serial to use
The connection drops mid-run The phone locked or the cable moved Keep the screen unlocked; run the command again. Offload resumes safely: files already moved are skipped

Tested on

Computer Phone Result
macOS (Apple Silicon), adb 1.0.41, Python 3.15 Samsung Galaxy S21 Ultra (SM-G998B), Android 15, One UI 7 the workflows this plugin automates were run by hand on this phone

Linux and Windows are documented and covered by the automated tests, which run against a simulated phone, but were not tried on real hardware by the authors. Reports from other phones and systems are welcome as issues.

Development

make hooks      # once: install the pre-commit hooks
make check      # everything CI runs: lint, workflow lint, tests, validation
make codex      # regenerate the Codex skills after editing a command or the skill
  • The Claude Code commands in plugins/mobile-optimizer/commands/ and the skill in plugins/mobile-optimizer/skills/ are the source. The Codex skills in codex-skills/ are generated; do not edit them.
  • Support for another phone brand is a JSON file in plugins/mobile-optimizer/data/vendors/.
  • README.md and LEGGIMI.md are kept in step: a pull request that changes one changes the other.
  • Releases are cut by labels. Merging a pull request labelled patch_release, minor_release or major_release bumps the version, tags it and publishes a GitHub release. Without a label nothing is released.

License

MIT. Copyright (c) 2026 CodeGeeks.

About

Claude Code and Codex plugin that analyzes and optimizes Android phones over adb: storage, cleanup, performance, apps. No app installed on the phone.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages