$npx -y skills add indranilbanerjee/contentforge --skill cf-switch-backendSwitch tracking backend (local/airtable/google) with optional data migration
| 1 | # Switch Tracking Backend |
| 2 | |
| 3 | Switch ContentForge's tracking and delivery backend between **Google Sheets + Drive**, **Airtable**, or **Local filesystem**. Optionally migrate existing tracking data and output files to the new backend. |
| 4 | |
| 5 | ## When to Use |
| 6 | |
| 7 | - Switching from local (default) to a cloud backend for collaboration |
| 8 | - Migrating from Google to Airtable (or vice versa) for simpler auth |
| 9 | - Downgrading to local when cloud access isn't needed |
| 10 | - Checking current backend status before switching |
| 11 | |
| 12 | **Running in Cowork?** The "local" backend writes to the ephemeral sandbox filesystem — files vanish at session end. For Cowork team setups, use the Google (Drive) route and run `/contentforge:cf-cowork-setup` first to wire the Drive folder layout. |
| 13 | |
| 14 | ## How to Use |
| 15 | |
| 16 | ``` |
| 17 | /contentforge:cf-switch-backend airtable |
| 18 | /contentforge:cf-switch-backend google |
| 19 | /contentforge:cf-switch-backend local |
| 20 | /contentforge:cf-switch-backend --status |
| 21 | ``` |
| 22 | |
| 23 | ## What This Command Does |
| 24 | |
| 25 | ### Step 1: Identify Current Backend |
| 26 | |
| 27 | Read the active brand profile's `tracking.backend` field. |
| 28 | |
| 29 | Report current state: |
| 30 | ``` |
| 31 | Current backend: local |
| 32 | Records: 47 tracking records |
| 33 | Output files: 42 files in ~/.claude-marketing/{brand}/tracking/outputs/ |
| 34 | ``` |
| 35 | |
| 36 | ### Step 2: Validate Target Backend |
| 37 | |
| 38 | **If switching to Airtable:** |
| 39 | 1. Check `AIRTABLE_TOKEN` environment variable exists |
| 40 | 2. If missing, guide through setup: |
| 41 | - Go to [airtable.com/create/tokens](https://airtable.com/create/tokens) |
| 42 | - Create a Personal Access Token with `data.records:read` and `data.records:write` scopes |
| 43 | - Select the base that will hold tracking data |
| 44 | - Set the environment variable: `export AIRTABLE_TOKEN=patXXXXXXXX` |
| 45 | 3. Ask for the Airtable Base ID (from the base URL: `airtable.com/appXXXXXXXXX/...`) |
| 46 | 4. Verify access by running: |
| 47 | ``` |
| 48 | python {scripts_dir}/airtable-tracker.py --action init --base-id {base_id} |
| 49 | ``` |
| 50 | |
| 51 | **If switching to Google Sheets + Drive:** |
| 52 | 1. Check Google credentials at `~/.claude-marketing/google-credentials.json` |
| 53 | 2. If missing, guide through setup: |
| 54 | - Go to Google Cloud Console > IAM & Admin > Service Accounts |
| 55 | - Create a project (or use existing) |
| 56 | - Enable Google Sheets API and Google Drive API |
| 57 | - Create a Service Account and download the JSON key |
| 58 | - Save to `~/.claude-marketing/google-credentials.json` |
| 59 | - Create a Google Sheet and share it with the service account email (Editor) |
| 60 | - Create a Google Drive folder and share it with the service account email (Editor) |
| 61 | 3. Ask for the Google Sheet ID and Drive folder ID |
| 62 | 4. Verify access by running: |
| 63 | ``` |
| 64 | python {scripts_dir}/sheets-tracker.py --action init --sheet-id {sheet_id} |
| 65 | ``` |
| 66 | |
| 67 | **If switching to Local:** |
| 68 | - No setup needed — works immediately |
| 69 | - Run init to ensure directory exists: |
| 70 | ``` |
| 71 | python {scripts_dir}/local-tracker.py --action init --brand "{brand}" |
| 72 | ``` |
| 73 | |
| 74 | ### Step 3: Offer Migration |
| 75 | |
| 76 | If the current backend has existing records: |
| 77 | |
| 78 | ``` |
| 79 | You have 47 tracking records and 42 output files on 'local'. |
| 80 | Would you like to migrate this data to Airtable? |
| 81 | 1. Yes — Copy all records and files to the new backend |
| 82 | 2. No — Start fresh (existing data preserved but not synced) |
| 83 | 3. Skip — Just switch, decide on migration later |
| 84 | ``` |
| 85 | |
| 86 | **If yes**, run: |
| 87 | ``` |
| 88 | python {scripts_dir}/backend-migrator.py --action migrate --brand "{brand}" --from {current} --to {target} [backend-specific args] |
| 89 | ``` |
| 90 | |
| 91 | Report migration results: |
| 92 | ``` |
| 93 | Migration complete: |
| 94 | Records migrated: 47 |
| 95 | Files migrated: 42 |
| 96 | Files failed: 0 |
| 97 | Source data preserved at: ~/.claude-marketing/{brand}/tracking/ |
| 98 | ``` |
| 99 | |
| 100 | ### Step 4: Update Brand Profile |
| 101 | |
| 102 | Update the brand profile JSON: |
| 103 | - Set `tracking.backend` to the new backend value |
| 104 | - Fill in backend-specific config (base_id, sheet_id, folder_id, etc.) |
| 105 | |
| 106 | ### Step 5: Confirm |
| 107 | |
| 108 | ``` |
| 109 | Backend switched to Airtable. |
| 110 | New tracking records → Airtable base appXXXXXX |
| 111 | Output files → Airtable attachment fields |
| 112 | Previous data preserved at: ~/.claude-marketing/{brand}/tracking/ |
| 113 | |
| 114 | Run /contentforge:cf-switch-backend --status to verify anytime. |
| 115 | ``` |
| 116 | |
| 117 | ## Backend Comparison |
| 118 | |
| 119 | | Factor | Google Sheets + Drive | Airtable | Local | |
| 120 | |--------|----------------------|----------|-------| |
| 121 | | Auth setup | Service account (~5 min) | Personal token (~2 min) | None | |
| 122 | | Tracking | Google Sheets | Airtable records | JSON file | |
| 123 | | File delivery | Google Drive | Attachment field | Local filesystem | |
| 124 | | Collaboration | Share via Google | Share via Airtable | Single user | |
| 125 | | Free tier | 15GB Drive | 1,000 records + 10GB | Unlimited | |
| 126 | | Offline | No | No | Yes | |
| 127 | |
| 128 | ## Check Status |
| 129 | |
| 130 | Run with `--status` flag to check current backend health: |
| 131 | |
| 132 | ``` |
| 133 | /contentforge:cf-switch-backend --status |
| 134 | ``` |
| 135 | |
| 136 | This runs: |
| 137 | ``` |
| 138 | python {scripts_dir}/backend-migrator.py --action status --brand "{brand}" --from {current_backend} |
| 139 | ``` |
| 140 | |
| 141 | ## Important Notes |
| 142 | |
| 143 | - **Migration is |