From bbd2f50c3849e205cd891b18f28afacc47dcee61 Mon Sep 17 00:00:00 2001 From: cexll Date: Wed, 19 Nov 2025 23:57:52 +0800 Subject: [PATCH] update codex skills model config --- skills/codex/SKILL.md | 30 ++++++++++++------------------ skills/codex/scripts/codex.py | 14 +++++++------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/skills/codex/SKILL.md b/skills/codex/SKILL.md index d2f5af7..191e0cc 100644 --- a/skills/codex/SKILL.md +++ b/skills/codex/SKILL.md @@ -14,33 +14,29 @@ Execute Codex CLI commands and parse structured JSON responses. Supports file re - Complex code analysis requiring deep understanding - Large-scale refactoring across multiple files - Automated code generation with safety controls -- Tasks requiring specialized reasoning models (gpt-5.1, gpt-5.1-codex) ## Usage **Mandatory**: Run every automated invocation through the Bash tool in the foreground with the command below, keeping the `timeout` parameter fixed at `7200000` milliseconds (do not change it or use any other entry point). ```bash -uv run ~/.claude/skills/codex/scripts/codex.py "" [model] [working_dir] +uv run ~/.claude/skills/codex/scripts/codex.py "" [working_dir] ``` **Foreground only (no background/BashOutput)**: Never set `background: true`, never accept Claude's “Running in the background” mode, and avoid `BashOutput` streaming loops. Keep a single foreground Bash call per Codex task; if work might be long, split it into smaller foreground runs instead of offloading to background execution. **Optional methods** (direct execution or via Python): ```bash -~/.claude/skills/codex/scripts/codex.py "" [model] [working_dir] +~/.claude/skills/codex/scripts/codex.py "" [working_dir] # or -python3 ~/.claude/skills/codex/scripts/codex.py "" [model] [working_dir] +python3 ~/.claude/skills/codex/scripts/codex.py "" [working_dir] ``` Resume a session: ```bash -uv run ~/.claude/skills/codex/scripts/codex.py resume "" [model] [working_dir] +uv run ~/.claude/skills/codex/scripts/codex.py resume "" [working_dir] ``` ## Environment Variables - -- **CODEX_MODEL**: Override default model (default: `gpt-5.1-codex`) - - Example: `export CODEX_MODEL=gpt-5-codex` - **CODEX_TIMEOUT**: Override timeout in milliseconds (default: 7200000 = 2 hours) - Example: `export CODEX_TIMEOUT=3600000` for 1 hour @@ -55,9 +51,6 @@ uv run ~/.claude/skills/codex/scripts/codex.py resume "" [mod ### Parameters - `task` (required): Task description, supports `@file` references -- `model` (optional): Model to use (default: gpt-5.1-codex) - - `gpt-5.1-codex`: Default, optimized for code - - `gpt-5.1`: Fast general purpose - `working_dir` (optional): Working directory (default: current) ### Return Format @@ -82,7 +75,7 @@ Return only the final agent message and session ID—do not paste raw `BashOutpu All automated executions may only invoke `uv run ~/.claude/skills/codex/scripts/codex.py "" ...` through the Bash tool in the foreground, and the `timeout` must remain fixed at `7200000` (non-negotiable): ``` Bash tool parameters: -- command: uv run ~/.claude/skills/codex/scripts/codex.py "" [model] [working_dir] +- command: uv run ~/.claude/skills/codex/scripts/codex.py "" [working_dir] - timeout: 7200000 - description: ``` @@ -91,10 +84,10 @@ Run every call in the foreground—never append `&` to background it—so logs a Alternatives: ``` # Direct execution (simplest) -- command: ~/.claude/skills/codex/scripts/codex.py "" [model] [working_dir] +- command: ~/.claude/skills/codex/scripts/codex.py "" [working_dir] # Using python3 -- command: python3 ~/.claude/skills/codex/scripts/codex.py "" [model] [working_dir] +- command: python3 ~/.claude/skills/codex/scripts/codex.py "" [working_dir] ``` ### Examples @@ -109,22 +102,23 @@ uv run ~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts" ~/.claude/skills/codex/scripts/codex.py "explain @src/main.ts" ``` -**Refactoring with specific model:** +**Refactoring with custom model (via environment variable):** ```bash -uv run ~/.claude/skills/codex/scripts/codex.py "refactor @src/utils for performance" "gpt-5.1-codex" +# Set model via environment variable +uv run ~/.claude/skills/codex/scripts/codex.py "refactor @src/utils for performance" # timeout: 7200000 ``` **Multi-file analysis:** ```bash -uv run ~/.claude/skills/codex/scripts/codex.py "analyze @. and find security issues" "gpt-5.1-codex" "/path/to/project" +uv run ~/.claude/skills/codex/scripts/codex.py "analyze @. and find security issues" "/path/to/project" # timeout: 7200000 ``` **Resume previous session:** ```bash # First session -uv run ~/.claude/skills/codex/scripts/codex.py "add comments to @utils.js" "gpt-5.1-codex" +uv run ~/.claude/skills/codex/scripts/codex.py "add comments to @utils.js" # Output includes: SESSION_ID: 019a7247-ac9d-71f3-89e2-a823dbd8fd14 # Continue the conversation diff --git a/skills/codex/scripts/codex.py b/skills/codex/scripts/codex.py index b09ccb9..e38d1a8 100755 --- a/skills/codex/scripts/codex.py +++ b/skills/codex/scripts/codex.py @@ -8,10 +8,12 @@ Codex CLI wrapper with cross-platform support and session management. **FIXED**: Auto-detect long inputs and use stdin mode to avoid shell argument issues. Usage: - New session: uv run codex.py "task" [model] [workdir] - Resume: uv run codex.py resume "task" [model] [workdir] + New session: uv run codex.py "task" [workdir] + Resume: uv run codex.py resume "task" [workdir] Alternative: python3 codex.py "task" Direct exec: ./codex.py "task" + + Model configuration: Set CODEX_MODEL environment variable (default: gpt-5.1-codex) """ import subprocess import json @@ -82,15 +84,13 @@ def parse_args(): 'mode': 'resume', 'session_id': sys.argv[2], 'task': sys.argv[3], - 'model': sys.argv[4] if len(sys.argv) > 4 else DEFAULT_MODEL, - 'workdir': sys.argv[5] if len(sys.argv) > 5 else DEFAULT_WORKDIR + 'workdir': sys.argv[4] if len(sys.argv) > 4 else DEFAULT_WORKDIR } else: return { 'mode': 'new', 'task': sys.argv[1], - 'model': sys.argv[2] if len(sys.argv) > 2 else DEFAULT_MODEL, - 'workdir': sys.argv[3] if len(sys.argv) > 3 else DEFAULT_WORKDIR + 'workdir': sys.argv[2] if len(sys.argv) > 2 else DEFAULT_WORKDIR } @@ -146,7 +146,7 @@ def build_codex_args(params: dict, target_arg: str) -> list: else: base_args = [ 'codex', 'e', - '-m', params['model'], + '-m', DEFAULT_MODEL, '--dangerously-bypass-approvals-and-sandbox', '--skip-git-repo-check', '-C', params['workdir'],