Keep a coding agent from undoing a fix
Save the behavior restored by the fix as a named requirement. Give the agent the exact command to check that requirement after its next edit, repair any finding, and run the same command again before committing. Keep the application regression test with the rule.
Save the behavior the fix restored
In this React example, an older search request must not replace the current results. The captured broken edit removes the obsolete-request guard from the fulfilled-response branch:
setState({items,error:null});The corrected branch keeps that guard:
if (!obsolete) setState({items,error:null});Full React implementation and integration prerequisites · Exact broken and corrected source.
| Implementation | Saved requirement | Broken source | Corrected source | Capture date |
|---|---|---|---|---|
| Keep old React search responses from replacing the current query | obsolete-search-does-not-update | Rule finding | No rule finding | 2026-10-14 |
Make the requirement independent of the conversation
The saved rule names the behavior the agent must preserve on src/useOrderSearch.js. Its captured check covers the fulfilled-response branch; keep the separate error-path regression test too.
- name: obsolete-search-does-not-update
where: "src/useOrderSearch.js"
ensure: >-
The fulfilled search response must check obsolete before setting items, so a response for a previous query cannot replace the current result.Make the agent check the requirement after its edit
Keep your existing perch.yaml. The scoped rule pack installs the saved requirement under .perch/rules/. Review its file selector and use the implementation’s integration prerequisites before adapting it to your application.
Install Perch and configure your agent
npm install -g @lakeday/perch
perch login
# Choose the setup command for your agent:
perch setup claude-code
# Or: perch setup codex
# Or: perch setup cursor
Check the edit and recheck the repair
curl -fL 'https://reporules.fyi/react/stale-request-cleanup/rule-pack.zip' -o requirement.zip
unzip -n requirement.zip
perch check src/useOrderSearch.js --rules obsolete-search-does-not-update --json
# Read the finding, repair the implementation, then repeat:
perch check src/useOrderSearch.js --rules obsolete-search-does-not-update --json
Run the same check on the repaired working file before committing. Keep the application regression tests alongside it. Fresh model judgments can vary; an unchanged request can reuse its cached answer. A passing check does not prove application correctness.
Ask Claude Code to verify the requirement before committing
Use perch setup claude-code to install Perch’s agent skill. For Codex or Cursor, choose that agent’s setup command instead. Give the task a file, a named rule and a completion condition:
After editing src/useOrderSearch.js, run:
perch check src/useOrderSearch.js --rules obsolete-search-does-not-update --json
Read the finding and fix the implementation. Repeat the identical check.
Run the application regression test and report the results before committing.Download the existing agent repair task · Perch agent setup documentation.
Check the code that will actually be committed
perch check reads the working file. If the staged version differs, inspect both diffs, stage the intended repair and check that implementation again. An agent instruction is a workflow; a required CI check is the separate repository gate.
git diff -- src/useOrderSearch.js
git diff --cached -- src/useOrderSearch.jsWorking-file check reference · Run Perch in CI · Claude Code hook behavior.
Choose the next requirement by its failure
Find authorization, transaction, concurrency, retry and cleanup rules or inspect the React source and captured checks. Adapt the selected example and tests to your application; the recorded source check remains evidence for its linked example.