14 KiB
| name | description |
|---|---|
| android-project-full-audit | Audit-level architecture report for an existing Android project, built by reading the source files themselves (not README/docs, which may be stale). Use when the user wants to understand, audit, map, or document how an Android app is architected — its file/module organization, the libraries and mechanisms behind each implementation category (UI, navigation, networking, concurrency, persistence, DI, background work, etc.) with code pointers, how modules interact and pass data to each other (grouped into user-facing and background interactions), and the user-facing features. Crawls files one by one (optionally fanned out to subagents), records findings into a library of per-category audit docs, then synthesizes a REPORT.md with an implementation table, a module interaction map and a features table. |
Android Project Full Audit
Goal: a report of how the app is built as implemented today. Every claim traces to a source file the auditor actually read. Documentation (README, docs/, wiki, ADRs, comments describing intent) is not evidence — it is excluded from the crawl and must not be used to fill gaps. Where code is unclear, say so; don't backfill from docs.
The audit runs in phases. All state lives in an audit workspace so the work can be resumed and split across subagents:
<AUDIT_DIR>/
ledger.tsv every in-scope file + status (pending/contributed/redundant/trivial/skipped)
library/<cat>.md one audit doc per implementation category — the findings library
occurrences.tsv further files that repeat an already-documented pattern (prevalence)
batches/ file lists for subagents
modules.txt, resource-counts.tsv
timeline.tsv phase start timestamps (duration tracking)
usage.md/.json token usage + duration, written by `finish`
REPORT.md final synthesized report
Timing and tokens: init starts the clock. Run bash $A phase $AUDIT_DIR <name> as the first command of each later phase (orientation, per-file, gate, cross-cutting, report). bash $A finish $AUDIT_DIR stops the clock and writes usage.md. Usage is read from the harness's own logs: Claude Code transcripts (main session, subagents and headless local workers) or OpenCode's session DB. Calls are counted only inside the audit window, and only from sessions whose transcript mentions AUDIT_DIR. Nothing to track by hand.
Harness notes (Claude Code and OpenCode)
This skill is shared by Claude Code and OpenCode, which both load it from ~/.claude/skills/.
SKILL_DIRis the directory containing this SKILL.md. Claude Code provides it; elsewhere use the skill's reported location, normally~/.claude/skills/android-project-full-audit.- Tool names: "file-read tool" means
Readin Claude Code andreadin OpenCode. "Subagent" means theAgenttool withgeneral-purposein Claude Code, and thetasktool with thegeneralagent in OpenCode. - Local model: if you yourself are running on a locally hosted model (e.g. OpenCode pointed at vLLM or Ollama), your subagents already run locally. Never use
local-worker-handofffrom there; it exists only to move work off Anthropic models in Claude Code.
Helper: A="$SKILL_DIR/scripts/audit.sh" (run bash $A with no args for usage). It is the only way findings and statuses are written — it validates categories, keeps one entry per pattern slug, and locks for concurrent subagents.
Phase 0 — Set up
- Confirm the project root (the dir with
settings.gradle(.kts)). If the user didn't give one, use the cwd if it qualifies; otherwise ask. AUDIT_DIRdefaults to<project>/.android-audit/. Tell the user it was created there and suggest adding it to.gitignore(don't edit.gitignoreyourself unless asked). Use another location if the user names one.- If
AUDIT_DIR/ledger.tsvalready exists with progress, resume: skip to the phasebash $A coverage $AUDIT_DIRindicates.initrefuses to overwrite progress. - Record the git SHA if the project is a repo (
git -C <project> rev-parse --short HEAD) for the report header.
Phase 1 — Inventory
bash $A init <project> <AUDIT_DIR> # builds ledger + empty library docs; prints counts by module/kind
bash $A tree <AUDIT_DIR> # module → source set → package tree with file counts
bash $A signals <AUDIT_DIR> # import/plugin hits per library
- The inventory includes
.kt .kts .java .gradle .toml gradle.properties gradle-wrapper.properties .pro .aidl .proto .sq, manifests,res/values|layout|navigation|xml, and CI config. It excludes build outputs, generated code, drawables/mipmaps/fonts/raw (counted only), translatedvalues-*, and all documentation (listed indocs.txtfor the optional drift step only). secret-files.txtlistslocal.properties, keystores,google-services.json,.envetc. Never open them. Record their existence and role from what the build scripts read (e.g. "TMDB_API_KEYread fromlocal.properties") undersecurity-auth.signalsoutput is a map of where to look, not evidence. A library on the classpath may be unused; an import may be dead. Nothing goes into the library fromsignalsalone.- If the ledger has obvious noise (e.g. a vendored SDK, sample app, or a huge generated dir the filters missed), mark those
skippedwith a reason and tell the user what was excluded.
Phase 2 — Orientation pass (main model, always)
bash $A phase $AUDIT_DIR orientation
Read these yourself first, in full, recording findings and marking each file. They establish the vocabulary every later reader needs:
settings.gradle(.kts),gradle/libs.versions.toml, rootbuild.gradle(.kts),gradle.properties, convention plugins (build-logic/,buildSrc/).- Each module's
build.gradle(.kts)— note plugins andproject(":…")dependencies → module graph. - Every
AndroidManifest.xml— components, permissions, deep links,Applicationclass. - The
Applicationclass, the launcher Activity, the DI root (Hilt modules / KoinstartKoin/ Dagger component), and the top-level nav host / nav graph.
Then write a 10–20 line orientation summary (modules and what each is for, core libraries + versions, architectural style as seen so far, slug names already used). Keep it in your context; it is passed to every subagent.
Phase 3 — Per-file audit
bash $A phase $AUDIT_DIR per-file
Every remaining pending file is read one by one, in full, and filed into the right library doc. The exact procedure — read, pick category, new pattern vs. refinement vs. repetition, features, mark status — is in references/file-auditor-prompt.md. Read it before starting this phase; it applies to you as much as to subagents.
Reading: use one file-read call per file (several independent reads in one message is fine). Don't cat whole packages through Bash — it blurs the per-file judgement and large UI packages overflow tool output.
Key rule on redundancy: a file does not need to contribute. When a file is "more of the same" (the 12th Room DAO, the 30th screen ViewModel with the identical shape) log it with also and mark it redundant. Only write prose when the file shows something not already in the library. Before writing, check bash $A patterns $AUDIT_DIR <category>.
Choose an execution mode from the pending count (bash $A coverage $AUDIT_DIR):
-
≤ 150 pending files → main model alone. Loop:
bash $A next $AUDIT_DIR 10, read and file each, repeat untilcoverageexits 0. -
> 150, or the user asked to offload to a local model → batched workers.
bash $A batch $AUDIT_DIR 40(batches stay within one module where possible). Fill the prompt inreferences/file-auditor-prompt.mdper batch ({PROJECT_ROOT},{AUDIT_DIR},{SKILL_DIR},{BATCH_FILE},{ORIENTATION_SUMMARY}). Then pick the worker backend:- Local worker (Claude Code only, preferred when available). If you are in Claude Code on an Anthropic model and the
local-worker-handoffskill is installed, load it and run itscheck. On success, write each filled prompt to a file and dispatch it through that skill'srun, with--cwd <project>and--allow "Read Grep Glob Bash(bash $A:*)", respecting the backend'smax_parallel. Use batches of ~20 files for local workers. This skill never names a server, model or key; those belong to the handoff skill's config. - Native subagents. This is the default in OpenCode and the fallback in Claude Code when the handoff skill is absent or
checkfails (say so in one line). Spawn one subagent per batch (see Harness notes for the tool), several in a single message: up to 6 at a time on hosted models, 2–3 at a time on a local model so they don't queue on one GPU. Local-model subagents get batches of ~20 files and the heavier spot-check in Phase 4.
When a wave finishes, run
patternsand pass any notable new slugs into the next wave's orientation summary so later workers reuse them instead of inventing synonyms. Tell the user the batch count and backend before launching, and give a one-line update per wave. - Local worker (Claude Code only, preferred when available). If you are in Claude Code on an Anthropic model and the
-
If the user asked for a quick/cheaper run, say what you'll reduce (e.g. read all Kotlin/Java but only sample res files) and mark the unsampled files
skippedwith notesampled-out— never silently drop coverage.
Phase 4 — Coverage gate
bash $A phase $AUDIT_DIR gate
bash $A gate $AUDIT_DIRmust printGATE: PASS: nopendingfiles, everycontributedfile is cited by a finding, everyredundantfile has a logged occurrence. Fix or re-audit whatever it lists. (coverageis the non-failing progress view.)- Spot-check delegated work (skip in main-model mode). Per batch, pick ~3 files marked
redundant/trivialand ~2contributedexemplars, open them, and confirm the status and the finding are right. Check local-worker batches more heavily (~5 + 3). If a batch looks skimmed (everythingtrivial, findings that don't match the file, invented line numbers), redo it with a built-in subagent or yourself and tell the user which batches were redone. - Check for slug synonyms across workers (
patternsoutput: e.g.retrofit-api-servicevsretrofit-service-interface). Treat them as one pattern in the report.
Phase 4.5 — Cross-cutting entries (main model)
bash $A phase $AUDIT_DIR cross-cutting
The per-file loop doesn't naturally produce these, so write them now:
file-organization: the packaging scheme, naming conventions and outliers, fromaudit.sh treeplus what you read. Use source(project).- Empty categories:
bash $A none $AUDIT_DIR <category> "<what you looked for>", so the report can say "None found in code" with evidence of looking. module-interactions: close the gaps the per-file pass leaves. For everyproject(":…")edge in the module graph (Phase 2), check that at least one interaction entry explains what that dependency is used for; read the files needed to fill any missing edge. Confirm or correct "Inferred:" callee sides with a refinement. In a single-module app, do the same across top-level feature/layer packages. If the app really is one undivided unit, recordnonesaying so.observations: inconsistencies across files, such as two mechanisms for one job or migrations in progress, that no single file reveals.- Superseded claims: the library is append-only. If an early finding was wrong or an "Inferred:" note was later confirmed, add a refinement to that slug saying so. The report uses the latest refinement.
Phase 5 — Consolidate and report
bash $A phase $AUDIT_DIR report
- Read every
library/*.mdin full andoccurrences.tsv(prevalence per slug:awk -F'\t' 'NR>1{print $1"/"$2}' occurrences.tsv | sort | uniq -c | sort -rn). - Resolve conflicts: where two mechanisms coexist (Gson + kotlinx.serialization, LiveData + StateFlow), report both with counts — that is a finding, not noise. Note which is newer/dominant only if the code shows it.
- Pick code pointers per category: the 1–3 files that most clearly show the pattern (usually the exemplar, but prefer a clean canonical file over a first-seen edge case). Verify each path exists.
- Run
bash $A finish $AUDIT_DIRimmediately before writing the report. It stops the clock and writesusage.md, whose tables go verbatim into the report's "Usage & duration" section. Tokens spent writing the report itself fall after the clock stops; the report's section says so. - Write
AUDIT_DIR/REPORT.mdfollowingreferences/report-template.md: at-a-glance, build & toolchain, file tree organization scheme, implementation summary table (Category | Implementation details | Code pointers), features table (Feature | What it lets the user do | Entry point), architecture & data flow with one end-to-end trace, module interactions (user-facing and background tables of From → To | Mechanism | Data passed | Trigger, plus a diagram), observations (inconsistencies, risks, strengths), coverage & method. - Print the summary to the terminal as the template's last paragraph describes, and give the full path to
REPORT.mdand the library dir.
If this skill is itself running inside a subagent and the harness refuses the REPORT.md write, don't work around it. Return the full report text as your final reply, with the intended path, so the parent session saves it.
Optional, only after the report is complete and only if documentation exists: add a "Documentation drift" section listing doc claims the code contradicts (e.g. README says Dagger, code uses Hilt). This is the only point where docs are opened, and they are compared against the report — never used to write it.
Guardrails
- Read files; don't infer content from names, grep hits, or
signals. - Cite paths (and
:linefor key facts). Mark inferences as "Inferred:". - Versions from version catalog/build files only.
- Never open files in
secret-files.txt, and never copy secret values into the library or report; note location and type only. - Don't modify the audited project. The only writes are inside
AUDIT_DIR.