From 204cb13d601ef8644a6a33979f9fbbdda0422195 Mon Sep 17 00:00:00 2001 From: Neil Bantoc Date: Wed, 4 Nov 2026 14:46:28 -0800 Subject: [PATCH] Rename scaffold skill to android-project-scaffold-new; add module interactions to android audit Co-Authored-By: Claude Opus 5.5 --- skills/android-project-full-audit/SKILL.md | 5 +-- .../references/file-auditor-prompt.md | 13 ++++++-- .../references/report-template.md | 33 ++++++++++++++++--- .../scripts/audit.sh | 4 ++- .../templates/library/module-interactions.md | 18 ++++++++++ skills/android-project-scaffold-new/SKILL.md | 2 +- 6 files changed, 65 insertions(+), 10 deletions(-) create mode 100644 skills/android-project-full-audit/templates/library/module-interactions.md diff --git a/skills/android-project-full-audit/SKILL.md b/skills/android-project-full-audit/SKILL.md index 6603583..e03ee16 100644 --- a/skills/android-project-full-audit/SKILL.md +++ b/skills/android-project-full-audit/SKILL.md @@ -1,6 +1,6 @@ --- name: android-project-full-audit -description: 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, 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 and a features table. +description: 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 @@ -100,6 +100,7 @@ Key rule on redundancy: a file does not need to contribute. When a file is "more The per-file loop doesn't naturally produce these, so write them now: - `file-organization`: the packaging scheme, naming conventions and outliers, from `audit.sh tree` plus what you read. Use source `(project)`. - Empty categories: `bash $A none $AUDIT_DIR ""`, so the report can say "None found in code" with evidence of looking. +- `module-interactions`: close the gaps the per-file pass leaves. For every `project(":…")` 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, record `none` saying 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. @@ -111,7 +112,7 @@ The per-file loop doesn't naturally produce these, so write them now: 2. 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. 3. 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. 4. Run `bash $A finish $AUDIT_DIR` immediately before writing the report. It stops the clock and writes `usage.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. -5. Write `AUDIT_DIR/REPORT.md` following **`references/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, observations (inconsistencies, risks, strengths), coverage & method. +5. Write `AUDIT_DIR/REPORT.md` following **`references/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. 6. Print the summary to the terminal as the template's last paragraph describes, and give the full path to `REPORT.md` and 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. diff --git a/skills/android-project-full-audit/references/file-auditor-prompt.md b/skills/android-project-full-audit/references/file-auditor-prompt.md index c2fe50b..52af96a 100644 --- a/skills/android-project-full-audit/references/file-auditor-prompt.md +++ b/skills/android-project-full-audit/references/file-auditor-prompt.md @@ -20,7 +20,7 @@ You are auditing part of an Android codebase. Your job is to read source files * ## For each file in the batch, in order 1. **Read the whole file** with the file-read tool (`Read` / `read`), one file per call (never judge from the filename or a grep, and never `cat` groups of files through Bash). For very large files (>800 lines) read it in chunks, but read all of it. -2. Decide what it shows. Categories: `build-and-modules file-organization architecture ui navigation networking serialization persistence concurrency dependency-injection background-work platform-integration security-auth observability testing features observations`. One file can feed several categories. +2. Decide what it shows. Categories: `build-and-modules file-organization architecture module-interactions ui navigation networking serialization persistence concurrency dependency-injection background-work platform-integration security-auth observability testing features observations`. One file can feed several categories. 3. For each thing it shows, choose ONE of: - **New pattern** → record it: ```bash @@ -34,7 +34,16 @@ You are auditing part of an Android codebase. Your job is to read source files * - **Refinement of an existing pattern** (adds something genuinely new — a variant, an exception, a second mechanism, or a correction of an earlier claim) → same `finding` command with the existing slug and **no title**; it is inserted under that entry. - **Pure repetition** (same pattern, nothing new) → `bash $A also {AUDIT_DIR} ` only. Do not write prose. This keeps prevalence counts honest without bloating the docs. 4. **Features:** if the file is a screen, route, entry point, worker, receiver, or widget the user experiences, record a `features` entry (slug `feature-`) describing in user language what it lets the user do, the entry-point file, and the route/deep link if any. Read string resources referenced for labels if needed. -5. Mark the file — exactly one status: +5. **Module interactions:** if the file calls into, exposes an API to, or exchanges data with **another module** (see the orientation summary's module list; in a single-module app, another top-level feature/layer package), record it under `module-interactions`. Slug names the edge and purpose: `-to--`, e.g. `feature-home-to-core-data-load-feed`, `sync-worker-to-core-network-refresh`. Body: + ``` + - **Kind:** user-facing | background + - **From → To:** `:feature:home` `HomeViewModel.load()` (`path:line`) → `:core:data` `FeedRepository.feed()` + - **Mechanism:** e.g. injected interface returning `Flow>` + - **Data passed:** request types → result/stream types; where mapping happens + - **Trigger:** e.g. screen open, pull-to-refresh, periodic WorkManager job + ``` + `user-facing` = started by a user action or feeding what's on screen; `background` = no user waiting (workers, services, receivers, push, alarms, startup init). If the same edge is used by both, record two entries. Record the side you can see; if the other side is outside your batch, name the expected callee path and mark it "Inferred:" until confirmed. A file that merely repeats a known edge gets `also`. +6. Mark the file — exactly one status: - `contributed` — you recorded at least one `finding` (new or refinement) - `redundant` — only `also` occurrences; note = the slug(s) it repeats - `trivial` — nothing worth recording (empty, constants, generated-like, tiny glue); note = why diff --git a/skills/android-project-full-audit/references/report-template.md b/skills/android-project-full-audit/references/report-template.md index 906149a..c547bed 100644 --- a/skills/android-project-full-audit/references/report-template.md +++ b/skills/android-project-full-audit/references/report-template.md @@ -50,15 +50,40 @@ Include user-perceivable background features (sync, notifications, widgets, shar - Offline/caching strategy, source of truth. - Optional Mermaid diagram. -## 7. Observations +## 7. Module interactions +How modules call each other and what data crosses each boundary, from `library/module-interactions.md` (prevalence from `occurrences.tsv`). In a single-module app, use top-level feature/layer packages as the units and say so. + +### 7.1 User-facing interactions +Started by a user action or feeding what's on screen. Group rows by feature (matching §5) when there are more than ~10. + +| From → To | Purpose | Mechanism | Data passed (in → out) | Trigger | Code pointers | +|---|---|---|---|---|---| +| `:feature:home` → `:core:data` | Load the feed | Injected `FeedRepository`, collected as `Flow` | `—` → `Flow>` (entity → domain mapped in `:core:data`) | Screen open, pull-to-refresh | `feature/home/.../HomeViewModel.kt:42`, `core/data/.../FeedRepositoryImpl.kt` | +| `:feature:home` → `:feature:detail` | Open an item | Nav route with args | `itemId: String` | Tap on item | `feature/home/.../HomeNavigation.kt` | + +### 7.2 Background interactions +No user waiting: workers, services, receivers, push, alarms, startup init, observers of shared storage. + +| From → To | Purpose | Mechanism | Data passed (in → out) | Trigger | Code pointers | +|---|---|---|---|---|---| +| `:sync` → `:core:network` → `:core:database` | Refresh cache | `CoroutineWorker` calls API, writes Room | `SyncRequest` → `List` → `FeedEntity` rows | Periodic WorkManager, 6h, unmetered | `sync/.../SyncWorker.kt` | + +### 7.3 Interaction map +A Mermaid `graph LR` of modules, with edges labelled by purpose and data type. Draw user-facing edges solid (`-->`) and background edges dashed (`-.->`). Keep it to the edges in the tables. If there are more than ~25, draw one diagram per group. + +### 7.4 Notes +- Shared state reached through more than one path (e.g. a Room table written by a worker and observed by a screen): say which module owns it. +- Module dependencies that no interaction uses (possibly dead), and layer violations, with paths. + +## 8. Observations - **Inconsistencies / migrations in progress** (two ways of doing the same thing, with counts). - **Risks & tech debt** (with paths). - **Strengths** worth preserving. -## 8. Coverage & method +## 9. Coverage & method How many files were in scope, read, and contributed; what was excluded and why (generated code, resources counted not read: `resource-counts.tsv`); how many subagents/batches. Location of the library: `{AUDIT_DIR}/library/`. -## 9. Usage & duration +## 10. Usage & duration Paste `usage.md` verbatim: wall-clock duration, per-phase durations, and the token table per harness / session kind / model, with the total row. Below it, add one line per caveat that applies: - Tokens for writing this report fall after `finish` and are not included. - The run was resumed across sessions, so wall clock includes idle time. @@ -66,4 +91,4 @@ Paste `usage.md` verbatim: wall-clock duration, per-phase durations, and the tok - Another audit or unrelated work ran in the same session during the window, so the session row includes that. ``` -After writing the file, print to the terminal: section 1, the Implementation summary table, the Features table, the top 3–5 observations, the duration and token total row from §9, and the path to `REPORT.md`. +After writing the file, print to the terminal: section 1, the Implementation summary table, the Features table, the two Module interactions tables (or their first ~10 rows each, if long), the top 3–5 observations, the duration and token total row from §10, and the path to `REPORT.md`. diff --git a/skills/android-project-full-audit/scripts/audit.sh b/skills/android-project-full-audit/scripts/audit.sh index 80026a4..e794053 100644 --- a/skills/android-project-full-audit/scripts/audit.sh +++ b/skills/android-project-full-audit/scripts/audit.sh @@ -26,7 +26,7 @@ set -euo pipefail SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" TEMPLATES="$SELF_DIR/../templates" -CATEGORIES="build-and-modules file-organization architecture ui navigation networking serialization persistence concurrency dependency-injection background-work platform-integration security-auth observability testing features observations" +CATEGORIES="build-and-modules file-organization architecture module-interactions ui navigation networking serialization persistence concurrency dependency-injection background-work platform-integration security-auth observability testing features observations" die() { echo "audit.sh: $*" >&2; exit 2; } now_ms() { python3 -I -c 'import time; print(int(time.time()*1000))'; } @@ -264,6 +264,8 @@ cmd_finding() { local body; body="$(cat)"; [ -n "$body" ] || die "finding body (stdin) is empty" local f="$AUDIT_DIR/library/$cat.md" lock + # A workspace from an older skill version may lack a newer category's doc: seed it from the template. + [ -f "$f" ] || cp "$TEMPLATES/library/$cat.md" "$f" if grep -q "^### \[$slug\]" "$f"; then # Same pattern already documented: insert the refinement right after that entry's block. printf '\n#### +[%s] refinement from `%s`\n%s\n\n' "$slug" "$src" "$body" > "$f.ins" diff --git a/skills/android-project-full-audit/templates/library/module-interactions.md b/skills/android-project-full-audit/templates/library/module-interactions.md new file mode 100644 index 0000000..b1a7f7a --- /dev/null +++ b/skills/android-project-full-audit/templates/library/module-interactions.md @@ -0,0 +1,18 @@ +# Module Interactions + +> Audit library doc. Findings come from reading source files — never from README/docs. +> Each pattern is one `### [slug] Title` entry (written via `audit.sh finding`), with an exemplar file. +> Further files that repeat a known pattern are logged with `audit.sh also`, not re-described. + +**Scope:** How modules call into each other and what data crosses each boundary. One entry per interaction (a caller module → callee module edge for one purpose), not per mechanism. "Module" means a Gradle module; in a single-module app, use the top-level feature/layer packages as the units instead. + +**Each entry states:** +- **Kind:** `user-facing` (triggered by a user action or feeding something on screen: a tap, a screen load, navigation, a deep link) or `background` (runs with no user on the other end: WorkManager/JobScheduler, services, receivers, sync, push, alarms, app startup init, DB/cache observers). +- **From → To:** caller module and callee module, with the class/function on each side (`path:line`). +- **Mechanism:** direct call through an interface, suspend function, Flow/StateFlow/LiveData stream, callback, navigation route/args, Intent/PendingIntent extras, WorkManager `Data`, broadcast, shared DB table/DataStore key observed by both sides, event bus, DI-provided binding. +- **Data passed:** the concrete types in each direction (request args → result/stream type), and where it is mapped (DTO → entity → domain → UiState). +- **Trigger:** what starts it (user action, lifecycle event, schedule, push, connectivity, other interaction). + +**Look for:** imports of another module's package; constructor-injected interfaces implemented in another module; `@Binds`/`@Provides` that bind an interface in one module to an implementation in another; nav routes and arguments crossing feature modules; Workers/Services calling repositories; repositories exposing Flows that UI modules collect; shared Room tables or DataStore keys written in one module and read in another; Intents/PendingIntents built in one module and handled in another; layer violations (UI module importing data-layer internals). + +## Findings diff --git a/skills/android-project-scaffold-new/SKILL.md b/skills/android-project-scaffold-new/SKILL.md index 200a0c7..b0dd70d 100644 --- a/skills/android-project-scaffold-new/SKILL.md +++ b/skills/android-project-scaffold-new/SKILL.md @@ -1,5 +1,5 @@ --- -name: scaffold-new-android-project +name: android-project-scaffold-new description: Scaffold a new Android project from scratch. Use when the user wants to start/create/bootstrap a new Android app, set up an Android project skeleton, or verify their Android dev environment (SDK, JDK, Gradle) before building. Verifies tooling, picks compatible AGP/Gradle/Kotlin versions, and produces a minimal Kotlin+Compose skeleton that `./gradlew build` passes before any feature work begins. ---