Source: https://frameworkrecipes.dev/fastify/

# Fastify: preserve requirements through advanced agent edits

Work through JavaScript examples of real application boundaries: Keep Fastify permission hooks inside the protected plugin; Keep Fastify reservation and order writes on the same transaction client. Each recipe includes implementation code, integration prerequisites, failure-path tests to add, a Perch rule, and the captured broken/fixed source checks.

[Download the Fastify rule pack ZIP](https://reporules.fyi/fastify/rule-pack.zip) · [Inspect the YAML rules](https://reporules.fyi/fastify/rules.yaml)

JavaScript

## [Keep Fastify permission hooks inside the protected plugin](https://frameworkrecipes.dev/fastify/plugin-permissions/)

Plugin encapsulation lets a permission hook cover the mutation routes without changing unrelated public routes. Authentication alone is insufficient: a signed-in read-only account must still be rejected before the handler changes an order.

Broken edit flagged · corrected edit passes

JavaScript

## [Keep Fastify reservation and order writes on the same transaction client](https://frameworkrecipes.dev/fastify/shared-transaction-client/)

A transaction callback can look atomic while a helper accidentally uses the pool. That helper’s write can commit independently. Pass the transaction client through every helper belonging to the reservation workflow, and let errors propagate to roll back.

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 Fastify documentation](https://fastify.dev/docs/latest/) · [All language and framework recipes](https://frameworkrecipes.dev/)

**Framework Recipes**

Implementation, failure path, check.

Published by Perch · © 2026 Verglas LLC. Framework Recipes is a Perch publication.

Perch’s MIT license covers the CLI; hosted model analysis is a paid service. Relevant source is sent to the configured model service.

[Perch CLI MIT license](https://github.com/lakeday-org/perch/blob/main/LICENSE) · [Article text](https://frameworkrecipes.dev/fastify/index.md) · [Resource index](https://frameworkrecipes.dev/llms.txt)
