59API

← Retour aux guides

Codex + Scripts: Automate Your First Dev Workflow

Claude Code · EN · 2026-10-22

Start with one small, testable task

The fastest way to automate workflows with Codex and scripts is to give each tool a clear job: Codex handles bounded code changes; your script handles sequencing, tests, and failure conditions. Start with something repeatable, such as adding regression tests for a bug or updating a deprecated function call.

This quick-start uses a JavaScript repository with an existing npm test command. Substitute your project's test runner where needed. You need Git, the Codex CLI, installed project dependencies, and an API key for a Codex-compatible model.

1. Configure Codex to use 59API

59API is a low-cost, pay-as-you-go AI API relay compatible with Codex, Claude Code, and OpenAI SDKs. It offers GPT models and Claude variants, including Opus, Sonnet, Haiku, and Fable. For this workflow, choose a GPT model that supports Codex's Responses API requirements; OpenAI-compatible access alone does not make every model interchangeable.

Store your key outside the repository. For local use, load it from your password manager or a private environment file. In CI, use the platform's secret store and expose the value as API59_KEY. Never commit credentials or enable shell tracing around secrets.

In ~/.codex/config.toml, add these top-level settings before any table headers. Replace MODEL_ID with the exact supported model identifier from your account:

model_provider = "relay59"

model = "MODEL_ID"

Then add the provider table:

[model_providers.relay59]

name = "59API"

base_url = "https://api.59api.com/v1"

env_key = "API59_KEY"

wire_api = "responses"

The service origin is https://api.59api.com. Confirm the API path in your account documentation: use the /v1 suffix only if specified, and never append it twice. If configuration already exists, merge these settings rather than duplicating keys.

2. Make the repository explain itself

Create an AGENTS.md file at the repository root. Codex reads these instructions, so document the commands and boundaries that should apply on every run:

Keep these rules specific to the repository. A short, accurate instruction file is more useful than a long list of generic coding advice.

3. Wrap a bounded task in a shell script

Start from a clean working tree and create a branch with git switch -c automation/parser-tests. Save the following command in scripts/codex-parser-tests.sh, then run it with sh scripts/codex-parser-tests.sh:

set -eu; codex exec --sandbox workspace-write "Inspect src/parser.js and its existing tests. Add regression tests for empty input and malformed JSON. Change application code only if a test demonstrates a bug. Do not install dependencies, access external services, or commit changes. Summarize your work." && npm test && git diff --check

Replace the example file path with a real module. The script stops on failure, runs an independent test gate, and checks for whitespace errors. Workspace-write limits Codex's filesystem access, but the subsequent npm command runs under your shell's permissions. Use an isolated runner for untrusted repositories.

4. Review before expanding automation

Inspect git diff and git status --short, including newly created files. Passing tests are necessary, not proof of correctness. Review assertions, edge cases, and unexpected edits before committing.

Once this works locally, run the same script in CI on an isolated checkout. Set a job timeout, restrict secret access, and retain logs without exposing credentials. Keep deployment and automatic merging outside the initial workflow.

Keep repeated runs affordable

Small prompts, narrow file scopes, and explicit stopping conditions reduce unnecessary work. 59API's pay-as-you-go pricing makes repeated development runs economical; it positions itself among the cheapest relays and provides native official-quality models without downgrading. Compare current per-model rates and track actual usage rather than assuming every task costs the same.

If this workflow fits your team, consider signing up for 59API and testing one bounded task first. A referral rebate is also available; check its current terms before including it in your cost estimates.

Tarifs · Docs

Prêt à commencer ?

Connectez Claude et GPT en quelques minutes aux prix les plus bas, sans bridage. Inscrivez-vous pour votre clé API.

Inscription gratuite