plan-and-execute
Use when creating implementation plans and executing tasks with proactive dual-model Codex routing (gpt-5.3-codex for code, gpt-5.4 for analysis) and fail-closed behavior before Claude/Sonnet fallback
What this skill does
# Plan and Execute
## Mission
Create bite-sized implementation plans and proactively dispatch execution to the cheapest capable backend.
## Hard Rules
1. Route first. Do not self-implement Codex-eligible tasks before trying Codex.
2. Route repository exploration for code tasks to Codex (read-only) before using Claude-native Explore/Task subagents.
3. Route analysis/reasoning research to Codex (gpt-5.4). Use Claude WebSearch/WebFetch for live web research.
4. Keep architecture and product decisions in Claude.
5. Codex is fail-closed by default. On Codex failure, ask the user for explicit approval before Claude/Sonnet fallback.
6. Verify outputs before handoff.
## 1) Backend Readiness Check
Before execution, check availability:
```bash
command -v codex >/dev/null && echo "codex:ok" || echo "codex:missing"
```
If Codex is missing for code tasks, stop and ask the user whether to proceed on Claude/Sonnet fallback.
## 2) Planning Requirements
- Save plan as `docs/plans/YYYY-MM-DD-feature.md`.
- Keep tasks `2-5 min` each.
- Every task must include:
- objective
- concrete file paths
- command(s)
- routed backend
- done criteria
- Add a routing summary table to the plan.
## 3) Routing Policy
| Work Type | Backend | Model | Invocation |
|---|---|---|---|
| Repository exploration / static codebase analysis | Codex CLI | `gpt-5.3-codex` | `CODEX_MODEL=gpt-5.3-codex ${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh "[prompt]" read-only /path/to/project` |
| Implementation/refactor/tests | Codex CLI | `gpt-5.3-codex` | `CODEX_MODEL=gpt-5.3-codex ${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh "[prompt]" workspace-write /path/to/project` |
| Code review/spec review | Codex CLI | `gpt-5.3-codex` | `CODEX_MODEL=gpt-5.3-codex ${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh "[prompt]" read-only /path/to/project` |
| Logic review / analysis / non-code reasoning | Codex CLI | `gpt-5.4` | `${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh "[prompt]" read-only /path/to/project` |
| Live web / docs / external research | Claude native | — | Use `WebSearch` / `WebFetch` tools; stay on Claude |
| Independent option gathering (compare model outputs) | Codex × 2 in parallel | both | Run two codex-runner.sh invocations concurrently — one with `CODEX_MODEL=gpt-5.3-codex`, one with default `gpt-5.4` |
| Orchestration/synthesis | Claude | — | Stay on Claude |
| Fallback | Sonnet 4.6 | — | `Task(prompt, model:sonnet)` only after explicit user confirmation when Codex fails |
## 4) Prompt Contract for Routed Tasks
For every routed task prompt, include:
1. Goal and acceptance criteria
2. File paths and constraints
3. Required commands/tests
4. Expected output format (patch, summary, citations, etc.)
## 5) Execution Loop
1. Load the plan.
2. Execute in batches of up to 3 independent tasks.
3. For independent option-gathering tasks, run two Codex invocations concurrently (one per model).
4. For all other tasks, dispatch to mapped backend with the correct `CODEX_MODEL` first.
5. Handle exit codes per fallback policy.
6. Review and verify outputs between batches.
7. Continue until all tasks are complete.
## 6) Codex CLI Usage
| Item | Value |
|---|---|
| Model (code tasks) | `gpt-5.3-codex` — set via `CODEX_MODEL=gpt-5.3-codex` |
| Model (logic/analysis/research tasks) | `gpt-5.4` (default) |
| Sandbox modes | `workspace-write`, `read-only` |
| Flags | `--full-auto --skip-git-repo-check` |
Accepted invocation formats:
- Standard: `codex-runner.sh "<prompt>" [sandbox-mode] [working-dir]`
- Legacy-compatible: `codex-runner.sh "<prompt>" <working-dir> [sandbox-mode]`
- Legacy default: if only `<working-dir>` is provided, sandbox defaults to `workspace-write`
```bash
"${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh" \
"$PROMPT" \
workspace-write \
/path/to/project
```
```bash
"${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh" \
"$PROMPT" \
read-only \
/path/to/project
```
```bash
"${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh" \
"$PROMPT" \
/path/to/project
"${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh" \
"$PROMPT" \
/path/to/project \
read-only
```
## 7) Parallel Dual-Model Option Mode
Use this when you want diverse analysis from both Codex models for the same objective. Run two codex-runner.sh invocations concurrently in the background.
```bash
# Run gpt-5.3-codex (code perspective) in background
CODEX_MODEL=gpt-5.3-codex /bin/bash "${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh" \
"$PROMPT" read-only /path/to/project &
CODEX_PID_1=$!
# Run gpt-5.4 (logic/analysis perspective) in background
/bin/bash "${CLAUDE_PLUGIN_ROOT}/skills/plan-and-execute/codex-runner.sh" \
"$PROMPT" read-only /path/to/project &
CODEX_PID_2=$!
wait $CODEX_PID_1; wait $CODEX_PID_2
```
## 9) Fallback and Error Handling
| Exit Code | Action |
|---|---|
| `0` | Success |
| `20` | Fail-closed signal. Ask user for explicit approval before Claude/Sonnet fallback. |
| `10`, `11`, `12`, `13`, `1` | Only if `CODEX_FAIL_CLOSED=0`: allow fallback/report per policy. |
## 10) Environment Defaults
| Variable | Default | Purpose |
|---|---|---|
| `CODEX_MODEL` | `gpt-5.4` | Override per-invocation; use `gpt-5.3-codex` for code tasks |
| `CODEX_MODEL_CODE` | `gpt-5.3-codex` | Reference value for code construction/review tasks |
| `CODEX_MODEL_LOGIC` | `gpt-5.4` | Reference value for logic review/analysis/research tasks |
| `CODEX_EFFORT` | `xhigh` | Reasoning effort |
| `CODEX_TIMEOUT` | `600` | Timeout in seconds |
| `CODEX_FAIL_CLOSED` | `1` | Stop and ask user before Claude fallback on failure |
Telemetry note:
- Router metrics track token offload plus backend attempt/success/failure health.
- Statusline format: `Offload C:<tokens> Σ:<tokens> | S/F C:<s>/<f> | RL C:<remaining>%@<reset-time>`.
## 11) Anti-Patterns
- Creating a plan without a backend route per task
- Using Claude-native `Explore`/`Task` subagents for Codex-eligible work before attempting routed runners
- Implementing code directly in Claude when Codex is available
- Using Claude for logic/analysis tasks when Codex (gpt-5.4) is available
- Skipping parallel dual-model invocation for independent option-gathering tasks
- Skipping verification between batches
- Falling back without first attempting the mapped backend
- Proceeding on Claude/Sonnet after Codex failure without explicit user approval
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.