post-connection-implement-relinkinglisted
Install: claude install-skill merge-api/merge-unified-skills
# Implementing Relinking and Detailed Error Messaging
## Purpose
Credentials expire, permissions get revoked, and admins change — relinking lets end users re-authenticate without contacting support. Detailed error messaging (rather than "something went wrong") tells users exactly what failed and who needs to fix it.
## Prerequisites
- `post-connection-build-settings-page` complete
- `/api/merge/relink-integration` endpoint working
---
## Before Proceeding
Tell the user: "Implementing relinking requires storing error state on the `linked_accounts` table (an `error_category` column and optionally `error_detail`). I'll generate a migration for this. Ready to proceed?"
Wait for confirmation before continuing.
## Part 1: Relinking Flow
Prompt the codebase to implement relinking with multiple entry points and clean state management:
> Implement relinking with the following requirements:
>
> **Entry points** — expose the reconnect action from at least two places:
> - Settings page: always-visible "Reconnect" button
> - Error banner CTA: "Reconnect" link surfaced when status is not active
> - Email notification link (deep-link into the settings page reconnect flow)
>
> **Flow:**
> 1. Call `POST /api/merge/relink-integration` to get a new link token
> 2. Open Merge Link modal using that token
> 3. On `onSuccess` callback: refresh integration status from DB and update UI
>
> **Success state:** Set `status = "active"` in `linked_accounts`, clear any stored error state (error