thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging
Claude Code and agent skill by thuir/memorybench
- community
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-mergingSKILL.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
- Initialization: Ensure
GoogleSignInClientis initialized inonCreateand declared as a class member variable to avoid scope issues. - Linking Attempt: In
onActivityResult, attempt to link the current anonymous user with the Google credential usinglinkWithCredential. - Collision Handling: If
linkWithCredentialfails withFirebaseAuthUserCollisionException:
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.
- 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
- User provides the context of an anonymous user upgrading to Google.
- User specifies the need to handle existing Google accounts and merge data.
- Assistant provides the Java code for
onActivityResultand 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
- SKILL.md in the repositoryCheckingbaselines/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/firebase-anonymous-to-google-account-linking-with-data-merging/SKILL.md
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
[](https://verified-skill.com/skills/thuir/memorybench/firebase-anonymous-to-google-account-linking-with-data-merging)