[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E7WA8GZ2Q1K2MCVAZACBF2":3,"skill-same:01M7E7WA8GZ2Q1K2MCVAZACBF2":93},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":36,"commitSha":37,"skillDirectory":38,"forksCount":14,"repositoryHtmlUrl":39,"repositoryHomepageUrl":6,"ownerHtmlUrl":40,"ownerBlogUrl":41,"ownerDescription":42,"updatedAt":43,"install":44,"resources":56},"01M7E7WA8GZ2Q1K2MCVAZACBF2","pytest-optimizer-03-execute",null,"Use when applying an approved pytest optimization plan as separate verified commits in an isolated worktree, with resumable progress.","tony\u002Fskills","tony","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F26336?v=4","01M72E5RNJ7SQV8F9KBM5RKRMN","Tony Narlock","01M7E7MBN5C6YZ4JJJ5Y82KBJG",0,"MIT","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: pytest-optimizer-03-execute\ndescription: >-\n  Use when applying an approved pytest optimization plan as separate\n  verified commits in an isolated worktree, with resumable progress.\ndisable-model-invocation: true\nallowed-tools: [\"Bash\", \"Read\", \"Grep\", \"Glob\", \"Write\", \"Edit\", \"AskUserQuestion\"]\nmetadata:\n  argument-hint: \"[--from=\u003Cindex>] [--dry-run] [--memory-dir=\u003Cpath>]\"\n  source: \"plugins\u002Fpytest-optimizer\u002Fskills\u002F03-execute\u002FSKILL.md\"\n---\n\n# 03-execute\n\nLand the plan as separate, verified commits on a new branch cut from the\napproved base. Every edit, test run and commit happens in an owned scratch\nworktree. The user's checkout, index and branches are never modified; the run\nends by naming the result branch and the command that merges it.\n\n`$ARGUMENTS` may pass `--from=\u003Cindex>` to start at a specific plan item,\n`--dry-run` to run the same steps in a detached worktree that is discarded\n(it writes nothing to `execution-log.json` or `state.json`), and\n`--memory-dir` to override the memory location.\n\nArithmetic and state go through `references\u002Fmeasure.py` and Git isolation through\n`references\u002Fisolate.py` (Python 3 standard library). Both paths resolve from\nthis skill's own directory, not the project's working directory: resolve this\nfile's directory, join each path, print the absolute paths once, and write those\nliteral paths in each command below where `\u003Cmeasure.py>` and `\u003Cisolate.py>`\nappear.\n\n## Step 1: Preconditions\n\nResolve the memory directory by the lookup order in\n`references\u002Fmemory-schema.md`. If none exists or `plan.json` is missing,\nstop with the halted-run shape in `references\u002Foutput-contract.md`.\n\nResolve `\u003Cruns-dir>` using the \"Run files\" section of\n`references\u002Fmemory-schema.md`; keep each item's verification record there.\n\nRead `plan.json` and `state.json`. Refuse to run unless the evidence is bound:\nthe plan was approved and is unchanged since (`plan_hash`), `state.json` has an\n`env_token`, every plan item carries it and a `patch_sha256`, and `HEAD` equals\n`base_head`. The command checks them in that order and names the first failure:\n\n```console\n$ python3 \u003Cisolate.py> stale \\\n    --memory-dir \u003Cmemory-dir> \\\n    --phase execute\n```\n\nOn exit 1, print its `reason` and send the user to the phase its `rerun` names\n(`pytest-optimizer:` followed by it).\n\nThen read `baseline.json`, `control.json`, `collection.txt`,\n`execution-log.json` if present, and the project quality-check and test\ncommands. The user's checkout may be dirty and may keep changing while this\nskill runs: nothing here reads or writes its files, index or branches, so a\ndirty tree is not a stop.\n\nA resumed run (`state.json` has `exec_branch`) checks the result branch instead\nof the checkout, listing every logged `commit_sha` in order:\n\n```console\n$ python3 \u003Cmeasure.py> chain \\\n    --base \u003Cbase_head> \\\n    --head \u003Cexec_branch> \\\n    \u003Cevery logged commit_sha, in order>\n```\n\nExit 1 means the recorded history could not be verified: stop, print its\n`reason`, and tell the user to run `pytest-optimizer:00-scan --force`.\n\nResume from `last_applied_index + 1` (or `--from`). Never re-apply an item that\nalready has a `commit_sha`. Nothing in this skill pushes.\n\n## Step 2: Open the owned worktree\n\nA fresh run (no `exec_branch`) takes a run id, then cuts the result branch from\nthe approved base:\n\n```console\n$ python3 \u003Cmeasure.py> run-id\n```\n\n```console\n$ python3 \u003Cisolate.py> start \\\n    --repo . \\\n    --base \u003Cbase_head> \\\n    --branch pytest-optimizer\u002F\u003Crun_id>\n```\n\nPrint its `tree` and `dir`, and store `run_id`, `exec_branch` and `exec_dir` in\n`state.json` with `measure.py state update \u003Cmemory-dir>\u002Fstate.json --set\n'exec_branch=\"\u003Cbranch>\"'` and the same for the others. A dry run omits `--branch`,\nwhich detaches the worktree, and stores nothing. When `start` fails, stop and\nprint its `reason`: execution needs a real branch.\n\nA resumed run reuses `exec_dir`'s `tree` when it still exists, otherwise reopens\nthe branch. A cleaned temp directory leaves git's record of the missing worktree\nin place until it is pruned (`git worktree`, \"prune\"), which would block the\nbranch, so the command first drops this tool's own record for that branch and\nleaves the user's other worktrees alone:\n\n```console\n$ python3 \u003Cisolate.py> start \\\n    --repo . \\\n    --base \u003Cbase_head> \\\n    --branch \u003Cexec_branch> \\\n    --existing\n```\n\nThen clear any half-applied item, inside the owned tree only:\n\n```console\n$ python3 \u003Cisolate.py> reset \\\n    --cwd \u003Ctree>\n```\n\nIf the last log entry has `pending_tree` and no `commit_sha`, a crash fell\nbetween commit and checkpoint. Check whether the branch tip is that commit:\n\n```console\n$ python3 \u003Cisolate.py> landed \\\n    --cwd \u003Ctree> \\\n    --parent \u003Cpending_parent> \\\n    --tree \u003Cpending_tree>\n```\n\nOn success, record the tip as the entry's `commit_sha`:\n\n```console\n$ python3 \u003Cmeasure.py> log commit \\\n    --memory-dir \u003Cmemory-dir> \\\n    --order \u003Corder> \\\n    --set 'commit_sha=\"\u003Ctip sha>\"'\n```\n\nOn failure, reset the\nowned tree to the item's `pending_parent` with `isolate.py reset --cwd \u003Ctree>\n--to \u003Cpending_parent>` and re-apply the item; a matching commit subject never\nestablishes identity.\n\nRun the project's commands below with `workdir` from the `start` output as the\nworking directory (`\u003Ctree>` itself, or the project's subdirectory when the\nrepository holds several projects), and the git and `isolate.py` commands on\n`\u003Ctree>`. The tree holds only tracked files: rebuild the\nenvironment there with the project's sync command, as `01-benchmark` does. The\ntree is a Git boundary, not a sandbox: a project hook or an absolute path in a\ntest can still write outside it.\n\n## Step 3: Apply each item in order\n\nFor each plan item not yet applied:\n\n1. **Apply** the item's measured patch, bound by the hash `01-benchmark`\n   recorded. Do not re-describe or retype the change:\n\n   ```console\n   $ python3 \u003Cisolate.py> apply \\\n       --cwd \u003Ctree> \\\n       --patch \u003Cmemory-dir>\u002F\u003Cpatch> \\\n       --sha256 \u003Cpatch_sha256> \\\n       --file \u003Ceach path in files>\n   ```\n\n   Exit 1 (altered patch, stale context, a path outside the plan) is a failed\n   item: go to 4.\n2. **Verify green.** Run the project quality checks as declared in the\n   project's `AGENTS.md`\u002F`CLAUDE.md`, then the `test_command` from\n   `baseline.json` with the item's measurement flags\n   (`references\u002Fdurations-parsing.md`, \"Measurement command\"):\n\n   ```console\n   $ python3 \u003Cmeasure.py> run \\\n       --cwd \u003Cworkdir> \\\n       -- pytest \\\n       -p no:cacheprovider \\\n       -p no:randomly \\\n       > \u003Cruns-dir>\u002Fverify-\u003Corder>.jsonl\n   ```\n\n   Substitute `test_command` for `pytest`, and drop `-p no:cacheprovider` when\n   the item's `cache` is `enabled`. Get the expected count from the script, which\n   counts only the items already applied:\n\n   ```console\n   $ python3 \u003Cmeasure.py> expected-total \\\n       --through \u003Corder> \\\n       \u003Cmemory-dir>\u002Fbaseline.json \\\n       \u003Cmemory-dir>\u002Fplan.json \\\n       \u003Cmemory-dir>\u002Fexecution-log.json\n   ```\n\n   Check outcome counts with the shared gate, which reads `valid` here and\n   never `clears_noise`, since one run does not establish a speedup. Pass the\n   number in the `expected_total` field as `--expect-total`:\n\n   ```console\n   $ python3 \u003Cmeasure.py> compare \\\n       --min-runs 1 \\\n       --expect-total \u003Cexpected_total> \\\n       \u003Cmemory-dir>\u002Fbaseline.json \\\n       \u003Cruns-dir>\u002Fverify-\u003Corder>.jsonl\n   ```\n\n   Check that the same tests exist. Write the listing from `test_command`\n   (not a bare `pytest`) run in `\u003Cworkdir>` to\n   `\u003Cruns-dir>\u002Fverify-\u003Corder>-collection.txt` as `00-scan` Step 2 does, and\n   compare node ids against `collection.txt`, allowing only the removals of\n   applied items (skip this for a typing or parametrize item, which changes ids\n   by design):\n\n   ```console\n   $ python3 \u003Cmeasure.py> ids \\\n       --plan \u003Cmemory-dir>\u002Fplan.json \\\n       --log \u003Cmemory-dir>\u002Fexecution-log.json \\\n       --through \u003Corder> \\\n       \u003Cmemory-dir>\u002Fcollection.txt \\\n       \u003Cruns-dir>\u002Fverify-\u003Corder>-collection.txt\n   ```\n\n   The item passes only when the quality checks pass, `valid` is true, and the\n   ids match. Missing or empty outcomes fail; an exit 0 is insufficient. For a\n   typing or parametrize item the type checker must cover `tests\u002F`.\n3. **Gate, then commit.** Check that the staged bytes are exactly the item's\n   files and the verification created or changed nothing else:\n\n   ```console\n   $ python3 \u003Cisolate.py> gate \\\n       --cwd \u003Ctree> \\\n       --file \u003Ceach path in files> \\\n       > \u003Cruns-dir>\u002Fgate-\u003Corder>.json\n   ```\n\n   On exit 1 the item failed (go to 4); the verification changed paths outside\n   the plan, which includes a formatter rewriting the patched files (read the\n   saved file for the `reason`). On success write the log entry from that file, with the drafted subject:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log begin \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --gate-json \u003Cruns-dir>\u002Fgate-\u003Corder>.json \\\n       --set 'pending_subject=\"\u003Csubject>\"'\n   ```\n\n   Then commit with the drafted why\u002Fwhat\n   message from `plan.json`, written per `references\u002Fprose-rules.md`\n   (no trailers, no emoji; hosts add them by default; do not mention this):\n\n   ```console\n   $ git -C \u003Ctree> commit \\\n       --message \u003Csubject> \\\n       --message \u003Cbody>\n   ```\n\n   Then confirm the commit holds the gated bytes, so a hook that edited files\n   cannot slip past the verification:\n\n   ```console\n   $ python3 \u003Cisolate.py> landed \\\n       --cwd \u003Ctree> \\\n       --parent \u003Cpending_parent> \\\n       --tree \u003Cpending_tree>\n   ```\n\n   On success record the `commit_sha` and the verify run's `seconds` (read from\n   the `verify-\u003Corder>.jsonl` run line), which also checkpoints `state.json`:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log commit \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --run-json \u003Cruns-dir>\u002Fverify-\u003Corder>.jsonl \\\n       --set 'commit_sha=\"\u003Csha>\"'\n   ```\n\n   When the commit fails (a hook rejects it, signing is unavailable) or `landed`\n   fails, never retry with `--no-verify` or `--no-gpg-sign`: run\n   `isolate.py reset --cwd \u003Ctree> --to \u003Cpending_parent>`, record the failure\n   (this sets `applied` false, removes the `pending_*` fields, and leaves later\n   items alone), and stop without starting the next item:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log skip \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --no-propagate \\\n       --set 'reason=\"commit failed: \u003Cfirst line of the error>\"'\n   ```\n\n   Report the error and tell the user to fix the hook or signing and re-run\n   `pytest-optimizer:03-execute --from=\u003Cindex>`.\n4. **On failure** (patch, verification, ids or gate), discard the item inside the\n   owned tree. The command refuses any directory this run did not create:\n\n   ```console\n   $ python3 \u003Cisolate.py> reset \\\n       --cwd \u003Ctree>\n   ```\n\n   Exit 1 means the discard did not complete: stop, report its `reason`, and\n   leave the tree for inspection. Otherwise log the skip, which also marks every\n   item whose `depends_on` names it, directly or through others, as skipped\n   (\"depends on a skipped item\"), and continue. Failures never reach the user's\n   checkout, so no later step depends on repairing it:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log skip \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --set 'reason=\"\u003Cprinted result>\"'\n   ```\n5. **Checkpoint**: every `log` call writes `execution-log.json` and sets\n   `phase` and `last_applied_index` in `state.json`, so a re-run continues from\n   the last checkpoint with nothing more to write.\n6. **Regression stop**: compare the item's verify `seconds` with the control:\n\n   ```console\n   $ python3 \u003Cmeasure.py> regress \\\n       \u003Cmemory-dir>\u002Fcontrol.json \\\n       \u003Cseconds>\n   ```\n\n   When `rerun` is true, re-run the verify command twice more and call it again\n   with all three timings. Exit 1 (`regressed`) means the commits so far made the\n   suite slower: stop before the next item, name the item, and ask whether to\n   continue or drop it from the branch. Without a question tool, stop and say\n   so.\n\nA dry run passes `--log-file \u003Cruns-dir>\u002Fdry-run-log.json` to every `log` call\n(use that file for the `expected-total` and `ids` commands), which leaves\n`state.json` alone; it ends with the discard in Step 4.\n\n## Step 4: Re-measure and report\n\nWhen no item was applied, remove the worktree and the unused branch, skip the\nre-measure, and report the control as the result:\n\n```console\n$ python3 \u003Cisolate.py> finish \\\n    --dir \u003Cexec_dir> \\\n    --drop-branch-at \u003Cbase_head>\n```\n\nOtherwise, with the final tree still open, resolve and create `\u003Cruns-dir>`, delete\n`post-runs.jsonl` there, run one untimed warm-up, and time as many runs as\n`baseline.json` recorded into it with the measurement flags above; if any applied\nitem has `cache` `enabled`, run them with the cache provider on so the warm-up\npopulates it and say so in the result. Compare against `control.json`, the same\nfresh checkout without the changes, passing the count the script returns once\nevery applied item is in the tree:\n\n```console\n$ python3 \u003Cmeasure.py> compare \\\n    --expect-total \u003Cexpected_total> \\\n    \u003Cmemory-dir>\u002Fcontrol.json \\\n    \u003Cruns-dir>\u002Fpost-runs.jsonl\n```\n\nThen remove the worktree; the branch stays. Read `removed` in the output: when it\nis not true, the worktree is still there, so say so in the closing sentence:\n\n```console\n$ python3 \u003Cisolate.py> finish \\\n    --dir \u003Cexec_dir>\n```\n\nUnless this was a dry run, mark the phase done with `measure.py state complete\n\u003Cmemory-dir>\u002Fstate.json --phase execute`. Emit the `03-execute`\nsections from `references\u002Foutput-contract.md`, hero line first, nothing\nbefore it. Write the prose per `references\u002Fprose-rules.md`. Reply in this\nshape, as plain text outside any code fence, with plain bullets, no bold\n(never `- **Label:** ...`), and no local paths:\n\n```text\n✓ 1 applied, 1 skipped on branch pytest-optimizer\u002Frun-1\n\n## Applied\n\n- 7c1e9d4 Share db_session across the session, verify green.\n\n## Skipped\n\n- H33 fixed sleep in test_report: discarded in the scratch worktree, test_report failed once the sleep was removed.\n\n## Result\n\n- 7.9s against 12.5s for the same checkout without the changes, 4.6s faster; the same 40 tests ran.\n\nMerge it with git merge --ff-only pytest-optimizer\u002Frun-1 when you are ready.\n```\n\nA run that skipped every item opens with `⚠`, has no `## Applied` section, no\nmerge sentence and no text about removing the worktree or branch, and states each failed verification as the printed result\n(counts and exit status), with no cause or threshold beyond that output; a dry run says \"verified, nothing committed\" in the hero and names no\nbranch. The merge sentence comes first: after it, the\n`ask-user-choice` panel offers a re-scan for a second pass (new candidates may\nsurface on a leaner suite), the opt-in cache\u002Ftiming scaffolds, or stop. Without\na question tool, follow the contract's next-step rule. A re-scan restarts at\n`pytest-optimizer:00-scan` with a fresh baseline, after the user merges.\n\n\n## Portability notes\n\n- `ask-user-choice` — present the listed options and wait for the user to pick one. Hosts with a structured multiple-choice tool (Claude Code's `AskUserQuestion`) should use it; otherwise print a numbered list and wait for a numbered reply. Never proceed on an assumed answer.\n- `$ARGUMENTS` — the text the user passed when invoking this skill. If your host does not substitute it, read it as the user's request in the current turn, and ask when there is none.\n- Bundled files — every relative path in this skill points at a file shipped inside this skill directory. Read them from here, not from the host's plugin tree.\n","# 03-execute\n\nLand the plan as separate, verified commits on a new branch cut from the\napproved base. Every edit, test run and commit happens in an owned scratch\nworktree. The user's checkout, index and branches are never modified; the run\nends by naming the result branch and the command that merges it.\n\n`$ARGUMENTS` may pass `--from=\u003Cindex>` to start at a specific plan item,\n`--dry-run` to run the same steps in a detached worktree that is discarded\n(it writes nothing to `execution-log.json` or `state.json`), and\n`--memory-dir` to override the memory location.\n\nArithmetic and state go through `references\u002Fmeasure.py` and Git isolation through\n`references\u002Fisolate.py` (Python 3 standard library). Both paths resolve from\nthis skill's own directory, not the project's working directory: resolve this\nfile's directory, join each path, print the absolute paths once, and write those\nliteral paths in each command below where `\u003Cmeasure.py>` and `\u003Cisolate.py>`\nappear.\n\n## Step 1: Preconditions\n\nResolve the memory directory by the lookup order in\n`references\u002Fmemory-schema.md`. If none exists or `plan.json` is missing,\nstop with the halted-run shape in `references\u002Foutput-contract.md`.\n\nResolve `\u003Cruns-dir>` using the \"Run files\" section of\n`references\u002Fmemory-schema.md`; keep each item's verification record there.\n\nRead `plan.json` and `state.json`. Refuse to run unless the evidence is bound:\nthe plan was approved and is unchanged since (`plan_hash`), `state.json` has an\n`env_token`, every plan item carries it and a `patch_sha256`, and `HEAD` equals\n`base_head`. The command checks them in that order and names the first failure:\n\n```console\n$ python3 \u003Cisolate.py> stale \\\n    --memory-dir \u003Cmemory-dir> \\\n    --phase execute\n```\n\nOn exit 1, print its `reason` and send the user to the phase its `rerun` names\n(`pytest-optimizer:` followed by it).\n\nThen read `baseline.json`, `control.json`, `collection.txt`,\n`execution-log.json` if present, and the project quality-check and test\ncommands. The user's checkout may be dirty and may keep changing while this\nskill runs: nothing here reads or writes its files, index or branches, so a\ndirty tree is not a stop.\n\nA resumed run (`state.json` has `exec_branch`) checks the result branch instead\nof the checkout, listing every logged `commit_sha` in order:\n\n```console\n$ python3 \u003Cmeasure.py> chain \\\n    --base \u003Cbase_head> \\\n    --head \u003Cexec_branch> \\\n    \u003Cevery logged commit_sha, in order>\n```\n\nExit 1 means the recorded history could not be verified: stop, print its\n`reason`, and tell the user to run `pytest-optimizer:00-scan --force`.\n\nResume from `last_applied_index + 1` (or `--from`). Never re-apply an item that\nalready has a `commit_sha`. Nothing in this skill pushes.\n\n## Step 2: Open the owned worktree\n\nA fresh run (no `exec_branch`) takes a run id, then cuts the result branch from\nthe approved base:\n\n```console\n$ python3 \u003Cmeasure.py> run-id\n```\n\n```console\n$ python3 \u003Cisolate.py> start \\\n    --repo . \\\n    --base \u003Cbase_head> \\\n    --branch pytest-optimizer\u002F\u003Crun_id>\n```\n\nPrint its `tree` and `dir`, and store `run_id`, `exec_branch` and `exec_dir` in\n`state.json` with `measure.py state update \u003Cmemory-dir>\u002Fstate.json --set\n'exec_branch=\"\u003Cbranch>\"'` and the same for the others. A dry run omits `--branch`,\nwhich detaches the worktree, and stores nothing. When `start` fails, stop and\nprint its `reason`: execution needs a real branch.\n\nA resumed run reuses `exec_dir`'s `tree` when it still exists, otherwise reopens\nthe branch. A cleaned temp directory leaves git's record of the missing worktree\nin place until it is pruned (`git worktree`, \"prune\"), which would block the\nbranch, so the command first drops this tool's own record for that branch and\nleaves the user's other worktrees alone:\n\n```console\n$ python3 \u003Cisolate.py> start \\\n    --repo . \\\n    --base \u003Cbase_head> \\\n    --branch \u003Cexec_branch> \\\n    --existing\n```\n\nThen clear any half-applied item, inside the owned tree only:\n\n```console\n$ python3 \u003Cisolate.py> reset \\\n    --cwd \u003Ctree>\n```\n\nIf the last log entry has `pending_tree` and no `commit_sha`, a crash fell\nbetween commit and checkpoint. Check whether the branch tip is that commit:\n\n```console\n$ python3 \u003Cisolate.py> landed \\\n    --cwd \u003Ctree> \\\n    --parent \u003Cpending_parent> \\\n    --tree \u003Cpending_tree>\n```\n\nOn success, record the tip as the entry's `commit_sha`:\n\n```console\n$ python3 \u003Cmeasure.py> log commit \\\n    --memory-dir \u003Cmemory-dir> \\\n    --order \u003Corder> \\\n    --set 'commit_sha=\"\u003Ctip sha>\"'\n```\n\nOn failure, reset the\nowned tree to the item's `pending_parent` with `isolate.py reset --cwd \u003Ctree>\n--to \u003Cpending_parent>` and re-apply the item; a matching commit subject never\nestablishes identity.\n\nRun the project's commands below with `workdir` from the `start` output as the\nworking directory (`\u003Ctree>` itself, or the project's subdirectory when the\nrepository holds several projects), and the git and `isolate.py` commands on\n`\u003Ctree>`. The tree holds only tracked files: rebuild the\nenvironment there with the project's sync command, as `01-benchmark` does. The\ntree is a Git boundary, not a sandbox: a project hook or an absolute path in a\ntest can still write outside it.\n\n## Step 3: Apply each item in order\n\nFor each plan item not yet applied:\n\n1. **Apply** the item's measured patch, bound by the hash `01-benchmark`\n   recorded. Do not re-describe or retype the change:\n\n   ```console\n   $ python3 \u003Cisolate.py> apply \\\n       --cwd \u003Ctree> \\\n       --patch \u003Cmemory-dir>\u002F\u003Cpatch> \\\n       --sha256 \u003Cpatch_sha256> \\\n       --file \u003Ceach path in files>\n   ```\n\n   Exit 1 (altered patch, stale context, a path outside the plan) is a failed\n   item: go to 4.\n2. **Verify green.** Run the project quality checks as declared in the\n   project's `AGENTS.md`\u002F`CLAUDE.md`, then the `test_command` from\n   `baseline.json` with the item's measurement flags\n   (`references\u002Fdurations-parsing.md`, \"Measurement command\"):\n\n   ```console\n   $ python3 \u003Cmeasure.py> run \\\n       --cwd \u003Cworkdir> \\\n       -- pytest \\\n       -p no:cacheprovider \\\n       -p no:randomly \\\n       > \u003Cruns-dir>\u002Fverify-\u003Corder>.jsonl\n   ```\n\n   Substitute `test_command` for `pytest`, and drop `-p no:cacheprovider` when\n   the item's `cache` is `enabled`. Get the expected count from the script, which\n   counts only the items already applied:\n\n   ```console\n   $ python3 \u003Cmeasure.py> expected-total \\\n       --through \u003Corder> \\\n       \u003Cmemory-dir>\u002Fbaseline.json \\\n       \u003Cmemory-dir>\u002Fplan.json \\\n       \u003Cmemory-dir>\u002Fexecution-log.json\n   ```\n\n   Check outcome counts with the shared gate, which reads `valid` here and\n   never `clears_noise`, since one run does not establish a speedup. Pass the\n   number in the `expected_total` field as `--expect-total`:\n\n   ```console\n   $ python3 \u003Cmeasure.py> compare \\\n       --min-runs 1 \\\n       --expect-total \u003Cexpected_total> \\\n       \u003Cmemory-dir>\u002Fbaseline.json \\\n       \u003Cruns-dir>\u002Fverify-\u003Corder>.jsonl\n   ```\n\n   Check that the same tests exist. Write the listing from `test_command`\n   (not a bare `pytest`) run in `\u003Cworkdir>` to\n   `\u003Cruns-dir>\u002Fverify-\u003Corder>-collection.txt` as `00-scan` Step 2 does, and\n   compare node ids against `collection.txt`, allowing only the removals of\n   applied items (skip this for a typing or parametrize item, which changes ids\n   by design):\n\n   ```console\n   $ python3 \u003Cmeasure.py> ids \\\n       --plan \u003Cmemory-dir>\u002Fplan.json \\\n       --log \u003Cmemory-dir>\u002Fexecution-log.json \\\n       --through \u003Corder> \\\n       \u003Cmemory-dir>\u002Fcollection.txt \\\n       \u003Cruns-dir>\u002Fverify-\u003Corder>-collection.txt\n   ```\n\n   The item passes only when the quality checks pass, `valid` is true, and the\n   ids match. Missing or empty outcomes fail; an exit 0 is insufficient. For a\n   typing or parametrize item the type checker must cover `tests\u002F`.\n3. **Gate, then commit.** Check that the staged bytes are exactly the item's\n   files and the verification created or changed nothing else:\n\n   ```console\n   $ python3 \u003Cisolate.py> gate \\\n       --cwd \u003Ctree> \\\n       --file \u003Ceach path in files> \\\n       > \u003Cruns-dir>\u002Fgate-\u003Corder>.json\n   ```\n\n   On exit 1 the item failed (go to 4); the verification changed paths outside\n   the plan, which includes a formatter rewriting the patched files (read the\n   saved file for the `reason`). On success write the log entry from that file, with the drafted subject:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log begin \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --gate-json \u003Cruns-dir>\u002Fgate-\u003Corder>.json \\\n       --set 'pending_subject=\"\u003Csubject>\"'\n   ```\n\n   Then commit with the drafted why\u002Fwhat\n   message from `plan.json`, written per `references\u002Fprose-rules.md`\n   (no trailers, no emoji; hosts add them by default; do not mention this):\n\n   ```console\n   $ git -C \u003Ctree> commit \\\n       --message \u003Csubject> \\\n       --message \u003Cbody>\n   ```\n\n   Then confirm the commit holds the gated bytes, so a hook that edited files\n   cannot slip past the verification:\n\n   ```console\n   $ python3 \u003Cisolate.py> landed \\\n       --cwd \u003Ctree> \\\n       --parent \u003Cpending_parent> \\\n       --tree \u003Cpending_tree>\n   ```\n\n   On success record the `commit_sha` and the verify run's `seconds` (read from\n   the `verify-\u003Corder>.jsonl` run line), which also checkpoints `state.json`:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log commit \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --run-json \u003Cruns-dir>\u002Fverify-\u003Corder>.jsonl \\\n       --set 'commit_sha=\"\u003Csha>\"'\n   ```\n\n   When the commit fails (a hook rejects it, signing is unavailable) or `landed`\n   fails, never retry with `--no-verify` or `--no-gpg-sign`: run\n   `isolate.py reset --cwd \u003Ctree> --to \u003Cpending_parent>`, record the failure\n   (this sets `applied` false, removes the `pending_*` fields, and leaves later\n   items alone), and stop without starting the next item:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log skip \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --no-propagate \\\n       --set 'reason=\"commit failed: \u003Cfirst line of the error>\"'\n   ```\n\n   Report the error and tell the user to fix the hook or signing and re-run\n   `pytest-optimizer:03-execute --from=\u003Cindex>`.\n4. **On failure** (patch, verification, ids or gate), discard the item inside the\n   owned tree. The command refuses any directory this run did not create:\n\n   ```console\n   $ python3 \u003Cisolate.py> reset \\\n       --cwd \u003Ctree>\n   ```\n\n   Exit 1 means the discard did not complete: stop, report its `reason`, and\n   leave the tree for inspection. Otherwise log the skip, which also marks every\n   item whose `depends_on` names it, directly or through others, as skipped\n   (\"depends on a skipped item\"), and continue. Failures never reach the user's\n   checkout, so no later step depends on repairing it:\n\n   ```console\n   $ python3 \u003Cmeasure.py> log skip \\\n       --memory-dir \u003Cmemory-dir> \\\n       --order \u003Corder> \\\n       --set 'reason=\"\u003Cprinted result>\"'\n   ```\n5. **Checkpoint**: every `log` call writes `execution-log.json` and sets\n   `phase` and `last_applied_index` in `state.json`, so a re-run continues from\n   the last checkpoint with nothing more to write.\n6. **Regression stop**: compare the item's verify `seconds` with the control:\n\n   ```console\n   $ python3 \u003Cmeasure.py> regress \\\n       \u003Cmemory-dir>\u002Fcontrol.json \\\n       \u003Cseconds>\n   ```\n\n   When `rerun` is true, re-run the verify command twice more and call it again\n   with all three timings. Exit 1 (`regressed`) means the commits so far made the\n   suite slower: stop before the next item, name the item, and ask whether to\n   continue or drop it from the branch. Without a question tool, stop and say\n   so.\n\nA dry run passes `--log-file \u003Cruns-dir>\u002Fdry-run-log.json` to every `log` call\n(use that file for the `expected-total` and `ids` commands), which leaves\n`state.json` alone; it ends with the discard in Step 4.\n\n## Step 4: Re-measure and report\n\nWhen no item was applied, remove the worktree and the unused branch, skip the\nre-measure, and report the control as the result:\n\n```console\n$ python3 \u003Cisolate.py> finish \\\n    --dir \u003Cexec_dir> \\\n    --drop-branch-at \u003Cbase_head>\n```\n\nOtherwise, with the final tree still open, resolve and create `\u003Cruns-dir>`, delete\n`post-runs.jsonl` there, run one untimed warm-up, and time as many runs as\n`baseline.json` recorded into it with the measurement flags above; if any applied\nitem has `cache` `enabled`, run them with the cache provider on so the warm-up\npopulates it and say so in the result. Compare against `control.json`, the same\nfresh checkout without the changes, passing the count the script returns once\nevery applied item is in the tree:\n\n```console\n$ python3 \u003Cmeasure.py> compare \\\n    --expect-total \u003Cexpected_total> \\\n    \u003Cmemory-dir>\u002Fcontrol.json \\\n    \u003Cruns-dir>\u002Fpost-runs.jsonl\n```\n\nThen remove the worktree; the branch stays. Read `removed` in the output: when it\nis not true, the worktree is still there, so say so in the closing sentence:\n\n```console\n$ python3 \u003Cisolate.py> finish \\\n    --dir \u003Cexec_dir>\n```\n\nUnless this was a dry run, mark the phase done with `measure.py state complete\n\u003Cmemory-dir>\u002Fstate.json --phase execute`. Emit the `03-execute`\nsections from `references\u002Foutput-contract.md`, hero line first, nothing\nbefore it. Write the prose per `references\u002Fprose-rules.md`. Reply in this\nshape, as plain text outside any code fence, with plain bullets, no bold\n(never `- **Label:** ...`), and no local paths:\n\n```text\n✓ 1 applied, 1 skipped on branch pytest-optimizer\u002Frun-1\n\n## Applied\n\n- 7c1e9d4 Share db_session across the session, verify green.\n\n## Skipped\n\n- H33 fixed sleep in test_report: discarded in the scratch worktree, test_report failed once the sleep was removed.\n\n## Result\n\n- 7.9s against 12.5s for the same checkout without the changes, 4.6s faster; the same 40 tests ran.\n\nMerge it with git merge --ff-only pytest-optimizer\u002Frun-1 when you are ready.\n```\n\nA run that skipped every item opens with `⚠`, has no `## Applied` section, no\nmerge sentence and no text about removing the worktree or branch, and states each failed verification as the printed result\n(counts and exit status), with no cause or threshold beyond that output; a dry run says \"verified, nothing committed\" in the hero and names no\nbranch. The merge sentence comes first: after it, the\n`ask-user-choice` panel offers a re-scan for a second pass (new candidates may\nsurface on a leaner suite), the opt-in cache\u002Ftiming scaffolds, or stop. Without\na question tool, follow the contract's next-step rule. A re-scan restarts at\n`pytest-optimizer:00-scan` with a fresh baseline, after the user merges.\n\n\n## Portability notes\n\n- `ask-user-choice` — present the listed options and wait for the user to pick one. Hosts with a structured multiple-choice tool (Claude Code's `AskUserQuestion`) should use it; otherwise print a numbered list and wait for a numbered reply. Never proceed on an assumed answer.\n- `$ARGUMENTS` — the text the user passed when invoking this skill. If your host does not substitute it, read it as the user's request in the current turn, and ask when there is none.\n- Bundled files — every relative path in this skill points at a file shipped inside this skill directory. Read them from here, not from the host's plugin tree.\n",{"name":5,"metadata":24,"description":7,"allowed-tools":27,"disable-model-invocation":35},{"source":25,"argument-hint":26},"plugins\u002Fpytest-optimizer\u002Fskills\u002F03-execute\u002FSKILL.md","[--from=\u003Cindex>] [--dry-run] [--memory-dir=\u003Cpath>]",[28,29,30,31,32,33,34],"Bash","Read","Grep","Glob","Write","Edit","AskUserQuestion",true,"main","5fbeb3b47beedea13813be7b7023f736a8d97a65",".agents\u002Fskills\u002Fpytest-optimizer-03-execute","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills","https:\u002F\u002Fgithub.com\u002Ftony","https:\u002F\u002Ftony.sh","lighthouse keeper","2026-11-08 17:57:34",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":35},[46,49,52],{"tool":47,"command":48},"npx","npx skills add tony\u002Fskills --skill pytest-optimizer-03-execute",{"tool":50,"command":51},"bunx","bunx skills add tony\u002Fskills --skill pytest-optimizer-03-execute",{"tool":53,"command":54},"pnpm","pnpm dlx skills add tony\u002Fskills --skill pytest-optimizer-03-execute","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002FSKILL.md",[57,63,67,73,77,81,85,89],{"path":58,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":61,"sourceHtmlUrl":62},"agents\u002Fopenai.yaml","REFERENCE","参考文档",306,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Fagents\u002Fopenai.yaml",{"path":64,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fdurations-parsing.md",5813,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Freferences\u002Fdurations-parsing.md",{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fisolate.py","SCRIPT","脚本",24741,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Freferences\u002Fisolate.py",{"path":74,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fmeasure.py",66026,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Freferences\u002Fmeasure.py",{"path":78,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":79,"sourceHtmlUrl":80},"references\u002Fmemory-schema.md",14354,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Freferences\u002Fmemory-schema.md",{"path":82,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":83,"sourceHtmlUrl":84},"references\u002Foutput-contract.md",8274,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Freferences\u002Foutput-contract.md",{"path":86,"resourceType":59,"resourceTypeDesc":60,"sizeBytes":87,"sourceHtmlUrl":88},"references\u002Fprose-rules.md",4644,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Freferences\u002Fprose-rules.md",{"path":90,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":91,"sourceHtmlUrl":92},"templates\u002Fpytest_optimizer_plugin.py",3385,"https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fpytest-optimizer-03-execute\u002Ftemplates\u002Fpytest_optimizer_plugin.py",[94,101,108,115,122,129],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M7E8NCSHXV2JPW4J61R0TQS7","serene-bliss","Use when asked to make a CLI --help, docs page, error message, or tooling UX more serene or calmer for developer experience; returns text, no edits.","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fweave\u002Fskills\u002Fserene-bliss\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M7E8N87MAVJD8RRQKQB1ZPS6","review","Weave code review: run independent adversarial reviews in parallel, then synthesize findings","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fweave\u002Fskills\u002Freview\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7E8N402XG4ZBFNACQ413163","refine","Use when asked to refine a draft, iterate on code until cleaner, or polish a README through repeated critique and improvement.","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fweave\u002Fskills\u002Frefine\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":19},"01M7E8N01KB86A7136P00GVKJW","prompt","Weave prompt: compare independent adversarial implementations, then adopt the single best one","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fweave\u002Fskills\u002Fprompt\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":19},"01M7E8MW7YJW2PCMDW3G9RTGNK","plan","Weave planning: compare independent adversarial plans, then synthesize the best one","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fweave\u002Fskills\u002Fplan\u002FSKILL.md",[],[],{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":19},"01M7E8MSBYXNCV4ZYWDS4PFJXK","fix-review","Fix weave review findings: validate, add test coverage, fix, and commit each as atomic changes","https:\u002F\u002Fgithub.com\u002Ftony\u002Fskills\u002Fblob\u002Fmain\u002Fplugins\u002Fweave\u002Fskills\u002Ffix-review\u002FSKILL.md",[],[]]