Codex Goal Loop logo

Codex Goal Loop

Community
matyasstoch
codex-goal-loop

Explain and write effective instructions for OpenAI Codex's `/goal` feature — the persistent self-checking agent loop (plan → act → test → review → iterate). Use when the user mentions Codex `/goal`, "goal loop", wants to kick off a long-running autonomous Codex run, asks how to write a goal prompt, or wants a one-paragraph goal instruction drafted.

Overview

Publishermatyasstoch
Repositorydavid-skills
Skill namecodex-goal-loop
Stars
61
Forks
11
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by matyasstoch on GitHub. Read the source before you install it.

Installation

Install the Codex Goal Loop AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/matyasstoch/david-skills/tree/main/skills/codex-goal-loop
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/matyasstoch/david-skills.git /tmp/david-skills
mkdir -p .claude/skills
cp -r /tmp/david-skills/skills/codex-goal-loop .claude/skills/codex-goal-loop
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Codex Goal Loop in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Codex Goal Loop on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Codex Goal Loop is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Codex /goal Loop

What /goal is

/goal is a slash command in Codex v0.128.0+ (April 30, 2026) that turns a Codex prompt into a persistent agent looping plan → act → test → review → iterate until a stop condition is met, the user pauses, or the token budget runs out.

Key difference from a normal prompt: when a turn ends but the goal isn't met, Codex auto-continues instead of waiting for input.

Lifecycle states: pursuing, paused, achieved, unmet, budget-limited.

Not: a budget command, a safety boundary, "run forever", or a replacement for /plan. It's a contract enforcer with a verification loop.

Requirements

  • Codex CLI/app/extension v0.128.0+
  • goals = true in ~/.codex/config.toml (or codex features enable goals)
  • ChatGPT auth (Plus/Pro/Business/Edu/Enterprise) — API-key auth does not work. Pro is the realistic minimum for long runs.

When to use it

Use only when all three are true:

  1. Task is >30 min of mechanical work.
  2. There's a verifiable stop condition (tests pass, coverage hit, eval ≥ X, build green).
  3. Repo is agent-ready (working build, decent tests, AGENTS.md present).

Fits: migrations, coverage lifts, TDD feature builds, refactors with contract tests, prompt/eval optimization, deploy retry loops, bug-repro-then-fix.

Bad fits: exploratory work, vague "improve this", anything without a "done" definition, prod credentials, destructive shared-infra ops.

The 4-part contract (every goal needs this)

  1. Objective — one sentence, one concrete outcome.
  2. Constraints — what must NOT change (public API, files, libs, conventions).
  3. Validation command — the exact shell command that proves progress (pytest -q, pnpm test, etc.).
  4. Stop condition — verifiable: "Stop when X passes" OR "when further changes need human/product input."

Plus: tell Codex what to read first, ask it to work in checkpoints with a short progress log.

Writing a one-paragraph goal (the core deliverable)

When the user wants a quick one-paragraph /goal instruction, produce a single dense paragraph that packs the 4-part contract into flowing prose. Template:

/goal <one-sentence objective>. Read first: <files/PLAN.md/issue>. Constraints: <what not to change, libs, conventions>. Validate after each change with: <exact command>. Work in checkpoints and log progress briefly. Stop when: <verifiable condition>, OR when further changes require human/product input.

Example (migration)

/goal Migrate this project from Pydantic v1 to v2. Read first: pyproject.toml, src/, tests/. Constraints: no public API changes; keep imports backwards-compatible via shims if needed; no new dependencies. Validate after each change with: pytest -q. Work in checkpoints; log progress briefly. Stop when: full suite passes with zero deprecation warnings, OR when a change requires architecture decisions.

Example (coverage lift)

/goal Raise coverage in src/auth/ from ~38% to ≥75%. Read first: src/auth/, tests/auth/, AGENTS.md. Constraints: no new deps; mirror existing test style; do not modify production code unless strictly required for testability. Validate with: pytest --cov=src/auth --cov-report=term-missing. Work in checkpoints; log coverage delta each one. Stop when: coverage ≥75% AND all tests pass, OR when uncovered code needs design changes.

Writing rules

  • One objective, one stop condition. Not a backlog.
  • Use literal strings for paths, commands, issue numbers — exact.
  • Forbid scope creep explicitly: "Do not refactor unrelated code. Do not add dependencies."
  • Tell Codex when to pause: "If , pause and ask before proceeding."
  • Short, vague goals burn tokens for no extra value vs. a normal prompt.

Meta-prompting trick (highest-leverage)

Hand-written goals under-specify. Ask a second AI session (Claude with the codebase loaded, ChatGPT with project connected, or a separate Codex thread in the same dir) to: (1) inspect the codebase, (2) surface hidden assumptions/constraints/edge cases, (3) emit a dense /goal paragraph using the 4-part contract. Paste that into Codex. Order-of-magnitude better runs.

Launching

  1. cd <repo> (goals run scoped to the working directory).
  2. Run codex (bare — opens TUI). Not codex exec "/goal ..." — /goal is a TUI slash command only.
  3. Sign in with ChatGPT (not API key).
  4. Type /goal <your contract> in the composer, Enter.
  5. Walk away.

Always launch on a branch or worktree. Never on main.

Controlling a running goal

CommandEffect
/goal (alone)Status: current checkpoint, what's verified, what remains, blockers
/goal pauseFreeze
/goal resumeUnfreeze (required in v0.129+; paused goals never auto-resume)
/goal clearKill the goal
/goal <new>Replace the current goal
Ctrl+C / any typed messageAuto-pauses; user input always wins priority

Resuming across sessions: goal state is persisted server-side. cd back into the repo, run codex, /goal for status, /goal resume.

Budget-limited state: Codex doesn't stop abruptly — it summarizes, notes what's left, saves state. /goal resume works after budget refresh or upgrade.

When a goal drifts

  • Minor drift: just type a correction in the composer (auto-pauses, folds it in, resumes).
  • Loose objective: /goal pause, read status, then /goal <tighter version> — replaces the contract. Don't pile instructions on a vague goal.
  • Bad mess: /goal clear, git reset --hard HEAD or git stash, rewrite with the meta-prompting trick, restart.

Don't let a drifting goal keep running "to see where it goes." Tokens burn, diffs compound.

Operational tips

  • Inspect status periodically with bare /goal.
  • Always review the diff before merging — long autonomy means more code to validate, not less. Human oversight becomes more critical, not optional.
  • Keep approvals/sandboxing tight; default permissions are correct.
  • First run: pick a 30-min scoped task so you learn how /goal actually stops before trusting it overnight.

Troubleshooting

SymptomFix
/goal missing from slash popupcodex update (need ≥0.128.0)
Flag on but command missingQuit and restart codex fully
Typed /goalsIt's singular: /goal
Doesn't activateSign out, sign back in with ChatGPT subscription (not API key)
Stopped with progress summaryBudget-limited — /goal resume after refresh, or tighten scope
/goal resume says no active goalTerminal state or cleared — start fresh with /goal <new>

Mental model

/goal is a contract enforcer with a verification loop, not a "run forever" button. The shift: stop writing prompts, start writing specifications with stop conditions. Spend the time upfront defining "done"; the run takes care of itself.

Frequently asked questions

What does the Codex Goal Loop AI skill do?

Explain and write effective instructions for OpenAI Codex's `/goal` feature — the persistent self-checking agent loop (plan → act → test → review → iterate). Use when the user mentions Codex `/goal`, "goal loop", wants to kick off a long-running autonomous Codex run, asks how to write a goal prompt, or wants a one-paragraph goal instruction drafted.

Why use Codex Goal Loop on TypingMind?

Because you install it once and use it with any model. Codex Goal Loop is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Codex Goal Loop in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/matyasstoch/david-skills/tree/main/skills/codex-goal-loop. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Codex Goal Loop?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Codex Goal Loop?

As many as you like. As long as a model supports skills, you can use Codex Goal Loop with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Codex Goal Loop AI skill free?

It is published on GitHub by matyasstoch. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇