Codex guides

FREE GUIDE

Codex in Slack, plus the SDK

Start repository work from a Slack conversation, or call Codex from a small server-side script.

  • 6 min read
  • Step by step
  • Copy-ready prompt

Start repository work from a Slack conversation, or call Codex from a small server-side script. These are two separate entry points. The original Slack integration used @Codex; current OpenAI instructions use @ChatGPT with Codex Cloud delegation.

Before you start

  • For the Slack route: a workspace where an administrator has enabled the ChatGPT Slack app and Codex Cloud delegation, plus an eligible published environment shared with the workspace.
  • For the Slack route: access to the selected environment and repository, a connected account when requested, and an enabled channel within your organization. Slack Connect channels are not supported by this flow.
  • For the SDK route: a local Git repository you can inspect, Node.js 18 or later, npm, and Codex CLI installed with working authentication. Use the current OpenAI authentication guide for your sign-in method.
  • For either route: one small repository question with a result you can verify. The first exercise asks for an explanation without editing code.

Want to do it yourself?

Difficulty
8 out of 10
Estimated completion time
1–2 hours

Skills you’ll need: Check Slack permissions and follow task results. The SDK route also requires running a script and inspecting its output.

How this helps your brand

A repository-specific explanation can turn a team discussion into a focused technical next step. Verifying the source files and checks helps collaborators act on evidence before changing customer-facing behavior.

  1. Step 1: Choose the route that fits your work

    Use Slack when the issue is already being discussed by your team and your administrator has prepared the integration. Follow steps 2 and 3, then the review step at the end.

    Use the TypeScript SDK when you want a local program to start and continue Codex work. Follow steps 4 and 5, then review the result. You do not need Slack to use the SDK, and a Slack task is not automatically an SDK thread.

  2. Step 2: Confirm the Slack setup and send a narrow request

    Ask your workspace administrator to confirm that ChatGPT is enabled in your channel, Cloud delegation is available, and the intended repository has a published workspace-shared environment. A personal Cloud environment does not qualify for this Slack flow.

    Mention @ChatGPT explicitly in the enabled channel. Name the repository or shared environment, summarize the relevant issue, and request an explanation of the code before an edit. Use the prompt at the end of this guide.

    If prompted to connect your account, follow the link, connect the same Slack workspace, then return to the original thread and mention @ChatGPT again. Review any private approval card before choosing Allow or Deny.

    Tip: The eventual channel reply is visible to people who can read that channel. Keep secrets and private customer details out of the request.

    Illustrated exampleA Slack request with a clear destination
    shop-engineeringExample channel
    Maya 10:42

    @ChatGPT Use Codex Cloud to investigate northline/shop using Shop · shared.

    Adding the same item twice leaves the cart quantity at 1. Expected: 2. Explain the relevant code and identify the check command. Do not edit files.

    Keep related follow-ups here, with another @ChatGPT mention.
    01 Address the app
    An explicit mention in an enabled internal channel.
    02 Name the destination
    A repository and a published workspace-shared environment.
    03 Bound the request
    One reproducible issue. Explanation before an edit.

    Visibility check The channel reply is readable by channel members. Codex Cloud task access is checked separately.

    Illustrative message and environment names. Confirm the app, account access and shared environment with your administrator before sending your own request.
  3. Step 3: Follow the Slack result or fix the access problem

    Repository work runs as a separate Codex Cloud task. When Follow along is available, use it to inspect the task. The channel reply does not grant every channel member access to that task.

    If no task starts, check the error rather than sending the request repeatedly. No eligible environment usually requires a published, shared setup or corrected account access. Where role-based access control applies, both your account and the deployment’s service account need Codex Cloud access.

    If there is no response, confirm the channel has the app enabled and that you mentioned @ChatGPT. Use an internal channel rather than Slack Connect. When the result arrives, request related corrections in the same thread and mention @ChatGPT again.

  4. Step 4: Prepare a small SDK script

    For the SDK route, work in a local test repository whose files you are allowed to inspect. Verify that Codex CLI can sign in and answer a simple repository question first. This isolates authentication and project setup problems from your script.

    Install the library by running npm install @openai/codex-sdk in that repository. This changes its dependency files, so use a test copy if you do not want those files added to your real project.

    Create a file named codex-check.mjs in the repository and put the following JavaScript in it. The .mjs extension lets this small Node script use imports and await without a separate TypeScript build.

    import { Codex } from "@openai/codex-sdk"; const codex = new Codex(); const thread = codex.startThread(); const result = await thread.run("Explain this repository’s purpose and identify its documented check command. Do not edit files or run commands."); console.log(result.finalResponse);

    The SDK runs server-side and starts a local Codex thread. Keep this exercise in your own terminal; do not put Codex execution or credentials in a browser page or expose it as an unauthenticated public endpoint.

  5. Step 5: Run the script and inspect what happened

    From the repository directory, run node codex-check.mjs. Read the final response and compare its explanation and check command with the repository’s files. Check the working tree too: the exercise requested no source edits, although installing the SDK changed dependency files.

    If Node cannot find @openai/codex-sdk, confirm that you installed it in this repository and that the script is using that installation. If authentication fails, return to the documented Codex CLI sign-in flow and verify it there before rerunning the script.

    To continue the same SDK conversation, call thread.run again on the same thread object while your script is running. The documented resumeThread method can reopen a past thread when you retain its ID. A new startThread call creates another thread rather than continuing the previous one.

    Illustrated exampleKeep an SDK follow-up on the same thread
    Local repository · server-side Node.jsExample excerpts from one running script
    1. Create one threadconst thread = codex.startThread();

      This creates a new SDK conversation.

    2. Ask the first questionconst result = await thread.run("Explain this repository. Do not edit files or run commands.");

      Read result.finalResponse and verify it against the files.

    3. Continue on the same objectawait thread.run("Which documented check command should I use? Do not run it.");

      The follow-up stays in the conversation above.

    Returning in a later script?

    Retain the thread ID, then reopen it with codex.resumeThread(savedThreadId). Another startThread() creates a different conversation.

    The line connects calls on one local SDK thread object. Slack work runs as a separate Cloud task; it does not automatically become this SDK conversation.
  6. Step 6: Check the answer before requesting changes

    For either route, verify at least one named file and the stated check command against the actual repository. If Codex could not access the code or find a command, the right outcome is a clear limitation, not a guessed answer.

    Only after the explanation is right should you request a focused edit. Specify the expected behavior, preserve unrelated work, and ask for the changed files and actual check results. Review the diff and reproduce the behavior before accepting it.

    Keep Slack follow-ups in the original thread with an explicit mention. Keep SDK follow-ups on the same thread object when they concern the same task. Use a fresh conversation when you need a different repository or environment.

You're done when

  • Your chosen route returns a repository-specific explanation you can check against a real file.
  • For Slack, you can identify the selected shared environment and inspect the returned result or an explicit access limitation.
  • For the SDK, node codex-check.mjs prints a final response, and you have checked for unexpected source edits separately from installation changes.
  • Any later code change has a reviewed diff and recorded check results before it is accepted.

Your prompt

Show promptHide prompt

COPY AND PASTE

@ChatGPT Use Codex Cloud to investigate [repository owner/name] using [published shared environment name].

Question: [one specific behavior or failing check]
Relevant context: [brief summary from this thread, without secrets]
Expected behavior: [what should happen]
Observed behavior: [what happened and how to reproduce it]

Inspect the repository and explain the relevant code with file paths. Identify the existing check command and any missing access. Do not edit, commit, or deploy yet. Return only information suitable for everyone in this channel to read. If no eligible shared environment is available, identify that limitation instead of guessing.

For the Slack route, replace all bracketed fields and send this in an enabled internal channel. For the SDK route, use the local script in steps 4 and 5; its thread.run string is the prompt.

FREE BY EMAIL

Get the full AI guide

Our complete, step-by-step guide to using AI in your business, sent straight to your inbox.

Keep goingMore Codex guidesReturn to Codex for more practical guides and launch notes.

Get every new tool guide in your inbox

When a tool drops a new feature, you get the breakdown: what it is, how it works, and how to use it.

By subscribing, you agree to receive the tool guides newsletter. Unsubscribe anytime.