Internal helper contract for calling the codex-companion runtime from the codex-rescue subagent. Not user-invocable.
# === RKstack Preamble (codex-cli-runtime) ===
# Read detection cache (written by session-start via rkstack detect)
if [ -f .rkstack/settings.json ]; then
cat .rkstack/settings.json
else
echo "WARNING: .rkstack/settings.json not found — detection cache missing"
fi
# Session-volatile checks (can change mid-session)
_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
_HAS_CLAUDE_MD=$([ -f CLAUDE.md ] && echo "yes" || echo "no")
echo "BRANCH: $_BRANCH"
echo "CLAUDE_MD: $_HAS_CLAUDE_MD"
Use the detection cache and preamble output to adapt your behavior:
detection.flowType (web or default). If web: check React/Vue/Svelte patterns, responsive design, component architecture. If default: CLI tools, MCP servers, backend scripts.just commands instead of raw shell.detection.stack for what's in the project and detection.stats for scale (files, code, complexity).detection.repoMode for solo vs collaborative.detection.services for Supabase and other service integrations.ALWAYS follow this structure for every AskUserQuestion call:
_BRANCH value from preamble — NOT any branch from conversation history or gitStatus), and the current plan/task. (1-2 sentences)RECOMMENDATION: Choose [X] because [one-line reason] — always prefer the complete option over shortcuts (see Completeness Principle). Include Completeness: X/10 for each option. Calibration: 10 = complete implementation (all edge cases, full coverage), 7 = covers happy path but skips some edges, 3 = shortcut that defers significant work.A) ... B) ... C) ... — when an option involves effort, show both scales: (human: ~X / CC: ~Y)Assume the user hasn't looked at this window in 20 minutes and doesn't have the code open. If you'd need to read the source to understand your own explanation, it's too complex.
AI makes completeness near-free. Always recommend the complete option over shortcuts — the delta is minutes with AI. A "lake" (100% coverage, all edge cases) is boilable; an "ocean" (full rewrite, multi-quarter migration) is not. Boil lakes, flag oceans.
Effort reference — always show both scales:
| Task type | Human team | CC + AI | Compression |
|---|---|---|---|
| Boilerplate | 2 days | 15 min | ~100x |
| Tests | 1 day | 15 min | ~50x |
| Feature | 1 week | 30 min | ~30x |
| Bug fix | 4 hours | 15 min | ~20x |
Include Completeness: X/10 for each option (10=all edge cases, 7=happy path, 3=shortcut).
REPO_MODE (from preamble) controls how to handle issues outside your branch:
solo — You own everything. Investigate and offer to fix proactively.collaborative / unknown — Flag via AskUserQuestion, don't fix (may be someone else's).Always flag anything that looks wrong — one sentence, what you noticed and its impact.
Before building anything unfamiliar, search first.
When first-principles reasoning contradicts conventional wisdom, name the insight explicitly.
When completing a skill workflow, report status using one of:
It is always OK to stop and say "this is too hard for me" or "I'm not confident in this result."
Bad work is worse than no work. You will not be penalized for escalating.
Escalation format:
STATUS: BLOCKED | NEEDS_CONTEXT
REASON: [1-2 sentences]
ATTEMPTED: [what you tried]
RECOMMENDATION: [what the user should do next]
Use this skill only inside the codex-rescue subagent.
node "${CLAUDE_PLUGIN_ROOT}/scripts/codex/codex-companion.mjs" task "<raw arguments>"
task once and return that stdout unchanged.git, direct codex CLI strings, or
any other Bash activity.setup, review, adversarial-review, status, result,
or cancel from codex-rescue.task for every rescue request, including diagnosis, planning,
research, and explicit fix requests.gpt-5-4-prompting skill to rewrite the user's request
into a tighter Codex prompt before the single task call.--effort unset unless the user explicitly requests a specific effort.--model only when the user explicitly
asks for one.spark to --model gpt-5.3-codex-spark.--write unless the user
explicitly asks for read-only behavior or only wants review, diagnosis,
or research without edits.task invocation per rescue handoff.--background or --wait, treat that as
Claude-side execution control only. Strip it before calling task, and do
not treat it as part of the natural-language task text.--model, normalize spark to
gpt-5.3-codex-spark and pass it through to task.--effort, pass it through to task.--resume, strip that token from the
task text and add --resume-last.--fresh, strip that token from the
task text and do not add --resume-last.--resume: always use task --resume-last, even if the request text is
ambiguous.--fresh: always use a fresh task run, even if the request sounds like
a follow-up.--effort: accepted values are none, minimal, low, medium, high,
xhigh.task --resume-last: internal helper for "keep going", "resume", "apply
the top fix", or "dig deeper" after a previous rescue run.codex-rescue unless the user
explicitly asks for read-only behavior.task command exactly as-is.