← Back to Skills Marketplace
opoojkk

Android Unused Resource Cleanup

by opoojkk · GitHub ↗ · v0.1.0 · MIT-0
cross-platform ✓ Security Clean
242
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install android-unused-resource-cleanup
Description
分析 Android 项目 Git 改动,找出本次修改后不再使用的资源文件(drawable、layout、string、color 等),并检查这些资源是否还在项目其他位置被引用。当用户需要清理 Android 项目中因代码改动而变得无用的资源文件时使用此 skill。支持分析暂存区、工作区或历史提交的改动。
README (SKILL.md)

\r \r

Android 未使用资源清理\r

\r 分析 Git 改动,智能识别因代码修改而变得不再使用的 Android 资源文件。\r \r

使用场景\r

\r

  • 替换了一个背景图/颜色/字符串后,旧资源不再使用\r
  • 重构布局后,旧的 layout 文件未被删除\r
  • 资源命名调整后,遗留下旧名称的资源文件\r
  • 批量清理项目中无用的资源文件\r \r

工作原理\r

\r

  1. 获取 Git diff,分析代码改动中的资源引用变化\r
  2. 识别被替换的资源(旧资源引用被删除,新资源引用被添加)\r
  3. 在项目中搜索旧资源的引用情况\r
  4. 如果旧资源不再被任何代码引用,标记为可安全删除\r \r

使用方法\r

\r

命令行运行\r

\r

# 分析暂存的改动(git add 后的内容)\r
python .agents/skills/android-unused-resource-cleanup/scripts/cleanup_unused_resources.py --source staged\r
\r
# 分析未暂存的改动(工作区修改)\r
python .agents/skills/android-unused-resource-cleanup/scripts/cleanup_unused_resources.py --source unstaged\r
\r
# 分析最近的一次提交\r
python .agents/skills/android-unused-resource-cleanup/scripts/cleanup_unused_resources.py --source HEAD~1\r
```\r
\r
### 支持的资源类型\r
\r
| 类型 | 示例 | 文件位置 |\r
|------|------|----------|\r
| drawable | `R.drawable.bg_main`, `@drawable/bg_main` | `res/drawable*/` |\r
| mipmap | `R.mipmap.ic_launcher` | `res/mipmap*/` |\r
| layout | `R.layout.activity_main` | `res/layout/` |\r
| string | `R.string.app_name`, `@string/app_name` | `res/values/` |\r
| color | `R.color.primary`, `@color/primary` | `res/values/` |\r
| dimen | `R.dimen.spacing`, `@dimen/spacing` | `res/values/` |\r
| style | `@style/AppTheme` | `res/values/` |\r
| anim | `@anim/fade_in` | `res/anim/` |\r
| raw | `R.raw.sound` | `res/raw/` |\r
| font | `@font/roboto` | `res/font/` |\r
\r
## 示例输出\r
\r
```\r
============================================================\r
Android 未使用资源分析报告\r
============================================================\r
\r
[可删除] 可以安全删除的资源 (2 个):\r
------------------------------------------------------------\r
\r
  [drawable] bg_old_main\r
    [文件] app/src/main/res/drawable/bg_old_main.xml\r
\r
  [string] old_title\r
    [文件] app/src/main/res/values/strings.xml\r
\r
\r
[保留] 仍在使用,不能删除的资源 (1 个):\r
------------------------------------------------------------\r
\r
  [color] primary_old\r
    [使用位置] 仍在以下位置使用:\r
       - app/src/main/res/layout/activity_settings.xml\r
\r
============================================================\r
\r
[删除建议]:\r
   del "app/src/main/res/drawable/bg_old_main.xml"\r
```\r
\r
## 注意事项\r
\r
1. **仅作为辅助工具**:脚本分析基于文本匹配,可能存在误判,删除前请人工确认\r
2. **动态引用无法检测**:通过字符串拼接动态生成的资源引用无法被检测\r
3. **反射调用无法检测**:通过反射获取的资源无法被检测\r
4. **跨模块引用**:如果资源被其他模块引用,可能无法正确检测\r
5. **建议操作**:\r
   - 先运行脚本获取可删除列表\r
   - 人工确认这些资源确实不再需要\r
   - 删除后编译项目验证无错误\r
\r
## 实现细节\r
\r
脚本通过以下方式识别资源引用:\r
- Java/Kotlin 代码: `R.type.name` 模式\r
- XML 文件: `@type/name` 模式\r
\r
支持从以下位置获取改动:\r
- `staged`:`git diff --cached`\r
- `unstaged`:`git diff`\r
- `HEAD~N`:`git diff HEAD~N`\r
Usage Guidance
This skill appears coherent and only analyzes local Git diffs and repo files to suggest unused Android resources. Before installing/using: 1) review the bundled script yourself (it's included) to confirm it only reports and does not delete files automatically; 2) run it from the intended repository root (the script uses the current project directory) and ensure you have git available; 3) treat results as suggestions—manually verify before deleting resources because dynamic references and cross-module usage can be missed; 4) if you plan to run it on repositories you don't control, inspect the code first to be comfortable with its file-reading behavior. If you want extra assurance, run it in a sandboxed environment or on a Git clone of the project.
Capability Analysis
Type: OpenClaw Skill Name: android-unused-resource-cleanup Version: 0.1.0 The skill is a legitimate utility designed to help Android developers identify and clean up unused resource files by analyzing Git diffs. The Python script (scripts/cleanup_unused_resources.py) uses standard libraries to execute local Git commands and perform text-based searches within the project directory to verify resource usage. It contains no network activity, data exfiltration logic, or suspicious execution patterns.
Capability Assessment
Purpose & Capability
Name/description: find unused Android resources after Git changes. What is present: a Python script that runs git diff, parses code/XML for R.type.name and @type/name patterns, searches the repo for usages, and reports candidate files. The requested artifacts (no env vars, no binaries, no installs) are appropriate for this task.
Instruction Scope
SKILL.md instructs running the included Python script against staged/unstaged/commit ranges and describes only local file analysis. The script reads repository files and runs git diff; it does not reference external endpoints, unrelated system paths, or other credentials. It performs text-based scanning only (explicitly notes limitations for dynamic/reflection cases).
Install Mechanism
No install spec; instruction-only with a bundled script. This is the lowest-risk model and is proportionate for a repo-scanning utility.
Credentials
The skill declares no environment variables, no credentials, and no config paths. The script uses the git binary (via subprocess) and reads repository files; both are expected and proportional to the stated purpose.
Persistence & Privilege
always is false and the skill does not request persistent system-wide privileges. It does not modify other skills or system configuration (based on provided files and SKILL.md).
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install android-unused-resource-cleanup
  3. After installation, invoke the skill by name or use /android-unused-resource-cleanup
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.1.0
Initial release – analyze git changes in Android projects to detect unused resources for cleanup. - Identifies unused Android resources (drawable, layout, string, color, etc.) resulting from recent git changes. - Checks whether these resources are still referenced elsewhere in the project. - Supports analyzing changes in the staging area, working tree, or historical commits. - Provides a suggested list of resources safe to delete, with detailed output. - Designed to prevent accidental deletion by encouraging manual confirmation. - Supports multiple resource types and both code and XML reference patterns.
Metadata
Slug android-unused-resource-cleanup
Version 0.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Android Unused Resource Cleanup?

分析 Android 项目 Git 改动,找出本次修改后不再使用的资源文件(drawable、layout、string、color 等),并检查这些资源是否还在项目其他位置被引用。当用户需要清理 Android 项目中因代码改动而变得无用的资源文件时使用此 skill。支持分析暂存区、工作区或历史提交的改动。 It is an AI Agent Skill for Claude Code / OpenClaw, with 242 downloads so far.

How do I install Android Unused Resource Cleanup?

Run "/install android-unused-resource-cleanup" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Android Unused Resource Cleanup free?

Yes, Android Unused Resource Cleanup is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Android Unused Resource Cleanup support?

Android Unused Resource Cleanup is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Android Unused Resource Cleanup?

It is built and maintained by opoojkk (@opoojkk); the current version is v0.1.0.

💬 Comments