git:20260811.08cc3c6 to git:20261006.c2a8989

19 added, 279 removed. Audit A to A.

---
name: cs-ralph-runner
- description: Use when the user wants Codex to turn a Markdown requirements document into a Ralph PRD and run a safe Ralph/Codex build workflow against a local Git repository. Triggers include "cs-ralph-runner", "run Ralph", "generate Ralph PRD", or requests to run a Markdown PRD against a repo.
- metadata:
- author: "陈硕"
- collection: "CS Skills"
- source: "https://github.com/ChenShuo2004/cs-skills"
- compatibility: "Codex and any agent that supports SKILL.md"
+ description: "将 Markdown 需求转换为 Ralph PRD,并在本地 Git 项目执行 overview 或有界 no-commit 构建。用户明确要求 Ralph 工作流时使用;不作为普通开发任务的默认循环器。"
---
- <!-- CS Skills · 陈硕 | portable skill entry | https://github.com/ChenShuo2004/cs-skills -->
-
- # Ralph Runner
-
- ## Purpose
-
- Use this skill to run a controlled local workflow in Codex:
-
- 1. Read a Markdown requirements document.
- 2. Resolve a target Git repository from a project alias, explicit path, or the current workspace.
- 3. Generate a Ralph-compatible PRD JSON in the target project.
- 4. Run `ralph` overview and a safe dry-run build through Codex.
- 5. Show the user the planned commands as an informational preview, then continue automatically.
- 6. Report paths, commands, logs, git state, and next steps.
-
- This skill is for Codex desktop/local CLI workflows. It is not a graphical project picker.
-
- ## `$` Workflow Triggers
-
- - `$cs-ralph-runner`: generic Markdown requirements to Ralph PRD and safe build workflow.
- - `$auto-cutting-ralph`: automatic video editing requirements to Ralph PRD, dry-run build, output generation plan, and verification feedback.
- - `$auto-cutting-prd`: automatic video editing requirements or PRD only, without running Ralph build unless requested.
- - `$auto-render-video`: direct render workflow; use Ralph only if the user asks for implementation automation.
-
- ## Inputs
-
- Require these before running:
-
- - Markdown requirements document path (`.md`).
- - Target project, which can be:
- - a project alias from `references/projects.json`, such as `web-app`;
- - an absolute local repository path, such as `<repo-path>`;
- - a relative repository path, resolved from the current workspace;
- - `.` or `current repo` to use the current working directory.
-
- Optional inputs:
-
- - Iteration count, default `1`.
- - Commit permission, default `false`.
- - Existing PRD JSON path, only if the user wants to skip PRD generation.
-
- If the document path is missing, ask for it before executing commands. If the target project is missing and the current working directory is a Git repository, use the current working directory as the target. If the current working directory is not a Git repository, ask for an alias or path.
-
- ## Run Policy
-
- Read `references/run-policy.json` before executing. It stores the default behavior that was agreed once and should be reused on later runs.
-
- Default policy:
-
- - Auto-run after required inputs are present.
- - Execution previews are informational, not confirmation gates.
- - Default mode is dry-run with `--no-commit`.
- - Default iteration count is `1`.
- - Stop on dirty worktrees.
- - Require explicit permission for commit-enabled runs.
-
- Do not ask the user for routine confirmation after the Markdown document and target project are known. Continue automatically through PRD generation, overview, and dry-run build.
-
- Ask only when one of these is true:
-
- - Required input is missing.
- - Project alias is unknown and the provided target cannot be resolved as a valid local path.
- - Target path does not exist or is not a Git repository.
- - `git status --short` is dirty before the run.
- - A command would overwrite existing Ralph config.
- - The user requests a commit-enabled run but did not explicitly allow commit.
- - A required tool is missing and the policy does not allow auto-install.
-
- ## Project Aliases and Paths
-
- Read `references/projects.json` before resolving aliases. Its shape is:
-
- ```json
- {}
- ```
-
- Resolve the target project in this order:
-
- 1. If the target is `.` or says `current repo` / `current workspace`, use the current working directory.
- 2. If the target matches a key in `references/projects.json`, use the mapped path.
- 3. If the target is an absolute path, use it directly.
- 4. If the target is a relative path, resolve it from the current working directory.
- 5. If no target was provided and the current working directory is a Git repository, use the current working directory.
-
- If an alias is unknown and the same value cannot be resolved to an existing path, show the known aliases and ask the user to choose an alias or provide a path. Do not require users to edit `projects.json` just to run Ralph in a one-off repository.
-
- ## Safety Rules
-
- - Never run in a non-Git directory.
- - Never run a formal commit build unless the user explicitly says commit is allowed, such as "allow commit", "commit is allowed", "formal run", "run with commit", or the equivalent in the user's language.
- - Default build command must include `--no-commit`.
- - If `git status --short` is not clean before the run, stop and summarize the existing changes. Ask before continuing.
- - Prefer Windows `.cmd` shims in PowerShell: `codex.cmd`, `npm.cmd`, `ralph.cmd`.
- - If PowerShell blocks `.ps1` scripts, do not change execution policy; use `.cmd`.
- - Do not use the Obsidian vault as the target project unless the user explicitly provides that path or an alias points there and it is a Git repo.
-
- ## Visibility Rules
-
- Before running `ralph.cmd prd`, `ralph.cmd overview`, `ralph.cmd build`, or a Git Bash fallback, send the user an execution preview in chat. This preview is informational only; continue automatically unless the Run Policy requires stopping.
-
- - Requirement document path.
- - Project target label and resolved path.
- - PRD output path.
- - Iteration count.
- - Dry-run or commit-enabled mode.
- - Exact command or commands about to run.
- - Where full output will be saved.
-
- During execution:
-
- - Run commands in the foreground so the terminal output remains visible.
- - Do not hide command output behind silent redirects.
- - If capturing output, tee it to both the terminal and a log file.
- - For PowerShell, prefer this pattern:
-
- ```powershell
- New-Item -ItemType Directory -Force -Path ".ralph\runs" | Out-Null
- $stamp = Get-Date -Format yyyyMMdd-HHmmss
- $log = ".ralph\runs\ralph-visible-<purpose>-$stamp.log"
- ralph.cmd build 1 --agent=codex --prd ".agents/tasks/prd-<short-slug>.json" --no-commit 2>&1 | Tee-Object -FilePath $log
- ```
-
- After each Ralph build command:
-
- - Inspect `.ralph/runs/` for new `run-*-iter-*.md` and `run-*-iter-*.log` files.
- - Show the user one section per iteration with:
- - Run ID and iteration.
- - Story ID/title.
- - Status.
- - Whether it was no-commit.
- - Verification results.
- - Full run summary/log paths.
- - A short tail of the terminal output if the log is long.
- - Do not paste huge logs in full; provide the full path and summarize the important output.
-
- ## Preflight
-
- Run these checks in the target project:
-
- ```powershell
- Test-Path -LiteralPath "<project-path>"
- git -C "<project-path>" rev-parse --show-toplevel
- git -C "<project-path>" status --short
- codex.cmd --version
- ralph.cmd help
- Get-Command bash -ErrorAction SilentlyContinue
- Test-Path -LiteralPath "<Git Bash path>"
- ```
-
- If `ralph.cmd` is missing, install it:
-
- ```powershell
- npm.cmd i -g @iannuttall/ralph
- ```
-
- Then re-run `ralph.cmd help`.
-
- Ralph build uses shell scripts internally. On Windows, if `ralph.cmd build` fails to start because `.sh` scripts cannot be launched, use Git Bash directly from the target project:
-
- ```powershell
- $env:AGENT_CMD = "codex.cmd exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check -"
- $env:PRD_PATH = ".agents/tasks/prd-<short-slug>.json"
- New-Item -ItemType Directory -Force -Path ".ralph\runs" | Out-Null
- $stamp = Get-Date -Format yyyyMMdd-HHmmss
- & "<Git Bash path>" ".agents/ralph/loop.sh" build 1 --no-commit 2>&1 | Tee-Object -FilePath ".ralph\runs\ralph-visible-build-$stamp.log"
- ```
-
- Only remove `--no-commit` when the user explicitly allows commit.
-
- ## Initialize Ralph
-
- From the target project:
-
- ```powershell
- ralph.cmd install
- ```
-
- If prompted to install skills, choose Codex and local project scope. If `.agents/ralph` already exists, do not overwrite unless the user explicitly asks.
-
- After install, ensure `.agents/ralph/config.sh` has Codex commands compatible with this Windows environment:
-
- ```bash
- AGENT_CMD="codex.cmd exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check -"
- PRD_AGENT_CMD="codex.cmd exec --dangerously-bypass-approvals-and-sandbox --skip-git-repo-check {prompt}"
- ```
-
- If the config already has custom `AGENT_CMD` values, preserve unrelated settings and ask before replacing them.
-
- ## PRD Generation
-
- Default behavior: generate a Ralph PRD from the Markdown requirements document.
-
- Preferred target:
-
- ```text
- .agents/tasks/prd-<short-slug>.json
- ```
-
- Use a Ralph-compatible schema:
-
- ```json
- {
- "version": 1,
- "project": "Project name",
- "qualityGates": [
- "Run the project's relevant typecheck, tests, or build command",
- "Keep git diff limited to the selected story"
- ],
- "stories": [
- {
- "id": "US-001",
- "title": "Short story title",
- "description": "What this story should accomplish",
- "acceptanceCriteria": [
- "Concrete, verifiable criterion"
- ],
- "dependsOn": [],
- "status": "open"
- }
- ]
- }
- ```
-
- Keep stories small enough for one Codex run. Prefer 3-8 stories for a normal feature. Split large requests by page, API, data model, state flow, or verification path.
-
- For automatic video editing requirements, first load the `auto-cutting` skill and read:
-
- ```text
- ../auto-cutting/references/optimized-ralph-workflow.md
- ```
-
- Then generate stories around the full closed loop: requirements and output mode, material manifest, metadata probing, editing plan, output generation, subtitles/audio, and verification report. If the user asks for direct video output, the PRD must include a render plan path, the render command, and the report path. Prefer the `li-auto-auto-cutting` project alias when the user does not provide another target.
+ <!-- CS Skills · 陈硕 | https://github.com/ChenShuo2004/cs-skills -->
- If using `ralph.cmd prd` is reliable for the document size, it is acceptable:
+ # CS Ralph Runner
- ```powershell
- ralph.cmd prd "<requirements summary>" --agent=codex --out ".agents/tasks/prd-<short-slug>.json"
- ```
+ 保留用户指定的 Ralph 工作流,完成需求转 PRD、项目预检和要求的执行。更强的模型不需要把每个普通开发请求都改造成循环代理。
- For long Markdown documents, generate the JSON file directly from the read document instead of passing the full content as a command argument.
+ ## 输入与模式
- ## Run Workflow
+ 需要实际 Markdown 需求和目标 Git 仓库;用户明确提供的路径优先。文档未指定时先检查会话与当前项目中明确对应的需求;仅有多个无法区分的候选才询问。未指定项目时使用当前 Git 仓库。别名仅在使用别名时读取 [projects](references/projects.json)。
- After PRD generation, run:
+ 执行前读取 [run policy](references/run-policy.json),保留本地约定:默认 1 次迭代、no-commit、缺工具不自动全局安装、执行预告不要求确认。
- ```powershell
- New-Item -ItemType Directory -Force -Path ".ralph\runs" | Out-Null
- $stamp = Get-Date -Format yyyyMMdd-HHmmss
- ralph.cmd overview --prd ".agents/tasks/prd-<short-slug>.json" 2>&1 | Tee-Object -FilePath ".ralph\runs\ralph-visible-overview-$stamp.log"
- ```
+ - plan / dry-run:读取需求、生成独立 PRD 与 overview;不启动 build。不把 overview 失败时的猜测称作真实预览。
+ - no-commit build:真实执行任务,可以修改代码;--no-commit 只禁止提交。
+ - commit build:沿用当前会话对 Ralph 运行内提交的明确授权;不包含推送/部署。
- Default dry-run build:
+ 只要必需输入与授权已具备就连续完成。用户说“运行并允许提交”本身已给提交授权,不重复询问。
- ```powershell
- New-Item -ItemType Directory -Force -Path ".ralph\runs" | Out-Null
- $stamp = Get-Date -Format yyyyMMdd-HHmmss
- ralph.cmd build 1 --agent=codex --prd ".agents/tasks/prd-<short-slug>.json" --no-commit 2>&1 | Tee-Object -FilePath ".ralph\runs\ralph-visible-build-$stamp.log"
- ```
+ ## 执行
- Only when the user explicitly allows commit:
+ 核对仓库、工作区、Ralph/Codex 版本和现有配置。按 [CLI 工作流](references/cli-workflow.md) 生成有业务验收条件的 stories,按真实依赖划分,不为凑固定数量拆任务。
- ```powershell
- New-Item -ItemType Directory -Force -Path ".ralph\runs" | Out-Null
- $stamp = Get-Date -Format yyyyMMdd-HHmmss
- ralph.cmd build 1 --agent=codex --prd ".agents/tasks/prd-<short-slug>.json" 2>&1 | Tee-Object -FilePath ".ralph\runs\ralph-visible-build-$stamp.log"
- ```
+ 已有 PRD/配置先检查能否复用;生成新文件可用独立名称,不覆盖用户配置。工作区有改动时遵守 stopOnDirtyWorktree:不得在原脏目录直接运行构建。可创建隔离工作区;若任务依赖未提交内容,必须将其纳入隔离副本并核对,否则说明输入缺口。不要自动 stash/reset 用户工作。
- Use the requested iteration count if provided. If not provided, use `1`.
+ 保留宿主的审批、沙箱与工具策略,不写绕过它们的 AGENT_CMD。Windows 使用实际可用的 .cmd 和 Git Bash 路径;根据 help 核实当前参数,不猜安装路径。
- ## Reporting
+ 运行前给简短预告:目标、模式、迭代数、命令和日志。执行日志保留完整文件,聊天只提供进展和重要失败;等待时保持用户可见进度。
- At the end, report:
+ ## 验收与恢复
- - Requirements document path.
- - Project target label and resolved project path.
- - PRD JSON path.
- - Overview path, if generated.
- - Exact commands run.
- - Whether this was dry-run or commit-enabled.
- - Git status before and after.
- - One visible-output section per Ralph iteration.
- - Log locations:
- - `.ralph/progress.md`
- - `.ralph/activity.log`
- - `.ralph/runs/`
- - Any failures, blocked checks, or manual confirmations needed.
+ 检查每次运行的 story、状态、产物、实际验证以及 Git 前后变化。no-commit 运行若产生提交,视为约束失败。overview、进程退出和代码验收分别记录,不等同。
- Keep the final answer concise and actionable.
+ 达到本次迭代上限或关键条件失败时停止循环并交付诊断,不擅自增加迭代;恢复先检查已有运行 ID 与日志,避免重复执行完成的 story。报告 PRD、日志、修改与未通过的验收。