.claude/skills/codex-implement/SKILL.md
Delegate code implementation to Codex CLI. Claude decomposes, scopes context, and verifies; Codex implements. Accepts a spec file, text description, or gathers requirements interactively.
npx skillsauth add benjaminshoemaker/ai_coding_project_base codex-implementInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Delegate bounded implementation tasks to OpenAI Codex CLI. Claude acts as Architect (decomposes, selects context, verifies); Codex acts as Editor (implements each bounded task).
--consult — Run /codex-consult on the implementation plan before executing--no-commit — Skip commits after each task (leave changes unstaged)--dry-run — Show Implementation Brief + task decomposition without executing--model MODEL — Override Codex model for this invocation--batch — Non-interactive mode for automated pipelines (skip user confirmations). Used by /phase-start --codex to drive tasks without pausing for approvalCopy this checklist and track progress:
Implementation Progress:
- [ ] Phase 1: Pre-flight checks
- [ ] Phase 2: Gather input
- [ ] Phase 3: Analyze and decompose
- [ ] Phase 4: Optional consultation (if --consult)
- [ ] Phase 5: Execute tasks
- [ ] Phase 6: Summary
# Already inside Codex?
if [ -n "$CODEX_SANDBOX" ]; then
echo "Already running inside Codex. Skipping."
exit 0
fi
# Codex CLI installed?
codex --version
# Authenticated?
codex login status
If Codex CLI is not available or not authenticated, report the error and STOP:
ERROR: Codex CLI required
==========================
Install: npm install -g @openai/codex
Auth: codex login
Read .claude/settings.local.json:
CODEX_MODEL=$(jq -r '.codexImplement.model // .codexReview.codeModel // empty' .claude/settings.local.json 2>/dev/null)
CODEX_EFFORT=$(jq -r '.codexImplement.effort // .codexReview.effort // empty' .claude/settings.local.json 2>/dev/null)
TIMEOUT_MINS=$(jq -r '.codexImplement.timeoutMinutes // .codexReview.taskTimeoutMinutes // 60' .claude/settings.local.json 2>/dev/null || echo "60")
MAX_TASKS=$(jq -r '.codexImplement.maxTasks // 5' .claude/settings.local.json 2>/dev/null || echo "5")
ENABLED=$(jq -r '.codexImplement.enabled // true' .claude/settings.local.json 2>/dev/null || echo "true")
If --model flag provided, override CODEX_MODEL.
If enabled is false, report and STOP.
Extract from argument string:
--consult → CONSULT=true--no-commit → NO_COMMIT=true--dry-run → DRY_RUN=true--batch → BATCH=true--model VALUE → override CODEX_MODELINPUT (file path or description)Determine input mode from INPUT:
If INPUT is a file path that exists:
BATCH is false: Present summary to user via AskUserQuestion: "This is what I'll have Codex implement. Correct?"If INPUT is quoted text (not a file path):
BATCH is false: Present brief to user via AskUserQuestion for confirmationIf BATCH is true and no INPUT provided: STOP with error — batch mode requires a spec file or description.
If no INPUT provided (and BATCH is false):
All modes produce this internal structure:
IMPLEMENTATION BRIEF
====================
Description: {what to build}
Affected files: {list of files Codex should read/modify}
Success criteria:
1. {testable criterion}
2. {testable criterion}
Constraints:
- {from AGENTS.md}
- {from codebase conventions}
See DECOMPOSITION.md for the full decision tree.
Claude reads the Implementation Brief and decides single vs. multi-task:
Single task if ALL of:
Multiple tasks if ANY of:
MAX_TASKS (default 5)/feature-spec → /feature-plan workflow,
but allow override if user confirmsPresent the task list to the user:
IMPLEMENTATION PLAN
===================
Tasks: {N}
1. {task description} — touches {files}
2. {task description} — touches {files}
...
Estimated Codex time: ~{N * timeout/4} minutes (worst case: {N * timeout} minutes)
If BATCH is false, ask: "Ready to execute?" with options:
If BATCH is true, proceed directly to execution.
If --dry-run: display the Implementation Brief and task list, then STOP.
If --consult flag is set:
/codex-consult on the temp fileBATCH is false: Ask: "Incorporate suggestions?" → refine brief if yesBATCH is true: Auto-incorporate non-breaking suggestions, skip interactive refinementApply this pattern before and after every Codex invocation to prevent accidental commits from persisting:
# Before invocation — fail fast on dirty worktree, record HEAD
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: Worktree has uncommitted changes. Commit or stash before running Codex."
fi
HEAD_BEFORE=$(git rev-parse HEAD)
# ... invoke Codex ...
# After invocation — revert any commits Codex made
HEAD_AFTER=$(git rev-parse HEAD)
if [ "$HEAD_BEFORE" != "$HEAD_AFTER" ]; then
echo "WARNING: Codex made commits. Reverting."
git reset --soft "$HEAD_BEFORE"
git restore --staged .
fi
For each task (sequentially):
Apply the safety guard pattern (pre-invocation half) defined above.
See PROMPT_TEMPLATE.md for the full template.
Write prompt to temp file. Include:
# Build model flag
MODEL_FLAG=""
if [ -n "$CODEX_MODEL" ]; then
MODEL_FLAG="--model $CODEX_MODEL"
fi
# Build effort flag
EFFORT_ARGS=()
if [ -n "$CODEX_EFFORT" ]; then
EFFORT_ARGS=(-c "model_reasoning_effort=\"$CODEX_EFFORT\"")
fi
PROMPT_FILE="/tmp/codex-impl-task-${TASK_NUM}.md"
OUTPUT_FILE="/tmp/codex-impl-task-${TASK_NUM}-output.txt"
cat $PROMPT_FILE | codex exec \
--sandbox danger-full-access \
-c 'approval_policy="never"' \
-c 'features.search=true' \
$MODEL_FLAG \
"${EFFORT_ARGS[@]}" \
-o $OUTPUT_FILE \
-
EXIT_CODE=$?
Use Bash tool timeout parameter: TIMEOUT_MINS * 60 * 1000 milliseconds.
MANDATORY rules:
run_in_background2>&1 (corrupts output parsing)timeoutApply the safety guard pattern (post-invocation half) defined above.
if [ $EXIT_CODE -eq 124 ]; then
STATUS="FAILED"; ISSUE="Timeout after ${TIMEOUT_MINS} minutes"
elif [ $EXIT_CODE -ne 0 ]; then
STATUS="FAILED"; ISSUE="Codex exited with code $EXIT_CODE"
elif [ ! -f "$OUTPUT_FILE" ]; then
STATUS="FAILED"; ISSUE="No output file produced"
else
STATUS=$(grep "^Status:" "$OUTPUT_FILE" | head -1 | awk '{print $2}')
if [ -z "$STATUS" ]; then
STATUS=$(grep "Status:" "$OUTPUT_FILE" | head -1 | awk '{print $2}')
fi
if [ -z "$STATUS" ]; then
STATUS="FAILED"; ISSUE="Could not parse task result"
fi
fi
See VERIFICATION.md for the full verification strategy.
4-tier verification:
git diff --name-only — did Codex only touch expected files?git diff, compare against success criteria--consult): Run /codex-review on the changesOn success (unless --no-commit):
git add {specific files}impl: {task description} [codex-implement]On failure:
BATCH is true: report failure status and return immediately (let the caller handle retry/skip/abort decisions)BATCH is false: Ask user via AskUserQuestion:
rm -f $PROMPT_FILE $OUTPUT_FILE
When BATCH is true, output this structured result block as the final output so callers can parse status:
CODEX_IMPLEMENT_RESULT
======================
Status: COMPLETE | PARTIAL | FAILED
Tasks: {completed}/{total}
Files changed: {list of changed file paths}
Issue: {description, only if PARTIAL or FAILED}
COMPLETE — all tasks succeeded and passed verificationPARTIAL — some tasks succeeded, others failed/skippedFAILED — no tasks succeeded or critical pre-flight failureWhen BATCH is false, show the full summary:
IMPLEMENTATION COMPLETE
=======================
Tasks: {completed}/{total}
Files created: {count}
Files modified: {count}
Commits: {count}
Changes:
{commit message 1}
{commit message 2}
...
Next steps:
- Run full test suite: {test command}
- Review changes: git diff HEAD~{N}
If any tasks failed or were skipped, include them in the summary with recommendations.
| Situation | Action |
|-----------|--------|
| Codex CLI not installed | Report, suggest install command, STOP |
| Codex not authenticated | Report, suggest codex login, STOP |
| Codex times out | Show partial output if available, ask user |
| Output unparseable | Show raw output, ask user to review |
| Scope violation | Warn, ask user to accept or revert |
| 2 consecutive failures | Recommend manual implementation |
| Exceeds maxTasks | Warn, suggest full workflow, allow override |
| --dry-run | Show brief + tasks, STOP before execution |
Add to .claude/settings.local.json:
{
"codexImplement": {
"enabled": true,
"model": "gpt-5.3-codex",
"effort": "xhigh",
"timeoutMinutes": 60,
"maxTasks": 5
}
}
Fallback chain: codexImplement → codexReview → defaults.
These rules are mandatory for every codex exec invocation:
run_in_background — always execute synchronously2>&1 — corrupts output parsing (Codex streams progress to stderr)timeout parameter — not shell timeout commandtesting
Audit project alignment with VISION.md, identify SDLC gaps, and generate feature proposals. Use when reviewing strategic direction or planning new features.
development
Run code-verification on a specific task. Use to verify a single task's acceptance criteria after implementation.
testing
Resolve Vercel preview deployment URL for the current git branch. Invoked by browser-verification when deployment.enabled is true, or directly to check deployment status. Use to check deployment status or when browser verification needs a URL.
tools
Discover and sync all toolkit-using projects with the latest skills. Use when skills are modified, after the post-commit hook reminds you, or to batch-sync multiple projects.