The integration has contract and HTTP service-chain coverage. No formal minimum Codex version is declared, and a full real Codex host-process E2E is Not validated.
Maturity and installation
A complete Codex installation needs all three plugin parts:- the
UserPromptSubmitHook for automatic recall, prompt capture, and optional flush; - the HTTP MCP Server for explicit operations;
- the bundled
project-contextSkill for Scope, Handoff, and write-intent rules.
Minimal usage
Open a new Codex session. Inspect/hooks for UserPromptSubmit and /mcp for the PowerContext Server. Then try the three paths:
- Ask a normal repository question. The Hook may inject recalled context and captures only that prompt as a Source.
- Ask Codex to search or maintain Memory. The bundled Skill directs it to the MCP tools.
- Say
handoff this workwhen you want Codex to prepare and commit one durable Handoff in the same turn.
Execution flow
Scope and Workstream binding
The Scope resolver checks, in order:POWERCONTEXT_CODEX_SCOPE_ID, when set;- a Git-private Workstream binding;
- normalized Git remote identity, then normalized project path.
latest Continue with no exact Workstream, the Skill calls select_handoff_workstream when available. Multiple candidates require user selection. Codex binds the returned scope_id, resolves again, and requires an exact match before a Handoff write. The picker itself is read-only.
Injection and API-base derivation
The Hook reads thepowercontext HTTP MCP URL from the installed plugin’s .mcp.json, requires a safe unambiguous /mcp URL, and derives the HTTP API base by removing that path. This keeps automatic HTTP calls and MCP on one endpoint. There is no independent Hook URL that may drift away from MCP configuration.
Prepared context is schema-checked and size-bounded before it reaches Hook stdout as additionalContext. An empty result yields no content. Unknown schema, redirect, oversized response, authentication failure, Server error, or wall-clock deadline all fail open with content-free diagnostics. Authorization is never forwarded across a redirect.
Capture and flush
Automatic capture writes only the current prompt to/v1/sources/content with a deterministic codex-user-prompt: Source ID and provenance. It does not capture the assistant final response or create a Task Outcome.
Expected recall failures are isolated so capture can still run. An unexpected recall exception can reach the outer fail-open handler and skip capture for that invocation, so do not claim unconditional independence. Disable capture with POWERCONTEXT_CODEX_CAPTURE_PROMPTS=false. Enable optional flush with POWERCONTEXT_CODEX_FLUSH_ON_CAPTURE=true; POWERCONTEXT_CODEX_FLUSH_MAX_CALLS bounds attempts. The Hook clears the wait only after current_cursor >= position. If the cursor never catches up, the turn continues without claiming that Memory was generated.
A captured prompt is Source evidence. Prompts longer than 200,000 characters are skipped. Codex capture does not apply DSH’s narrow secret-marker filter, so disable it when prompts must not be persisted. Scheduler/flush processing may produce a Candidate, and Review may commit Memory or choose a no-op.
MCP, Skill, Handoff, and permission
MCP exposes explicit Memory maintenance, Work Contract, Handoff, acknowledgement, Outcome, and Review operations.POWERCONTEXT_CODEX_AUTHORIZATION may supply the complete Authorization value through .mcp.json env_http_headers; it is optional for a public local Server. Use HTTPS for remote endpoints.
The Skill gives handoff this work one-turn semantics. Codex inspects the current conversation and repository, calls handoff_current_work once with a unique source_id, passes the returned handoff unchanged to commit_handoff in the same turn, and reports success only after an exact Revision returns. It does not ask for a second confirmation when the imperative already authorizes the Handoff.
That rule has a sharp preview boundary. A Handoff question, design discussion, draft request, or preview and make no writes request authorizes no write. Codex renders the proposed fields in chat and must not call handoff_current_work, because preparation itself records a boundary Source. A Prepared Handoff can remain uncommitted, but it is not a zero-write preview.
Explicit durable mutations must report failure. MCP tool annotations describe read/write, destructive, and idempotent intent, but visibility is not an authorization boundary. Host permission UI and enforcement remain Host-gated and Not validated; do not borrow a stronger no-UI guarantee from another adapter.
Unsupported vs Not validated
Managed Skill export supports Codex, but an exported managed Skill and the bundled plugin Skill are different objects. Installing one does not substitute for the other.
Negative experiments
- Stop the Server and submit a normal prompt. Codex should continue; an explicit write should report failure.
- Trigger an expected recall failure and confirm capture still runs. Inject an unexpected recall exception separately and confirm the whole Hook still fails open; capture may be skipped for that invocation.
- Change the MCP URL to an unsafe, ambiguous, or non-
/mcpvalue. Settings should reject it rather than guessing an API base. - Redirect a Hook request. Authorization must not reach the target.
- Return an unknown schema or oversized response. Nothing should be injected.
- Let flush exhaust its attempt/deadline budget while the cursor stays behind. The turn should continue without a false Memory claim.
- Let Handoff preparation succeed and commit fail. Report the boundary Source and absence of a durable milestone; do not create a second boundary merely to retry.
- Request
preview and make no writes. Confirm no PowerContext call writes a Source or Handoff. - Revise or retire Memory with an old Citation. Expect conflict, refresh the head, and do not overwrite blindly.
Configuration defaults
The hook derives its API base from plugin.mcp.json, which defaults to http://127.0.0.1:8000/mcp. Other behavior comes from POWERCONTEXT_CODEX_ environment variables:
Plugin
.mcp.json needs at least these fields. Put the environment variable name in the file, not the token:
/hookslists the PowerContextUserPromptSubmithook. Trust it only when prompted./mcpshows a Server namedpowercontext. It should be connected when the Server is running.- The
/mcptool list includesremember_memoryand does not includeprepare_context.
POWERCONTEXT_CODEX_SERVER_URL is ignored. server_url comes only from plugin .mcp.json. Do not put the token in .mcp.json, the Server URL, or a static MCP header. Disable capture when the current work must not become Source evidence:
Finish the shared check on this host
What should happen after the OpenAPI contract changes?
- Store the answer in a stable Scope with MCP
remember_memory. Do not rely on automatic capture alone. - Open a new Codex session, confirm
/mcpstill sees the Server, and ask the same question. - The recall must include a Citation and appear only in
UserPromptSubmitadditionalContext. - Stop the Server and ask an ordinary coding question. The hook may fail open. Coding should continue.
- Call MCP
remember_memoryagain. The failure must stay visible. Do not pretend the write succeeded.
Completion checklist
Treat the integration as complete only when these results are observable:powercontext doctor codexfinds the installed, enabled plugin.- Separate
powercontext doctorchecks Server liveness/readiness. /hooksshowsUserPromptSubmit./mcpshows the PowerContext Server.- The bundled
project-contextSkill is present alongside Hook and MCP. - The Hook derives the API base from the same
.mcp.jsonURL used by MCP. - Codex and Claude Code resolve one repository/Workstream Scope.
- Automatic Source contains the user prompt only, never the assistant final response.
- Prompts that must remain private have capture disabled.
- Optional flush is bounded and proves
current_cursor >= positionbefore success. preview and make no writesproduces no write.- An imperative Handoff completes in one turn and returns an exact committed Revision.
- Explicit write failure remains visible while automatic recall/capture failures remain fail-open.
- Unsupported, Not validated, and Host-gated claims above remain separate, including real-host Handoff, preview, and permission validation.

