远端 pack 服务仍故障(git-upload-pack 返回 0008NAK 后截断),push 待服务器恢复。 未跟踪的 5 个归档临时副本(rtl-ip-replace / sim-rtl-flow / simulink_rtl_dev / simulink-rtl-redev / zynq-imx6-flow)刻意不入库,待 pull 后由远端提供。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0135YszNe4pwwJxwaLqKTCKG
15 KiB
name, description
| name | description |
|---|---|
| langgraph-plan-review | Use the LangGraph plan-review workflow from the current Claude Code session. Trigger when the user asks to create Taskxx plans, run the Claude/Codex review loop, generate or revise Notes/Taskxx.md, or use the LangGraph workflow described by Task00.md. This skill uses the current Claude Code environment for Claude steps and only invokes the Python LangGraph app for Codex review and discuss file numbering. |
LangGraph Plan Review Workflow
Use this skill to run the LangGraph plan-review workflow. All scripts are bundled under the skill's own scripts\ directory (%USERPROFILE%\.claude\skills\langgraph-plan-review\scripts\) — no dependency on E:\LangGraph_Design\lab00.
运行方式:进程内驱动,无 dev server(2026-07 起)
本 skill 已去掉 langgraph dev 服务器。工作流由进程内 runner scripts\clean_run.py 直接驱动:
它 build_workflow() 编译图、用 SqliteSaver(scripts\.plan_review_state.sqlite)做跨调用持久化、
自己处理 interrupt/Command(resume=...)。不再需要 manage_dev_server.ps1 / run_langgraph.ps1 /
run_workflow.py(这些是旧的 dev-server 路径,保留仅作参考,勿再使用)。
-
入口:用
langgraphconda 环境的 python 跑clean_run.py:# CONDA_LANGGRAPH_PYTHON from ~\skills_env.md; resolves either conda layout. $PY = @("$env:USERPROFILE\miniconda3\envs\langgraph\python.exe","$env:USERPROFILE\.conda\envs\langgraph\python.exe") | Where-Object { Test-Path $_ } | Select-Object -First 1 $RUN = "$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\clean_run.py" # 首次(到 write_plan 中断): & $PY $RUN --task-id 10 --work-dir "<work_dir>" --notes-dir Notes --prompt "<原始请求>" # resume(写完/改完 Task10.md 后;resume 值 base64(JSON)): $resume = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes('true')) & $PY $RUN --task-id 10 --work-dir "<work_dir>" --notes-dir Notes --resume-b64 $resume --codex-review-command-b64 $CMD --timeout 900每次调用推进到下一个
interrupt或结束,打印一行 JSON:{"status":"waiting","action_required":{...}}或{"status":"done","has_serious_issue":...}。action_required的处理同下(write_plan / decide / revise / write_rejection),resume 值:write_plan/revise/write_rejection用true;decide用{"accepts":true}或{"accepts":false,"reason":"..."}。 -
codex 评审的两个必备条件(本次踩坑记录):
- codex CLI 要足够新。config.toml 若配了较新模型(如
gpt-5.6-sol),旧 codex 会返回 400requires a newer version of Codex。升级:npm i -g @openai/codex@latest(≥0.144.5 实测可用)。 - codex 子进程要能到 chatgpt.com。
clean_run.py会自动读 Windows 系统代理(HKCU Internet Settings 的ProxyServer)设进HTTP(S)_PROXY,让 codex 走代理;也可用PLAN_REVIEW_PROXY覆盖。 - codex 超时:
review_task.py的内层 codex 超时取 argv[5](默认 300s,评审常不够)。用--codex-review-command-b64传一条末尾带超时秒数的命令(见 Workflow)。--timeout(外层 agents.py 超时)必须明显大于内层值(如内层 1500 / 外层 1800)——两者相等时外层会在 codex 正常收尾前把它杀掉,报subprocess.TimeoutExpired(2026-08-26 踩坑)。
- codex CLI 要足够新。config.toml 若配了较新模型(如
-
2026-08-26 踩坑补充(三条都已实测):
- npm 最新版 codex 也可能太旧:服务端 models 列表新增
maxreasoning 档位后,npm 的 0.149.1 解析失败(unknown variant 'max')直接退出。VS Code ChatGPT 扩展自带的 codex 更新 (如%USERPROFILE%\.vscode\extensions\openai.chatgpt-<最新版本号>-win32-x64\bin\windows-x86_64\codex.exe, 0.150.0-alpha.8 可用)。review_task.py支持CODEX_EXE环境变量指定该二进制,调用clean_run.py前$env:CODEX_EXE = "<扩展codex.exe路径>"即可(扩展目录版本号会随更新变化, 用 Get-ChildItem 找最新一个)。 - Windows elevated 沙箱挂起:config.toml 有
[windows] sandbox = "elevated"时,codex 在 ChatGPT 应用之外独立运行会让每条 shell 命令挂起,评审读不到文件(表现为评审意见说 "cannot open file")。review_task.py已固定加-c sandbox_mode=read-only规避(评审只需读; 注意codex exec resume不认--sandbox旗标,只能用-c)。 - UTF-8:直接跑
clean_run.py时先设$env:PYTHONUTF8='1'; $env:PYTHONIOENCODING='utf-8', 否则父进程按 cp1252 解码 codex 输出中的中文会 UnicodeDecodeError(旧 dev-server 路径由 run_langgraph.ps1 代设,clean_run 路径需要自己设)。
- npm 最新版 codex 也可能太旧:服务端 models 列表新增
-
改了
workflow.py/agents.py/clean_run.py后:无 dev server 缓存,下次clean_run.py直接生效。 若图结构改到与旧 checkpoint 不兼容,删scripts\.plan_review_state.sqlite重新开始该 thread。
Pre-flight: Environment Setup
Before running the workflow for the first time (or when unsure the environment is ready), verify that the required packages are installed in the langgraph conda env:
# Install langgraph dev server, SDK, and HTTP client
conda run -n langgraph pip install "langgraph-cli[inmem]" langgraph-sdk httpx
# Verify the SDK is importable
conda run -n langgraph python -c "from langgraph_sdk import get_sync_client; print('SDK OK')"
# Verify the langgraph dev command is available
conda run -n langgraph langgraph --version
| Package | Purpose |
|---|---|
langgraph-cli[inmem] |
Provides the langgraph dev server command |
langgraph-sdk |
Python client used by run_workflow.py to submit runs |
httpx |
HTTP health-check in run_workflow.py |
Codex auth (if not already set up): %USERPROFILE%\.codex\auth.json must contain a valid ChatGPT OAuth token. Run codex auth login if the file is missing.
Invariants
- Drive the graph only through the dev server (see the mandatory rule above):
run_langgraph.ps1→run_workflow.py→http://127.0.0.1:2024. Never import or rungraph.py/workflow.py/agents.pyin-process to execute the workflow — that bypasses the dev server and LangGraph Studio cannot track it. - Use the current Claude Code session for all Claude Code work. Do not launch another
claudeprocess. - Assume the current Claude Code session already has
--dangerously-skip-permissions. - Run Python through the recorded conda environment.
run_langgraph.ps1resolves conda from-CondaExe,CONDA_EXE,condaon PATH, or the user-profile miniconda fallback:<resolved conda.exe> run -n langgraph python - Codex CLI is installed in the
langgraphconda env ascodex.cmd(path = the langgraph env from~\skills_env.mdCONDA_LANGGRAPH_PYTHON, withpython.exe→codex.cmd). It must be invoked viacmd /cbecause.cmdfiles are not directly executable by Python subprocess on Windows. - Codex auth uses ChatGPT OAuth tokens stored in
%USERPROFILE%\.codex\auth.json. No API key is needed. run_langgraph.ps1setsCODEX_HOMEfrom-CodexHome, existingCODEX_HOME, or<UserProfile>\.codex.- Always use
review_task.pyas the Codex review shim. Pass it via--codex-review-commandas a JSON array with no spaces. This shim handles all Windows-specific codex invocation requirements:cmd /c, stdin prompt passing,--skip-git-repo-check, session resume, and explicitcwd. - Keep all workflow files under
<Claude launch work_dir>\Notesunless the user explicitly overrides-NotesDir. TaskIdis the numeric suffix, such as01; write the plan toNotes\Task01.md.discussxx-yy.mdnumbering is managed by the LangGraph app for Codex review files. If Claude rejects a review comment, create the next numbered discuss file manually before rerunning review.- The workflow uses LangGraph
interrupt()and persists state via the langgraph dev server. - Each
run_langgraph.ps1invocation advances the graph to the next interrupt or completion. Use-Resumeto continue the same thread after completing the requested Claude Code action.
Dev Server Lifecycle ⛔ DEPRECATED
已弃用(2026-07 起)。 本 skill 现用
clean_run.py进程内驱动,不再需要 dev server。 下面这套manage_dev_server.ps1/langgraph dev/ Studio 仅作历史参考,正常流程不要用。
The langgraph dev server must be running for the entire duration of a workflow session.
Use manage_dev_server.ps1 to start it before the first run_langgraph.ps1 call and stop it after the workflow completes.
# Start (idempotent — safe to call even if already running)
$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\manage_dev_server.ps1 start
# Stop (call once when workflow returns {"status":"done"})
$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\manage_dev_server.ps1 stop
# Status check
$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\manage_dev_server.ps1 status
startwaits up to 45 s forhttp://127.0.0.1:2024/okto respond, then prints the Studio URL.stopkills the process by PID file and removes it; falls back to killing by port 2024 if the PID is stale.- If the server is already running,
startis a no-op. - Server stdout/stderr logs are written to
%TEMP%\langgraph_dev_server.stdout.logand%TEMP%\langgraph_dev_server.stderr.logfor debugging. - Studio URL:
https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024— open in browser to track workflow execution in real time.
Workflow
注意:下列步骤是旧的 dev-server 流程(
manage_dev_server.ps1+run_langgraph.ps1)。 正常请用上方"运行方式:进程内驱动"节的clean_run.py。以下 action 语义(write_plan / decide / revise / write_rejection 及其 resume 值)两种流程通用,可参考。
-
Determine
TaskIdfrom the user. If missing, ask for it. -
Start the dev server (idempotent):
$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\manage_dev_server.ps1 startWait for the "[dev-server] Ready" line in the output. Then immediately tell the user in your text response:
- that the dev server is running, and
- the Studio URL:
https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
Example message to user:
LangGraph dev server 已就绪。可在浏览器中打开 Studio 实时监控工作流: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024
-
Start or resume the LangGraph app:
# Build the JSON array with ConvertTo-Json so Windows backslashes are escaped for you. # $task_path / $latest_discuss_path / etc. are Python Template placeholders — single-quote them literal. $PY = @("$env:USERPROFILE\miniconda3\envs\langgraph\python.exe","$env:USERPROFILE\.conda\envs\langgraph\python.exe") | Where-Object { Test-Path $_ } | Select-Object -First 1 $review = "$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\review_task.py" $codexCmd = ConvertTo-Json -Compress @($PY,$review,'$task_path','$latest_discuss_path','$codex_session_id','$work_dir') & "$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\run_langgraph.ps1" ` -TaskId <TaskId> ` -Prompt "<original user request>" ` -CodexReviewCommand $codexCmd ` -Timeout 300 -
Inspect the returned JSON. If
statusiswaiting, performaction_requiredin the current Claude Code session:write_plan: writeTask<TaskId>.mdwith project background, task objective, and concrete implementation plan, then resume with-Resume 'true'.decide: read the discuss file and resume with-Resume '{"accepts":true}'or-Resume '{"accepts":false,"reason":"..."}'.revise: reviseTask<TaskId>.md, then resume with-Resume 'true'.write_rejection: write the specifiedoutput_path, then resume with-Resume 'true'.
Why
review_task.py: Using the shim keeps all codex-specific logic in Python, and the JSON array stays simple.run_langgraph.ps1base64-encodes the JSON command and resume payload before passing them throughconda run, so normal PowerShell single-quoted JSON can be used. Windows paths inside the JSON string must use\\(double backslash) to produce valid JSON (ConvertTo-Jsondoes this for you), e.g.%USERPROFILE%\\....run_langgraph.ps1automatically setsPYTHONIOENCODING=utf-8so prompts containing Unicode (Chinese, etc.) pass through correctly. -
Inspect the command output after each resume.
- Check
"status"to determine next action:"waiting"means perform the nextaction_required;"done"means the workflow is complete. - If a new
latest_discuss_pathis present in the output, read that discuss file for context.
- Check
-
Stop when the workflow returns
{"status":"done", ...}:$env:USERPROFILE\.claude\skills\langgraph-plan-review\scripts\manage_dev_server.ps1 stop
Rejection File Rule
When the action_required is write_rejection, the interrupt payload already contains the exact file path:
{"action": "write_rejection", "output_path": "Notes/discuss04-01.md", "reason_hint": "..."}
Write the rejection content directly to action_required.output_path:
# discuss<TaskId>-<yy>
## Claude Code Rejection
<reason>
Notes
- The LangGraph app automatically scans existing discuss files and writes the next Codex review file without overwriting old discussions.
- The app no longer accepts Claude command arguments; Claude actions happen in this current session.
- If
codexis unavailable, report that the review step cannot run rather than simulating it. review_task.pypasses the review prompt through stdin with-to avoid Windows command-line quoting issues with multiline prompts.review_task.pypasses--skip-git-repo-checkso the workflow can run from Claude launch directories that are not git repositories.review_task.pyreads Codex final output via--output-last-messageso intermediate JSONL progress messages are not treated as review findings.review_task.pypersists the Codex session id through LangGraph state and usescodex exec resumeon later review passes.review_task.pyruns Codex with the original Claude Code launch working directory as cwd.- Codex review output is normalized to JSON for
agents.py:{"has_serious_issue":true/false,"comment":"...","codex_session_id":"..."}. - If the dev server restarts,
run_workflow.pydetects that the stored thread no longer exists and creates a new thread automatically. run_workflow.pypasses the codex command and timeout asconfig["configurable"]per run — no server restart needed when switching projects.