360 Secure SkillHub
360 安全技能中心

CodexDelegate

核心功能是将编码、仓库分析、文件编辑、代码审查等任务委托给本地已认证的Codex CLI,返回处理结果,无需嵌入OpenAI API密钥。典型场景包括仓库总结、创建文档、修复测试等。需本地已安装并认证Codex CLI,运行于目标仓库或指定目录,输入含任务提示等参数,输出为Codex结果,写操作需用户确认。

jlacroix82
jlacroix82
热度 53.27
最近更新 2026-08-03 04:04:28
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 代码审查 / 调试排错 / 摘要总结

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add agent-codex-delegate
Metadata
name
codex-delegate
version
0.1.3
description
Delegate coding, repository analysis, file edits, test runs, or code review to the local Codex CLI without embedding an OpenAI API key. This skill was created to work with ChatGPT/Codex enterprise accounts that may not have the same level of API access. Invokes codex exec with existing ChatGPT/Codex CLI authentication and returns Codex's final output.
license
MIT
metadata
{"openclaw":{"requires":{"bins":["codex"]}}}

Codex Delegate

Use this skill when the user wants OpenClaw to hand a coding or repository task to Codex and receive a result back. It is meant for local, trusted operator setups where codex is already installed and signed in.

Preconditions

  • codex is installed on PATH.
  • Codex CLI has already been authenticated by the operator, preferably with ChatGPT sign-in. Do not ask the user for an API key.
  • Run inside the target repository or pass --cwd.
  • OpenClaw must allow this agent to use exec for the wrapper script.

If Codex is not authenticated, tell the operator to run codex or codex login once and complete the ChatGPT browser login. Do not request, print, copy, or inspect ~/.codex/auth.json.

Wrapper

Prefer the bundled wrapper:

{baseDir}/scripts/codex-delegate.sh --cwd /path/to/repo --prompt "summarize the repository and list the riskiest files"

For file creation or edits:

{baseDir}/scripts/codex-delegate.sh \
  --cwd /path/to/repo \
  --sandbox workspace-write \
  --prompt "Create docs/architecture.md explaining the current service layout."

For machine-readable event logs while still returning the final Codex answer:

{baseDir}/scripts/codex-delegate.sh \
  --cwd /path/to/repo \
  --sandbox workspace-write \
  --json-log .openclaw/codex-runs/last.jsonl \
  --output .openclaw/codex-runs/last.md \
  --prompt "Review the auth changes and fix any failing tests."

To pass CLI-style context:

npm test 2>&1 | {baseDir}/scripts/codex-delegate.sh \
  --cwd /path/to/repo \
  --sandbox workspace-write \
  --prompt "Summarize the failing tests and make the smallest safe fix."

Use --prompt-file path when a generated prompt is already on disk. Use --stdin-file path when another tool wrote context to a file.

Permissions

This skill requires:

  • exec: Run the codex CLI and the bundled wrapper script
  • fs.read: Read repository files for analysis
  • fs.write: Write files when --sandbox workspace-write is used

Scope

This skill is limited to delegating coding and repository tasks to the local Codex CLI. It does not manage Codex configuration, handle authentication, or perform actions outside the target repository. All write operations require explicit user confirmation before proceeding.

Delegation Workflow

  1. Restate the exact Codex task in one compact prompt.
  2. Choose the narrowest sandbox:
    • read-only for analysis, review, summaries, planning.
    • workspace-write for creating or editing files in the repo.
    • danger-full-access only on an isolated machine/container with explicit operator approval.
  3. Run the wrapper from the repository root or with --cwd.
  4. Return Codex's final answer to the user.
  5. If edits were allowed, inspect git diff --stat and relevant diffs before claiming files were changed.

Safety Rules

  • Never pass OPENAI_API_KEY, CODEX_API_KEY, or raw tokens to Codex. The wrapper unsets API-key env vars before invoking codex exec.
  • Never read, reveal, summarize, or copy ~/.codex/auth.json.
  • Do not run this skill from public or untrusted chat channels.
  • Do not give Codex secrets, credentials, private keys, or production data unless the operator explicitly approved that exact data flow.
  • Prefer an isolated checkout or git worktree for write tasks.
  • Treat Codex output as another agent's report; verify important claims locally.

Failure Handling

  • codex: command not found: ask the operator to install Codex CLI.
  • Authentication failure: ask the operator to run codex login with ChatGPT sign-in, then retry.
  • Git repo error: run in a git repository, or use --skip-git-repo-check only for a deliberately isolated scratch workspace.
  • Permission error on edits: retry with --sandbox workspace-write only if file changes are intended.