When a bug survives an initial pass, a separate coding agent can investigate it with fresh context. In Claude Code, the Codex plugin can delegate a bounded fix and apply the changes to the same working tree.

A rescue request allows file edits unless it explicitly asks for read-only investigation. Naming the affected files, the failing test, and what must remain unchanged gives Codex a concrete boundary for the repair.

Background jobs belong to the Claude Code session that started them. The prompt returns while Codex works, but ending that session stops unfinished jobs, so the session must stay open until the result has been retrieved.

The Codex plugin must already be installed, with Claude Code and Codex signed in. The regression test below uses Python's built-in unittest runner; another project needs its own failing test command.
Related: How to install the Codex plugin in Claude Code

Steps to delegate a task to Codex in Claude Code:

  1. Run the failing test in the repository that Codex will change.
    $ python3 -m unittest -v
    test_quantity (test_pricing.PriceTests.test_quantity) ... FAIL
    
    ##### snipped #####
    AssertionError: 7 != 12
    
    ##### snipped #####
    FAILED (failures=1)

    Here, total_price(4, 3) should return 12, but pricing.py adds the two arguments and returns 7. The existing test_pricing.py records the expected behavior.

  2. Submit a bounded fix request with /codex:rescue --background in Claude Code.

    Codex can edit files in this checkout and run project commands. Repository code can reach the configured Codex provider. A backed-up working tree or disposable branch provides a recovery point before delegation. Concurrent edits to the same files can conflict with its patch.

    /codex:rescue --background --fresh --effort low Fix the failing test in this repository. Run python3 -m unittest -v, correct total_price in pricing.py, and rerun the tests. Do not change test_pricing.py or commit anything.

    --background returns the Claude prompt while the job runs. --fresh starts a new Codex thread, and --effort low selects low reasoning effort for this small fix. Without --fresh or --resume, a later rescue request can offer to continue the earlier thread. --resume chooses continuation explicitly. In Claude Code 2.1.318 with default fork mode, a rescue request without an execution flag still showed Backgrounded agent; --wait did the same. Anthropic documents that fork mode prevents foreground waiting in interactive sessions.

  3. Check the delegated job while Codex is running.
    /codex:status

    The output identifies the job, its running status, phase, elapsed time, and Codex session ID. The Claude forwarding subagent can finish before the Codex job does. Without a job ID, status is scoped to the current Claude session; an explicit job ID selects one job.

  4. Check that the job has reached completed before reading its result.
    /codex:status

    A completed job shows its duration and a summary. A failed or cancelled job does not establish that the fix was applied; its stored result can explain what stopped it.

  5. Retrieve the stored Codex response in the same Claude Code session.
    /codex:result
    Job ID: task-mw2vloj9-i0w3g9
    Status: completed
    
    Fixed total_price in pricing.py (/home/node/delegate-demo/pricing.py:2) to multiply price by quantity.
    
    python3 -m unittest -v now passes (1 test). test_pricing.py is unchanged, and nothing was committed.
    
    Codex session ID: [session-id]
    Resume in Codex: codex resume [session-id]

    The job ID and session ID vary between runs. The session identifier above is redacted. Without a job ID, /codex:result retrieves the latest job in the current session; /codex:result task-mw2vloj9-i0w3g9 selects the shown job explicitly.

  6. Inspect the patch that Codex left in the working tree.
    $ git diff -- pricing.py test_pricing.py
    diff --git a/pricing.py b/pricing.py
    index f8e4978..8e9ca7f 100644
    --- a/pricing.py
    +++ b/pricing.py
    @@ -1,2 +1,2 @@
     def total_price(price, quantity):
    -    return price + quantity
    +    return price * quantity

    The diff changes the calculation and leaves the regression test unchanged. A job's completion message alone does not establish that its changes match the request.

  7. Rerun the original failing test against the changed code.
    $ python3 -m unittest -v
    test_quantity (test_pricing.PriceTests.test_quantity) ... ok
    
    ----------------------------------------------------------------------
    Ran 1 test in 0.000s
    
    OK

    The same test now passes with the multiplication fix in place.

Share this guide