acpx-codex-playbook
Use acpx as a structured control plane for Codex. Prefer persistent sessions, prompt files, and shell-based file generation over fragile one-shot prompts and tool-native file writes.
Quick start
Run this default flow for any non-trivial task:
CODEBLOCK0
Prefer this over acpx codex exec ... when the task needs iteration, file output, validation, or retries.
Workflow
1. Choose session type
Use exec only for small one-shot tasks.
Use a persistent session when the task involves any of the following:
- - generating files
- multiple retries
- long prompts
- validation steps
- local installs or virtual environments
- deliverables such as
.pptx, .docx, reports, videos, or scripts
2. Set mode explicitly
For practical work, set mode before prompting:
CODEBLOCK1
Interpretation:
- -
read-only: inspect only - INLINECODE5 : moderate default behavior
- INLINECODE6 : broader session capability, including easier file edits and broader path/network freedom
Do not assume full-access means sudo or root. It relaxes the ACP session; it does not guarantee system-level privilege escalation.
3. Use prompt files, not huge shell strings
For long or delicate instructions, always write a prompt file and pass -f:
CODEBLOCK2
This avoids shell quoting failures and makes retries reproducible.
4. Prefer shell/Python file writes over ACP fs writes
If the task must create or rewrite files, instruct Codex to prefer:
- - shell heredocs
- INLINECODE9
- direct command-line generation
Prefer these over tool-native fs/write_text_file style edits when prior attempts showed permission failures.
Recommended instruction snippet:
CODEBLOCK3
5. Use writable output paths first
For fragile generation tasks, write outputs under /tmp first, validate them, then move/copy them into the target workspace.
Recommended pattern:
- - generate under INLINECODE12
- validate structure and existence
- copy to final destination only after success
This is especially useful for generated binaries like .pptx.
6. Validate before declaring success
Always ask Codex to verify outputs.
Examples:
- - file exists
- zip/XML structure parses for INLINECODE14
- image dimensions or PDF page count
- report file with output path, validation result, and model if visible
Practical patterns
Pattern: generated deliverables
For PPT/report/document generation, require all of the following in the prompt:
- - exact output path
- exact report path
- validation steps
- final two-line summary with model/path if possible
See references/ppt-playbook.md for a concrete template.
Pattern: local dependency installs
If non-stdlib packages are needed, prefer project-local installs:
CODEBLOCK4
Avoid assuming global install rights. Use system-level installs only when explicitly intended and actually permitted by the host.
Pattern: troubleshooting failed writes
If touch or shell writes work but ACP file edits fail, treat it as an ACP handler or sandbox-path issue, not proof that Codex itself lacks capability. Switch the generation strategy to shell/Python writes.
Decision rules
- - If the task is small and read-heavy:
exec is acceptable. - If the task must create deliverables: use a persistent session.
- If the prompt is long: use
-f prompt.txt. - If file editing fails once: switch to shell/Python write strategy.
- If dependencies are missing: try local
.venv install before changing system state. - If a binary artifact is required: generate in
/tmp, validate, then move.
Anti-patterns
Avoid these common failure modes:
- - stuffing long multilingual prompts directly into one shell string
- assuming
full-access equals sudo/root - relying only on ACP fs writes for large generated files
- declaring success before validating output structure
- writing the final artifact directly into a path that may be sandbox-restricted
References
- - Read
references/ppt-playbook.md when the task is to generate a PPT or similar structured binary deliverable via acpx/Codex. - Read
references/troubleshooting.md when acpx sessions start but file creation, mode behavior, or sandbox boundaries are unclear.
acpx-codex-playbook
将acpx用作Codex的结构化控制平面。优先使用持久会话、提示文件和基于shell的文件生成,而不是脆弱的单次提示和工具原生文件写入。
快速开始
对于任何非平凡任务,运行此默认流程:
bash
acpx codex sessions new --name task
acpx codex set-mode -s task full-access
acpx codex -s task -f prompt.txt
当任务需要迭代、文件输出、验证或重试时,优先使用此方式而非acpx codex exec ...。
工作流程
1. 选择会话类型
仅对小型单次任务使用exec。
当任务涉及以下任何内容时,使用持久会话:
- - 生成文件
- 多次重试
- 长提示
- 验证步骤
- 本地安装或虚拟环境
- 可交付成果,如.pptx、.docx、报告、视频或脚本
2. 显式设置模式
对于实际工作,在提示前设置模式:
bash
acpx codex set-mode -s task full-access
解释:
- - read-only:仅检查
- auto:适度的默认行为
- full-access:更广泛的会话能力,包括更轻松的文件编辑和更广泛的路径/网络自由
不要假设full-access意味着sudo或root。它放宽了ACP会话;并不保证系统级权限提升。
3. 使用提示文件,而非庞大的shell字符串
对于长或精细的指令,始终编写提示文件并传递-f参数:
bash
cat > prompt.txt <
任务:...
约束:...
输出:...
验证:...
TXT
acpx codex -s task -f prompt.txt
这避免了shell引号失败,并使重试可重现。
4. 优先使用shell/Python文件写入而非ACP文件系统写入
如果任务必须创建或重写文件,指示Codex优先使用:
- - shell heredocs
- python - <
- 直接命令行生成
当先前的尝试显示权限失败时,优先使用这些方式而非工具原生的fs/writetextfile风格编辑。
推荐的指令片段:
text
如果内置文件编辑工具失败,通过shell heredoc或Python脚本写入文件,而不是使用ACP文件系统写入调用。
5. 首先使用可写输出路径
对于脆弱的生成任务,先在/tmp下写入输出,验证它们,然后移动/复制到目标工作区。
推荐模式:
- - 在/tmp/...下生成
- 验证结构和存在性
- 仅在成功后复制到最终目标
这对于生成的二进制文件(如.pptx)特别有用。
6. 在声明成功前进行验证
始终要求Codex验证输出。
示例:
- - 文件存在
- 对于.pptx,zip/XML结构可解析
- 图像尺寸或PDF页数
- 包含输出路径、验证结果和模型(如果可见)的报告文件
实用模式
模式:生成可交付成果
对于PPT/报告/文档生成,在提示中要求以下所有内容:
- - 确切的输出路径
- 确切的报告路径
- 验证步骤
- 包含模型/路径(如果可能)的最终两行摘要
参见references/ppt-playbook.md获取具体模板。
模式:本地依赖安装
如果需要非标准库包,优先使用项目本地安装:
bash
python3 -m venv .venv
. .venv/bin/activate
pip install
避免假设全局安装权限。仅当明确意图且主机实际允许时,才使用系统级安装。
模式:故障排除写入失败
如果touch或shell写入有效但ACP文件编辑失败,将其视为ACP处理程序或沙箱路径问题,而非Codex本身能力不足的证据。将生成策略切换到shell/Python写入。
决策规则
- - 如果任务较小且以读取为主:exec是可接受的。
- 如果任务必须创建可交付成果:使用持久会话。
- 如果提示较长:使用-f prompt.txt。
- 如果文件编辑失败一次:切换到shell/Python写入策略。
- 如果缺少依赖:在更改系统状态前,先尝试本地.venv安装。
- 如果需要二进制工件:在/tmp中生成,验证,然后移动。
反模式
避免这些常见失败模式:
- - 将长多语言提示直接塞入一个shell字符串
- 假设full-access等于sudo/root
- 仅依赖ACP文件系统写入来处理大型生成文件
- 在验证输出结构前声明成功
- 将最终工件直接写入可能受沙箱限制的路径
参考
- - 当任务是通过acpx/Codex生成PPT或类似结构化二进制可交付成果时,阅读references/ppt-playbook.md。
- 当acpx会话启动但文件创建、模式行为或沙箱边界不明确时,阅读references/troubleshooting.md。