Agent Skills › daymade/claude-code-skills › codex-1m-context-window-setup

codex-1m-context-window-setup

GitHub

配置和验证 OpenAI Codex CLI/Desktop 的上下文窗口,解决自动压缩触发频繁或限制异常问题。通过 doctor/apply/verify 流程动态调整模型上下文与压缩阈值,确保设置符合模型声明的最大值及用户策略。

daymade-codex/codex-1m-context-window-setup/SKILL.md daymade/claude-code-skills

Trigger Scenarios

Codex 显示约 258K 上下文,需要扩展到 500K 或 1M 自动压缩触发过于频繁 需要修复 model_context_window 或 model_auto_compact_token_limit 配置

Install

npx skills add daymade/claude-code-skills --skill codex-1m-context-window-setup -g -y
More Options

Non-standard path

npx skills add https://github.com/daymade/claude-code-skills/tree/main/daymade-codex/codex-1m-context-window-setup -g -y

Use without installing

npx skills use daymade/claude-code-skills@codex-1m-context-window-setup

指定 Agent (Claude Code)

npx skills add daymade/claude-code-skills --skill codex-1m-context-window-setup -a claude-code -g -y

安装 repo 全部 skill

npx skills add daymade/claude-code-skills --all -g -y

预览 repo 内 skill

npx skills add daymade/claude-code-skills --list

SKILL.md

Frontmatter
{
    "name": "codex-1m-context-window-setup",
    "description": "Configures and verifies an expanded, model-aware context window for OpenAI Codex CLI and Desktop. Use when Codex shows ~258K context, you want 500K or 1M tokens, auto-compaction fires too often, or model_context_window\/model_auto_compact_token_limit needs repair. Not for changing the selected model or other Codex settings.",
    "argument-hint": "[doctor|apply|verify]"
}

Codex 1m Context Window Setup

Expand future Codex sessions without pretending every model supports one million tokens. The bundled script reads Codex's current model catalog, caps the request at the selected model's declared maximum, and applies the user's established 60% auto-compaction policy.

Route the request

User intent Action
Inspect the current limit, explain 258K, or preview the recommendation Run doctor
Configure/fix/raise the context window Run apply
Confirm a prior setup is still correct after an update or model switch Run verify

Do not ask the user for raw token numbers. The model catalog is the authority and the script derives the attainable values.

Run the workflow

When this Skill loads, the host exposes its installed path. Resolve it explicitly:

  • In Codex, take the directory containing SKILL.md from this Skill's file: entry in the current Available skills catalog.
  • In Claude Code, use the Base directory for this skill shown by the Skill load result.

Do not search a home directory for another copy. If the host did not expose an installed path, stop with installed Skill path not exposed rather than guessing.

On macOS/Linux, set that exact directory and run:

SKILL_DIR="/absolute/path/from-the-loaded-skill-metadata"
uv run --no-project python "$SKILL_DIR/scripts/codex_context_window.py" doctor
uv run --no-project python "$SKILL_DIR/scripts/codex_context_window.py" apply
uv run --no-project python "$SKILL_DIR/scripts/codex_context_window.py" verify

On Windows PowerShell, use the same exposed directory with forward slashes:

$SkillDir = "C:/absolute/path/from-the-loaded-skill-metadata"
uv run --no-project python "$SkillDir/scripts/codex_context_window.py" doctor
uv run --no-project python "$SkillDir/scripts/codex_context_window.py" apply
uv run --no-project python "$SkillDir/scripts/codex_context_window.py" verify

doctor

Run first. It is read-only and reports:

  • selected model resolved by Codex;
  • catalog default, model maximum, and usable percentage;
  • requested raw window (up to 1,000,000), usable window, and 60% compaction point;
  • current base-config values and whether apply is needed;
  • exact $CODEX_HOME/config.toml target.

If Codex cannot return a live model catalog, stop. Do not substitute remembered model limits, API marketing numbers, or a bundled default.

apply

Run only after doctor succeeds. The script:

  1. Re-reads the live model contract.
  2. Changes only the top-level model_context_window and model_auto_compact_token_limit keys.
  3. Creates a content-addressed backup only when bytes will change.
  4. Uses an atomic same-directory replace and refuses to overwrite a concurrently changed config.
  5. Runs Codex strict-config diagnostics; a failure restores the exact prior bytes.
  6. Reads the written file back and reports the values that future sessions will use.

Existing sessions do not grow in place. After success, tell the user to start a new CLI thread or restart/open a new Codex Desktop thread.

verify

Run after Codex upgrades, default-model changes, or on a newly configured machine. It exits non-zero when the current base config no longer equals the model-aware recommendation. Report the mismatch; do not call it configured.

Report the outcome

Copy exact values from script output. Include:

  • model slug;
  • configured raw window;
  • usable window shown to the session;
  • automatic compaction threshold;
  • whether the model capped the 1M request;
  • config and backup paths;
  • restart_required: true after a changed apply.

Refuse scope expansion

This Skill does not:

  • change the selected model, reasoning effort, service tier, sandbox, approvals, plugins, MCP servers, browser/computer-use settings, or shell aliases;
  • edit profile-specific config files or override per-command -c flags;
  • claim the current running thread was expanded;
  • force 1M when the selected model declares a smaller maximum;
  • fall back to stale or guessed model metadata.

Read references/context_window_contract.md when diagnosing model caps, the 95% usable-window display, or compaction semantics.

Version History

  • c6903aa Current 2026-09-28 12:34

    精简技能描述以符合长度规范,并统一相关技能的归属说明。

  • 98c21cf 2026-08-28 22:48

Same Skill Collection

auto-repo-setup/SKILL.md
bilibili-source/SKILL.md
capture-screen/SKILL.md
cli-demo-generator/SKILL.md
cloudflare-troubleshooting/SKILL.md
codex-image-gallery/SKILL.md
competitors-analysis/SKILL.md
data-visualization-discipline/SKILL.md
daymade-audio/asr-transcribe-to-text/SKILL.md
daymade-audio/audio-router/SKILL.md
daymade-audio/meeting-minutes-taker/SKILL.md
daymade-audio/stepfun-asr/SKILL.md
daymade-audio/stepfun-tts/SKILL.md
daymade-audio/transcript-fixer/SKILL.md
daymade-claude-code/agent-web-search-setup/SKILL.md
daymade-claude-code/claude-code-hooks/SKILL.md
daymade-claude-code/claude-code-ops-router/SKILL.md
daymade-claude-code/claude-code-ping-start-5h-quota/SKILL.md
daymade-claude-code/claude-export-txt-better/SKILL.md
daymade-claude-code/claude-skills-troubleshooting/SKILL.md
daymade-claude-code/claude-switch-models-setup/SKILL.md
daymade-claude-code/claude-usage-analyst/SKILL.md
daymade-claude-code/continue-claude-code-work/SKILL.md
daymade-claude-code/continue-claude-work/SKILL.md
daymade-claude-code/continue-codex-work/SKILL.md
daymade-claude-code/lark-cli-router/SKILL.md
daymade-claude-code/local-conversation-history/SKILL.md
daymade-claude-code/marketplace-dev/SKILL.md
daymade-claude-code/prior-work-retrieval/SKILL.md
daymade-claude-code/read-claude-code-history/SKILL.md
daymade-claude-code/read-claude-web-conversation/SKILL.md
daymade-claude-code/read-codex-history/SKILL.md
daymade-claude-code/statusline-generator/SKILL.md
daymade-claude-code/tech-selection/SKILL.md
daymade-claude-code/terminal-screenshot/SKILL.md
daymade-codex/codex-image-gallery/SKILL.md
daymade-codex/design-style-picker/SKILL.md
daymade-codex/interaction-design-board/SKILL.md
daymade-codex/local-codex/SKILL.md
daymade-docs/docs-router/SKILL.md
daymade-docs/docx-creator/SKILL.md
daymade-docs/excel-automation/SKILL.md
daymade-docs/mermaid-tools/SKILL.md
daymade-docs/pdf-creator/SKILL.md
daymade-docs/ppt-creator/SKILL.md
daymade-docs/read-docx-review/SKILL.md
daymade-financial/ashare-news-fetcher/SKILL.md
daymade-financial/benchmark-due-diligence/SKILL.md
daymade-financial/bigdata-skill/SKILL.md

Metadata

Files
0
Version
c6903aa
Hash
b936ebe2
Indexed
2026-08-28 22:48

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-28 23:04
浙ICP备14020137号-1