How to Use Claude Code or Codex to Generate Local Business Leads
A practical walkthrough for using Claude Code, Codex, or another AI coding agent to build a CSV of local business leads, plus the prompt for doing it without any paid lead tool.
Table of contents
Claude Code and Codex can both help you build a lead list.
The useful version is not just "give me plumbers in San Diego." The useful version is a CSV you can actually use for outreach:
- business name
- website
- Google Maps listing
- phone number
- phone type
- owner or decision-maker name
- review count
- rating
- social profiles
- source URLs
- website text you can use for personalization
That last part matters. If all you have is a business name and phone number, your outreach is going to sound like every other scrape-and-blast campaign.
If you also have text from the business website, service pages, about page, contact page, and team page, you can ask Claude or Codex to write outreach that references something real.
That is the difference between:
Hey, do you need help with marketing?
and:
I noticed you have separate pages for emergency drain cleaning and trenchless sewer repair, but your Google Business Profile is ranking below smaller shops for "drain cleaning Denver." There may be an SEO gap there.
Both Claude Code and Codex can help with this. There are two ways to do it.
The two ways to generate the CSV
You can do this with no extra tool at all.
Or you can use a lead enrichment tool like LocalProspects and have the agent pull a much deeper CSV through the API.
The no-tool method is free, but it is limited. Claude Code and Codex are not reliable Google Maps scrapers by themselves. They often get blocked, rate-limited, or pushed into using random directories instead of actual Google Business Profiles.
That can still work for small research jobs. It just will not be as complete.
The LocalProspects method is better when you want:
- hundreds or thousands of leads
- Google Maps-style rank and listing data
- owner names where available
- website emails
- phone type
- social links
- website page text
- a clean CSV in one run
Method 1: Use LocalProspects with Claude Code or Codex
This is the workflow I use when I want a real outreach CSV.
- Go to LocalProspects.
- Create a free account.
- Open your dashboard and copy your API key.
- Go to the docs and copy the LocalProspects skill file.
- Paste the skill into Claude Code, Codex, Cursor, or whatever agent you use.
- Give it your API key.
- Tell it what niche and location you want.
Example:
Use the LocalProspects skill.
Find dentists in Colorado.
Use major cities and towns only.
Limit this test to 2 searches.
Export the final results as a CSV.
The agent can then:
- find the right location codes
- start the searches
- wait for the jobs to finish
- pull the results
- inspect the returned fields
- save the CSV locally
For example, a search for dentists in Denver and Colorado Springs can return hundreds of leads with columns like:
- Google Maps rank
- business name
- website
- phone
- phone type
- owner name
- rating
- review count
- social profiles
- logo URL
- website page URLs
- website page text
The website text is the part most tools do not give you.
That text is what lets you turn the CSV into actual outreach. You can feed the row back into Claude or Codex and ask it to write a first line based on the business's real services, location pages, about page, or positioning.
Why the website text matters
Most lead tools stop at the listing.
They give you:
- name
- phone
- address
- category
- website
- rating
- review count
That is useful, but it is not enough to personalize outreach well.
If you are selling websites, SEO, ads, recruiting, software, or local services, you want to know what the business actually says about itself.
For example:
- Do they mention emergency services?
- Do they serve residential, commercial, or both?
- Do they have city-specific service pages?
- Do they have a team page with names?
- Do they show an owner or founder?
- Do they have outdated website copy?
- Are they missing important pages?
- Are they ranking below weaker competitors?
That is why I care about the first few pages of website text. It gives the AI something real to work with.
Method 2: Do it with no tools
You can also ask Claude Code or Codex to research the leads manually.
This is the free way.
It can work, but there are tradeoffs:
- Google Maps is hard for agents to scrape directly.
- The agent may fall back to business directories.
- Owner-name fill rate will usually be low.
- Email fill rate will be hit or miss.
- It will be slower.
- The source quality will vary more.
Still, if you only need a small starter list, it is worth trying.
Here is the prompt.
You are a lead research agent. Your job is to find 100 local business leads for the following niche and location:
Niche: Plumber
Location: San Diego
Goal:
Create a CSV of 100 local businesses with as much verified public information as possible.
Process:
1. Start With Google Maps / Local Search
Search Google Maps first if available. Look for businesses matching the niche and location. Build a broad initial list before doing deep research. Try searches like:
- "[niche] in [city]"
- "[niche] near [city]"
- "best [niche] [city]"
- "[specific service] [city]"
If Google Maps access is limited, use normal Google search, business directories, local chamber pages, Yelp, BBB, Facebook pages, or other public sources.
2. Build The Initial Lead List
For each business, collect the basics first:
- Business name
- Website URL
- Google Maps listing URL, if available
- Phone number
- Address
- City / state
- Review count
- Average rating
- Business category / niche
Prioritize real operating businesses with websites. Avoid duplicates, franchises if possible, closed businesses, or businesses outside the target area.
3. Visit Each Website
For every business with a website, inspect the site for additional details. Check pages like:
- Home
- About
- Contact
- Team
- Staff
- Leadership
- Footer
- Privacy policy
- Terms
- Blog / author pages
Try to find:
- Owner name
- Founder name
- Manager / decision-maker name
- Public email address
- Contact form URL
- Additional phone numbers
- Social profile links
Only use publicly available information. Do not bypass logins, CAPTCHAs, paywalls, or private systems.
4. Find Emails Carefully
Look for emails on the website first. If none are visible, check obvious public pages and social profiles. Do not invent emails. If you infer a possible email pattern, mark it clearly as "inferred" in the notes, but keep the main email field blank unless verified.
5. Collect Social Profiles
Find public social links where available:
- Facebook
- Instagram
- LinkedIn
- Twitter / X
- YouTube
- TikTok
6. Verify And Clean The Data
Before finalizing:
- Remove duplicates
- Make sure every lead is relevant to the niche/location
- Normalize phone numbers and addresses where possible
- Keep source URLs for important data
- Use "Not found" for missing data instead of guessing
7. Return A CSV
Return the final result as a CSV with exactly these columns:
business_name,website_url,google_maps_url,category,phone,address,city,state,rating,review_count,owner_name,owner_title,email,contact_form_url,facebook_url,instagram_url,linkedin_url,twitter_url,youtube_url,tiktok_url,source_urls,notes
Requirements:
- Find 100 leads if possible.
- If fewer than 100 valid leads exist, return the best available set and explain why.
- Accuracy matters more than speed.
- Do not fabricate missing information.
- Include source URLs in the source_urls column.
- Final answer should include the CSV content or a saved CSV file path if working in a local coding environment.
You can change the niche and location:
Niche: Dentist
Location: Denver
or:
Niche: Roofer
Location: Southern California
The prompt is intentionally strict about not making things up. That matters because these agents will sometimes try to be helpful by filling in missing fields.
For lead research, blanks are better than fake data.
What the no-tool method usually gets wrong
The no-tool method can find some businesses.
But it usually struggles with three things.
1. Google Maps access
Google is aggressive about blocking automated browsing. Claude Code and Codex may not be able to scrape Maps directly from the browser.
When that happens, they will often use:
- directories
- chamber of commerce pages
- BBB pages
- Yelp
- niche-specific sites
Those sources can be useful, but they are not the same as a clean Google Maps search.
2. Owner names
Owner names are hard.
Some businesses list the owner clearly on the About page. Some have a team page. Some show the doctor, dentist, attorney, or founder. Many do not.
If you ask the agent to find owner names without a strong source rule, it may guess from email addresses, domain names, or LinkedIn snippets.
Do not do that.
Tell it to leave the field blank unless the name is publicly shown.
3. Emails
Emails are also inconsistent.
Some websites show info@, contact@, or a named email. Others only have a form. Some hide emails behind scripts. Some only list social profiles.
For outreach, you want the source URL and the confidence level. If the email is not clearly found, keep it blank.
What to do after you have the CSV
Once you have the CSV, do not send it straight into a cold email tool.
Run one more pass with Claude or Codex.
Ask it to:
- remove weak leads
- flag bad emails
- group businesses by angle
- write a short personalization field
- create a final outreach-ready CSV
Example:
Review this CSV and prepare it for cold email.
Keep only businesses with a website and at least one usable contact path.
Remove obvious franchises and duplicates.
Create a personalization_idea column based only on the website text or source URLs.
Do not invent details.
Export the cleaned list as outreach-ready.csv.
That step is where AI agents are actually useful.
The agent is not just collecting data. It is turning raw local business data into a campaign.
My recommendation
Use the no-tool prompt if you want to test the idea for free.
Use LocalProspects if you want the better CSV.
Claude Code and Codex are good at working with data once they have it. They can filter, clean, score, write, and export. The weak point is getting high-quality local business data in the first place.
That is why I prefer giving the agent a dedicated lead source and letting it do the workflow around it.
You get the data faster, the CSV is deeper, and the outreach has more context.
That is the whole game.
