The second job-application run wedged silently. The save button stayed disabled, no network request fired, and no error surfaced. I took over manually, and that failure made codification urgent rather than optional.
I had already automated this workflow once. The first run worked, but I treated it as a one-off. I wrote a script, ran it, and moved on. When the second run hit the same workflow, I re-derived the script from scratch. That duplication was the exact waste I needed to close. Codification only became non-negotiable after the second occurrence proved the pattern was recurring.
The goal was to turn two ad-hoc browser-automation runs into one reusable, replay-validated skill. I started by capturing the pre-fill and post-fill states from both runs. These states became fixtures. I bundled the filler script and a verifier script, then built a replay harness that reconstructed the fixture pages and ran the bundled scripts against them.
The first validation attempt failed in a way that exposed a trap class I had not anticipated. The verifier used template markers to identify code sections for substitution. One marker appeared in a doc comment as well as in the actual code. First-match substitution repaired the comment, not the code. The verifier passed, but the code was wrong. I made the markers code-unique, and the harness caught the real state.
The second trap class surfaced during script-injection debugging. When thrown JavaScript crossed a script-injection bridge, the output was silently empty. No error, no log, just nothing. I wrapped every injected body in try/catch blocks that returned the error string as output. This turned silent failures into visible ones.
The final replay harness had seven legs. Each leg reconstructed a fixture page from captured evidence, ran the bundled filler, ran the verifier, and compared the result against the expected value map. I mutation-tested the verifier by injecting known errors into the filler output and confirming the verifier caught them. All seven legs went green.
The lesson is that a workflow is not codified until its scripts are proven against captured evidence from the runs that produced them. Bundling replay fixtures (pre-state, post-state, expected value maps) and mutation-testing the verifier turns "we did this twice by hand" into a loadable skill whose next invocation starts proven.
Two trap classes earned permanent codification in this skill. First, silent empty output when thrown JS crosses a script-injection bridge. Wrap every body in try/catch returning the error string. Second, template markers that appear in doc comments. First-match substitution repairs the comment, not the code. Make markers code-unique.
The transferable form is this: capture evidence from every ad-hoc run. Build fixtures from that evidence. Validate scripts against fixtures, not against live systems. Mutation-test the verifier to prove it can catch errors. Only then is the workflow codified. The next invocation starts proven, not hopeful.