agentleFS
noltenolte/claude-android-engineering/skills/android-notification-derive/SKILL.md

android-notification-derive

Skill0 starsChanged 3 months agoMITView on GitHub

Decides which alerting channel a business event gets in an Android app and implements it on the device, per spec/android/notifications-alerting/. Classifies the event on six axes, runs the ordered gate chain so the cheaper channel wins, and records a justified row per event in project/notification-ledger.md incl. the rejected gate. Then applies the device-side code: channel creation with permanent importance, the notification build, category, visibility, grouping, update and cancel rule, foreground-service or Live-Update contract. Operations: derive, audit (read-only report), apply. Invoke when the user asks whether or how an app should notify about something, wants notifications audited, or reports them missed, ignored, or switched off. Also handles equivalent German-language requests. Don't use for the permission declaration (android-permissions-derive) or the FCM/WorkManager delivery path (android-feature-implement). Supports resume on re-invocation.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 6 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read references/gate-chain.md in full — it is the decision-time rule set distilled from the spec, and every event is classified against it.

    line 146
  2. Very specific:

    Read the existing project/notification-ledger.md when one exists.

    line 148
  3. Distinctive:

    Check for uncommitted changes in the paths to be touched.

    line 150
  4. Distinctive:

    Run the steps in order, once per event.

    line 155
  5. Distinctive:

    Update. Gate: confirm before anything is written.

    line 191
  6. Very specific:

    Write or update project/notification-ledger.md per references/ledger-and-verification.md: one row per event, every column filled.

    line 195
  7. Very specific:

    Read references/channel-templates.md and write: the channel creation (guarded by API level, importance set at creation), the notification …

    line 202
  8. Very specific:

    Run the verification of references/ledger-and-verification.md: the granted, denied, and channel-blocked states as tests.

    line 215
  9. Distinctive:

    Never leave a red or skipped element unreported (REQ-7).

    line 221
  10. Distinctive:

    Read-only throughout. Nothing is written — not the ledger, not the code, not the manifest.

    line 225
  11. Very specific:

    Enumerate the surface: Every notify() call site, every channel and channel-group creation, every foreground-service startForeground(), and …

    line 227
  12. Very specific:

    Reconcile against the ledger: Read project/notification-ledger.md where it exists.

    line 230
  13. Very specific:

    Read references/gate-chain.md before step 2 for the six axes, the ordered gates, and the channel catalogue's trade-offs in decision form.

    line 249
  14. Very specific:

    Read references/ledger-and-verification.md in step 5 for the ledger's column contract and in step 7 for the verification and test matrix.

    line 251
  15. Very specific:

    Read references/channel-templates.md in step 6 for the channel-creation, notification, grouping, foreground-service, and Live-Update …

    line 253
  16. Distinctive:

    Never: create a channel or write a notification before a complete ledger row exists for its event (REQ-21).

    line 270
  17. Very specific:

    When a spec under spec/android/ disagrees with this skill, the spec wins — report the gap and propose a spec change (REQ-6).

    line 295

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Android Notification Derive

Decides how an app tells a user that something happened — and, far more often than developers expect, decides that it does not tell them at all. The channel is derived from what the event is, not from what is easiest to reach for.

The governing idea is that the ability to notify is a shared, revocable, app-wide resource. From Android 13 a single denial silences every channel the app has, so every notification is spent against every future notification the app will want to post. The cheapest channel that serves the event therefore wins, and anything more intrusive has to beat it on evidence.

The authoritative rules live in spec/android/notifications-alerting/; this skill operationalizes them and never restates or contradicts them. On any conflict the spec wins — report the gap and propose a spec change rather than deciding silently (REQ-6).

Grounding specs, in the order they bind this skill: spec/android/notifications-alerting/ (the model, the classification, the gate chain, the channel catalogue, delivery, construction, degradation, verification), spec/android/permissions/ §F (the notification permission family, whose derivation belongs to its own skill), spec/android/app-architecture/ §B/§D (where state lives, how a write reaches the backend), spec/android/iconography/ §D (notification icon formats), spec/android/localization/ §A (notification text is externalized like any other string), spec/android/ui-components/ §A (the in-app surface the presence gate selects), and spec/android/test-automation/ (where the notification tests live).

German trigger phrases

Respond to these (and equivalents) exactly as to their English counterparts; the frontmatter description stays English-only per skill-management §Structure:

  • "Soll die App darüber benachrichtigen?", "Welchen Benachrichtigungskanal bekommt dieses Ereignis?", "Leite die Notification für X ab"
  • "Auditiere/prüfe die bestehenden Benachrichtigungen", "Begründe diese Notification"
  • "Nutzer schalten unsere Benachrichtigungen ab", "Wichtige Benachrichtigungen werden übersehen", "Die Channel-Wichtigkeit ist falsch", "Live Update / Foreground-Service-Notification für eine laufende Aktivität"

Why this is a skill, not an agent

  • Mid-flow approval is the contract. Admitting a channel more intrusive than the one below it, refusing a requested notification as out of policy, and every code write are operator decisions with consequences that outlive the run (REQ-8); an agent's fire-and-forget shape cannot carry those gates.
  • The persistent artifact is the deliverable. The notification ledger and the channel code land in the working tree and are reviewed in context, not behind a report boundary.
  • It composes with sibling capabilities. Permissions → android-permissions-derive, in-app surface → android-compose-ui, non-appearing notification → android-debugging; per spec/claude/skill-vs-agent/ §Primary decision rule the orchestrator is always a skill.
  • Counter-dimension considered: the read-only audit would suit a dedicated auditor agent (a candidate spec extension); it stays here because its findings are phrased as the derive rows the operator starts next, so one gate vocabulary serves both.

Boundary vs the sibling capabilities

  • android-permissions-derive owns every permission decision (REQ-20). POST_NOTIFICATIONS, the FOREGROUND_SERVICE_* pair, USE_FULL_SCREEN_INTENT, and POST_PROMOTED_NOTIFICATIONS are consequences of a channel derived here: hand the ledger row over and take the declaration back, never write one into the manifest here. Guard-code ownership: the SDK-version guards around canUseFullScreenIntent() (API 34+) and canPostPromotedNotifications() (API 36+), their degradation branch, and the settings-intent launch (ACTION_MANAGE_APP_USE_FULL_SCREEN_INTENT, ACTION_APP_NOTIFICATION_PROMOTION_SETTINGS + EXTRA_APP_PACKAGE) are written here, by the apply templates; the permission skill records the obligation in its ledger row and verifies the guard exists.
  • android-compose-ui owns every in-app surface (REQ-13). When the silence or presence gate matches, this skill decides that the in-app path carries the event and hands the authoring there; it does not build screens.
  • android-feature-implement owns the feature across layers (REQ-19) and calls this skill for the channel step; this skill ends at the device-side notification code. The delivery path of spec/android/notifications-alerting/ §E lives in that skill's flat-layer-checklist §10 and layer-templates §5. Delivery column ownership: android-feature-implement owns the decision (step 3) and the implementation (step 5.3) of the delivery path; android-notification-derive owns the ledger row and records the handed-over value (local / scheduled / pushed) — it never decides it.
  • android-ux-reviewer reviews UI read-only (REQ-14); notification-channel conformance is outside its Compose surface and is audited by the audit operation here.
  • android-debugging diagnoses why a notification never appeared (REQ-16). A wrong channel is a decision defect and belongs here; a notification that should appear and does not is a runtime defect and belongs there.

User-language policy

Detect the operator's language and respond in it (German for this operator). Generated artifacts stay canonical: Kotlin, channel IDs, and identifiers in English; the ledger is written in English so it stays reviewable alongside the spec corpus; user-visible notification text is externalized to strings.xml per spec/android/localization/ §A — never inlined in a builder call.

Operations

Pick one at the start and say which is running. The split is deliberate: derive decides and records, audit only reports, apply writes code. Nothing is written into the app before a complete ledger row exists for it.

  • derive — an event exists or is planned and its channel is undecided. Runs steps 1–4 and the ledger write of step 5. Touches no code.
  • audit — an app already posts notifications and the set needs justifying. Runs the audit procedure below and writes nothing at all (REQ-21): it produces a severity-classified findings report (Critical / Warning / Suggestion / Info per spec/claude/review-plan/) naming the ledger rows the app owes; turning a finding into a row is a derive run the operator starts afterwards.
  • apply — a ledger row exists and its device-side code is to be written or corrected. Runs steps 5–7.

The numbered procedure below is the derive/apply path; audit runs the separate audit procedure that follows it.

Preconditions

Before deciding anything:

  • Confirm the working directory is a git repository holding an Android project scaffolded per spec/android/project-structure/. If there is no Gradle Android module, stop and route to android-project-scaffold.
  • Read references/gate-chain.md in full — it is the decision-time rule set distilled from the spec, and every event is classified against it.
  • Read the existing project/notification-ledger.md when one exists; an event already recorded there is re-derived, not duplicated.
  • Check for uncommitted changes in the paths to be touched. If dirty, report and ask whether to stash, commit, or abort — never overwrite unconfirmed work (REQ-8).

Procedure

Run the steps in order, once per event. Confirm with the operator at each gate before writing.

1. State the event

Name the business event in one sentence, as something that happens to or for the user — not as a technical trigger ("the sync job finished" is a trigger; "the user's order was shipped" is an event). An event that cannot be stated this way is usually not an event the user needs. Gate: confirm the statement before classifying.

2. Classify on the six axes

Fill all six axes from references/gate-chain.md: origination, presence, time sensitivity, actionability, consequence of missing it, and continuity. Presence is a runtime property, so record the behaviour for each of its three cases rather than assuming one. An axis the operator cannot answer is a question for them, never a guess.

3. Run the gate chain

Walk the gates in order and take the first that matches. The ordering is the mechanism by which the cheaper channel wins, so a later gate is only reached by failing every earlier one. Record the matched gate and the cheaper gate that was rejected, with the reason. Two outcomes end the run without a channel: the refusal gate (promotional, re-engagement-driven, celebratory, a greeting, or a rating request — reported as out of policy) and the gap gate (a case the spec does not cover — reported as a spec gap per REQ-6, never resolved by analogy). Gate: confirm the outcome.

4. Derive the channel's properties

For a channel-bearing outcome, decide and record: the channel ID and user-visible name, its permanent importance — one channel per type of event the user would want to control separately — the setCategory() value, lock-screen visibility (with a public version wherever the content is sensitive, and the sensitivity classification it applied), the delivery path (recorded as handed over by android-feature-implement, never decided here), the group key with the summary behaviour, the update key (recorded as its own ledger column), the dismissal and cancellation rule, and the degradation behaviour when notifications are off. Where the outcome is the ongoing family, add its contract — foreground-service type, or the promotion requirements of a Live Update. Gate: confirm before anything is written.

5. Write the ledger row

Write or update project/notification-ledger.md per references/ledger-and-verification.md: one row per event, every column filled. An incomplete row is not admitted, and no code is written for an event that lacks one. Hand every permission the chosen channel implies to android-permissions-derive at this point.

6. Apply the device-side code

Read references/channel-templates.md and write: the channel creation (guarded by API level, importance set at creation), the notification build through NotificationCompat, the group and summary where the app can produce more than one of a kind — promoted Live Updates excepted, which are never grouped — the cancel and update paths, the conversation or call shape where the row's gate was 4 (MessagingStyle bound to a long-lived shortcut, or CallStyle), and the ongoing contract where it applies — including the SDK-guarded canUseFullScreenIntent() / canPostPromotedNotifications() checks, their fallbacks, and settings routes, which this skill owns. The content intent targets its activity directly — never a trampoline. User-visible text goes through strings.xml. Gate: confirm before each file that would overwrite existing code (REQ-8).

7. Verify and report

Run the verification of references/ledger-and-verification.md: the granted, denied, and channel-blocked states as tests; the Doze and app-standby behaviour for any scheduled or pushed row; the user-stop and timeout paths for a foreground-service row. Then ./gradlew build green (REQ-1). Report, in the operator's language: the events derived and their matched and rejected gates, the ledger rows written, the permissions handed over, each verification element that was green, red, or unrunnable and why, and any spec gap found. Never leave a red or skipped element unreported (REQ-7).

Audit procedure (operation audit)

Read-only throughout. Nothing is written — not the ledger, not the code, not the manifest.

  1. Enumerate the surface. Every notify() call site, every channel and channel-group creation, every foreground-service startForeground(), and the notification-related permissions in the merged manifest.
  2. Reconcile against the ledger. Read project/notification-ledger.md where it exists. A posted notification with no row, and a row with no code, are both findings.
  3. Re-derive each posting site. Classify its event per step 2 and walk the gates per step 3, then compare the outcome with what the code actually does. A channel more intrusive than the chain admits is the finding this operation exists for.
  4. Check the construction rules of references/channel-templates.md per site: channel importance against the row, category set, lock-screen visibility against the row's Visibility column, grouping with an update key where more than one of a kind can be posted, cancellation of stale notifications, no trampoline, no custom layout, the SDK guards around canUseFullScreenIntent() / canPostPromotedNotifications() — and, where the app bubbles a conversation, that the notification still works as an ordinary one when bubbles are disabled.
  5. Report on the canonical severity scale: Critical for a posting site with no row or a channel the chain forbids, Warning for a construction rule broken, Suggestion for a cheaper gate the event would now match, Info for a surface scanned clean. Each finding carries the file and line, the spec section, and the operation that would fix it.

Reference files

  • Read references/gate-chain.md before step 2 for the six axes, the ordered gates, and the channel catalogue's trade-offs in decision form.
  • Read references/ledger-and-verification.md in step 5 for the ledger's column contract and in step 7 for the verification and test matrix.
  • Read references/channel-templates.md in step 6 for the channel-creation, notification, grouping, foreground-service, and Live-Update templates.

Resumability

Per spec/claude/resumable-work/, this skill is resumable: true. State is persisted to .resume/android-notification-derive/<run-id>.yml after every gate and at each named step boundary. On re-invocation, scan .resume/android-notification-derive/*.yml for files with status: in_progress whose inputs: snapshot (repository + event name) matches the current request; when one matches, prompt Resume run <run_id> from phase <phase> (last checkpoint <last_checkpoint_at>)? [resume / start-new / discard]. resume re-hydrates and re-asks no answered gate; start-new leaves the old file intact; discard deletes it. Fail closed on unparseable or higher-schema_version files. The envelope keys and lifecycle are load-bearing in the spec and are not duplicated here.

Hard rules

  • Never create a channel or write a notification before a complete ledger row exists for its event (REQ-21).
  • Never implement a promotional, re-engagement-driven, celebratory, greeting, or rating-request notification. The refusal gate reports it as out of policy — including when the operator asks for it directly, in which case the report names the policy rather than complying (REQ-21).
  • Never change the importance of an existing channel in place; it is immutable after creation. A reclassification is a new channel, with the old one's retirement recorded in the ledger (REQ-21).
  • Never declare a notification-related permission here. POST_NOTIFICATIONS, the FOREGROUND_SERVICE_* pair, USE_FULL_SCREEN_INTENT, and POST_PROMOTED_NOTIFICATIONS go to android-permissions-derive with the ledger row as their justification (REQ-21).
  • Never post a point event as a notification for a surface the user is currently looking at, and never demote an ongoing activity to the in-app path because it happened to start on that surface — the ongoing gate is evaluated before the presence gate for exactly that reason.
  • Never route a notification tap through a service or broadcast receiver that then starts an activity; the content intent targets the activity directly.
  • Never ship a custom notification layout, and never let an event exist only as a notification — the in-app path is part of every ledger row.
  • Never resolve a gap-gate outcome by analogy to a neighbouring event; report it (REQ-6).
  • Always record the matched gate and the rejected cheaper gate; a row without the rejection is not a derivation, only a preference.
  • Always end with the verification the operation calls for and an explicit report of every red or unrunnable element (REQ-7): step 7 in full for apply, the ledger row and its recorded gates for derive (which touches no code and therefore has nothing to build), the severity-classified report for audit.
  • When a spec under spec/android/ disagrees with this skill, the spec wins — report the gap and propose a spec change (REQ-6).

Gotchas

Concrete corrections to non-obvious facts the executing agent would otherwise get wrong:

  • A channel's behaviour is frozen at creation, not at first use. Importance, sound, vibration, and group membership can never be changed by the app afterwards — only name and description can. A wrong importance is not a tuning mistake; it costs a channel.
  • Deleted channels stay visible. System settings count deleted channels as a spam signal, so churning channel IDs is itself a cost the user sees; on a development device, reinstall or clear app data to reset test channels.
  • A notification posted to a blocked channel succeeds silently. notify() does not throw; only areNotificationsEnabled() plus the channel's getImportance() distinguish "delivered" from "accepted and discarded".
  • A foreground-service notification may not appear for ten seconds. Android 12+ defers it — right for short work, wrong when the user is waiting; FOREGROUND_SERVICE_IMMEDIATE opts out.
  • Rapid updates are dropped, not queued. Re-posting the same ID many times a second is throttled; update on meaningful change, with setOnlyAlertOnce(true).

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.