← Blog

Using Codex for GTM engineering: automate your pipeline

GTM Engineering9 min readMay 2026

OpenAI shipped Codex as a cloud-based coding agent. It reads your repo, writes code, runs tests, and opens PRs. Most coverage focuses on software engineering. But Codex has a second life that nobody talks about: running GTM pipelines.

If you give Codex access to CLI tools and APIs, it becomes an autonomous GTM operator. It can research accounts, find contacts, validate emails, enrich data, and push results to your CRM. All from a single prompt. This guide walks through exactly how to set that up with gtmcli.

We will cover what Codex is, why it matters for GTM work, how to connect it to gtmcli, and how to build a full pipeline from account research through CRM loading. We will also compare Codex to Claude Code for GTM engineering and break down real credit costs.

What Codex is and why GTM teams should care

Codex is OpenAI's agentic coding environment. You give it a task in natural language. It spins up a sandboxed cloud environment, installs dependencies, writes code, executes it, and returns results. Think of it as a junior developer that works in the background and pings you when it is done.

For GTM engineering, this model is powerful. Most pipeline work is not complex software engineering. It is scripting. Pull data from API A, transform it, validate it with API B, push it to API C. Codex handles this well because each step is concrete, testable, and sequential.

The key difference from chatbot-style AI: Codex actually executes code. It does not just suggest a curl command. It runs it. It reads the response. It handles errors. It retries. This makes it suitable for real production work, not just brainstorming.

Connect gtmcli to Codex

gtmcli is a command-line tool for email finding, validation, and enrichment. It wraps our API in simple commands that any agent can call. To connect it to Codex, you need two things: the gtmcli npm package and your API key.

In your Codex environment setup, install gtmcli and set the environment variable:

npm install -g gtmcli
export GTMCLI_API_KEY=your_api_key_here

Once installed, Codex can call any gtmcli command. Validate an email. Find contacts at a company. Enrich a domain. The agent treats these commands like any other CLI tool. It reads the output, parses JSON, and decides what to do next.

You can also use the gtmcli API directly via HTTP. Codex is good at writing fetch calls. But the CLI is simpler for most workflows because the output is already structured and the agent does not need to manage authentication headers manually.

# Codex can call these directly
gtmcli validate jeff@example.com
gtmcli find-email --name "Jeff Tucker" --domain "example.com"
gtmcli enrich --domain "example.com"

Build a full pipeline: research to CRM

Here is the pipeline we are building. Four stages, each one feeding the next.

Stage 1: Account research

Start with a target list. Maybe 50 companies in your ICP. Give Codex a CSV with company names and domains. Prompt it to research each one.

Prompt to Codex:

"Read accounts.csv. For each company, use gtmcli enrich
to get company data. Write the results to a new CSV called
accounts_enriched.csv with columns: domain, company_name,
industry, employee_count, location, description.
Skip any company where the enrich call fails."

Codex will write a script, loop through the CSV, call gtmcli for each domain, parse the JSON responses, and assemble the output file. Total time for 50 companies: about 3 minutes.

Stage 2: Contact finding

Now take the enriched accounts and find the right people. Define your persona: VP of Sales, Head of Revenue Operations, Director of Growth. Codex uses gtmcli to find email addresses for each persona at each company.

Prompt to Codex:

"Read accounts_enriched.csv. For each company domain,
use gtmcli find-email to find contacts with these titles:
VP Sales, Head of Revenue Ops, Director of Growth.
Write results to contacts.csv with columns: domain,
company_name, contact_name, title, email.
Try all three titles per company."

For 50 companies with 3 personas each, that is 150 lookups. At $0.01 per lookup, the cost is $1.50. Codex handles the looping, error handling, and CSV assembly.

Stage 3: Email validation

Never send to an unvalidated email. Every address from the previous step gets validated before it touches your CRM or sequencer.

Prompt to Codex:

"Read contacts.csv. Validate every email address using
gtmcli validate. Add a 'status' column with the result.
Remove any row where status is 'invalid'. Write the
clean list to contacts_validated.csv."

Validation costs 1 credit per check. For 150 contacts, that is 150 credits. The validation step typically removes 15-25% of addresses, which protects your sender reputation and saves wasted sequence slots.

Stage 4: CRM load

The final step pushes validated, enriched contacts into your CRM. Codex can write to the HubSpot or Salesforce API directly.

Prompt to Codex:

"Read contacts_validated.csv. For each contact, create
or update a contact in HubSpot using the HubSpot API.
Map columns: email -> email, contact_name -> firstname/
lastname, title -> jobtitle, company_name -> company,
domain -> website. Use the HUBSPOT_API_KEY env variable.
Log results to crm_load_log.csv."

Codex writes the API calls, handles rate limits, deduplicates against existing contacts, and logs every create or update. The entire four-stage pipeline runs without human intervention after the initial prompt.

The single-prompt version

You can also run the entire pipeline in one shot. Here is a production prompt that chains all four stages:

"I have a file called target_accounts.csv with columns
'company' and 'domain'. For each account:

1. Run gtmcli enrich --domain {domain} to get company info
2. Run gtmcli find-email for titles: VP Sales, Head of
   Revenue Ops, Director of Growth
3. Validate every found email with gtmcli validate
4. Push valid contacts to HubSpot via the API

Write a summary CSV with all contacts, their validation
status, and whether they were created or updated in
HubSpot. Skip invalid emails entirely.

Use GTMCLI_API_KEY and HUBSPOT_API_KEY from env vars."

Codex will break this into a multi-step script, execute each stage, handle errors at each step, and produce the summary file. For 50 accounts, the whole thing runs in about 8-12 minutes.

Codex vs Claude Code for GTM engineering

Both Codex and Claude Code can run GTM pipelines. The choice depends on your workflow and what you value.

Codex runs in the cloud. You submit a task, walk away, and come back to results. It works asynchronously. Good for large batch jobs where you do not need to supervise. It runs in a sandboxed environment, so it cannot access your local filesystem or tools that require local state. You interact through the Codex UI or API.

Claude Code runs locally in your terminal. It has direct access to your filesystem, your installed tools, your environment variables, and your network. It can read and write files on your machine, call local APIs, and interact with MCP servers. This makes it better for workflows that touch local data or require interactive debugging.

For GTM specifically, here is how they compare:

Codex strengths:

- Runs in background while you do other work

- Good for overnight batch jobs (10,000+ contacts)

- Isolated environment reduces risk of side effects

- Parallel task execution via multiple Codex sessions

Claude Code strengths:

- MCP server integration for direct tool access

- Reads local files, databases, CRM exports

- Interactive: you can steer the agent mid-run

- Better reasoning for complex multi-step logic

- Faster iteration when building new workflows

In practice, many GTM engineers use both. Claude Code for building and testing workflows locally. Codex for running proven workflows at scale in the background.

Credit costs: what a real pipeline costs

Let us break down the cost of a real pipeline run. Take 100 target accounts, 3 personas each, which produces roughly 300 contacts.

Account enrichment: 100 credits (1 per domain)

Email finding: 300 credits (1 per lookup)

Email validation: 300 credits (1 per address)

─────────────────────────────────────────

Total gtmcli cost: 700 credits

At $0.01/credit: $7.00

Codex cost: ~$0.50-1.00 per task

─────────────────────────────────────────

Total pipeline cost: ~$8.00 for 300 contacts

Compare that to manual work. A sales ops person spending 40 hours on the same task at $50/hour costs $2,000. A data vendor subscription for similar coverage runs $500-2,000/month. The agent-driven approach is cheaper by an order of magnitude.

For larger runs, the economics get even better. 1,000 accounts with 3,000 contacts costs about $70 in gtmcli credits plus $5-10 in Codex compute. That is 3,000 validated, enriched contacts ready for sequencing.

Tips for running Codex GTM pipelines

Start small. Run 10 accounts first. Check the output. Verify the CRM entries look right. Then scale to 100, then 1,000. Every pipeline has edge cases that only surface at volume.

Be explicit in your prompts about error handling. Tell Codex what to do when an API call fails, when a contact has no email, when the CRM returns a duplicate. Vague prompts produce brittle scripts.

Always validate before loading to CRM. This is non-negotiable. One bad batch can damage your sender reputation for weeks. Validation is cheap. Reputation recovery is expensive.

Log everything. Have Codex write a log file for every pipeline run. Include timestamps, API responses, error messages, and row-level status. When something breaks at row 847, you want to know exactly what happened.

Use environment variables for all API keys. Never hardcode credentials in prompts. Codex supports environment secrets. Use them.

Try gtmcli

100 free credits. No credit card.