agentleFS
GDvegaGDvega/super-android-kotlin-firebase-skill/skills/workmanager-background-sync/SKILL.md

workmanager-background-sync

Skill2 starsChanged 5 months agoMITView on GitHub

Use for WorkManager background sync, offline-first uploads, retry/backoff policies, constraints, foreground work and worker tests.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Keep work inside structured coroutine APIs.

    line 31
  2. Distinctive:

    Add unit tests for success, retry and failure.

    line 33
  3. Very specific:

    Do not use GlobalScope.

    line 37
  4. Distinctive:

    Do not create unnecessary Services.

    line 38
  5. Distinctive:

    Do not run infinite loops inside Workers.

    line 39
  6. Distinctive:

    Use constraints for network/battery when relevant.

    line 40
  7. Distinctive:

    Do not assume these companion skills are installed.

    line 54
  8. Distinctive:

    Use $super-android-kotlin-firebase to add WorkManager offline sync.

    line 91
  9. Distinctive:

    Use $super-android-kotlin-firebase to test this CoroutineWorker retry behavior.

    line 92

≈ “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

Purpose

Implement reliable Android background work without leaking scopes, draining battery or duplicating sync jobs.

When to use

  • Scheduling background sync.
  • Uploading data when network returns.
  • Adding periodic or one-time WorkManager jobs.
  • Testing retry and backoff behavior.
  • Designing offline-first synchronization.

Inputs to inspect

  • Worker classes
  • Repository and Room transaction boundaries
  • Network layer and DTO mapping
  • DI setup for workers
  • AndroidManifest.xml permissions
  • Existing sync scheduler code

Required workflow

  1. Define the sync contract and idempotency key.
  2. Choose one-time or periodic work with constraints.
  3. Keep work inside structured coroutine APIs.
  4. Persist progress and retry safely.
  5. Add unit tests for success, retry and failure.

Rules

  • Do not use GlobalScope.
  • Do not create unnecessary Services.
  • Do not run infinite loops inside Workers.
  • Use constraints for network/battery when relevant.
  • Make sync idempotent and retry-safe.

Related existing skills

Local skills to invoke

  • room-datastore
  • networking-retrofit-ktor
  • firebase-core
  • testing

External companion skills to use when installed

Do not assume these companion skills are installed. Prefer the local skills above first, then consult Companion Skills for install and verification commands.

  • android/skills — use for official Android workflow alignment when a first-party companion skill exists for the task.

Files commonly touched

  • *Worker.kt
  • SyncScheduler.kt
  • Repository and DAO files
  • DI modules
  • AndroidManifest.xml
  • Worker tests

Commands to validate

./gradlew test
./gradlew assembleDebug

Common mistakes to avoid

  • Scheduling duplicate unique work.
  • Retrying non-idempotent uploads.
  • Doing long foreground work without notification requirements.
  • Ignoring process death and app restart.

Checklist

  • Constraints chosen.
  • Unique work policy documented.
  • Backoff configured.
  • Sync idempotent.
  • Worker tests added or recommended.

Example prompts

  • Use $super-android-kotlin-firebase to add WorkManager offline sync.
  • Use $super-android-kotlin-firebase to test this CoroutineWorker retry behavior.

Expected response style

Respond with: brief diagnosis, change plan, affected files, code or diff summary, validation commands, tests added or recommended, risks, and next step. For review tasks, lead with findings ordered by severity.

References

  • ../../docs/audits/FUENTES_LOCALES.md
  • references/workmanager-patterns.md
  • references/offline-sync-strategy.md
  • references/retry-and-backoff.md
  • references/foreground-work.md
  • templates/coroutine-worker-template.kt
  • templates/sync-scheduler-template.kt
  • templates/worker-test-template.md

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.