Skip to main content
skill CX Codex

backfill-geo-data — Claude Code skill: what it does, how to install

Fills missing city, state, and country fields on HubSpot contacts and companies. Useful for territory routing and compliance audits.

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

What backfill-geo-data does

This skill guides the discovery and backfilling of missing regional properties in HubSpot records. It works through HubSpot Operations Hub workflows, matches domain records to copy location details from linked companies, or pulls coordinates from form fields like ip_city and ip_country.

Running the Python lookup routines requires Python 3.10+, uv, and a HUBSPOT_ACCESS_TOKEN in .env with contact and company read/write scopes. The process operates under a strict rule against overwriting existing values: updates touch only empty fields, and batches remain capped at 100 items to observe API rate quotas.

What it helps with

  • identify HubSpot records missing city, state, or country fields
  • copy location details from associated company objects to contacts
  • promote IP geolocation properties to primary address fields
  • create a baseline CSV audit trail before running bulk updates

Example prompts for the agent

  • Identify contacts missing a country and copy location details from their associated companies
  • Populate empty city fields using ip_city values across HubSpot records
  • Count records missing state data and export a rollback baseline to CSV

How to install backfill-geo-data

1Skills CLI (Vercel)

npx skills add TomGranot/hubspot-admin-skills --skill backfill-geo-data -a claude-code

2Manually: put the files in place

~/.claude/skills/backfill-geo-data/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/backfill-geo-data/

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

Questions about backfill-geo-data

How to install backfill-geo-data in Claude Code?

Run npx skills add TomGranot/hubspot-admin-skills --skill backfill-geo-data -a claude-code. The definition lands in ~/.claude/skills/backfill-geo-data/SKILL.md.

What does backfill-geo-data do?

It coordinates a step-by-step workflow to detect and populate missing geographic attributes in HubSpot CRM, using internal associations or external lookups.

What are the prerequisites for this skill?

You need Python 3.10+ with uv and a valid HUBSPOT_ACCESS_TOKEN stored in .env providing read and write scopes for contacts and companies.

Source text

SKILL.md · MIT
---
name: backfill-geo-data
description: "Enrich missing geographic data (country, state, city) on contacts and companies using HubSpot workflows, external data providers, or IP-based geolocation."
license: MIT
metadata:
  author: tomgranot
  version: "1.1"
  category: ongoing-maintenance
---

# Backfill Geographic Data

Fill in missing country, state, and city values on contacts and companies. Geographic data enables territory assignment, regional reporting, and compliance (GDPR, state privacy laws).

## Prerequisites

- A HubSpot service key (`HUBSPOT_ACCESS_TOKEN` in `.env`; an existing legacy private app token also works) with contact and company read/write scopes
- Python 3.10+ with [`uv`](https://github.com/astral-sh/uv)
- Standardized geo values already in place (run `/standardize-geo-values` first)

## Enrichment Methods

### Method 1: HubSpot Workflow Enrichment (Simplest)

Use HubSpot's built-in Operations Hub data quality tools or Breeze Intelligence (if available on your plan) to auto-fill geographic fields.

1. Create a workflow triggered by: country is unknown AND email is known
2. Use the "Enrich contact" action (Operations Hub Professional+) or Breeze Intelligence enrichment
3. If enrichment fills country/state, the workflow completes
4. If enrichment fails, branch to flag for manual review

### Method 2: Company Domain Lookup (API-based)

For contacts with a company domain but no geo data, look up the company's geographic information:

```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"}

# Find contacts missing country but with company association
resp = requests.post(f"{BASE}/crm/v3/objects/contacts/search", headers=HEADERS, json={
    "filterGroups": [{"filters": [
        {"propertyName": "country", "operator": "NOT_HAS_PROPERTY"},
        {"propertyName": "associatedcompanyid", "operator": "HAS_PROPERTY"},
    ]}],
    "properties": ["email", "associatedcompanyid"],
    "limit": 100,
})
resp.raise_for_status()
```

Copy country/state/city from the associated company to the contact (same pattern as `/enrich-company-name`).

### Method 3: External Data Provider

Use `/waterfall-enrich-contacts` — it provides pluggable provider adapters (FullEnrich by default; Apollo, Hunter, Dropcontact included, or bring your own), per-run cost caps, no-overwrite safety, and a CSV audit trail. Exhaust Methods 1-2 first: external lookups cost credits per contact, internal data is free.

## Step-by-Step Instructions

### Stage 1: Plan

1. Choose the enrichment method (see above) based on volume, plan tier, and budget — confirm with the user.
2. Confirm the no-overwrite rule: enrichment must only fill empty fields.

### Stage 2: Before — Assess the Gap

1. Count contacts missing country, state, and city.
2. Segment by source — which lead sources tend to have missing geo data?
3. Export a CSV baseline of the affected records before changing anything.

### Stage 3: Execute — Run Enrichment

1. Apply the chosen method (or combine methods for maximum coverage).
2. Process in batches of 100 to respect rate limits.
3. Validate enriched values against the standardized geo format from `/standardize-geo-values`.

### Stage 4: After — Verify

1. Re-count contacts missing geographic fields. Calculate improvement percentage.
2. Spot-check 20-30 enriched contacts for accuracy.
3. Set up the new-contact hygiene workflow to prevent future gaps.

## Rollback

- If enrichment data is inaccurate, filter contacts updated by the enrichment process (use `hs_lastmodifieddate` range) and clear the geo fields.
- Keep a backup export of the original data before running enrichment.

## Tips

- IP-based geolocation (from form submissions) is already captured by HubSpot in `ip_city`, `ip_state`, `ip_country`. Copy these to the standard fields if the standard fields are empty.
- Do not overwrite manually-entered geo data with enrichment data — always check "if empty" before writing.

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

Similar skills

All skills for Data and databases →

From the same set37

cleanup-forms Audits and cleans up unused, test, and deprecated HubSpot forms via the Forms API. Keeps dashboards, workflows, and reporting clean. CX Codex +1 ★ 78repo stars cleanup-deals Finds overdue, stale, incomplete and likely test HubSpot deals, then routes flagged records to their owners for review. Test-deal deletion requires a human-reviewed CSV. 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 build-smart-lists Creates core active dynamic lists in HubSpot using Lists API v3 and provides rules for UI-built segments. Useful for standardizing marketing audiences and sales prioritization. CX Codex +1 ★ 78repo stars build-lead-scoring This skill guides HubSpot setup for separate company-fit and contact-engagement scores. Use it to help sales and marketing prioritize leads by different signals. 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 audit-api-usage This skill maps HubSpot API callers, flags legacy endpoints and private apps, and turns the findings into a migration checklist. 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