.qwen/skills/agent-reproduce-feature/references/capture-workflow.md
This skill follows the nested-agent pattern described in "解决问题的原始冲动": run the original tool under a harness, capture the real request bodies and tool schemas, implement the substitute, then compare traces.
codex, claude, or claude-code command that demonstrates the feature.mitmdump, and terminal transcript
capture.Select one reference adapter before capture:
| Adapter | Interactive command | Headless command |
|---|---|---|
codex | codex | codex exec "<prompt>" |
claude-code | claude or claude-code | Discover locally; if unavailable, use tmux interaction |
Do not assume Claude Code's exact non-interactive flags. Check claude --help or claude-code --help in the user's environment and record the command used.
Use non-interactive/headless mode when:
Use tmux when:
Use both when a feature has model calls and visible terminal state.
Run a state snapshot before and after the reference scenario:
.qwen/skills/agent-reproduce-feature/scripts/capture_state.py \
snapshot OUT_DIR/state-before --agent codex
.qwen/skills/agent-reproduce-feature/scripts/capture_state.py \
snapshot OUT_DIR/state-after --agent codex
.qwen/skills/agent-reproduce-feature/scripts/capture_state.py \
diff OUT_DIR/state-before OUT_DIR/state-after \
--out-dir OUT_DIR/state-diff
Default state roots:
| Adapter | State root |
|---|---|
codex | ~/.codex |
claude-code | ~/.claude |
Generated files:
state-manifest.json: file metadata plus redacted text for safe small text
files.state-diff.md: model-readable summary of added, removed, and modified
files.state-diff.json: machine-readable equivalent.The snapshot tool records symlinks but does not follow them. It emits only metadata, without content hashes, for paths that look like auth, token, session, history, cache, log, or credential files. Review the Markdown before putting any state diff into a tracked artifact.
Install mitmproxy if needed:
python -m pip install --user mitmproxy
Run a command under capture:
.qwen/skills/agent-reproduce-feature/scripts/run_with_mitm.sh OUT_DIR -- COMMAND ARG...
Generated files:
mitm.log: mitmdump process loghttp.jsonl: redacted request/response recordscommand.stdout, command.stderr, command.exit: child process resultenv.txt: non-secret capture metadataThe script sets:
HTTP_PROXY, HTTPS_PROXY, ALL_PROXYNODE_EXTRA_CA_CERTSSSL_CERT_FILE, REQUESTS_CA_BUNDLEREPRO_CAPTURE_OUTThe default CA path is ~/.mitmproxy/mitmproxy-ca-cert.pem. Some CLIs ignore one or more of these variables; if http.jsonl is empty, verify proxy support before changing product code.
Run:
.qwen/skills/agent-reproduce-feature/scripts/run_tmux_capture.sh OUT_DIR COMMAND ARG...
Generated files:
tmux-pane.txt: captured pane contentstmux-session.txt: session metadata and attach instructionscommand.txt: the launched commandThe tmux session stays alive so the outer agent can send keys, inspect output, and capture again. Kill it after use:
tmux kill-session -t SESSION_NAME
From HTTP records:
From terminal records:
From state diffs:
Never commit raw traces. Before moving examples into docs or tests, remove: