Skip to main content
skill CX Codex

sandbox-self-test — Claude Code skill: tests and setup

Runs the HubSpot toolkit against a disposable test account, seeds fixtures, checks scripted paths, writes a graded report, and cleans up.

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

What sandbox-self-test does

This skill validates HubSpot skills in a developer test account or sandbox rather than a live portal. It creates synthetic companies and contacts, runs each scripted skill’s read path, exercises destructive and round-trip cases, and writes PASS, FAIL, or SKIP results to reports/selftest-{date}.md.

The workflow is split across four scripts. preflight.py checks the account type and scopes, seed.py creates marked fixtures, run_suite.py executes the cases, and teardown.py exports an audit log before deleting matching objects after typed TEARDOWN confirmation. The enrichment case uses a mock provider, so it does not spend credits.

You need a HubSpot developer test account or standard sandbox, a separate HUBSPOT_SANDBOX_ACCESS_TOKEN, the listed CRM scopes, Python 3.10+, and uv. The skill refuses production access: every script accepts only DEVELOPER_TEST or SANDBOX, and account-type verification fails closed.

What it helps with

  • check read paths across scripted HubSpot skills
  • seed synthetic companies and contacts
  • exercise destructive end-to-end cases safely
  • verify list and workflow API round trips
  • generate a PASS/FAIL/SKIP test report

Example prompts for the agent

  • Run sandbox-self-test against a disposable HubSpot developer test account and validate the toolkit.
  • Run preflight, seed the fixtures, execute the suite, and inspect reports/selftest-{date}.md.
  • Tear down the marked objects after the report and ask for typed TEARDOWN confirmation.

How to install sandbox-self-test

1Skills CLI (Vercel)

npx skills add TomGranot/hubspot-admin-skills --skill sandbox-self-test -a claude-code

2Manually: put the files in place

~/.claude/skills/sandbox-self-test/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/sandbox-self-test/

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

Questions about sandbox-self-test

How do I install sandbox-self-test in Claude Code?

Run npx skills add TomGranot/hubspot-admin-skills --skill sandbox-self-test -a claude-code, then use ~/.claude/skills/sandbox-self-test/SKILL.md.

What does sandbox-self-test do?

It tests HubSpot skills against disposable data, covering read paths, end-to-end actions, and API round trips. It produces a graded report and removes marker-matched fixtures afterward.

What does sandbox-self-test require?

Use a developer test account or standard sandbox, HUBSPOT_SANDBOX_ACCESS_TOKEN with the required CRM scopes, Python 3.10+, and uv. Production accounts are refused.

Source text

SKILL.md · MIT
---
name: sandbox-self-test
description: "Verify the entire toolkit against a disposable HubSpot developer test account or sandbox that you bring: seed synthetic fixtures, run every scripted skill's read path, exercise end-to-end and API round-trip cases, produce a graded report, and tear everything down. Hard-refuses to run against production."
license: MIT
metadata:
  author: tomgranot
  version: "1.0"
  category: audit-planning
---

# Sandbox Self-Test

## Purpose

Every skill in this repo mutates or reads a live HubSpot portal, and no two portals are alike. This skill lets anyone — a contributor before opening a PR, an admin before trusting the toolkit with production, or the maintainer after a HubSpot API change — verify the whole toolkit against a **disposable portal they bring themselves**. HubSpot gives every account up to 10 free developer test accounts, so there is no shared test infrastructure to maintain and no credentials in the repo: bring your own sandbox, run the suite, read the report, throw the sandbox away.

## Key Constraint

**This suite seeds, mutates, and deletes data. It must never touch production.** The lockout is enforced in code, not by convention:

1. The suite reads its own env var, `HUBSPOT_SANDBOX_ACCESS_TOKEN` — it never reads `HUBSPOT_ACCESS_TOKEN`, so a production token in your `.env` cannot be picked up by accident.
2. Every script (not just preflight) calls `GET /account-info/v3/details` before acting and **refuses unless `accountType` is `DEVELOPER_TEST` or `SANDBOX`**. The check fails closed — any error verifying the account type is a refusal — and there is no override flag.

## Prerequisites

- A **developer test account** (free: HubSpot Settings > Testing > Developer test accounts, up to 10 per account, 90-day expiry renewed by API activity) or a **standard sandbox** (Enterprise plans)
- A service key (or legacy private app) **inside that test account** with scopes: `crm.objects.contacts.read/write`, `crm.objects.companies.read/write`, `crm.objects.owners.read`, `crm.lists.read/write`, `automation`
- Its token in `.env` as `HUBSPOT_SANDBOX_ACCESS_TOKEN` (keep it separate from your production `HUBSPOT_ACCESS_TOKEN`)
- Python 3.10+ with [`uv`](https://github.com/astral-sh/uv)

## Scripts

Script paths are relative to this skill's directory. Run them from your project directory so `.env`, `data/`, and `reports/` resolve there: prefix each path with wherever this skill is installed (`skills/sandbox-self-test/` in a clone of the repo).

| Stage | Script | Run with |
|-------|--------|----------|
| Before | [`scripts/preflight.py`](./scripts/preflight.py) | `uv run scripts/preflight.py` |
| Execute | [`scripts/seed.py`](./scripts/seed.py) | `uv run scripts/seed.py` |
| Execute | [`scripts/run_suite.py`](./scripts/run_suite.py) | `uv run scripts/run_suite.py` |
| After | [`scripts/teardown.py`](./scripts/teardown.py) | `uv run scripts/teardown.py` |

`preflight.py` gates on account type and probes scopes. `seed.py` creates the fixture matrix (idempotent). `run_suite.py` runs the cases and writes the report (`--list` prints the plan without any API call). `teardown.py` deletes everything marker-matched, with typed confirmation.

## Execution Pattern

### Stage 1: Plan

Confirm with the user:

1. **Which portal.** They must name the developer test account / sandbox being used. If they only have a production token, stop and walk them through creating a test account first — do not improvise.
2. **What is in it.** The suite tolerates other data in the sandbox (all assertions are marker-scoped), but a sandbox that mirrors production data deserves a warning: `delete-no-email-contacts` runs for real and will delete *all* no-email contacts in the portal, not just fixtures. An empty or purpose-made sandbox is the recommendation.
3. **Whether to tear down at the end** (default: yes).

### Stage 2: Before

Run preflight. It must print `GO` — portal ID, account type, and all scope probes OK. A `REFUSED` here is the safety system working; never work around it.

### Stage 3: Execute

Seed, then run the suite:

1. `seed.py` creates 3 companies and 9 contacts, one defect per testable skill (no email, no owner, no lifecycle stage, messy geo spellings, duplicate company domains, missing company name with an association to copy from, an enrichable contact for the mock provider).
2. `run_suite.py` runs three kinds of cases:
   - **before-smoke** — every scripted skill's `before.py` runs as a subprocess with the sandbox token standing in for `HUBSPOT_ACCESS_TOKEN`; read-only, asserts clean exit. This is the widest net: it catches endpoint drift, scope gaps, and pagination breakage across the whole toolkit.
   - **end-to-end** — `delete-no-email-contacts` (full destructive cycle with piped confirmation, verified against the Search API), `waterfall-enrich-contacts` with the **mock provider** (no credits spent, write-back verified), `workflows-as-code` export (JSON on disk verified).
   - **api-roundtrip** — a dynamic list and a v4 workflow are each created (`[SELFTEST]`-prefixed, workflow disabled with a never-matching enrollment filter), fetched, verified, and deleted.

All fixtures are triple-marked: reserved-TLD emails (`@selftest.hubspot-admin-skills.invalid` — can never receive mail), `SELFTEST` name prefixes, `[SELFTEST]` list/workflow prefixes.

### Stage 4: After

Read `reports/selftest-{date}.md` with the user: PASS/FAIL/SKIP per case. Investigate any FAIL before using the failing skill on production — a failure here is either a fixture problem, a scope problem, or a real regression against HubSpot's current API behavior, and telling those apart is the whole point of the suite. Then run teardown.

## Safety Mechanisms

| Mechanism | Detail |
|-----------|--------|
| **Production lockout** | Account-type gate (`DEVELOPER_TEST`/`SANDBOX` only) enforced independently in preflight, seed, suite, and teardown. Fails closed, no override. |
| **Separate token variable** | `HUBSPOT_SANDBOX_ACCESS_TOKEN` only — a production token in `HUBSPOT_ACCESS_TOKEN` is invisible to this suite. |
| **Marker-scoped teardown** | Deletion matches selftest markers (reserved-TLD email domain, `SELFTEST`/`[SELFTEST]` prefixes) — never "everything in the portal". |
| **CSV audit trail** | Teardown exports every object it will delete to `data/audit-logs/` before deleting, and requires typed `TEARDOWN` confirmation. |
| **No credits spent** | The enrichment case forces `ENRICHMENT_PROVIDER=mock` (deterministic fake data, no network). |
| **Skips are visible** | Anything a sandbox can't simulate is reported `SKIP` with the reason — the report never overstates coverage. |

## Technical Gotchas

1. **A sandbox cannot simulate everything.** Bounce state (`hs_email_hard_bounce_reason_enum`), global unsubscribes (`hs_email_optout`), marketing status (`hs_marketable_status`, read-only via API), and deactivated owners all come from real events HubSpot records — they cannot be fabricated. The suite reports these as SKIP; verify those paths once, manually, when first running the corresponding skills on a real portal.
2. **Search index lag.** The Search API indexes writes asynchronously; the suite sleeps ~5s before asserting post-mutation counts. On a slow day a fresh mutation can still be missed — re-run the suite before concluding a skill is broken.
3. **Developer test accounts expire after 90 days** without API activity. Running this suite counts as activity, so a monthly run keeps the sandbox alive. Deleted fixtures follow the same 90-day recovery window as production.
4. **`before-smoke` failures on an empty sandbox are usually legitimate zero-data exits.** The shipped `before.py` scripts exit 0 on "nothing found" — if one exits non-zero on your sandbox, read its output in the report; that's a real signal, not noise.
5. **Plan-tier gaps.** Developer test accounts carry Enterprise-trial features, but a standard sandbox inherits its parent portal's tier — the v4 workflow round-trip reports SKIP on 403 rather than failing.

## Rollback

Teardown *is* the rollback: `uv run scripts/teardown.py` removes every marker-matched object, and archived records remain recoverable in the sandbox for 90 days (Settings > Data Management > Deleted Objects). The nuclear option is equally valid: delete the developer test account and create a fresh one — that is what "disposable" means. Nothing this skill does can touch production, by construction.

## CI (optional)

A ready-made GitHub Actions workflow ships at [`ci/sandbox-self-test.yml`](./ci/sandbox-self-test.yml). To enable it, copy it into your fork's workflows directory and set the repository secret:

```bash
mkdir -p .github/workflows
cp ci/sandbox-self-test.yml .github/workflows/
gh secret set HUBSPOT_SANDBOX_ACCESS_TOKEN
```

It runs preflight → seed → suite → teardown on **manual dispatch only** and uploads the report as an artifact. It never runs on push or PR — the sandbox is yours, so the trigger is too. (It ships outside `.github/workflows/` deliberately: enabling CI that spends your sandbox is an explicit opt-in, and tokens without the `workflow` scope can still push this repo.)

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

Similar skills

All skills for Testing and QA →

From the same set21

weekly-cleanup-routine A weekly HubSpot checklist for spotting issues with bounced emails, new contacts, workflows, lists, and data quality. CX Codex +1 ★ 78repo stars waterfall-enrich-contacts Pulls emails, phone numbers and job titles for HubSpot contacts from an external provider and writes them back with an audit trail. CX Codex +1 ★ 78repo stars suppress-ghost-contacts Finds HubSpot contacts that got marketing email but never opened any of it, then audits them so you can stop mailing the ones that hurt deliverability. CX Codex +1 ★ 78repo stars 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 quarterly-database-cleanup Audits HubSpot lists, contact data, engagement and scoring, then creates a report comparing quarters. Use it for recurring CRM maintenance. 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 lifecycle-progression-workflow This skill creates four HubSpot workflows that move contacts from Lead to Customer. Use it to advance lifecycle stages based on sales events. CX Codex +1 ★ 78repo stars enrich-industry This skill guides a HubSpot workflow that copies a company’s industry to associated contacts. Use it to prepare contact records for industry-based segmentation. 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