React: preserve requirements through advanced agent edits
Work through JavaScript examples of real application boundaries: Keep old React search responses from replacing the current query; Serialize and roll back an optimistic React cancellation. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.
Download the React rule pack ZIP · Inspect the YAML rules
JavaScript
Requests can complete in a different order from the queries that started them. Aborting reduces wasted work; invalidating the old effect prevents a response already resolving from writing stale state. Protect the error branch as well as successful results.
Broken edit flagged · corrected edit passes
JavaScript
An optimistic UI can falsely display a completed transition after the server rejected it. Keep a snapshot, allow only one mutation at a time, and use the server-returned state on acknowledgement. A rejected operation restores the local snapshot and exposes its failure.
Broken edit flagged · corrected edit passes
Use a correction as a saved requirement
Choose the failure you need to prevent, add the scoped rule to your repository, and check both the broken and corrected implementation. Ask your agent to inspect the finding, repair the code and recheck the same rule. Keep framework tests beside the model check.
Perch keeps the requirement beside the code. Reuse the named check during the agent’s next edit and in CI, with cached answers free on unchanged requests.
Official React documentation · All language and framework recipes