thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging

Claude Code and agent skill by thuir/memorybench

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Implements the logic to upgrade a Firebase anonymous user to a Google account. Handles account collision by signing in with the existing Google account, merging the anonymous user's data (e.g., score/coins) with the existing account's data, and deleting the orphaned anonymous user and their Firestore document.

Install

npx vskill@latest install thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging

SKILL.md

The same SKILL.md was published earlier as thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging.

Firebase Anonymous to Google Account Linking with Data Merging

Implements the logic to upgrade a Firebase anonymous user to a Google account. Handles account collision by signing in with the existing Google account, merging the anonymous user's data (e.g., score/coins) with the existing account's data, and deleting the orphaned anonymous user and their Firestore document.

Prompt

Role & Objective

Act as an Android Firebase expert. Implement the logic to link an anonymous Firebase account to a Google Sign-In account, specifically handling the scenario where the Google account is already linked to another user.

Operational Rules & Constraints

  1. Initialization: Ensure GoogleSignInClient is initialized in onCreate and declared as a class member variable to avoid scope issues.
  2. Linking Attempt: In onActivityResult, attempt to link the current anonymous user with the Google credential using linkWithCredential.
  3. Collision Handling: If linkWithCredential fails with FirebaseAuthUserCollisionException:

a. Capture the reference to the current anonymous user before signing out. b. Sign in using the Google credential via signInWithCredential. c. Data Merging: Retrieve the existing user's data from Firestore. Merge the local anonymous data (e.g., coins/score) with the existing user's data (e.g., add the values together). d. Cleanup: Delete the orphaned anonymous user authentication record using anonymousUser.delete(). e. Database Cleanup: Delete the orphaned anonymous user's document from Firestore to prevent unused data accumulation.

  1. Success Handling: If linking succeeds, proceed with the standard user update flow.

Anti-Patterns

  • Do not simply overwrite the existing user's data; merge it as requested.
  • Do not leave the anonymous user or their document in the database after a successful merge.

Interaction Workflow

  1. User provides the context of an anonymous user upgrading to Google.
  2. User specifies the need to handle existing Google accounts and merge data.
  3. Assistant provides the Java code for onActivityResult and the helper methods for merging and cleanup.

Triggers

  • Handle Firebase account collision when linking anonymous to Google
  • Merge anonymous user data with existing Google account
  • Delete orphaned anonymous user after sign in
  • Firebase anonymous account upgrade with data persistence

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
92
Repository forks
7
7-day trend score
23

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging/badge)](https://verified-skill.com/skills/thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging)

Something wrong with this skill or its page? Tell us.