$npx -y skills add webflow/webflow-skills --skill custom-code-managementAdd, review, or remove inline custom scripts on a Webflow site (up to 10,000 chars). Use for analytics, tracking pixels, chat widgets, or any custom JavaScript. Also manages page-level scripts.
| 1 | # Custom Code Management |
| 2 | |
| 3 | Add, review, and manage inline custom scripts on a Webflow site — analytics, tracking pixels, chat widgets, or any custom JavaScript. |
| 4 | |
| 5 | ## Important Note |
| 6 | |
| 7 | **ALWAYS use Webflow MCP tools for all operations:** |
| 8 | - Use Webflow MCP's `webflow_guide_tool` to get best practices **before any other tool call** |
| 9 | - Use Webflow MCP's `data_sites_tool` with action `list_sites` to identify available sites |
| 10 | - Use Webflow MCP's `data_scripts_tool` with action `list_registered_scripts` to list all registered scripts |
| 11 | - Use Webflow MCP's `data_scripts_tool` with action `list_applied_scripts` to list scripts applied to pages |
| 12 | - Use Webflow MCP's `data_scripts_tool` with action `add_inline_site_script` to register a new inline script |
| 13 | - Use Webflow MCP's `data_scripts_tool` with action `delete_all_site_scripts` to remove ALL site scripts (no selective delete) |
| 14 | - Use Webflow MCP's `data_scripts_tool` with action `get_page_script` to get custom code for a specific page |
| 15 | - Use Webflow MCP's `data_scripts_tool` with action `upsert_page_script` to add or update page-level custom code |
| 16 | - Use Webflow MCP's `data_scripts_tool` with action `delete_all_page_scripts` to remove all custom code from a page |
| 17 | - All tool calls must include the required `context` parameter (15-25 words, third-person perspective) |
| 18 | |
| 19 | ## Instructions |
| 20 | |
| 21 | ### Phase 1: Discovery |
| 22 | 1. **Call `webflow_guide_tool` first** — always the first MCP tool call |
| 23 | 2. **Get the site**: Use `data_sites_tool` with action `list_sites`. If only one site, use it automatically. |
| 24 | |
| 25 | ### Phase 2: Analysis |
| 26 | 3. **List scripts**: Call `list_registered_scripts` and `list_applied_scripts` in parallel |
| 27 | 4. **Check page-level scripts** (if relevant): Use `get_page_script` for specific pages |
| 28 | 5. **Present findings**: Name, version, location (header/footer), registration vs application status |
| 29 | |
| 30 | ### Phase 3: Planning & Confirmation |
| 31 | Before any mutation, present the plan and require explicit confirmation: |
| 32 | - Adding scripts: user must type **"add"** |
| 33 | - Removing ALL site scripts: user must type **"delete all"** (warn: no selective delete) |
| 34 | - Page-level changes: user must type **"update"** |
| 35 | |
| 36 | ### Phase 4: Execution |
| 37 | 6. **Add site script**: `add_inline_site_script` with displayName, sourceCode, version, location, canCopy |
| 38 | 7. **Remove all site scripts**: `delete_all_site_scripts` |
| 39 | 8. **Add/update page script**: `upsert_page_script` |
| 40 | 9. **Remove page scripts**: `delete_all_page_scripts` |
| 41 | |
| 42 | ### Phase 5: Verification |
| 43 | 10. Re-list scripts to confirm success |
| 44 | 11. Report what changed (name, location, version, char count) |
| 45 | 12. Remind user to publish — suggest using `safe-publish` skill |
| 46 | |
| 47 | ## Examples |
| 48 | |
| 49 | ### Example 1: View scripts |
| 50 | **User:** "What scripts are on my site?" |
| 51 | 1. `webflow_guide_tool` → `data_sites_tool` → `list_registered_scripts` + `list_applied_scripts` in parallel |
| 52 | 2. Present summary of all scripts |
| 53 | |
| 54 | ### Example 2: Add Google Tag Manager |
| 55 | **User:** "Add GTM to my site" |
| 56 | 1. `webflow_guide_tool` → `data_sites_tool` → ask for GTM container ID |
| 57 | 2. Preview script, require "add" → `add_inline_site_script` (header, version "1.0.0") |
| 58 | 3. Verify and remind to publish |
| 59 | |
| 60 | ### Example 3: Remove all scripts |
| 61 | **User:** "Remove all scripts" |
| 62 | 1. `webflow_guide_tool` → `data_sites_tool` → list current scripts |
| 63 | 2. Warn: removes ALL scripts. Require "delete all" → `delete_all_site_scripts` |
| 64 | 3. Verify and remind to publish |
| 65 | |
| 66 | ### Example 4: Page-specific tracking |
| 67 | **User:** "Add conversion tracking to my thank-you page" |
| 68 | 1. `webflow_guide_tool` → `data_sites_tool` → `get_page_script` to check existing |
| 69 | 2. Preview, require "update" → `upsert_page_script` |
| 70 | 3. Verify and remind to publish |
| 71 | |
| 72 | ## Guidelines |
| 73 | |
| 74 | - **`webflow_guide_tool` always first** — before any other MCP tool |
| 75 | - **No `<script>` tags** — Webflow adds them automatically |
| 76 | - **Max 10,000 characters** per script; `displayName` + `version` must be unique |
| 77 | - **Site-level** scripts (`add_inline_site_script`) apply to all pages; **page-level** scripts (`upsert_page_script`) apply to one page |
| 78 | - **No selective delete** — `delete_all_site_scripts` removes everything; always list scripts first so user knows what will be lost |
| 79 | - **Hosted/external scripts** not available via MCP — inline only |
| 80 | - Recommend **header** for analytics (GA, GTM); **footer** for chat widgets and non-critical scripts |
| 81 | - If `displayName + version` exists, suggest incrementing the version |
| 82 | - Always remind users to **publish** after changes |