Skip to main content
skill CX Codex

cleanup-workflows — Claude Code skill: prune dead HubSpot workflows

Audits HubSpot workflows and flags the ones worth deleting: never enrolled, switched off for 90+ days, or left over from testing.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add TomGranot/hubspot-admin-skills --skill cleanup-workflows -a claude-code
Open on GitHub

What cleanup-workflows does

The skill walks through a HubSpot automation audit and clears out clutter. It pulls every workflow through the v4 Automation API and records the flow ID, name, enabled state, type, creation date and last update. From there it marks candidates: switched off for 90+ days, zero enrollments ever, names containing “test” or “copy of”, replaced by a newer version, or stuck in a failing error state.

Before anything gets deleted, the skill checks whether one workflow triggers another, whether it writes properties other workflows read, and whether docs point at it. You see the candidate list and nothing happens without your explicit go-ahead. The recommended path is archive-first: turn the workflow off, wait a week, then remove it with DELETE /automation/v4/flows/{flowId} or in the UI. Disabling through the API needs the current revisionId.

You need a HubSpot service key with the automation scope, stored as HUBSPOT_ACCESS_TOKEN in .env; a legacy private app token also works. Python 3.10+ with uv is required. Some plan tiers return 403 from the Automation API, so on those the audit has to happen by hand under Automation > Workflows. HubSpot does not restore deleted workflows, which is why the skill tells you to run /workflows-as-code first and keep the JSON export — that file lets you recreate a flow with POST /automation/v4/flows.

What it helps with

  • list every HubSpot workflow with its status and dates
  • tell test workflows apart from live automations
  • spot workflows disabled more than 90 days ago
  • check whether another workflow depends on the one you delete
  • keep a JSON export before removing automations

Example prompts for the agent

  • Audit my HubSpot workflows and show me what can go
  • Turn off workflows that have been disabled for 90+ days and queue them for deletion
  • Export every workflow with /workflows-as-code before the cleanup

How to install cleanup-workflows

1Skills CLI (Vercel)

npx skills add TomGranot/hubspot-admin-skills --skill cleanup-workflows -a claude-code

2Manually: put the files in place

~/.claude/skills/cleanup-workflows/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/cleanup-workflows/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about cleanup-workflows

How do I install cleanup-workflows in Claude Code?

Run npx skills add TomGranot/hubspot-admin-skills --skill cleanup-workflows -a claude-code. The skill lands in ~/.claude/skills/cleanup-workflows/SKILL.md.

What does cleanup-workflows do?

It inventories your HubSpot workflows via the v4 Automation API, flags inactive, test and deprecated ones, then disables and deletes the confirmed candidates.

What do I need before running it?

A HubSpot service key with the automation scope in HUBSPOT_ACCESS_TOKEN, plus Python 3.10+ with uv. On some plan tiers the Automation API answers with 403 and you audit in the HubSpot UI instead.

Source text

SKILL.md · MIT
---
name: cleanup-workflows
description: "Audit and remove inactive, test, or deprecated workflows from HubSpot. Identifies workflows that have never enrolled contacts, workflows turned off for 90+ days, and test workflows."
license: MIT
metadata:
  author: tomgranot
  version: "1.1"
  category: ongoing-maintenance
---

# Cleanup Workflows

Audit HubSpot workflows to remove dead weight. Unused workflows clutter the automation dashboard and make it harder to understand what is actually running.

## Prerequisites

- A HubSpot service key (`HUBSPOT_ACCESS_TOKEN` in `.env`; an existing legacy private app token also works) with the `automation` scope
- Python 3.10+ with [`uv`](https://github.com/astral-sh/uv)
- Note: The Automation API may return 403 on some plan tiers. If so, audit manually in HubSpot UI under Automation > Workflows.
- Strongly recommended: run `/workflows-as-code` first to export a JSON backup of every workflow — deleted workflows cannot be restored, but an export lets you recreate them via the API.

## Step-by-Step Instructions

### Stage 1: Plan

Confirm with the user before starting:

1. Archive-first policy: turn off, wait a week, then delete (recommended)?
2. Any workflows that must never be touched (compliance, integrations)?

### Stage 2: Before

Inventory all workflows via the v4 Automation API:

```python
import os, requests
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.environ["HUBSPOT_ACCESS_TOKEN"]
BASE = "https://api.hubapi.com"
HEADERS = {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}

flows, after = [], None
while True:
    params = {"limit": 100}
    if after:
        params["after"] = after
    resp = requests.get(f"{BASE}/automation/v4/flows", headers=HEADERS, params=params)
    resp.raise_for_status()
    data = resp.json()
    flows.extend(data.get("results", []))
    after = data.get("paging", {}).get("next", {}).get("after")
    if not after:
        break
```

For each workflow, record: flow ID, name, enabled status, type, created date, last updated date. Enrollment counts are visible in the UI (Automation > Workflows > Details).

### Stage 3: Execute

Flag workflows matching any of these criteria:

1. **Turned off** for 90+ days with no plans to reactivate
2. **Zero enrollments** ever (likely test or abandoned drafts)
3. **Test workflows** (names containing "test", "temp", "copy of", "draft")
4. **Superseded workflows** replaced by newer versions
5. **Error state** workflows that have been failing consistently

Before deleting, check:
- Does the workflow feed into another workflow (via enrollment trigger or go-to-workflow action)?
- Does the workflow set properties that other workflows depend on?
- Is there any documentation referencing this workflow?

Present the candidate list to the user and wait for explicit confirmation. Then, for confirmed candidates: turn each workflow off first (in the UI, or `PUT /automation/v4/flows/{flowId}` with `isEnabled: false` — the PUT requires the current `revisionId`), wait one week, then delete via `DELETE /automation/v4/flows/{flowId}` or the UI.

### Stage 4: After

1. Re-run the inventory and confirm the deleted workflows are gone.
2. Document deleted workflows in a cleanup log (name, purpose, reason for deletion).
3. Notify workflow owners.

## Rollback

- Deleted workflows cannot be restored in HubSpot.
- A `/workflows-as-code` export taken beforehand contains each workflow's full JSON definition — recreate a deleted workflow with `POST /automation/v4/flows` from its export.
- HubSpot retains workflow activity history on contact records even after the workflow is deleted.

## Tips

- Use folders in the workflows dashboard to organize by team, purpose, or status.
- Prefix draft/test workflows with "[TEST]" so they are easy to identify later.
- Review workflows quarterly as part of the database cleanup routine.

© tomgranot · MIT · TomGranot/hubspot-admin-skills

Similar skills

All skills for Automation and no-code: n8n, Zapier, Make →

From the same set11

review-bounced-contacts A weekly manual pass over contacts with 3+ bounces: delete them or try to recover. Keeps suppression from going too far while bad records still leave. CX Codex +1 ★ 78repo stars new-contact-hygiene-workflow Builds a HubSpot workflow that stages every new contact and pulls company details from the associated company record. CX Codex +1 ★ 78repo stars enrich-company-name Copies the company name from a linked company record into empty contact fields in HubSpot. Useful when empty values break segmentation and personalization tokens. CX Codex +1 ★ 78repo stars create-segment-lists Builds a library of HubSpot segment lists — customers, partners, competitors, employees, ICP tiers, industries. Feeds targeting, suppression and reporting. CX Codex +1 ★ 78repo stars cleanup-lead-owners Strips departed employees out of HubSpot and moves their contacts, companies and deals to someone still on the team. Handy the week a person leaves. CX Codex +1 ★ 78repo stars cleanup-dashboards Walks you through auditing HubSpot dashboards: spots abandoned screens, duplicates and test copies, then helps merge reports into a few that people actually open. CX Codex +1 ★ 78repo stars bounce-monitoring-workflow The skill builds three HubSpot workflows that watch email bounces: it suppresses contacts past a set count, alerts on hard bounces, and flags addresses for a weekly review. CX Codex +1 ★ 78repo stars assign-unowned-contacts Gives every ownerless marketing contact in HubSpot an owner. Useful when owner-based reports and the actual contact list disagree. CX Codex +1 ★ 78repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor